Skip to content

Commit c3dde3e

Browse files
author
Gal C
committed
added github workflows
1 parent cceddf5 commit c3dde3e

2 files changed

Lines changed: 347 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
code-quality:
11+
name: Code Quality
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '18'
22+
cache: 'yarn'
23+
24+
- name: Install dependencies
25+
run: yarn install --frozen-lockfile
26+
27+
- name: Run linting
28+
run: yarn lint
29+
30+
- name: Check formatting
31+
run: yarn format:check
32+
33+
- name: Type check
34+
run: yarn type-check
35+
36+
unit-tests:
37+
name: Unit Tests
38+
runs-on: ubuntu-latest
39+
needs: code-quality
40+
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Setup Node.js
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version: '18'
49+
cache: 'yarn'
50+
51+
- name: Install dependencies
52+
run: yarn install --frozen-lockfile
53+
54+
- name: Run unit tests
55+
run: yarn test:ci
56+
57+
- name: Upload test results
58+
uses: actions/upload-artifact@v4
59+
if: always()
60+
with:
61+
name: unit-test-results
62+
path: |
63+
coverage/
64+
junit.xml
65+
retention-days: 30
66+
67+
visual-tests:
68+
name: Visual Tests
69+
runs-on: ubuntu-latest
70+
needs: code-quality
71+
72+
steps:
73+
- name: Checkout code
74+
uses: actions/checkout@v4
75+
76+
- name: Setup Node.js
77+
uses: actions/setup-node@v4
78+
with:
79+
node-version: '18'
80+
cache: 'yarn'
81+
82+
- name: Install dependencies
83+
run: yarn install --frozen-lockfile
84+
85+
- name: Install system dependencies for Puppeteer
86+
run: |
87+
sudo apt-get update
88+
sudo apt-get install -y \
89+
ca-certificates \
90+
fonts-liberation \
91+
libappindicator3-1 \
92+
libasound2 \
93+
libatk-bridge2.0-0 \
94+
libatk1.0-0 \
95+
libc6 \
96+
libcairo2 \
97+
libcups2 \
98+
libdbus-1-3 \
99+
libexpat1 \
100+
libfontconfig1 \
101+
libgbm1 \
102+
libgcc1 \
103+
libglib2.0-0 \
104+
libgtk-3-0 \
105+
libnspr4 \
106+
libnss3 \
107+
libpango-1.0-0 \
108+
libpangocairo-1.0-0 \
109+
libstdc++6 \
110+
libx11-6 \
111+
libx11-xcb1 \
112+
libxcb1 \
113+
libxcomposite1 \
114+
libxcursor1 \
115+
libxdamage1 \
116+
libxext6 \
117+
libxfixes3 \
118+
libxi6 \
119+
libxrandr2 \
120+
libxrender1 \
121+
libxss1 \
122+
libxtst6 \
123+
lsb-release \
124+
wget \
125+
xdg-utils
126+
127+
- name: Setup Expo CLI
128+
run: npm install -g @expo/cli
129+
130+
- name: Start Expo server
131+
run: |
132+
yarn start --web &
133+
echo $! > expo_pid.txt
134+
# Wait for server to start
135+
timeout 120 bash -c 'until curl -f http://localhost:8081 > /dev/null 2>&1; do sleep 2; done'
136+
env:
137+
CI: true
138+
EXPO_NO_DOTENV: true
139+
140+
- name: Run visual tests
141+
run: yarn test:visual:headless
142+
env:
143+
CI: true
144+
145+
- name: Stop Expo server
146+
if: always()
147+
run: |
148+
if [ -f expo_pid.txt ]; then
149+
kill $(cat expo_pid.txt) || true
150+
rm expo_pid.txt
151+
fi
152+
153+
- name: Upload visual test results
154+
uses: actions/upload-artifact@v4
155+
if: always()
156+
with:
157+
name: visual-test-results
158+
path: |
159+
test-results/
160+
baselines/
161+
retention-days: 30
162+
163+
- name: Upload visual test screenshots
164+
uses: actions/upload-artifact@v4
165+
if: failure()
166+
with:
167+
name: visual-test-screenshots
168+
path: test-results/screenshots/
169+
retention-days: 7
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: Visual Regression Testing
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
paths:
7+
- 'src/**'
8+
- 'tests/visual/**'
9+
- 'package.json'
10+
- 'yarn.lock'
11+
12+
jobs:
13+
visual-regression:
14+
name: Visual Regression Tests
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout PR code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '18'
27+
cache: 'yarn'
28+
29+
- name: Install dependencies
30+
run: yarn install --frozen-lockfile
31+
32+
- name: Install system dependencies for Puppeteer
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y \
36+
ca-certificates \
37+
fonts-liberation \
38+
libappindicator3-1 \
39+
libasound2 \
40+
libatk-bridge2.0-0 \
41+
libatk1.0-0 \
42+
libc6 \
43+
libcairo2 \
44+
libcups2 \
45+
libdbus-1-3 \
46+
libexpat1 \
47+
libfontconfig1 \
48+
libgbm1 \
49+
libgcc1 \
50+
libglib2.0-0 \
51+
libgtk-3-0 \
52+
libnspr4 \
53+
libnss3 \
54+
libpango-1.0-0 \
55+
libpangocairo-1.0-0 \
56+
libstdc++6 \
57+
libx11-6 \
58+
libx11-xcb1 \
59+
libxcb1 \
60+
libxcomposite1 \
61+
libxcursor1 \
62+
libxdamage1 \
63+
libxext6 \
64+
libxfixes3 \
65+
libxi6 \
66+
libxrandr2 \
67+
libxrender1 \
68+
libxss1 \
69+
libxtst6 \
70+
lsb-release \
71+
wget \
72+
xdg-utils
73+
74+
- name: Setup Expo CLI
75+
run: npm install -g @expo/cli
76+
77+
- name: Create baseline directory
78+
run: mkdir -p baselines/screenshots
79+
80+
- name: Checkout base branch baselines
81+
run: |
82+
git fetch origin ${{ github.event.pull_request.base.ref }}
83+
git checkout origin/${{ github.event.pull_request.base.ref }} -- baselines/ || echo "No baselines found in base branch"
84+
85+
- name: Start Expo server
86+
run: |
87+
yarn start --web &
88+
echo $! > expo_pid.txt
89+
timeout 120 bash -c 'until curl -f http://localhost:8081 > /dev/null 2>&1; do sleep 2; done'
90+
env:
91+
CI: true
92+
EXPO_NO_DOTENV: true
93+
94+
- name: Run visual tests
95+
run: yarn test:visual:headless
96+
env:
97+
CI: true
98+
99+
- name: Stop Expo server
100+
if: always()
101+
run: |
102+
if [ -f expo_pid.txt ]; then
103+
kill $(cat expo_pid.txt) || true
104+
rm expo_pid.txt
105+
fi
106+
107+
- name: Compare screenshots
108+
run: |
109+
if [ -d "baselines/screenshots" ] && [ -d "test-results/screenshots" ]; then
110+
echo "Comparing screenshots..."
111+
# Create a simple comparison report
112+
for baseline in baselines/screenshots/*.png; do
113+
if [ -f "$baseline" ]; then
114+
filename=$(basename "$baseline")
115+
if [ -f "test-results/screenshots/$filename" ]; then
116+
echo "✅ Found matching screenshot: $filename"
117+
else
118+
echo "❌ Missing screenshot in test results: $filename"
119+
fi
120+
fi
121+
done
122+
123+
for result in test-results/screenshots/*.png; do
124+
if [ -f "$result" ]; then
125+
filename=$(basename "$result")
126+
if [ ! -f "baselines/screenshots/$filename" ]; then
127+
echo "🆕 New screenshot detected: $filename"
128+
fi
129+
fi
130+
done
131+
else
132+
echo "No baseline screenshots found for comparison"
133+
fi
134+
135+
- name: Upload comparison results
136+
uses: actions/upload-artifact@v4
137+
if: always()
138+
with:
139+
name: visual-regression-comparison
140+
path: |
141+
test-results/
142+
baselines/
143+
retention-days: 14
144+
145+
- name: Comment PR with results
146+
uses: actions/github-script@v7
147+
if: always()
148+
with:
149+
script: |
150+
const fs = require('fs');
151+
const path = require('path');
152+
153+
let comment = '## 📸 Visual Regression Test Results\n\n';
154+
155+
// Check if visual tests passed
156+
if (fs.existsSync('test-results/screenshots')) {
157+
const screenshots = fs.readdirSync('test-results/screenshots');
158+
comment += `✅ Visual tests completed successfully\n`;
159+
comment += `📊 Generated ${screenshots.length} screenshot(s)\n\n`;
160+
161+
if (screenshots.length > 0) {
162+
comment += '### Screenshots Generated:\n';
163+
screenshots.forEach(screenshot => {
164+
comment += `- \`${screenshot}\`\n`;
165+
});
166+
}
167+
} else {
168+
comment += '❌ Visual tests failed to generate screenshots\n\n';
169+
}
170+
171+
comment += '\n💡 **Tip**: Download the artifacts to view the actual screenshots and compare them manually if needed.';
172+
173+
github.rest.issues.createComment({
174+
issue_number: context.issue.number,
175+
owner: context.repo.owner,
176+
repo: context.repo.repo,
177+
body: comment
178+
});

0 commit comments

Comments
 (0)