Merge pull request #619 from hmlanigan/labels #972
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 using different terraform versions | |
# and clouds. | |
name: Build | |
# This GitHub action runs your tests for each pull request. | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
# paths-ignore: | |
# DON'T SET - these are "required" so they need to run on every PR | |
push: | |
branches: | |
- "main" | |
# Testing only needs permissions to read the repository contents. | |
permissions: | |
contents: read | |
jobs: | |
# Ensure project builds before running testing matrix | |
go-install: | |
name: install | |
runs-on: [self-hosted, jammy] | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- run: go mod tidy | |
- run: go install | |
# Ensure the generated docs are up todate | |
generate: | |
runs-on: [self-hosted, jammy] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: "1.9.*" | |
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) | |
# Ensure the go code is formatted properly | |
format: | |
runs-on: [self-hosted, jammy] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- run: gofmt -w -l -s . | |
- name: git diff | |
run: | | |
git diff --compact-summary --exit-code || \ | |
(echo; echo "Unexpected difference in directories after go fmt. Run 'gofmt -w -l -s .' command and commit."; exit 1) | |
# This runs golangci-lint against the codebase | |
lint: | |
name: golangci-lint | |
runs-on: [self-hosted, jammy] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Determine which tests to run | |
uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
go: | |
- '**.go' | |
- 'go.mod' | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
cache: false | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: v1.54.0 | |
args: --print-issued-lines=true | |
# This runs golangci-lint against the codebase | |
copyright-check: | |
name: copyright-check | |
runs-on: [self-hosted, jammy] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
cache: false | |
- run: | | |
OUT=$(find . -name '*.go' | sort | xargs grep -L -E '// (Copyright|Code generated)' || true) | |
LINES=$(echo "${OUT}" | wc -w) | |
if [ "$LINES" != 0 ]; then | |
echo "" | |
echo "$(red 'Found some issues:')" | |
echo -e '\nThe following files are missing copyright headers' | |
echo "${OUT}" | |
exit 1 | |
fi | |