Merge pull request #36652 from mattburgess/autoscaling-plans-awssdkv2… #2
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
name: Provider Checks | |
on: | |
push: | |
branches: | |
- main | |
- "release/**" | |
pull_request: | |
paths: | |
- .github/workflows/provider.yml | |
- .ci/.golangci.yml | |
- .ci/tools/go.mod | |
- .markdownlint.yml | |
- internal/** | |
- docs/index.md | |
- docs/data-sources/** | |
- docs/guides/** | |
- docs/resources/** | |
- go.sum | |
- GNUmakefile | |
- main.go | |
- names/** | |
- website/** | |
env: | |
AWS_DEFAULT_REGION: us-west-2 | |
TERRAFORM_VERSION: "1.0.6" | |
jobs: | |
go_mod_download: | |
name: go mod download | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version-file: go.mod | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
id: cache-go-pkg-mod | |
timeout-minutes: 2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} | |
- if: steps.cache-go-pkg-mod.outputs.cache-hit != 'true' || steps.cache-go-pkg-mod.outcome == 'failure' | |
run: go mod download | |
go_build: | |
name: go build | |
needs: [go_mod_download] | |
runs-on: [custom, linux, medium] | |
steps: | |
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
id: cache-terraform-plugin-dir | |
timeout-minutes: 2 | |
with: | |
path: terraform-plugin-dir | |
key: ${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**') }} | |
- if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' | |
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version-file: go.mod | |
# See also: https://github.com/actions/setup-go/issues/54 | |
- if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' | |
name: go env | |
run: | | |
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV | |
- if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
path: ${{ env.GOCACHE }} | |
key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**') }} | |
- if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} | |
- if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' | |
name: go build | |
run: go build -o terraform-plugin-dir/registry.terraform.io/hashicorp/aws/99.99.99/$(go env GOOS)_$(go env GOARCH)/terraform-provider-aws . | |
go_generate: | |
name: go generate | |
needs: [go_build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version-file: go.mod | |
# See also: https://github.com/actions/setup-go/issues/54 | |
- name: go env | |
run: | | |
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
timeout-minutes: 2 | |
with: | |
path: ${{ env.GOCACHE }} | |
key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**') }} | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
timeout-minutes: 2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} | |
- run: go install golang.org/x/tools/cmd/goimports@latest | |
- run: make gen | |
- name: Check for Git Differences | |
run: | | |
git diff --compact-summary --exit-code || \ | |
(echo; echo "Unexpected difference in directories after code generation. Run 'make gen' command and commit."; exit 1) | |
go_test: | |
name: go test | |
needs: [go_build] | |
runs-on: [custom, linux, xl] | |
steps: | |
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version-file: go.mod | |
# See also: https://github.com/actions/setup-go/issues/54 | |
- name: go env | |
run: | | |
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
timeout-minutes: 2 | |
with: | |
path: ${{ env.GOCACHE }} | |
key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**') }} | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
timeout-minutes: 2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} | |
- name: Go Test | |
run: go test ./... | |
importlint: | |
needs: [go_build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version-file: go.mod | |
# See also: https://github.com/actions/setup-go/issues/54 | |
- name: go env | |
run: | | |
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
timeout-minutes: 2 | |
with: | |
path: ${{ env.GOCACHE }} | |
key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**') }} | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
timeout-minutes: 2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} | |
- run: cd .ci/tools && go install github.com/pavius/impi/cmd/impi | |
- run: impi --local . --scheme stdThirdPartyLocal ./... | |
# validate_sweepers_unlinked checks that the sweeper functions are not linked in the provider binary. | |
# As a pre-check, to validate that the check will work, it confirms that `strings` will find the function | |
# names in the compiled sweeper binary. | |
validate_sweepers_unlinked: | |
name: Sweeper Functions Not Linked | |
needs: [go_build] | |
runs-on: [custom, linux, medium] | |
steps: | |
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version-file: go.mod | |
# See also: https://github.com/actions/setup-go/issues/54 | |
- name: go env | |
run: | | |
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
timeout-minutes: 2 | |
with: | |
path: ${{ env.GOCACHE }} | |
key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**') }} | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
timeout-minutes: 2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} | |
- name: Pre-Check sweeper binary | |
run: | | |
go test -c -o ./sweeper-bin ./internal/sweep/ | |
count=$(strings ./sweeper-bin | \ | |
grep --count --extended-regexp 'internal/service/[a-zA-Z0-9]+\.sweep[a-zA-Z0-9]+$') | |
[ $count -gt 0 ] || \ | |
(echo; echo "Expected `strings` to detect sweeper function names in sweeper binary."; exit 1) | |
# Use cached provider or rebuild | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 | |
continue-on-error: true | |
id: cache-terraform-plugin-dir | |
timeout-minutes: 2 | |
with: | |
path: terraform-plugin-dir | |
key: ${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**') }} | |
- if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' | |
name: go build | |
run: go build -o terraform-plugin-dir/registry.terraform.io/hashicorp/aws/99.99.99/$(go env GOOS)_$(go env GOARCH)/terraform-provider-aws . | |
- name: Check provider binary | |
run: | | |
# grep returns the exit code 1 if there are no results. Disable immediate exit. | |
set +e | |
count=$(strings "terraform-plugin-dir/registry.terraform.io/hashicorp/aws/99.99.99/$(go env GOOS)_$(go env GOARCH)/terraform-provider-aws" | \ | |
grep --count --extended-regexp 'internal/service/[a-zA-Z0-9]+\.sweep[a-zA-Z0-9]+$') | |
set -e | |
[ $count -eq 0 ] || \ | |
(echo; echo "Expected `strings` to detect no sweeper function names in provider binary."; exit 1) | |
terraform_providers_schema: | |
name: terraform providers schema | |
needs: [go_build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
id: cache-terraform-providers-schema | |
timeout-minutes: 2 | |
with: | |
path: terraform-providers-schema | |
key: ${{ runner.os }}-terraform-providers-schema-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**') }} | |
- if: steps.cache-terraform-providers-schema.outputs.cache-hit != 'true' || steps.cache-terraform-providers-schema.outcome == 'failure' | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
timeout-minutes: 2 | |
with: | |
path: terraform-plugin-dir | |
key: ${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**') }} | |
- if: steps.cache-terraform-providers-schema.outputs.cache-hit != 'true' || steps.cache-terraform-providers-schema.outcome == 'failure' | |
uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 | |
with: | |
terraform_version: ${{ env.TERRAFORM_VERSION }} | |
terraform_wrapper: false | |
- if: steps.cache-terraform-providers-schema.outputs.cache-hit != 'true' || steps.cache-terraform-providers-schema.outcome == 'failure' | |
name: terraform init | |
run: | | |
# We need a file to initialize the provider | |
echo 'data "aws_partition" "example" {}' > example.tf | |
terraform init -plugin-dir terraform-plugin-dir | |
- if: steps.cache-terraform-providers-schema.outputs.cache-hit != 'true' || steps.cache-terraform-providers-schema.outcome == 'failure' | |
name: terraform providers schema | |
run: | | |
mkdir terraform-providers-schema | |
terraform providers schema -json > terraform-providers-schema/schema.json | |
tfproviderdocs: | |
needs: [terraform_providers_schema] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version-file: go.mod | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
continue-on-error: true | |
timeout-minutes: 2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} | |
- run: cd .ci/tools && go install github.com/YakDriver/tfproviderdocs | |
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
timeout-minutes: 2 | |
with: | |
path: terraform-providers-schema | |
key: ${{ runner.os }}-terraform-providers-schema-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**') }} | |
- name: tfproviderdocs check | |
run: | | |
tfproviderdocs check \ | |
-allowed-resource-subcategories-file website/allowed-subcategories.txt \ | |
-enable-contents-check \ | |
-ignore-file-missing-data-sources aws_alb,aws_alb_listener,aws_alb_target_group,aws_alb_trust_store,aws_alb_trust_store_revocation,aws_albs \ | |
-ignore-file-missing-resources aws_alb,aws_alb_listener,aws_alb_listener_certificate,aws_alb_listener_rule,aws_alb_target_group,aws_alb_target_group_attachment,aws_alb_trust_store,aws_alb_trust_store_revocation \ | |
-provider-source registry.terraform.io/hashicorp/aws \ | |
-providers-schema-json terraform-providers-schema/schema.json \ | |
-require-resource-subcategory \ | |
-ignore-cdktf-missing-files | |
markdown-lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
- uses: avto-dev/markdown-lint@04d43ee9191307b50935a753da3b775ab695eceb # v1.5.0 | |
with: | |
args: "." | |
ignore: "./docs ./website/docs ./CHANGELOG.md ./internal/service/cloudformation/testdata/examplecompany-exampleservice-exampleresource/docs" |