test.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
  23. - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
  24. with:
  25. go-version-file: 'go.mod'
  26. cache: true
  27. - run: go mod download
  28. - run: go build -v .
  29. generate:
  30. runs-on: ubuntu-latest
  31. steps:
  32. - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
  33. - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
  34. with:
  35. go-version-file: 'go.mod'
  36. cache: true
  37. - run: go generate ./...
  38. - name: git diff
  39. run: |
  40. git diff --compact-summary --exit-code || \
  41. (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
  42. # Run acceptance tests in a matrix with Terraform CLI versions
  43. test:
  44. name: Terraform Provider Acceptance Tests
  45. needs: build
  46. runs-on: ubuntu-latest
  47. timeout-minutes: 15
  48. strategy:
  49. fail-fast: false
  50. matrix:
  51. # list whatever Terraform versions here you would like to support
  52. terraform:
  53. - '1.0.*'
  54. - '1.1.*'
  55. - '1.2.*'
  56. steps:
  57. - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
  58. - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
  59. with:
  60. go-version-file: 'go.mod'
  61. cache: true
  62. - uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
  63. with:
  64. terraform_version: ${{ matrix.terraform }}
  65. terraform_wrapper: false
  66. - run: go mod download
  67. - env:
  68. TF_ACC: "1"
  69. run: go test -v -cover ./internal/provider/
  70. timeout-minutes: 10