Skip to content

A local-first personal finance app

Fix end-to-end testing workflow (#758)

Jed Fox2762495a6844
diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml
index 53be312d81..509373a46f 100644
--- a/.github/workflows/e2e-test.yml
+++ b/.github/workflows/e2e-test.yml
@@ -15,24 +15,16 @@ jobs:
uses: ./.github/actions/setup
- name: Setup Playwright
run: npx playwright install chromium --with-deps
- - name: Wait for Pages changed to neutral
- uses: fountainhead/[email protected]
- id: wait-for-Netlify
- with:
- token: ${{ secrets.GITHUB_TOKEN }}
- ref: ${{ github.event.pull_request.head.sha || github.sha }}
- checkName: 'Pages changed - actualbudget'
- - name: Waiting for Netlify Preview
- if: steps.wait-for-Netlify.outputs.conclusion == 'neutral'
- uses: jakepartusch/[email protected]
- id: waitFor200
- with:
- site_name: 'actualbudget'
- max_timeout: 240
+ - name: Wait for Netlify build to finish
+ id: netlify
+ env:
+ COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: ./bin/netlify-wait-for-build
- name: Run E2E Tests on Netlify URL
run: yarn e2e
env:
- E2E_START_URL: https://deploy-preview-${{env.GITHUB_PR_NUMBER}}--actualbudget.netlify.app
+ E2E_START_URL: ${{ steps.netlify.outputs.url }}
- uses: actions/upload-artifact@v3
if: always()
with:
diff --git a/bin/netlify-wait-for-build b/bin/netlify-wait-for-build
new file mode 100755
index 0000000000..c3cb9540cc
--- /dev/null
+++ b/bin/netlify-wait-for-build
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+current_commit=$(git rev-parse HEAD)
+
+echo "Running on commit $COMMIT_SHA"
+
+function get_status() {
+ echo "::group::API Response"
+ curl --header "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/actualbudget/actual/commits/$COMMIT_SHA/statuses" > /tmp/status.json
+ cat /tmp/status.json
+ echo "::endgroup::"
+ netlify=$(jq '[.[] | select(.context == "netlify/actualbudget/deploy-preview")][0]' /tmp/status.json)
+ state=$(jq -r '.state' <<< "$netlify")
+ echo "::group::Netlify Status"
+ echo "$netlify"
+ echo "::endgroup::"
+}
+
+get_status
+
+while [ "$netlify" == "null" ]; do
+ echo "Waiting for Netlify to start building..."
+ sleep 10
+ get_status
+done
+
+while [ "$state" == "pending" ]; do
+ echo "Waiting for Netlify to finish building..."
+ sleep 10
+ get_status
+done
+
+if [ "$state" == "success" ]; then
+ echo -e "\033[0;32mNetlify build succeeded!\033[0m"
+ jq -r '"url=" + .target_url' <<< "$netlify" > $GITHUB_OUTPUT
+ exit 0
+else
+ echo -e "\033[0;31mNetlify build failed. Cancelling end-to-end tests.\033[0m"
+ exit 1
+fi
diff --git a/upcoming-release-notes/758.md b/upcoming-release-notes/758.md
new file mode 100644
index 0000000000..59a6b76ee0
--- /dev/null
+++ b/upcoming-release-notes/758.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [j-f1]
+---
+
+Fix end-to-end testing workflow