From bed5a9fe94e5fc875809d4a56baef759a7fc5b46 Mon Sep 17 00:00:00 2001 From: Alexander Rashed Date: Fri, 8 Nov 2024 15:48:50 +0100 Subject: [PATCH 1/8] update artifacts GitHub actions to v4 --- ephemeral/shutdown/action.yml | 2 +- ephemeral/startup/action.yml | 4 ++-- finish/action.yml | 2 +- local/action.yml | 4 ++-- prepare/action.yml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ephemeral/shutdown/action.yml b/ephemeral/shutdown/action.yml index 8a1364c..d710269 100644 --- a/ephemeral/shutdown/action.yml +++ b/ephemeral/shutdown/action.yml @@ -13,7 +13,7 @@ runs: using: composite steps: - name: Download PR artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: pr diff --git a/ephemeral/startup/action.yml b/ephemeral/startup/action.yml index 3a4d999..af0c47c 100644 --- a/ephemeral/startup/action.yml +++ b/ephemeral/startup/action.yml @@ -51,7 +51,7 @@ runs: } - name: Download PR artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: pr @@ -102,7 +102,7 @@ runs: echo "AWS_ENDPOINT_URL=$endpointUrl" >> $GITHUB_ENV - name: Upload preview instance URL - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pr path: ./ls-preview-url.txt diff --git a/finish/action.yml b/finish/action.yml index c5e2e09..e922a7c 100644 --- a/finish/action.yml +++ b/finish/action.yml @@ -20,7 +20,7 @@ runs: # Try to get pr artifact from current workflow - name: Download current PR artifact id: get-pr-artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 continue-on-error: true with: name: pr diff --git a/local/action.yml b/local/action.yml index 1705300..e28824d 100644 --- a/local/action.yml +++ b/local/action.yml @@ -17,7 +17,7 @@ runs: - name: Download current workflow's Local State artifact id: get-state-artifact if: ${{ inputs.action == 'load' }} - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 continue-on-error: true with: name: ${{ inputs.name }} @@ -48,7 +48,7 @@ runs: ACTION: "${{ inputs.action }}" - name: Upload LocalStack State - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ inputs.action == 'save' }} with: name: ${{ inputs.name }} diff --git a/prepare/action.yml b/prepare/action.yml index d1276d1..a4333e4 100644 --- a/prepare/action.yml +++ b/prepare/action.yml @@ -16,7 +16,7 @@ runs: run: echo ${{ github.event.number }} > ./pr-id.txt - name: Upload PR number - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pr path: ./pr-id.txt From 6770aaa8334eebc290c6df13665d39634914f329 Mon Sep 17 00:00:00 2001 From: Alexander Rashed Date: Tue, 19 Nov 2024 18:12:49 +0100 Subject: [PATCH 2/8] fix issue with non-unique artifact ID --- ephemeral/shutdown/action.yml | 2 +- ephemeral/startup/action.yml | 4 ++-- finish/action.yml | 4 ++-- prepare/action.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ephemeral/shutdown/action.yml b/ephemeral/shutdown/action.yml index d710269..84f0cb8 100644 --- a/ephemeral/shutdown/action.yml +++ b/ephemeral/shutdown/action.yml @@ -15,7 +15,7 @@ runs: - name: Download PR artifact uses: actions/download-artifact@v4 with: - name: pr + name: pr-id - name: Load the PR ID id: pr diff --git a/ephemeral/startup/action.yml b/ephemeral/startup/action.yml index af0c47c..9f33fa4 100644 --- a/ephemeral/startup/action.yml +++ b/ephemeral/startup/action.yml @@ -53,7 +53,7 @@ runs: - name: Download PR artifact uses: actions/download-artifact@v4 with: - name: pr + name: pr-id - name: Setup preview name shell: bash @@ -104,7 +104,7 @@ runs: - name: Upload preview instance URL uses: actions/upload-artifact@v4 with: - name: pr + name: preview-instance-url path: ./ls-preview-url.txt - name: Run preview deployment diff --git a/finish/action.yml b/finish/action.yml index e922a7c..bab35d0 100644 --- a/finish/action.yml +++ b/finish/action.yml @@ -23,14 +23,14 @@ runs: uses: actions/download-artifact@v4 continue-on-error: true with: - name: pr + name: pr-id # If the above fails, try to get the latest pr artifact from the PR related workflows - name: Download latest PR artifact uses: dawidd6/action-download-artifact@v6 if: ${{ steps.get-pr-artifact.outcome == 'failure' }} with: - name: pr + name: pr-id pr: ${{ github.event.pull_request.number }} # Can be ID or workflow file name, if empty falls back to the latest successful run of the current workflow workflow: ${{ env.PR_ARTIFACT_WORKFLOW }} diff --git a/prepare/action.yml b/prepare/action.yml index a4333e4..0b48846 100644 --- a/prepare/action.yml +++ b/prepare/action.yml @@ -18,7 +18,7 @@ runs: - name: Upload PR number uses: actions/upload-artifact@v4 with: - name: pr + name: pr-id path: ./pr-id.txt - name: Create initial PR comment From f0de04c6db2f19bb0e56cae24f1689f2096ec7ef Mon Sep 17 00:00:00 2001 From: lukqw Date: Wed, 4 Dec 2024 10:51:03 +0100 Subject: [PATCH 3/8] update finish action to download separate artifact incase of pr previews --- finish/action.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/finish/action.yml b/finish/action.yml index bab35d0..a8e539c 100644 --- a/finish/action.yml +++ b/finish/action.yml @@ -40,6 +40,23 @@ runs: shell: bash run: echo "pr_id=$(> $GITHUB_OUTPUT + - name: Download preview instance URL + id: get-preview-instance-url-artifact + if: inputs.include-preview + uses: actions/download-artifact@v4 + with: + name: preview-instance-url + + # If the above fails, try to get the latest pr artifact from the PR related workflows + - name: Download latest PR artifact + uses: dawidd6/action-download-artifact@v6 + if: ${{ steps.get-preview-instance-url-artifact.outcome == 'failure' }} + with: + name: preview-instance-url + pr: ${{ github.event.pull_request.number }} + # Can be ID or workflow file name, if empty falls back to the latest successful run of the current workflow + workflow: ${{ env.PR_ARTIFACT_WORKFLOW }} + - name: Load the Ephemeral Instance URL shell: bash if: inputs.include-preview From 697cbd5ae4566aa0552be69b4df18b7e05a2ac35 Mon Sep 17 00:00:00 2001 From: lukqw Date: Wed, 4 Dec 2024 10:51:20 +0100 Subject: [PATCH 4/8] update smoke test suite for ephemeral instances --- .github/workflows/ephemeral.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ephemeral.yml b/.github/workflows/ephemeral.yml index d2ddff8..33efe12 100644 --- a/.github/workflows/ephemeral.yml +++ b/.github/workflows/ephemeral.yml @@ -18,6 +18,7 @@ jobs: "github-token": ${{ toJSON(secrets.GITHUB_TOKEN) }}, "state-backend": "ephemeral", "state-action": "start", + "include-preview": "true", "skip-ephemeral-stop": "true", "preview-cmd": ${{ toJSON(env.PREVIEW_CMD) }}, "lifetime": 5, From fb37edc9d9dbd073f183ffca3d2ca5b3cd2c50f1 Mon Sep 17 00:00:00 2001 From: lukqw Date: Wed, 4 Dec 2024 11:05:38 +0100 Subject: [PATCH 5/8] add assertion which checks for preview comment --- .github/workflows/ephemeral.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/ephemeral.yml b/.github/workflows/ephemeral.yml index 33efe12..32587b8 100644 --- a/.github/workflows/ephemeral.yml +++ b/.github/workflows/ephemeral.yml @@ -45,6 +45,22 @@ jobs: exit 1 fi + - name: Check PR Comments for preview text + id: check-comments + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + TEXT_TO_FIND="Preview for this PR" + + # Fetch PR comments + comments=$(gh api repos/${{ github.repository }}/issues/$PR_NUMBER/comments) + + # Check if the specific text is in the comments + if echo "$comments" | jq -e --arg text "$TEXT_TO_FIND" '.[] | select(.body | contains($text))' > /dev/null; then + echo "Found the text in PR comments." + else + echo "Text not found in PR comments." + exit 1 + fi # We want explicit shutdown - name: Shutdown ephemeral instance From 6ecd57939947d09a8f18769a196b6f1bd12d01c4 Mon Sep 17 00:00:00 2001 From: lukqw Date: Wed, 4 Dec 2024 11:08:14 +0100 Subject: [PATCH 6/8] add gh token --- .github/workflows/ephemeral.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ephemeral.yml b/.github/workflows/ephemeral.yml index 32587b8..44cf021 100644 --- a/.github/workflows/ephemeral.yml +++ b/.github/workflows/ephemeral.yml @@ -61,6 +61,8 @@ jobs: echo "Text not found in PR comments." exit 1 fi + env: + GH_TOKEN: ${{ github.token }} # We want explicit shutdown - name: Shutdown ephemeral instance From a84276f3adf6956dcbcc50f60df82e2e98448757 Mon Sep 17 00:00:00 2001 From: lukqw Date: Wed, 4 Dec 2024 11:13:04 +0100 Subject: [PATCH 7/8] failure case check --- .github/workflows/ephemeral.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ephemeral.yml b/.github/workflows/ephemeral.yml index 44cf021..45ad7e5 100644 --- a/.github/workflows/ephemeral.yml +++ b/.github/workflows/ephemeral.yml @@ -18,7 +18,6 @@ jobs: "github-token": ${{ toJSON(secrets.GITHUB_TOKEN) }}, "state-backend": "ephemeral", "state-action": "start", - "include-preview": "true", "skip-ephemeral-stop": "true", "preview-cmd": ${{ toJSON(env.PREVIEW_CMD) }}, "lifetime": 5, From a118c9cc18483dd5581f604c648c9ac2da672fb6 Mon Sep 17 00:00:00 2001 From: lukqw Date: Wed, 4 Dec 2024 11:15:17 +0100 Subject: [PATCH 8/8] make tests green again --- .github/workflows/ephemeral.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ephemeral.yml b/.github/workflows/ephemeral.yml index 45ad7e5..35041ad 100644 --- a/.github/workflows/ephemeral.yml +++ b/.github/workflows/ephemeral.yml @@ -18,6 +18,7 @@ jobs: "github-token": ${{ toJSON(secrets.GITHUB_TOKEN) }}, "state-backend": "ephemeral", "state-action": "start", + "include-preview": "true", "skip-ephemeral-stop": "true", "preview-cmd": ${{ toJSON(env.PREVIEW_CMD) }}, "lifetime": 5, @@ -31,7 +32,7 @@ jobs: awslocal sqs create-queue --queue-name=test-queue echo "Deploy is done." - - name: Assertion step + - name: Assert mailhog is installed run: | sudo apt-get install jq jo response=$(curl ${AWS_ENDPOINT_URL}/_localstack/extensions/list)