|
| 1 | +# Terraform Provider testing workflow. |
| 2 | +name: Tests |
| 3 | + |
| 4 | +# This GitHub action runs your tests for each pull request and push. |
| 5 | +# Optionally, you can turn it on using a schedule for regular testing. |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + paths-ignore: |
| 9 | + - "README.md" |
| 10 | + push: |
| 11 | + paths-ignore: |
| 12 | + - "README.md" |
| 13 | + |
| 14 | +# Testing only needs permissions to read the repository contents. |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + # Ensure project builds before running testing matrix |
| 20 | + build: |
| 21 | + name: Build |
| 22 | + runs-on: ubuntu-latest |
| 23 | + timeout-minutes: 5 |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 26 | + - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 |
| 27 | + with: |
| 28 | + go-version-file: "go.mod" |
| 29 | + cache: true |
| 30 | + - run: go mod download |
| 31 | + - run: go build -v . |
| 32 | + - name: Run linters |
| 33 | + uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 |
| 34 | + with: |
| 35 | + version: latest |
| 36 | + |
| 37 | + generate: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 41 | + - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 |
| 42 | + with: |
| 43 | + go-version-file: "go.mod" |
| 44 | + cache: true |
| 45 | + # Temporarily download Terraform 1.8 prerelease for function documentation support. |
| 46 | + # When Terraform 1.8.0 final is released, this can be removed. |
| 47 | + - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 |
| 48 | + with: |
| 49 | + terraform_version: "1.8.0-alpha20240216" |
| 50 | + terraform_wrapper: false |
| 51 | + - run: go generate ./ |
| 52 | + - name: git diff |
| 53 | + run: | |
| 54 | + git diff --compact-summary --exit-code || \ |
| 55 | + (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1) |
| 56 | +
|
| 57 | + # Run acceptance tests in a matrix with Terraform CLI versions |
| 58 | + test: |
| 59 | + name: Terraform Provider Acceptance Tests |
| 60 | + needs: build |
| 61 | + runs-on: ubuntu-latest |
| 62 | + timeout-minutes: 15 |
| 63 | + strategy: |
| 64 | + fail-fast: false |
| 65 | + max-parallel: 1 |
| 66 | + matrix: |
| 67 | + terraform: |
| 68 | + - "1.4.*" |
| 69 | + - "1.5.*" |
| 70 | + - "1.6.*" |
| 71 | + - "1.7.*" |
| 72 | + - "1.8.*" |
| 73 | + - "1.9.*" |
| 74 | + - "1.10.*" |
| 75 | + is-pr: |
| 76 | + - ${{ github.event_name == 'pull_request' }} |
| 77 | + # Only run the latest version of Terraform on pull requests |
| 78 | + exclude: |
| 79 | + - terraform: "1.4.*" |
| 80 | + is-pr: true |
| 81 | + - terraform: "1.5.*" |
| 82 | + is-pr: true |
| 83 | + - terraform: "1.6.*" |
| 84 | + is-pr: true |
| 85 | + - terraform: "1.7.*" |
| 86 | + is-pr: true |
| 87 | + - terraform: "1.8.*" |
| 88 | + is-pr: true |
| 89 | + - terraform: "1.9.*" |
| 90 | + is-pr: true |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 93 | + - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 |
| 94 | + with: |
| 95 | + go-version-file: "go.mod" |
| 96 | + cache: true |
| 97 | + - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 |
| 98 | + with: |
| 99 | + terraform_version: ${{ matrix.terraform }} |
| 100 | + terraform_wrapper: false |
| 101 | + - run: go mod download |
| 102 | + - env: |
| 103 | + TF_ACC: "1" |
| 104 | + PORKBUN_API_KEY: ${{ secrets.PORKBUN_API_KEY }} |
| 105 | + PORKBUN_SECRET_KEY: ${{ secrets.PORKBUN_SECRET_KEY }} |
| 106 | + PORKBUN_TEST_DOMAIN: ${{ secrets.PORKBUN_TEST_DOMAIN }} |
| 107 | + run: go test -v -cover ./internal/provider/ |
| 108 | + timeout-minutes: 10 |
0 commit comments