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: 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: | |
push: | |
branches: [main] | |
# Testing only needs permissions to read the repository contents. | |
permissions: | |
contents: read | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# Ensure project builds before running testing matrix | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- run: go mod download | |
- run: go build -v . | |
- name: Run linters | |
uses: golangci/[email protected] | |
with: | |
version: latest | |
generate: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- uses: hashicorp/[email protected] | |
with: | |
terraform_version: "1.9.2" | |
terraform_wrapper: false | |
- run: go generate ./... | |
- name: Check for uncommitted changes | |
run: | | |
test -z "$(git status --porcelain)" || \ | |
(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: Acceptance Test | |
needs: build | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
strategy: | |
fail-fast: false | |
matrix: | |
terraform: | |
- "1.8.*" | |
- "1.9.*" | |
netbox: | |
- "4.0.9" | |
include: | |
- netbox: "4.0.9" | |
netbox_bgp: "0.13.2" | |
env: | |
DOCKER_COMPOSE: docker compose --progress=plain | |
BUILDKIT_PROGRESS: plain | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- uses: hashicorp/[email protected] | |
with: | |
terraform_version: ${{ matrix.terraform }} | |
terraform_wrapper: false | |
- run: go mod download | |
- run: make docker-up | |
id: docker | |
- run: docker compose logs netbox | |
if: failure() && steps.docker.outcome == 'failure' | |
- run: make testacc | |
env: | |
NETBOX_VERSION: ${{ matrix.netbox }} | |
NETBOX_BGP_VERSION: ${{ matrix.netbox_bgp }} | |
timeout-minutes: 10 |