Skip to content

CI: improve fmt and validate check #323

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

Merged
merged 1 commit into from
Jun 17, 2025
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
51 changes: 25 additions & 26 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,22 @@ jobs:
terraform-fmt:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: terraform-fmt
run: |
if [ ! -f /usr/local/bin/terraform ]; then
wget -q https://releases.hashicorp.com/terraform/1.6.0/terraform_1.6.0_linux_amd64.zip
unzip terraform_1.6.0_linux_amd64.zip -d /usr/local/bin/
fi
error=false
echo "===> Terraform fmt -diff checking in quickstarts"
(terraform -chdir=quickstarts fmt -check -recursive -list=false) || error=true
terraform -chdir=quickstarts fmt -diff -recursive
if ${error}; then
echo -e "\033[31m[ERROR]\033[0m: Some quickstarts codes has not been formatted, and please running terraform fmt --recursive command before pushing."
exit 1
fi
- uses: actions/checkout@v4

- uses: hashicorp/setup-terraform@v3

- name: Terraform fmt
id: fmt
run: terraform -chdir=quickstarts fmt -check -recursive


terraform-validate:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: hashicorp/setup-terraform@v3

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v34
Expand All @@ -46,19 +40,24 @@ jobs:
dir_names_max_depth: 3
- name: pr-check
run: |
if [ ! -f /usr/local/bin/terraform ]; then
wget -q https://releases.hashicorp.com/terraform/1.6.0/terraform_1.6.0_linux_amd64.zip
unzip terraform_1.6.0_linux_amd64.zip -d /usr/local/bin/
fi
CHANGED_FOLDERS="${{ steps.changed-files.outputs.all_changed_files }}"
if [ -z "${{ github.event.number }}" ]; then
CHANGED_FOLDERS=$(find ./quickstarts -maxdepth 2 -mindepth 2 -type d | tr '\n' ',')
fi
if [ -z "$CHANGED_FOLDERS" ]; then
echo "No changed quickstarts found"
exit 0
fi
bash scripts/terraform-validate.sh ${CHANGED_FOLDERS}

error=false
for f in ${CHANGED_FOLDERS//,/ }
do
f=$(echo $f | xargs echo -n)
echo "===> Terraform validating in" $f
terraform -chdir=$f init -upgrade
terraform -chdir=$f validate
if [[ $? -ne 0 ]]; then
echo -e "\033[31m[ERROR]\033[0m: Some quickstarts codes contain errors, and please running terraform validate command before pushing."
exit 1
fi
done


e2e-check:
Expand Down
12 changes: 0 additions & 12 deletions scripts/terraform-install.sh

This file was deleted.

17 changes: 0 additions & 17 deletions scripts/terraform-validate.sh

This file was deleted.

Loading