Bump tj-actions/changed-files from 34 to 46 in /.github/workflows #2
This file contains hidden or 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: E2E Test Check | |
on: | |
pull_request: | |
branches: | |
- master | |
- main | |
types: [ 'opened', 'synchronize' ] | |
jobs: | |
commitlint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: ahmadnassri/action-commit-lint@v2 | |
changes-files: | |
runs-on: ubuntu-latest | |
outputs: | |
changed_files_list: ${{ steps.changed-files.outputs.all_changed_files }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v46 | |
with: | |
separator: "," | |
terraform-fmt: | |
runs-on: ubuntu-latest | |
needs: changes-files | |
if: contains(needs.changes-files.outputs.changed_files_list, '.tf') | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: hashicorp/setup-terraform@v3 | |
- name: Terraform fmt | |
id: fmt | |
run: terraform fmt -check -recursive | |
terraform-validate: | |
runs-on: ubuntu-latest | |
needs: changes-files | |
if: contains(needs.changes-files.outputs.changed_files_list, '.tf') | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- uses: hashicorp/setup-terraform@v3 | |
- name: validate-check | |
run: | | |
exp="examples" | |
output_file="combined_output.txt" | |
if [[ -d "$exp" ]]; then | |
find $exp -type d -print -mindepth 1 -maxdepth 1 >> $output_file | |
fi | |
exitCode=0 | |
while IFS= read -r line | |
do | |
echo "===> Terraform validate checking in $line" | |
terraform -chdir=$line init -upgrade | |
terraform -chdir=$line validate | |
if [[ $? -ne 0 ]]; then | |
echo -e "\033[31m[ERROR]\033[0m: Some codes contain errors, and please running terraform validate command before pushing." | |
exitCode=1 | |
fi | |
done < $output_file | |
rm $output_file | |
exit $exitCode | |
tflint: | |
runs-on: ubuntu-latest | |
needs: changes-files | |
if: contains(needs.changes-files.outputs.changed_files_list, '.tf') | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- uses: actions/checkout@v4 | |
name: Checkout source code | |
- uses: actions/cache@v4 | |
name: Cache plugin dir | |
with: | |
path: ~/.tflint.d/plugins | |
key: ${{ matrix.os }}-tflint-${{ hashFiles('.tflint.hcl') }} | |
- uses: terraform-linters/setup-tflint@v4 | |
name: Setup TFLint | |
with: | |
tflint_version: v0.52.0 | |
- name: Init TFLint | |
run: tflint --init | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: tflint | |
run: | | |
tflint --recursive \ | |
--enable-rule=terraform_comment_syntax \ | |
--enable-rule=terraform_deprecated_index \ | |
--enable-rule=terraform_deprecated_interpolation \ | |
--enable-rule=terraform_deprecated_lookup \ | |
--enable-rule=terraform_documented_outputs \ | |
--enable-rule=terraform_documented_variables \ | |
--enable-rule=terraform_typed_variables \ | |
--enable-rule=terraform_unused_declarations \ | |
--enable-rule=terraform_required_version \ | |
--enable-rule=terraform_standard_module_structure \ | |
--disable-rule=terraform_required_providers | |
if [[ $? -ne 0 ]]; then | |
exit_code=1 | |
fi | |
e2e-check: | |
needs: [terraform-fmt, terraform-validate, tflint] | |
runs-on: ubuntu-latest | |
name: 'e2e check' | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: set id | |
id: set-job-id | |
uses: ayachensiyuan/get-action-job-id@v1.6 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
job-name: 'e2e check' | |
- name: Get pull request info | |
run: | | |
echo "repo name is" ${{github.event.pull_request.head.repo.full_name}} | |
echo "branch is" ${{github.event.pull_request.head.ref}} | |
echo "The current job id is ${{ steps.set-job-id.outputs.jobId }}" | |
- name: e2e test | |
run: | | |
objectPath="github-action/${{github.repository}}/e2e/Action-${{github.run_number}}-${{github.run_id}}-${{ steps.set-job-id.outputs.jobId }}" | |
go run scripts/curl_fc_trigger.go ${{github.event.pull_request.head.ref}} ${{github.event.pull_request.head.repo.full_name}} ${objectPath} | |
go run scripts/e2e_check.go ${objectPath} |