test.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. # Default values to simplify job configurations below.
  16. env:
  17. # Go language version to use for building. This value should also be updated
  18. # in the release workflow if changed.
  19. GO_VERSION: '1.17'
  20. jobs:
  21. # Ensure project builds before running testing matrix
  22. build:
  23. name: Build
  24. runs-on: ubuntu-latest
  25. timeout-minutes: 5
  26. steps:
  27. - uses: actions/setup-go@v2
  28. with:
  29. go-version: ${{ env.GO_VERSION }}
  30. - uses: actions/checkout@v3
  31. - run: go mod download
  32. - run: go build -v .
  33. generate:
  34. runs-on: ubuntu-latest
  35. steps:
  36. - uses: actions/setup-go@v3
  37. with:
  38. go-version: ${{ env.GO_VERSION }}
  39. - uses: actions/checkout@v3
  40. - run: go generate ./...
  41. - name: git diff
  42. run: |
  43. git diff --compact-summary --exit-code || \
  44. (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
  45. # Run acceptance tests in a matrix with Terraform CLI versions
  46. test:
  47. name: Terraform Provider Acceptance Tests
  48. needs: build
  49. runs-on: ubuntu-latest
  50. timeout-minutes: 15
  51. strategy:
  52. fail-fast: false
  53. matrix:
  54. # list whatever Terraform versions here you would like to support
  55. terraform:
  56. - '1.0.*'
  57. - '1.1.*'
  58. steps:
  59. - uses: actions/setup-go@v2
  60. with:
  61. go-version: ${{ env.GO_VERSION }}
  62. - uses: hashicorp/setup-terraform@v1
  63. with:
  64. terraform_version: ${{ matrix.terraform }}
  65. terraform_wrapper: false
  66. - uses: actions/checkout@v3
  67. - run: go mod download
  68. - env:
  69. TF_ACC: "1"
  70. run: go test -v -cover ./internal/provider/
  71. timeout-minutes: 10