test.yml 2.5 KB

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