Tagging #18
Workflow file for this run
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: lint | |
on: | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: The branch, tag or SHA to checkout | |
default: main | |
type: string | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- ".git**" | |
pull_request: | |
jobs: | |
check-docs: | |
name: Docs up to date | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
- name: terraform-docs | |
env: | |
TERRAFORM_DOCS_VERSION: '0.16.0' | |
run: | | |
echo "Downloading terraform-docs-v${TERRAFORM_DOCS_VERSION} binary." | |
curl -Lsf \ | |
"https://github.com/terraform-docs/terraform-docs/releases/download/v${TERRAFORM_DOCS_VERSION}/terraform-docs-v${TERRAFORM_DOCS_VERSION}-linux-amd64.tar.gz" | tar -zxf - terraform-docs | |
echo "Checking whether auto-generated README files are up to date." | |
PATH="$PATH:$PWD" tools/update-docs.sh | |
if ! git diff --exit-code; then | |
echo "The documentation isn't up to date. Run tools/update-docs.sh and commit the results." | |
exit 1 | |
fi | |
shellcheck: | |
name: Shellcheck | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
- name: Run ShellCheck | |
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0 | |
env: | |
SHELLCHECK_OPTS: -e SC2086 -e SC1117 | |
terraform-fmt: | |
name: terraform fmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
- uses: actions/cache@v3 | |
with: | |
path: ~/tfenv | |
key: tfenv-${{ runner.os }} | |
- name: terraform install | |
env: | |
TFENV_VERSION: '3.0.0' | |
run: | | |
echo "Installing tfenv." | |
mkdir -p tfenv | |
curl -L --silent --fail \ | |
"https://github.com/tfutils/tfenv/archive/refs/tags/v${TFENV_VERSION}.tar.gz" \ | |
| tar -zxf - --strip-components=1 -C tfenv | |
export PATH="$PATH:$PWD/tfenv/bin" | |
echo "Installing default Terraform version." | |
tfenv install | |
tfenv use | |
echo "Installing other necessary Terraform versions." | |
for version in $(find terraform/ -type f -name '.terraform-version' | xargs sort -u); do | |
tfenv install "$version" | |
done | |
- name: terraform fmt | |
run: | | |
find terraform/ \ | |
-type f -name main.tf -not -path "*.terraform*" \ | |
-execdir "$PWD/tfenv/bin/terraform" fmt -recursive . \; | |
if ! git diff --exit-code; then | |
echo "Run terraform fmt -recursive . to fix formatting." | |
exit 1 | |
fi | |
other-linters: | |
name: Other linters | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
- uses: ruby/setup-ruby@v1 | |
- uses: actions/cache@v3 | |
with: | |
path: vendor/bundle | |
key: bundle-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: bundle | |
- name: bundle install | |
run: bundle install -j8 --deployment --without development | |
- name: RSpec | |
run: bundle exec rspec spec/validate_resources_spec.rb | |
- name: Lint resource names | |
run: bundle exec lib/resource_name_lint.rb | |
- name: Validate JSON | |
run: find . -type -f -name '*.json' | xargs tools/json-check.sh | |
- name: Check ADRs | |
run: tools/adr-check.sh |