Merge pull request #197 from megaport/dependabot/go_modules/golang.or… #476
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 | |
on: | |
push: | |
paths-ignore: | |
- 'README.md' | |
branches: | |
- 'main' | |
pull_request: | |
paths-ignore: | |
- 'README.md' | |
branches: | |
- 'main' | |
workflow_dispatch: | |
# 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 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- run: go mod download | |
- run: go build -v . | |
- name: Run linters | |
uses: golangci/golangci-lint-action@v5 | |
with: | |
version: latest | |
generate: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
# Temporarily download Terraform 1.8 prerelease for function documentation support. | |
# When Terraform 1.8.0 final is released, this can be removed. | |
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1 | |
with: | |
terraform_version: '1.8.0-alpha20240216' | |
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 unit tests | |
unit-test: | |
name: Terraform Provider Unit Tests | |
needs: build | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- run: go mod download | |
- run: go test -v -timeout=30m -cover ./internal/provider/ | |
# TODO: reenable these once we get a better public workflow for PRs | |
# # Run acceptance tests in a matrix with Terraform CLI versions | |
# test: | |
# name: Terraform Provider Acceptance Tests | |
# needs: build | |
# runs-on: ubuntu-latest | |
# timeout-minutes: 30 | |
# strategy: | |
# fail-fast: false | |
# matrix: | |
# # list whatever Terraform versions here you would like to support | |
# terraform: | |
# - '1.7.*' | |
# - '1.8.*' | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - uses: actions/setup-go@v5 | |
# with: | |
# go-version-file: 'go.mod' | |
# cache: true | |
# - uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1 | |
# with: | |
# terraform_version: ${{ matrix.terraform }} | |
# terraform_wrapper: false | |
# - run: go mod download | |
# - env: | |
# TF_ACC: "1" | |
# MEGAPORT_ACCESS_KEY: ${{ secrets.MEGAPORT_ACCESS_KEY }} | |
# MEGAPORT_SECRET_KEY: ${{ secrets.MEGAPORT_SECRET_KEY }} | |
# run: go test -v -timeout=30m -cover ./internal/provider/ |