From 532edd6921b72731bfd83e9f206058023d2598fb Mon Sep 17 00:00:00 2001 From: Benjamin Smith Date: Fri, 15 Dec 2023 12:51:24 -0800 Subject: [PATCH 01/17] remove || --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 97b35c4..7182035 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,6 @@ runs: ${{ inputs.component }} \ -s ${{ inputs.stack }} \ --format json \ - --file "$OUTPUT_FILE" || echo '{}' > "$OUTPUT_FILE" + --file "$OUTPUT_FILE" value=$(jq -rc --arg key ${{ inputs.settings-path }} '. | getpath($key | split("."))' "$OUTPUT_FILE") echo "value=$value" >> $GITHUB_OUTPUT From c27c6a8bbc28d133508645850ab4532721ec7a17 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 20:29:53 +0100 Subject: [PATCH 02/17] Added test for non existing stack --- .github/workflows/test-negative.yml | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/test-negative.yml diff --git a/.github/workflows/test-negative.yml b/.github/workflows/test-negative.yml new file mode 100644 index 0000000..0d6fade --- /dev/null +++ b/.github/workflows/test-negative.yml @@ -0,0 +1,46 @@ +name: Test non-existent component stack +on: + # # Uncomment when test added first time to register workflow and comment it back after workflow would be registered + # # + # # Added pull_request to register workflow from the PR. + # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo + pull_request: {} + workflow_dispatch: {} + +jobs: + test: + runs-on: ubuntu-latest + continue-on-error: true + outputs: + result: ${{ steps.current.outputs.value }} + outcome: ${{ steps.current.outcome }} + steps: + - name: Setup terraform + uses: hashicorp/setup-terraform@v2 + - name: Setup atmos + uses: cloudposse/github-action-setup-atmos@1.0.2 + with: + install-wrapper: false + - name: Checkout + uses: actions/checkout@v3 + + - uses: ./ + id: current + with: + component: bar + stack: core-ue1-dev + settings-path: settings.level1.level2.level3.secrets-arn + + assert: + runs-on: ubuntu-latest + needs: [test] + steps: + - uses: nick-fields/assert-action@v1 + with: + expected: "" + actual: ${{ needs.test.outputs.result }} + + - uses: nick-fields/assert-action@v1 + with: + expected: success + actual: ${{ needs.test.outputs.outcome }} From 478680bd6e2eff8a3b7feadc7814f9d8b4197be6 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 20:32:49 +0100 Subject: [PATCH 03/17] Added test for non existing stack --- .github/workflows/test-empty-setting.yml | 48 ++++++++++++++++++++++++ .github/workflows/test-negative.yml | 12 +++--- 2 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test-empty-setting.yml diff --git a/.github/workflows/test-empty-setting.yml b/.github/workflows/test-empty-setting.yml new file mode 100644 index 0000000..f89cd4a --- /dev/null +++ b/.github/workflows/test-empty-setting.yml @@ -0,0 +1,48 @@ +name: Test non-existent setting +on: + # # Uncomment when test added first time to register workflow and comment it back after workflow would be registered + # # + # # Added pull_request to register workflow from the PR. + # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo + pull_request: {} + workflow_dispatch: {} + +jobs: + test: + runs-on: ubuntu-latest + continue-on-error: true + outputs: + result: ${{ steps.current.outputs.value }} + outcome: ${{ steps.current.outcome }} + steps: + - name: Setup terraform + uses: hashicorp/setup-terraform@v2 + - name: Setup atmos + uses: cloudposse/github-action-setup-atmos@1.0.2 + with: + install-wrapper: false + - name: Checkout + uses: actions/checkout@v3 + + - uses: ./ + id: current + with: + component: foo + stack: core-ue1-dev + settings-path: settings.level5 + + assert: + runs-on: ubuntu-latest + if: always() + needs: [test] + steps: + - uses: nick-fields/assert-action@v1 + with: + expected: success + actual: ${{ needs.test.outputs.outcome }} + + - uses: nick-fields/assert-action@v1 + with: + expected: "" + actual: ${{ needs.test.outputs.result }} + diff --git a/.github/workflows/test-negative.yml b/.github/workflows/test-negative.yml index 0d6fade..ba0c23f 100644 --- a/.github/workflows/test-negative.yml +++ b/.github/workflows/test-negative.yml @@ -4,7 +4,7 @@ on: # # # # Added pull_request to register workflow from the PR. # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo - pull_request: {} + # pull_request: {} workflow_dispatch: {} jobs: @@ -33,14 +33,16 @@ jobs: assert: runs-on: ubuntu-latest + if: always() needs: [test] steps: - uses: nick-fields/assert-action@v1 with: - expected: "" - actual: ${{ needs.test.outputs.result }} + expected: failure + actual: ${{ needs.test.outputs.outcome }} - uses: nick-fields/assert-action@v1 with: - expected: success - actual: ${{ needs.test.outputs.outcome }} + expected: "" + actual: ${{ needs.test.outputs.result }} + From afb522ef7de658690dc9f25053f47aeae8371e7a Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 20:38:29 +0100 Subject: [PATCH 04/17] Added test for non existing stack --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 7182035..d94edb7 100644 --- a/action.yml +++ b/action.yml @@ -33,4 +33,5 @@ runs: --format json \ --file "$OUTPUT_FILE" value=$(jq -rc --arg key ${{ inputs.settings-path }} '. | getpath($key | split("."))' "$OUTPUT_FILE") + echo "value=$value" echo "value=$value" >> $GITHUB_OUTPUT From 2feba4a6c3834362a44ba38b42341a0bd8259389 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 20:38:54 +0100 Subject: [PATCH 05/17] Added test for non existing stack --- .github/workflows/test-empty-setting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-empty-setting.yml b/.github/workflows/test-empty-setting.yml index f89cd4a..4b50842 100644 --- a/.github/workflows/test-empty-setting.yml +++ b/.github/workflows/test-empty-setting.yml @@ -4,7 +4,7 @@ on: # # # # Added pull_request to register workflow from the PR. # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo - pull_request: {} + # pull_request: {} workflow_dispatch: {} jobs: From bd37ddcf2bcde71464e8f24f6f5a45867be3920d Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 20:42:11 +0100 Subject: [PATCH 06/17] Added test for non existing stack --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index d94edb7..d3cb604 100644 --- a/action.yml +++ b/action.yml @@ -33,5 +33,5 @@ runs: --format json \ --file "$OUTPUT_FILE" value=$(jq -rc --arg key ${{ inputs.settings-path }} '. | getpath($key | split("."))' "$OUTPUT_FILE") - echo "value=$value" + cat $OUTPUT_FILE echo "value=$value" >> $GITHUB_OUTPUT From 68ee833a9c2e85769ef6e39270e80dd8213e5aa1 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 20:47:29 +0100 Subject: [PATCH 07/17] Added test for non existing stack --- action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yml b/action.yml index d3cb604..fe2f8fb 100644 --- a/action.yml +++ b/action.yml @@ -32,6 +32,5 @@ runs: -s ${{ inputs.stack }} \ --format json \ --file "$OUTPUT_FILE" - value=$(jq -rc --arg key ${{ inputs.settings-path }} '. | getpath($key | split("."))' "$OUTPUT_FILE") - cat $OUTPUT_FILE + value=$(jq -rc --arg key ${{ inputs.settings-path }} '. | getpath($key | split(".")) | if . == null then "" else . end' "$OUTPUT_FILE") echo "value=$value" >> $GITHUB_OUTPUT From f07c3e6e49907a3249bcf051f05099b50e029177 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 21:00:24 +0100 Subject: [PATCH 08/17] Added test for non existing stack --- .github/workflows/test-wrong-atmos-config.yml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/test-wrong-atmos-config.yml diff --git a/.github/workflows/test-wrong-atmos-config.yml b/.github/workflows/test-wrong-atmos-config.yml new file mode 100644 index 0000000..c300907 --- /dev/null +++ b/.github/workflows/test-wrong-atmos-config.yml @@ -0,0 +1,45 @@ +name: Test wrong atmos config +on: + # # Uncomment when test added first time to register workflow and comment it back after workflow would be registered + # # + # # Added pull_request to register workflow from the PR. + # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo + pull_request: {} + workflow_dispatch: {} + +jobs: + test: + runs-on: ubuntu-latest + continue-on-error: true + outputs: + result: ${{ steps.current.outputs.value }} + outcome: ${{ steps.current.outcome }} + steps: + - name: Setup terraform + uses: hashicorp/setup-terraform@v2 + - name: Setup atmos + uses: cloudposse/github-action-setup-atmos@1.0.2 + with: + install-wrapper: false + - name: Checkout + uses: actions/checkout@v3 + + - uses: ./ + id: current + with: + component: foo + stack: core-ue1-dev + settings-path: settings.level1.level2.level3.secrets-arn + env: + ATMOS_CLI_CONFIG_PATH: ./atmos-config-wrong.yaml + + assert: + runs-on: ubuntu-latest + if: always() + needs: [test] + steps: + - uses: nick-fields/assert-action@v1 + with: + expected: failure + actual: ${{ needs.test.outputs.outcome }} + From b74401bd86a0521d541db98dddb64dbca8e17cbf Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 21:02:22 +0100 Subject: [PATCH 09/17] Added test for non existing stack --- action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yml b/action.yml index fe2f8fb..15df2c3 100644 --- a/action.yml +++ b/action.yml @@ -24,6 +24,8 @@ runs: - id: settings shell: bash run: | + set +e + OUTPUT_FILE="$(tr / _ <<<${{ inputs.stack }}-${{ inputs.component }}.json)" # Extract the settings value from the component's stack configuration From f61e06559d439c1d932df04888893578b24bc443 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 21:04:05 +0100 Subject: [PATCH 10/17] Added test for non existing stack --- .github/workflows/test-wrong-atmos-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-wrong-atmos-config.yml b/.github/workflows/test-wrong-atmos-config.yml index c300907..d0cc679 100644 --- a/.github/workflows/test-wrong-atmos-config.yml +++ b/.github/workflows/test-wrong-atmos-config.yml @@ -4,7 +4,7 @@ on: # # # # Added pull_request to register workflow from the PR. # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo - pull_request: {} + # pull_request: {} workflow_dispatch: {} jobs: From 8c7568adc8130e1de783c3aefc3888e4a1595d5d Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 21:11:55 +0100 Subject: [PATCH 11/17] Added test for non existing stack --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 15df2c3..71d2a3d 100644 --- a/action.yml +++ b/action.yml @@ -24,7 +24,7 @@ runs: - id: settings shell: bash run: | - set +e + set -e OUTPUT_FILE="$(tr / _ <<<${{ inputs.stack }}-${{ inputs.component }}.json)" From c69ec35f30f9a9f5a804195a85860e60c2332c85 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 21:46:15 +0100 Subject: [PATCH 12/17] Added test for non existing stack --- action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/action.yml b/action.yml index 71d2a3d..fe2f8fb 100644 --- a/action.yml +++ b/action.yml @@ -24,8 +24,6 @@ runs: - id: settings shell: bash run: | - set -e - OUTPUT_FILE="$(tr / _ <<<${{ inputs.stack }}-${{ inputs.component }}.json)" # Extract the settings value from the component's stack configuration From e3f703e8c4f42817ec7302067d7716f1515254f4 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 21:52:38 +0100 Subject: [PATCH 13/17] Added test for non existing stack --- action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yml b/action.yml index fe2f8fb..98ce93f 100644 --- a/action.yml +++ b/action.yml @@ -32,5 +32,10 @@ runs: -s ${{ inputs.stack }} \ --format json \ --file "$OUTPUT_FILE" + RESULT=$? + if [ $RESULT -ne 0 ]; then + echo "Atmos config not found" + exit 1 + fi value=$(jq -rc --arg key ${{ inputs.settings-path }} '. | getpath($key | split(".")) | if . == null then "" else . end' "$OUTPUT_FILE") echo "value=$value" >> $GITHUB_OUTPUT From 0aec2e913871f26c4fea36c00347f82ea0759f52 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 22:38:38 +0100 Subject: [PATCH 14/17] Added test for non existing stack --- .github/workflows/test-wrong-atmos-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-wrong-atmos-config.yml b/.github/workflows/test-wrong-atmos-config.yml index d0cc679..9236a72 100644 --- a/.github/workflows/test-wrong-atmos-config.yml +++ b/.github/workflows/test-wrong-atmos-config.yml @@ -31,7 +31,7 @@ jobs: stack: core-ue1-dev settings-path: settings.level1.level2.level3.secrets-arn env: - ATMOS_CLI_CONFIG_PATH: ./atmos-config-wrong.yaml + ATMOS_CLI_CONFIG_PATH: /tmp assert: runs-on: ubuntu-latest From e17eb5d134ab7aa0017980efbb251e8821af6aae Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 22:43:41 +0100 Subject: [PATCH 15/17] Added test for non existing stack --- .github/workflows/test-wrong-atmos-config.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-wrong-atmos-config.yml b/.github/workflows/test-wrong-atmos-config.yml index 9236a72..3592aea 100644 --- a/.github/workflows/test-wrong-atmos-config.yml +++ b/.github/workflows/test-wrong-atmos-config.yml @@ -7,6 +7,9 @@ on: # pull_request: {} workflow_dispatch: {} +env: + ATMOS_CLI_CONFIG_PATH: /tmp + jobs: test: runs-on: ubuntu-latest @@ -21,6 +24,7 @@ jobs: uses: cloudposse/github-action-setup-atmos@1.0.2 with: install-wrapper: false + - name: Checkout uses: actions/checkout@v3 @@ -30,8 +34,6 @@ jobs: component: foo stack: core-ue1-dev settings-path: settings.level1.level2.level3.secrets-arn - env: - ATMOS_CLI_CONFIG_PATH: /tmp assert: runs-on: ubuntu-latest From df1e66b43ea47e739bb14b6aa562b9be6c55184b Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 21 Dec 2023 23:54:50 +0100 Subject: [PATCH 16/17] Added test for non existing stack --- .github/workflows/test-wrong-atmos-config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-wrong-atmos-config.yml b/.github/workflows/test-wrong-atmos-config.yml index 3592aea..5f05e15 100644 --- a/.github/workflows/test-wrong-atmos-config.yml +++ b/.github/workflows/test-wrong-atmos-config.yml @@ -9,6 +9,7 @@ on: env: ATMOS_CLI_CONFIG_PATH: /tmp + ATMOS_BASE_PATH: /tmp jobs: test: From 1c6d244e2380ddc1ad22ffe2ce0c2e8afd83337f Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Fri, 22 Dec 2023 00:00:13 +0100 Subject: [PATCH 17/17] Added test for non existing stack --- action.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/action.yml b/action.yml index 98ce93f..fe2f8fb 100644 --- a/action.yml +++ b/action.yml @@ -32,10 +32,5 @@ runs: -s ${{ inputs.stack }} \ --format json \ --file "$OUTPUT_FILE" - RESULT=$? - if [ $RESULT -ne 0 ]; then - echo "Atmos config not found" - exit 1 - fi value=$(jq -rc --arg key ${{ inputs.settings-path }} '. | getpath($key | split(".")) | if . == null then "" else . end' "$OUTPUT_FILE") echo "value=$value" >> $GITHUB_OUTPUT