test.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. - 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@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
  37. - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.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. steps:
  61. - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
  62. - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
  63. with:
  64. go-version-file: 'go.mod'
  65. cache: true
  66. - uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
  67. with:
  68. terraform_version: ${{ matrix.terraform }}
  69. terraform_wrapper: false
  70. - run: go mod download
  71. - env:
  72. TF_ACC: "1"
  73. run: go test -v -cover ./internal/provider/
  74. timeout-minutes: 10