diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d4952ce..4dac8cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,7 @@ -# Terraform Provider testing workflow. +# This GitHub action runs your tests for each commit push and/or PR. Optionally +# you can turn it on using a cron schedule for regular testing. +# name: Tests - -# This GitHub action runs your tests for each pull request and push. -# Optionally, you can turn it on using a schedule for regular testing. on: pull_request: paths-ignore: @@ -10,47 +9,58 @@ on: push: paths-ignore: - 'README.md' - -# Testing only needs permissions to read the repository contents. -permissions: - contents: read - + # For systems with an upstream API that could drift unexpectedly (like most SaaS systems, etc.), + # we recommend testing at a regular interval not necessarily tied to code changes. This will + # ensure you are alerted to something breaking due to an API change, even if the code did not + # change. + # schedule: + # - cron: '0 13 * * *' jobs: - # Ensure project builds before running testing matrix + # ensure the code builds... build: name: Build runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version-file: 'go.mod' - cache: true - - run: go mod download - - run: go build -v . - - name: Run linters - uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0 - with: - version: latest + + - name: Check out code into the Go module directory + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Set up Go + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + with: + go-version-file: 'go.mod' + cache: true + id: go + + - name: Get dependencies + run: | + go mod download + + - name: Build + run: | + go build -v . generate: runs-on: ubuntu-latest steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version-file: 'go.mod' cache: true + - name: Get dependencies + run: | + go mod download - run: go generate ./... - name: git diff run: | git diff --compact-summary --exit-code || \ (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1) - # Run acceptance tests in a matrix with Terraform CLI versions + # run acceptance tests in a matrix with Terraform core versions # test: - # name: Terraform Provider Acceptance Tests + # name: Matrix Test # needs: build # runs-on: ubuntu-latest # timeout-minutes: 15 @@ -59,25 +69,37 @@ jobs: # matrix: # # list whatever Terraform versions here you would like to support # terraform: - # - '1.0.*' - # - '1.1.*' - # - '1.2.*' - # - '1.3.*' - # - '1.4.*' # - '1.5.*' - # steps: - # - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - # - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - # with: - # go-version-file: 'go.mod' - # cache: true - # - uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0 - # with: - # terraform_version: ${{ matrix.terraform }} - # terraform_wrapper: false - # - run: go mod download - # - env: - # TF_ACC: "1" - # run: go test -v -cover ./internal/provider/ - # timeout-minutes: 10 + + # - name: Check out code into the Go module directory + # uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + # - name: Set up Go + # uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + # with: + # go-version-file: 'go.mod' + # cache: true + # id: go + + # - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 + # with: + # terraform_version: ${{ matrix.terraform }} + # terraform_wrapper: false + + # - name: Get dependencies + # run: | + # go mod download + + # - name: TF acceptance tests + # timeout-minutes: 10 + # env: + # TF_ACC: "1" + + # # Set whatever additional acceptance test env vars here. You can + # # optionally use data from your repository secrets using the + # # following syntax: + # # SOME_VAR: ${{ secrets.SOME_VAR }} + + # run: | + # go test -v -cover ./internal/provider/