Skip to content

Commit 16dd08f

Browse files
committed
ci: add e2e login flow test workflow
- Add scheduled nightly and on-demand workflow - Configure GH_TEST_EMAIL, GH_TEST_PASSWORD, GH_TEST_TOTP_SECRET secrets - Install system dependencies (postgresql-client, lsof) - Upload Playwright reports and screenshots on failure
1 parent 852011d commit 16dd08f

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: E2E Login Flow Tests
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Run nightly at 6am PT (14:00 UTC) to avoid OAuth rate limits
7+
- cron: '0 14 * * *'
8+
9+
jobs:
10+
e2e-login-flow:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check for required secrets
15+
id: check-secrets
16+
run: |
17+
if [ -z "${{ secrets.GH_TEST_EMAIL }}" ] || [ -z "${{ secrets.GH_TEST_PASSWORD }}" ]; then
18+
echo "skip=true" >> $GITHUB_OUTPUT
19+
echo "⚠️ GitHub test credentials not configured - skipping tests"
20+
else
21+
echo "skip=false" >> $GITHUB_OUTPUT
22+
fi
23+
24+
- name: Checkout repository
25+
if: steps.check-secrets.outputs.skip != 'true'
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Bun
29+
if: steps.check-secrets.outputs.skip != 'true'
30+
uses: oven-sh/setup-bun@v2
31+
with:
32+
bun-version: '1.3.0'
33+
34+
- name: Cache dependencies
35+
if: steps.check-secrets.outputs.skip != 'true'
36+
uses: actions/cache@v3
37+
with:
38+
path: |
39+
node_modules
40+
*/node_modules
41+
packages/*/node_modules
42+
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lock*') }}
43+
restore-keys: |
44+
${{ runner.os }}-deps-
45+
46+
- name: Install system dependencies
47+
if: steps.check-secrets.outputs.skip != 'true'
48+
run: |
49+
sudo apt-get update
50+
sudo apt-get install -y postgresql-client lsof
51+
52+
- name: Install dependencies
53+
if: steps.check-secrets.outputs.skip != 'true'
54+
run: bun install --frozen-lockfile
55+
56+
- name: Install Playwright browsers
57+
if: steps.check-secrets.outputs.skip != 'true'
58+
run: cd e2e && bunx playwright install chromium --with-deps
59+
60+
- name: Set environment variables
61+
if: steps.check-secrets.outputs.skip != 'true'
62+
env:
63+
SECRETS_CONTEXT: ${{ toJSON(secrets) }}
64+
run: |
65+
VAR_NAMES=$(bun scripts/generate-ci-env.ts)
66+
echo "$SECRETS_CONTEXT" | jq -r --argjson vars "$VAR_NAMES" '
67+
to_entries | .[] | select(.key as $k | $vars | index($k)) | .key + "=" + .value
68+
' >> $GITHUB_ENV
69+
echo "CODEBUFF_GITHUB_ACTIONS=true" >> $GITHUB_ENV
70+
echo "NEXT_PUBLIC_CB_ENVIRONMENT=test" >> $GITHUB_ENV
71+
echo "NEXT_PUBLIC_INFISICAL_UP=true" >> $GITHUB_ENV
72+
# GitHub test account credentials
73+
echo "GH_TEST_EMAIL=${{ secrets.GH_TEST_EMAIL }}" >> $GITHUB_ENV
74+
echo "GH_TEST_PASSWORD=${{ secrets.GH_TEST_PASSWORD }}" >> $GITHUB_ENV
75+
echo "GH_TEST_TOTP_SECRET=${{ secrets.GH_TEST_TOTP_SECRET }}" >> $GITHUB_ENV
76+
77+
- name: Build SDK
78+
if: steps.check-secrets.outputs.skip != 'true'
79+
run: cd sdk && bun run build
80+
81+
- name: Run E2E Login Flow Tests
82+
if: steps.check-secrets.outputs.skip != 'true'
83+
uses: nick-fields/retry@v3
84+
with:
85+
timeout_minutes: 30
86+
max_attempts: 3
87+
command: cd e2e && bun run test
88+
89+
- name: Upload Playwright Report
90+
uses: actions/upload-artifact@v4
91+
if: always() && steps.check-secrets.outputs.skip != 'true'
92+
with:
93+
name: playwright-report
94+
path: e2e/playwright-report/
95+
retention-days: 7
96+
97+
- name: Upload Test Screenshots
98+
uses: actions/upload-artifact@v4
99+
if: failure() && steps.check-secrets.outputs.skip != 'true'
100+
with:
101+
name: test-screenshots
102+
path: e2e/test-results/
103+
retention-days: 7
104+
105+
- name: Log skip reason
106+
if: steps.check-secrets.outputs.skip == 'true'
107+
run: |
108+
echo "E2E Login Flow tests skipped: GitHub test account credentials not configured."
109+
echo "To enable these tests, add the following secrets:"
110+
echo " - GH_TEST_EMAIL"
111+
echo " - GH_TEST_PASSWORD"
112+
echo " - GH_TEST_TOTP_SECRET (if 2FA is enabled on the test account)"

0 commit comments

Comments
 (0)