Skip to content

Commit 5a4f9c5

Browse files
committed
chore: Update E2E testing workflow and enhance test script
- Renamed workflow from "E2E Tests" to "End-to-End Tests" for clarity. - Limited push and pull request triggers to the main branch. - Added a nightly schedule for automated testing. - Consolidated Node.js and pnpm setup into a single step using a custom action. - Enhanced the E2E test script to support CI mode with GitHub Actions reporter. - Improved logging and cleanup processes for background tasks. - Updated deployment and client startup procedures for better reliability. These changes streamline the E2E testing process and improve the overall testing framework for the Cookie Jar protocol.
1 parent e634211 commit 5a4f9c5

File tree

9 files changed

+1222
-97
lines changed

9 files changed

+1222
-97
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: 'Setup Node.js and pnpm'
2+
description: 'Setup Node.js, pnpm, and install dependencies for Cookie Jar project'
3+
4+
inputs:
5+
node-version:
6+
description: 'Node.js version to use'
7+
required: false
8+
default: '18'
9+
pnpm-version:
10+
description: 'pnpm version to use'
11+
required: false
12+
default: '8'
13+
working-directory:
14+
description: 'Working directory to run commands'
15+
required: false
16+
default: '.'
17+
18+
runs:
19+
using: 'composite'
20+
steps:
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ inputs.node-version }}
25+
cache: 'npm'
26+
cache-dependency-path: '${{ inputs.working-directory }}/pnpm-lock.yaml'
27+
28+
- name: Setup pnpm
29+
uses: pnpm/action-setup@v3
30+
with:
31+
version: ${{ inputs.pnpm-version }}
32+
33+
- name: Install dependencies
34+
shell: bash
35+
working-directory: ${{ inputs.working-directory }}
36+
run: pnpm install --frozen-lockfile
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
name: Accessibility Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '0 6 * * 1' # Weekly on Mondays at 6 AM UTC
10+
workflow_dispatch:
11+
12+
env:
13+
NODE_VERSION: '18'
14+
PNPM_VERSION: '8'
15+
16+
jobs:
17+
accessibility-tests:
18+
name: A11y Compliance Tests
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 45
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
with:
26+
submodules: recursive
27+
28+
- name: Setup Node.js and pnpm
29+
uses: ./.github/actions/setup-node-pnpm
30+
with:
31+
node-version: ${{ env.NODE_VERSION }}
32+
pnpm-version: ${{ env.PNPM_VERSION }}
33+
34+
- name: Install Foundry
35+
uses: foundry-rs/foundry-toolchain@v1
36+
with:
37+
version: nightly
38+
39+
- name: Install Playwright Browsers
40+
run: npx playwright install --with-deps
41+
42+
- name: Setup test environment (minimal)
43+
run: |
44+
echo "🚀 Setting up minimal environment for accessibility tests..."
45+
46+
# Start Anvil
47+
cd contracts
48+
anvil --host 0.0.0.0 --port 8545 --chain-id 31337 \
49+
--accounts 10 --balance 1000 > anvil.log 2>&1 &
50+
ANVIL_PID=$!
51+
echo "ANVIL_PID=$ANVIL_PID" >> $GITHUB_ENV
52+
53+
# Wait for Anvil
54+
for i in {1..20}; do
55+
if curl -s -X POST -H "Content-Type: application/json" \
56+
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
57+
http://127.0.0.1:8545 > /dev/null 2>&1; then
58+
break
59+
fi
60+
sleep 1
61+
done
62+
63+
# Quick contract build and deploy
64+
forge build
65+
forge script script/DeployLocal.s.sol:DeployLocalScript \
66+
--rpc-url http://127.0.0.1:8545 \
67+
--broadcast \
68+
--sender 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
69+
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
70+
71+
cd ..
72+
./scripts/create-deployment-file.sh
73+
./scripts/copy-deployment.sh
74+
75+
# Start client
76+
cd client
77+
pnpm generate
78+
npm run dev &
79+
CLIENT_PID=$!
80+
echo "CLIENT_PID=$CLIENT_PID" >> $GITHUB_ENV
81+
82+
# Wait for client
83+
cd ..
84+
for i in {1..30}; do
85+
if curl -s http://localhost:3000 > /dev/null 2>&1; then
86+
echo "✅ Test environment ready!"
87+
break
88+
fi
89+
sleep 2
90+
done
91+
92+
- name: Run accessibility tests
93+
run: |
94+
echo "♿ Running accessibility compliance tests..."
95+
96+
# Run only accessibility-focused tests
97+
npx playwright test --grep "accessibility" --reporter=github
98+
99+
if [ $? -eq 0 ]; then
100+
echo ""
101+
echo "✅ Accessibility tests passed!"
102+
else
103+
echo ""
104+
echo "❌ Accessibility issues detected"
105+
echo "💡 Check the detailed report for WCAG compliance issues"
106+
fi
107+
108+
- name: Generate accessibility report
109+
if: always()
110+
run: |
111+
echo "📊 Generating accessibility compliance summary..."
112+
113+
# Generate HTML report for accessibility tests
114+
npx playwright show-report --host=0.0.0.0 --port=9323 > /dev/null 2>&1 &
115+
REPORT_PID=$!
116+
sleep 2
117+
118+
# Create summary
119+
echo ""
120+
echo "♿ ACCESSIBILITY SUMMARY"
121+
echo "======================="
122+
echo "📋 This workflow tests WCAG 2.1 Level AA compliance"
123+
echo "🔍 Areas covered:"
124+
echo " • Keyboard navigation"
125+
echo " • Screen reader compatibility"
126+
echo " • Color contrast ratios"
127+
echo " • Focus management"
128+
echo " • Semantic HTML structure"
129+
echo " • ARIA labels and roles"
130+
echo ""
131+
132+
if [ -d "e2e/playwright-report" ]; then
133+
echo "📊 Detailed report available in artifacts"
134+
else
135+
echo "⚠️ No detailed report generated"
136+
fi
137+
138+
kill $REPORT_PID 2>/dev/null || true
139+
140+
- name: Accessibility recommendations
141+
if: always()
142+
run: |
143+
echo ""
144+
echo "💡 ACCESSIBILITY BEST PRACTICES"
145+
echo "================================"
146+
echo "✅ Automated testing completed"
147+
echo ""
148+
echo "🔍 Additional manual testing recommended:"
149+
echo " • Test with actual screen readers (NVDA, JAWS, VoiceOver)"
150+
echo " • Verify keyboard-only navigation flows"
151+
echo " • Test with high contrast mode"
152+
echo " • Validate with zoom up to 200%"
153+
echo " • Check color blindness simulation"
154+
echo ""
155+
echo "🛠️ Tools for manual testing:"
156+
echo " • axe DevTools browser extension"
157+
echo " • WAVE Web Accessibility Evaluator"
158+
echo " • Lighthouse accessibility audit"
159+
echo " • Color contrast analyzers"
160+
echo ""
161+
echo "📚 Resources:"
162+
echo " • WCAG 2.1 Guidelines: https://www.w3.org/WAI/WCAG21/quickref/"
163+
echo " • A11y Project: https://www.a11yproject.com/"
164+
echo " • WebAIM: https://webaim.org/"
165+
166+
- name: Cleanup
167+
if: always()
168+
run: |
169+
if [ ! -z "$ANVIL_PID" ]; then
170+
kill $ANVIL_PID || true
171+
fi
172+
if [ ! -z "$CLIENT_PID" ]; then
173+
kill $CLIENT_PID || true
174+
fi
175+
pkill anvil || true
176+
pkill -f "next dev" || true
177+
178+
- name: Upload accessibility report
179+
uses: actions/upload-artifact@v4
180+
if: always()
181+
with:
182+
name: accessibility-report
183+
path: e2e/playwright-report/
184+
retention-days: 30
185+
186+
- name: Upload test results
187+
uses: actions/upload-artifact@v4
188+
if: always()
189+
with:
190+
name: accessibility-test-results
191+
path: e2e/test-results/
192+
retention-days: 30
193+
194+
accessibility-summary:
195+
name: Accessibility Summary
196+
runs-on: ubuntu-latest
197+
needs: [accessibility-tests]
198+
if: always()
199+
200+
steps:
201+
- name: Summary
202+
run: |
203+
echo "♿ ACCESSIBILITY TESTING COMPLETED"
204+
echo "=================================="
205+
echo ""
206+
echo "📊 Test Results: ${{ needs.accessibility-tests.result }}"
207+
echo ""
208+
209+
if [ "${{ needs.accessibility-tests.result }}" = "success" ]; then
210+
echo "✅ Accessibility tests passed!"
211+
echo "🎉 Cookie Jar meets automated WCAG compliance checks"
212+
echo "💡 Continue with manual testing for comprehensive coverage"
213+
else
214+
echo "⚠️ Accessibility issues detected"
215+
echo "💡 Review test artifacts for detailed WCAG violations"
216+
echo "🔧 Fix accessibility issues before production deployment"
217+
fi
218+
219+
echo ""
220+
echo "🔄 This analysis runs:"
221+
echo " • On every push to main branch"
222+
echo " • On every PR to main branch"
223+
echo " • Weekly on Monday at 6 AM UTC"
224+
echo " • Manually via workflow dispatch"
225+
echo ""
226+
echo "🎯 Goal: Ensure Cookie Jar is accessible to all users"

.github/workflows/code-quality.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Code Quality & Linting
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
env:
9+
NODE_VERSION: '18'
10+
PNPM_VERSION: '8'
11+
12+
jobs:
13+
code-quality:
14+
name: Lint & Type Check
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 10
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js and pnpm
23+
uses: ./.github/actions/setup-node-pnpm
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
pnpm-version: ${{ env.PNPM_VERSION }}
27+
28+
- name: Lint client code
29+
run: |
30+
cd client
31+
pnpm run lint
32+
33+
- name: TypeScript type checking
34+
run: |
35+
cd client
36+
pnpm run type-check
37+
38+
- name: Format check
39+
run: |
40+
cd client
41+
if ! pnpm run format:check 2>/dev/null; then
42+
echo "⚠️ Format check script not found, checking with prettier directly"
43+
npx prettier --check "**/*.{ts,tsx,js,jsx,json,md}" --ignore-path .gitignore || {
44+
echo ""
45+
echo "❌ Code formatting issues found!"
46+
echo "💡 Run 'pnpm run format' or 'npx prettier --write .' to fix"
47+
exit 1
48+
}
49+
fi
50+
51+
- name: Check for unused dependencies
52+
run: |
53+
cd client
54+
if command -v depcheck &> /dev/null; then
55+
echo "📦 Checking for unused dependencies..."
56+
npx depcheck --ignores="@types/*,@typescript-eslint/*,eslint-*"
57+
else
58+
echo "⚠️ Skipping dependency check (depcheck not available)"
59+
fi
60+
continue-on-error: true # Don't fail build on unused deps
61+
62+
- name: Summary
63+
if: always()
64+
run: |
65+
echo ""
66+
echo "✅ Code quality checks completed!"
67+
echo "📋 This workflow provides fast feedback on:"
68+
echo " • ESLint rule compliance"
69+
echo " • TypeScript compilation"
70+
echo " • Code formatting consistency"
71+
echo ""
72+
if [ "${{ job.status }}" = "success" ]; then
73+
echo "🎉 All checks passed - code is ready for review!"
74+
else
75+
echo "❌ Some checks failed - please review and fix issues above"
76+
fi

0 commit comments

Comments
 (0)