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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  23. - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.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@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0
  31. with:
  32. version: latest
  33. generate:
  34. runs-on: ubuntu-latest
  35. steps:
  36. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  37. - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  64. - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
  65. with:
  66. go-version-file: 'go.mod'
  67. cache: true
  68. - uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
  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