Terraform Provider Tests #555
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Terraform Provider testing workflow. | |
name: Terraform Provider 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: | |
- "README.md" | |
push: | |
paths-ignore: | |
- "README.md" | |
schedule: | |
# Runs every day at 9 AM Pacific Time (when PT is UTC-8) | |
- cron: "0 17 * * *" | |
# Testing only needs permissions to read the repository contents. | |
permissions: | |
contents: read | |
jobs: | |
# Ensure project builds before running testing matrix | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
cache-dependency-path: go.sum | |
- run: go mod download | |
- run: go build -v . | |
- name: Run linters | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: latest | |
args: --timeout=5m | |
generate: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
# list whatever Terraform versions here you would like to support | |
terraform: | |
- "1.9.*" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
cache-dependency-path: go.sum | |
- uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: ${{ matrix.terraform }} | |
terraform_wrapper: false | |
- 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 | |
test: | |
name: Terraform Provider Acceptance Tests | |
needs: build | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
strategy: | |
fail-fast: false | |
matrix: | |
# list whatever Terraform versions here you would like to support | |
terraform: | |
- "1.8.*" | |
- "1.9.*" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
cache-dependency-path: go.sum | |
- uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: ${{ matrix.terraform }} | |
terraform_wrapper: false | |
- run: go mod download | |
- env: | |
TF_ACC: "1" | |
NEOSYNC_ENDPOINT: ${{ vars.NEOSYNC_ENDPOINT }} | |
NEOSYNC_API_TOKEN: ${{ secrets.NEOSYNC_API_TOKEN }} | |
NEOSYNC_ACCOUNT_ID: ${{ vars.NEOSYNC_ACCOUNT_ID }} | |
run: go test -v -cover ./internal/provider/ | |
timeout-minutes: 10 | |
notify: | |
needs: [build, test] | |
runs-on: ubuntu-latest | |
if: > | |
always() && | |
github.event_name == 'schedule' | |
steps: | |
- name: Send notification to Slack | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.TEST_NOTIFY_SLACK_WEBHOOK_URL }} | |
SLACK_COLOR: ${{ (needs.build.result == 'success' && needs.test.result == 'success') && 'good' || 'danger' }} | |
SLACK_MESSAGE: "Build Job Status: ${{ needs.build.result }}. Test Job Status: ${{ needs.test.result }}. Check the run here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
SLACK_TITLE: "Neosync Terraform Provider scheduled tests - Build: ${{ needs.build.result }}, Test: ${{ needs.test.result }}" | |
SLACK_FOOTER: "" | |
SLACK_USERNAME: "Neosync Test Bot" |