Skip to content

Commit

Permalink
Added drift support for json metadata (#41)
Browse files Browse the repository at this point in the history
* Added drift support for json metadata

* Added drift support for json metadata

* Added drift support for json metadata

* Added drift support for json metadata

* Added drift support for json metadata

* Added drift support for json metadata

* Added drift support for json metadata
  • Loading branch information
goruha authored Oct 11, 2023
1 parent ca354b7 commit e8ef6e7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/test-changes-exists-drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ jobs:
echo "file_md_exists=${FILE_EXISTS}" >> $GITHUB_OUTPUT
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
- uses: nick-fields/assert-action@v1
with:
Expand All @@ -106,6 +108,12 @@ jobs:
actual: "${{ fromJSON(needs.test.outputs.summary) }}"
expected: "${{ fromJSON(steps.metadata.outputs.file_md) }}"

- uses: nick-fields/assert-action@v1
with:
actual: "${{ fromJSON(steps.metadata.outputs.file_json) }}"
expected: |
{ "stack": "plat-ue2-sandbox", "component": "foobar/changes", "componentPath": "components/terraform/foobar", "drifted": true, "error": false }
- uses: nick-fields/assert-action@v1
with:
actual: "${{ fromJSON(needs.test.outputs.summary) }}"
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test-failed-plan-drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ jobs:
echo "file_md_exists=${FILE_EXISTS}" >> $GITHUB_OUTPUT
echo "file_md=$(cat ./metadata/issue-description-plat-ue2-sandbox-foobar-fail.md | jq -Rs .)" >> $GITHUB_OUTPUT
echo "file_json=$(cat ./metadata/plat-ue2-sandbox-foobar-fail.metadata.json | jq -Rs . )" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@v1
with:
Expand All @@ -97,6 +99,12 @@ jobs:
actual: "${{ fromJSON(needs.test.outputs.summary) }}"
expected: "${{ fromJSON(steps.metadata.outputs.file_md) }}"

- uses: nick-fields/assert-action@v1
with:
actual: "${{ fromJSON(steps.metadata.outputs.file_json) }}"
expected: |
{ "stack": "plat-ue2-sandbox", "component": "foobar-fail", "componentPath": "components/terraform/foobar", "drifted": false, "error": true }
- uses: nick-fields/assert-action@v1
with:
actual: "${{ fromJSON(needs.test.outputs.summary) }}"
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ runs:
if: ${{ steps.atmos-github-actions-enabled.outputs.value == 'true' && inputs.drift-detection-mode-enabled == 'true' }}
shell: bash
run: |
echo -n '{ "stack": "${{ inputs.stack }}", "component": "${{ inputs.component }}", "componentPath": "${{ inputs.component-path }}", "drifted": '"${{ steps.atmos-plan.outputs.changes }}"' }' > "metadata/${{ steps.vars.outputs.component_slug }}.metadata.json"
echo -n '{ "stack": "${{ inputs.stack }}", "component": "${{ inputs.component }}", "componentPath": "${{ inputs.component-path }}", "drifted": '"${{ steps.atmos-plan.outputs.changes }}"', "error": '"${{ steps.atmos-plan.outputs.error }}"' }' > "metadata/${{ steps.vars.outputs.component_slug }}.metadata.json"
- name: Publish Summary or Generate GitHub Issue Description for Drift Detection
id: summary
Expand Down

0 comments on commit e8ef6e7

Please sign in to comment.