From 7ce5db8510c9210440873f7917529024c679106d Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Mon, 16 Oct 2023 18:46:40 +0300 Subject: [PATCH] Fix drift detection mode (#42) * Fix drift detection mode * Fix drift detection mode * Fix drift detection mode * Fix drift detection mode * Fix drift detection mode * Fix drift detection mode * Fix drift detection mode * Fix drift detection mode * Fix drift detection mode * Fix drift detection mode * Fix drift detection mode * Fix drift detection mode * Fix drift detection mode --- .../workflows/test-changes-exists-drift.yml | 9 ++++++++- .../workflows/test-no-changes-drift-more.yml | 20 ++++++++++++++++++- action.yml | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-changes-exists-drift.yml b/.github/workflows/test-changes-exists-drift.yml index 89b677f2d..cc6f8b7ee 100644 --- a/.github/workflows/test-changes-exists-drift.yml +++ b/.github/workflows/test-changes-exists-drift.yml @@ -81,7 +81,9 @@ jobs: echo "file_md=$(cat ./metadata/issue-description-plat-ue2-sandbox-foobar_changes.md | jq -Rs .)" >> $GITHUB_OUTPUT - echo "file_json=$(cat ./metadata/plat-ue2-sandbox-foobar_changes.metadata.json | jq -Rs . )" >> $GITHUB_OUTPUT + echo "file_json=$(cat ./metadata/plat-ue2-sandbox-foobar_changes.metadata.json | jq -Rs . )" >> $GITHUB_OUTPUT + + echo files_json_count=$(ls -lA ./metadata/*.json | wc -l) >> $GITHUB_OUTPUT - uses: nick-fields/assert-action@v1 with: @@ -108,6 +110,11 @@ jobs: actual: "${{ fromJSON(needs.test.outputs.summary) }}" expected: "${{ fromJSON(steps.metadata.outputs.file_md) }}" + - uses: nick-fields/assert-action@v1 + with: + actual: "${{ steps.metadata.outputs.files_json_count }}" + expected: "1" + - uses: nick-fields/assert-action@v1 with: actual: "${{ fromJSON(steps.metadata.outputs.file_json) }}" diff --git a/.github/workflows/test-no-changes-drift-more.yml b/.github/workflows/test-no-changes-drift-more.yml index 52547430c..fb10f38a5 100644 --- a/.github/workflows/test-no-changes-drift-more.yml +++ b/.github/workflows/test-no-changes-drift-more.yml @@ -70,17 +70,35 @@ jobs: test -f ./metadata/plat-ue2-sandbox-foobar.metadata.json FILE_EXISTS=$? echo "file_exists=${FILE_EXISTS}" >> $GITHUB_OUTPUT + + test -f ./metadata/issue-description-plat-ue2-sandbox-foobar.md + FILE_EXISTS=$? + echo "file_md_exists=${FILE_EXISTS}" >> $GITHUB_OUTPUT + + echo "file_json=$(cat ./metadata/plat-ue2-sandbox-foobar.metadata.json | jq -Rs . )" >> $GITHUB_OUTPUT + - uses: nick-fields/assert-action@v1 with: actual: "${{ steps.metadata.outputs.dir_exists }}" - expected: "1" + expected: "0" - uses: nick-fields/assert-action@v1 with: actual: "${{ steps.metadata.outputs.file_exists }}" + expected: "0" + + - uses: nick-fields/assert-action@v1 + with: + actual: "${{ steps.metadata.outputs.file_md_exists }}" expected: "1" + - uses: nick-fields/assert-action@v1 + with: + actual: "${{ fromJSON(steps.metadata.outputs.file_json) }}" + expected: | + { "stack": "plat-ue2-sandbox", "component": "foobar", "componentPath": "components/terraform/foobar", "drifted": false, "error": false } + - uses: nick-fields/assert-action@v1 with: actual: "${{ fromJSON(needs.test.outputs.summary) }}" diff --git a/action.yml b/action.yml index 88a378bc0..97ae2958a 100644 --- a/action.yml +++ b/action.yml @@ -417,7 +417,7 @@ runs: fi - name: Upload Artifacts - if: ${{ inputs.drift-detection-mode-enabled == 'true' && steps.atmos-plan.outputs.no-changes == 'false' }} + if: ${{ steps.atmos-github-actions-enabled.outputs.value == 'true' && inputs.drift-detection-mode-enabled == 'true' }} uses: actions/upload-artifact@v3 with: name: metadata