Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add support for autoformatting YAML and spell checking via pre-commit hooks #1874

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ Steps to reproduce the behavior:
<!-- Have you cleared the local cache (see Notice section above)? -->
<!-- List steps in order that led up to the issue you encountered -->

## Expected behaviour
## Expected behavior

<!-- A clear and concise description of what you expected to happen -->

## Actual behaviour
## Actual behavior

<!-- A clear and concise description of what actually happened -->

Expand Down
42 changes: 6 additions & 36 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pre-commit
name: Pre-commit

on:
pull_request:
Expand All @@ -10,41 +10,19 @@ on:
- '**.yaml'

env:
TERRAFORM_VERSION: 1.3.10
TERRAFORM_DOCS_VERSION: v0.16.0
TFSEC_VERSION: v1.22.0
TF_PLUGIN_CACHE_DIR: ${{ github.workspace }}/.terraform.d/plugin-cache
TFLINT_VERSION: v0.42.1
TFLINT_VERSION: v0.50.2

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
collectInputs:
name: Collect workflow inputs
runs-on: ubuntu-latest
outputs:
directories: ${{ steps.dirs.outputs.directories }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Get root directories
id: dirs
uses: clowdhaus/terraform-composite-actions/[email protected]

preCommitMinVersions:
pre-commit:
name: Min TF pre-commit
needs: collectInputs
runs-on: ubuntu-latest
strategy:
matrix:
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
Expand All @@ -62,7 +40,7 @@ jobs:
with:
filters: |
src:
- '${{ matrix.directory }}/*.tf'
- '*.tf'

- name: Config Terraform plugin cache
if: steps.changes.outputs.src== 'true'
Expand All @@ -76,18 +54,10 @@ jobs:
key: ${{ runner.os }}-terraform-${{ hashFiles('**/.terraform.lock.hcl') }}
restore-keys: ${{ runner.os }}-terraform-

- name: Terraform min/max versions
uses: clowdhaus/[email protected]
if: steps.changes.outputs.src== 'true'
id: minMax
with:
directory: ${{ matrix.directory }}

- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
uses: clowdhaus/terraform-composite-actions/[email protected]
if: steps.changes.outputs.src== 'true'
with:
terraform-version: ${{ steps.minMax.outputs.maxVersion }}
terraform-version: ${{ env.TERRAFORM_VERSION }}
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}
tflint-version: ${{ env.TFLINT_VERSION }}
args: '--files ${{ matrix.directory }}/*'
41 changes: 25 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
repos:
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.3.0
hooks:
- id: cspell
args: [--exclude, 'ADOPTERS.md', --exclude, '.pre-commit-config.yaml', --exclude, '.gitignore', --exclude, '*.drawio', --exclude, 'mkdocs.yml', --exclude, '.helmignore', --exclude, '.github/workflows/*', --exclude, 'patterns/istio-multi-cluster/*', --exclude, 'patterns/blue-green-upgrade/*']
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2', --offset, '2', --preserve-quotes]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
args: ['--markdown-linebreak-ext=md']
- id: end-of-file-fixer
- id: check-merge-conflict
- id: detect-private-key
- id: detect-aws-credentials
args: ['--allow-missing-credentials']
args: [--allow-missing-credentials]
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.86.0
hooks:
- id: terraform_fmt
- id: terraform_docs
args:
- '--args=--lockfile=false'
- --args=--lockfile=false
- id: terraform_tflint
args:
- '--args=--only=terraform_deprecated_interpolation'
- '--args=--only=terraform_deprecated_index'
- '--args=--only=terraform_unused_declarations'
- '--args=--only=terraform_comment_syntax'
- '--args=--only=terraform_documented_outputs'
- '--args=--only=terraform_documented_variables'
- '--args=--only=terraform_typed_variables'
- '--args=--only=terraform_module_pinned_source'
- '--args=--only=terraform_naming_convention'
- '--args=--only=terraform_required_version'
- '--args=--only=terraform_required_providers'
- '--args=--only=terraform_unused_required_providers'
- '--args=--only=terraform_workspace_remote'
- --args=--only=terraform_deprecated_interpolation
- --args=--only=terraform_deprecated_index
- --args=--only=terraform_unused_declarations
- --args=--only=terraform_comment_syntax
- --args=--only=terraform_documented_outputs
- --args=--only=terraform_documented_variables
- --args=--only=terraform_typed_variables
- --args=--only=terraform_module_pinned_source
- --args=--only=terraform_naming_convention
- --args=--only=terraform_required_version
- --args=--only=terraform_required_providers
- --args=--only=terraform_unused_required_providers
- --args=--only=terraform_workspace_remote
- id: terraform_validate
exclude: (docs|modules)
6 changes: 6 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dictionaryDefinitions:
- name: bpWords
path: ./docs/cSpell_dict.txt
addWords: true
dictionaries:
- bpWords
161 changes: 161 additions & 0 deletions docs/cSpell_dict.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
acmpca
acmca_arn
addrs
adot
agones
akuity
algbw
ALLOWVOLUMEEXPANSION
amazonlinux
apigatewayv2
apiextensions
apiversion
applicationset
appsets
argocd
argoproj
athenaaccess
athenacurcfn
autoscaler
awscli
awscliv2
awslabs
awspca
awspcaclusterissuers
basepath
billingreports
bootstrappers
boto
bottlerocket
busbw
cacerts
cainjector
chdir
cidrsubnet
ciliumnetworkpolicy
clusterip
clusterissuer
clusterrole
clusterrolebinding
clusterwide
cncf
compat
configmap
concat
containerd
coredns
cuda
customresourcedefinition
crossplane
crds
curlimages
cwlogs
daemonset
dcgm
distro
ecrpublic
ecsdemo
ecsfrontend
elbv
eksctl
eksvpc
emrcontainers
errexit
eventbridge
externaldns
externalsecrets
externalsnat
fargate
fileexists
finalizer
finalizers
flblogs
fluentbit
gameserver
gameservers
gavinbunney
gitops
helloworld
heptio
identitystore
iedn
iezn
ingressgateway
instanceids
ipam
irsa
istio
istiod
istioing
jsonencode
karpenter
kiali
kubeconfig
kubecost
kubeflow
kubelet
kyverno
libfabric
logtag
loglevel
makefiles
maxport
minport
mkdocs
mktemp
mountpoint
mpijob
mpijobs
mtls
nccl
netcat
nics
nodegroup
nodeport
nvme
oidc
persistentvolume
pkce
pubkey
privateca
privatelink
prometheusservice
proto
readyz
reclaimpolicy
redop
replicaset
rdmap
rolearn
rollouts
rootdir
rpfilter
secretpassword
secretstore
secretuser
selfsigned
serviceaccount
SHA512WITHRSA
sleepdocs
ssoadmin
storageclass
storageclasses
tcpdump
templatefile
tfstate
tfvars
tolist
toset
velero
VOLUMEBINDINGMODE
vpclattice
webfront
wontfix
yamlencode
xlarge
xonotic
xrds
xvda
xvdb
zipkin
zipmap
4 changes: 2 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ directory of your choice.
terraform apply -auto-approve
```

For patterns that deviate from this general flow, see the pattern's respective `REAMDE.md` for more details.
For patterns that deviate from this general flow, see the pattern's respective `README.md` for more details.

!!! info "Terraform targetted apply"
!!! info "Terraform targeted apply"
Please see the [Terraform Caveats](https://aws-ia.github.io/terraform-aws-eks-blueprints/#terraform-caveats) section for details on the use of targeted Terraform apply's

3. Once all of the resources have successfully been provisioned, the following command can be used to update the `kubeconfig`
Expand Down
1 change: 0 additions & 1 deletion docs/v4-to-v5/example/v5.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ provider "kubernetes" {
# Cluster
################################################################################

#tfsec:ignore:aws-eks-enable-control-plane-logging
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 19.13"
Expand Down
12 changes: 6 additions & 6 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
site_name: Amazon EKS Blueprints for Terraform
docs_dir: 'docs/'
copyright: 'Copyright &copy; Amazon 2023'
site_author: 'AWS'
site_url: 'https://aws-ia.github.io/terraform-aws-eks-blueprints/'
repo_name: 'terraform-aws-eks-blueprints'
repo_url: 'https://github.com/aws-ia/terraform-aws-eks-blueprints'
docs_dir: docs/
copyright: Copyright &copy; Amazon 2023
site_author: AWS
site_url: https://aws-ia.github.io/terraform-aws-eks-blueprints/
repo_name: terraform-aws-eks-blueprints
repo_url: https://github.com/aws-ia/terraform-aws-eks-blueprints

theme:
name: material
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ metadata:
generateName: "simple-game-server-"
spec:
ports:
- name: default
portPolicy: Dynamic
containerPort: 7654
- name: default
portPolicy: Dynamic
containerPort: 7654
template:
spec:
containers:
- name: simple-game-server
image: gcr.io/agones-images/simple-game-server:0.3
resources:
requests:
memory: "64Mi"
cpu: "20m"
limits:
memory: "64Mi"
cpu: "20m"
- name: simple-game-server
image: gcr.io/agones-images/simple-game-server:0.3
resources:
requests:
memory: "64Mi"
cpu: "20m"
limits:
memory: "64Mi"
cpu: "20m"
Loading
Loading