Skip to content

CI pipeline for PR - (#549) feat(specs): Add spec, tests and examples for globalprotect-gateway #986

CI pipeline for PR - (#549) feat(specs): Add spec, tests and examples for globalprotect-gateway

CI pipeline for PR - (#549) feat(specs): Add spec, tests and examples for globalprotect-gateway #986

Workflow file for this run

# This workflow will build and test a golang project
name: PR CI
run-name: 'CI pipeline for PR - (#${{ github.event.number }}) ${{ github.event.pull_request.title }}'
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
with:
go-version: '1.23'
- name: golangci-lint
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6
with:
version: v1.60
ci:
name: Continuous integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up Go
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
with:
go-version: '1.23'
- name: Download Go dependencies
run: go get ./... && go mod tidy
- name: Check if all dependencies were commited
shell: bash
run: |
if [ "$(git status --porcelain)" ]; then
git status
exit 1
else
exit 0
fi
- name: Build codegen
run: go build -v ./...
- name: Test codegen
run: go test -v ./...
generate:
needs: ci
name: Generate code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up Go
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
with:
go-version: '1.23'
- name: Download Go dependencies
run: go get ./... && go mod tidy
- name: Test codegen
run: go test -v ./...
- name: Build codegen
run: go build -v ./...
- name: Execute codegen for all targets
run: go run cmd/codegen/main.go
- name: Test generated code
run: |
for dir in $(ls ../generated); do
echo "Run tests for ${dir}"
cd ../generated/${dir}
go test -v ./...
cd -
done
- name: Build provider
run: |
cd ../generated/terraform-provider-panos/
go build -o terraform-provider-panos
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/PaloAltoNetworks/panos/1.0.0/linux_amd64
mv terraform-provider-panos ~/.terraform.d/plugins/registry.terraform.io/PaloAltoNetworks/panos/1.0.0/linux_amd64
- name: Setup Terraform
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
with:
terraform_version: '1.11.2'
- name: Validate Terraform Examples
working-directory: assets/terraform/examples
run: |
# Create provider configuration template
cat << EOF > provider.tf.template
terraform {
required_providers {
panos = {
source = "PaloAltoNetworks/panos"
version = "1.0.0"
}
}
}
provider "panos" {
alias = "ci"
}
EOF
# Find all directories containing .tf files except ephemeral-resources
DIRS=$(find . -type f -name "*.tf" -exec dirname {} \; | sort -u)
# Loop through each directory and validate
for dir in $DIRS; do
# Copy provider configuration for validation
cp provider.tf.template $dir/provider.tf
echo "Validating configurations in: $dir"
cd "$dir"
# Initialize and validate
terraform init -no-color
terraform validate -no-color
# Clean up provider configuration
rm provider.tf
# Return to the examples directory
cd - > /dev/null
done
# Clean up template
rm provider.tf.template
- name: Workaround actions/upload-artifact#176
run: |
echo "artifacts_path=$(realpath ../generated/pango)" >> $GITHUB_ENV
- name: Upload generated files for pango SDK
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: generated-pango
path: |
${{ env.artifacts_path }}
retention-days: 3
if-no-files-found: error