From 694b9c266df9829ba8278b0f81a65357e4fcf065 Mon Sep 17 00:00:00 2001 From: Sumanth Reddy Chinna Pullaiah Date: Wed, 6 Mar 2024 23:03:20 +0000 Subject: [PATCH] test --- .github/workflows/get-changed-files.yml | 24 +++++++++++++++++++----- modules/terraform/aws/variables.tf | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/get-changed-files.yml b/.github/workflows/get-changed-files.yml index 1d8058e54..e8e69e42d 100644 --- a/.github/workflows/get-changed-files.yml +++ b/.github/workflows/get-changed-files.yml @@ -14,11 +14,25 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Generate test matrix scenarios + id: setup-matrix-scenarios + run: | + matrix=$(find $GITHUB_WORKSPACE/scenarios/ -name "*.json" | awk -F'/' '{split($11, file_name, "."); split(file_name[1], cloud_region, "-");region= (length(cloud_region) > 1) ? substr($11, index($11, "-") + 1) : ""; cloud=cloud_region[1]; gsub(".json", "", region); print "{\"cloud\": \"" cloud "\", \"file_name\": \"" file_name[1] "\", " (region != "" ? "\"region\": \"" region "\", " : "") "\"scenario_type\": \"" $8 "\", \"scenario_name\": \"" $9 "\"},"}' | sort | uniq | sed 's/,$/,/') + matrix="${matrix//$'\n'/''}" + echo "matrix_combinations={\"include\": [${matrix%?}]}" >> "$GITHUB_OUTPUT" + outputs: + matrix-combinations: ${{ steps.setup-matrix-scenarios.outputs.matrix_combinations }} - name: List all changed files run: | - set -eux - file_changes=$(git diff --name-only -r origin/main HEAD | grep -Ev '\.md$|\.github/' | xargs) - for file in $file_changes; do - echo "Changed file: $file" + set -eu + echo $matrix + echo $matrix['include'] + file_changes=$(git diff --name-only -r origin/main HEAD | grep -Ev '\.md$|\.github/' | xargs) + + terraform_provider_changes=echo "$file_changes" | grep -E '\.tf$' | awk -F'/' '{print $3}' | xargs + + for cloud in $terraform_provider_changes; do + filtered_matrix=$(echo "$matrix" | jq 'any(.cloud == "$cloud")'; echo $?) done - \ No newline at end of file + env: + matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix-combinations) }} \ No newline at end of file diff --git a/modules/terraform/aws/variables.tf b/modules/terraform/aws/variables.tf index 49dc70f6f..e1fcad2b0 100644 --- a/modules/terraform/aws/variables.tf +++ b/modules/terraform/aws/variables.tf @@ -151,3 +151,4 @@ variable "private_link_conf" { }) default = null } +