test.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. # Temporarily download Terraform 1.8 prerelease for function documentation support.
  42. # When Terraform 1.8.0 final is released, this can be removed.
  43. - uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
  44. with:
  45. terraform_version: '1.8.0-alpha20240216'
  46. terraform_wrapper: false
  47. - run: go generate ./...
  48. - name: git diff
  49. run: |
  50. git diff --compact-summary --exit-code || \
  51. (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
  52. # Run acceptance tests in a matrix with Terraform CLI versions
  53. test:
  54. name: Terraform Provider Acceptance Tests
  55. needs: build
  56. runs-on: ubuntu-latest
  57. timeout-minutes: 15
  58. strategy:
  59. fail-fast: false
  60. matrix:
  61. # list whatever Terraform versions here you would like to support
  62. terraform:
  63. - '1.0.*'
  64. - '1.1.*'
  65. - '1.2.*'
  66. - '1.3.*'
  67. - '1.4.*'
  68. steps:
  69. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  70. - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
  71. with:
  72. go-version-file: 'go.mod'
  73. cache: true
  74. - uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
  75. with:
  76. terraform_version: ${{ matrix.terraform }}
  77. terraform_wrapper: false
  78. - run: go mod download
  79. - env:
  80. TF_ACC: "1"
  81. run: go test -v -cover ./internal/provider/
  82. timeout-minutes: 10