test.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Terraform Provider testing workflow.
  2. name: Tests
  3. # This GitHub action runs your tests for each pull request and push.
  4. # Optionally, you can turn it on using a schedule for regular testing.
  5. on:
  6. pull_request:
  7. paths-ignore:
  8. - 'README.md'
  9. push:
  10. paths-ignore:
  11. - 'README.md'
  12. # Testing only needs permissions to read the repository contents.
  13. permissions:
  14. contents: read
  15. jobs:
  16. # Ensure project builds before running testing matrix
  17. build:
  18. name: Build
  19. runs-on: ubuntu-latest
  20. timeout-minutes: 5
  21. steps:
  22. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  23. - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
  24. with:
  25. go-version-file: 'go.mod'
  26. cache: true
  27. - run: go mod download
  28. - run: go build -v .
  29. - name: Run linters
  30. uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
  31. with:
  32. version: latest
  33. generate:
  34. runs-on: ubuntu-latest
  35. steps:
  36. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  37. - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
  38. with:
  39. go-version-file: 'go.mod'
  40. cache: true
  41. # We need the latest version of Terraform for our documentation generation to use
  42. - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
  43. with:
  44. terraform_wrapper: false
  45. - run: make generate
  46. - name: git diff
  47. run: |
  48. git diff --compact-summary --exit-code || \
  49. (echo; echo "Unexpected difference in directories after code generation. Run 'make generate' command and commit."; exit 1)
  50. # Run acceptance tests in a matrix with Terraform CLI versions
  51. test:
  52. name: Terraform Provider Acceptance Tests
  53. needs: build
  54. runs-on: ubuntu-latest
  55. timeout-minutes: 15
  56. strategy:
  57. fail-fast: false
  58. matrix:
  59. # list whatever Terraform versions here you would like to support
  60. terraform:
  61. - '1.0.*'
  62. - '1.1.*'
  63. - '1.2.*'
  64. - '1.3.*'
  65. - '1.4.*'
  66. steps:
  67. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  68. - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
  69. with:
  70. go-version-file: 'go.mod'
  71. cache: true
  72. - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
  73. with:
  74. terraform_version: ${{ matrix.terraform }}
  75. terraform_wrapper: false
  76. - run: go mod download
  77. - env:
  78. TF_ACC: "1"
  79. run: go test -v -cover ./internal/provider/
  80. timeout-minutes: 10