forked from SemiAnalysisAI/InferenceX-app
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (158 loc) · 6.21 KB
/
tests-e2e.yml
File metadata and controls
165 lines (158 loc) · 6.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: 'Tests (E2E)'
on:
pull_request:
branches: [main, master]
types: [opened, synchronize, ready_for_review]
paths:
- '.github/workflows/tests-e2e.yml'
- 'package.json'
- 'packages/app/**'
- 'packages/constants/**'
- 'packages/db/**'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'tsconfig.json'
jobs:
component-tests:
if: ${{ !github.event.pull_request.draft }}
timeout-minutes: 15
runs-on: blacksmith-8vcpu-ubuntu-2404
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6.0.5
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
CYPRESS_INSTALL_BINARY: '0'
- name: Cache Cypress binary
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cache/Cypress
key: cypress-binary-${{ runner.os }}-${{ runner.arch }}-component-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
cypress-binary-${{ runner.os }}-${{ runner.arch }}-
- name: Install Cypress binary if missing
working-directory: packages/app
run: pnpm exec cypress verify || pnpm exec cypress install
- name: Build app
run: pnpm build
env:
E2E_FIXTURES: '1'
- name: Run component tests
working-directory: packages/app
run: pnpm exec cypress run --component --browser chrome
env:
CI: true
- name: Upload Cypress artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ !cancelled() }}
with:
name: cypress-component-report
path: |
packages/app/cypress/screenshots/
retention-days: 1
cypress:
if: ${{ !github.event.pull_request.draft }}
timeout-minutes: 15
runs-on: blacksmith-8vcpu-ubuntu-2404
permissions:
contents: read
strategy:
fail-fast: false
matrix:
browser: [chrome, firefox]
shard: [1, 2, 3, 4]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6.0.5
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
cache: pnpm
- uses: browser-actions/setup-firefox@fcf821c621167805dd63a29662bd7cb5676c81a8 # v1.7.1
if: matrix.browser == 'firefox'
with:
firefox-version: latest
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
CYPRESS_INSTALL_BINARY: '0'
- name: Cache Cypress binary
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cache/Cypress
key: cypress-binary-${{ runner.os }}-${{ runner.arch }}-${{ matrix.browser }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
cypress-binary-${{ runner.os }}-${{ runner.arch }}-
- name: Install Cypress binary if missing
working-directory: packages/app
run: pnpm exec cypress verify || pnpm exec cypress install
- name: Build app
run: pnpm build
env:
E2E_FIXTURES: '1'
- name: Select shard specs
id: shard-specs
env:
SHARD_INDEX: ${{ matrix.shard }}
SHARD_TOTAL: 4
run: |
node <<'EOF'
const fs = require('node:fs');
const path = require('node:path');
const rootDir = path.resolve('packages/app/cypress/e2e');
const shardIndex = Number(process.env.SHARD_INDEX);
const shardTotal = Number(process.env.SHARD_TOTAL);
const outputFile = process.env.GITHUB_OUTPUT;
function collectSpecs(dir) {
const entries = fs.readdirSync(dir, { withFileTypes: true });
const files = [];
for (const entry of entries) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
files.push(...collectSpecs(fullPath));
} else if (entry.isFile() && entry.name.endsWith('.cy.ts')) {
files.push(path.relative(path.resolve('packages/app'), fullPath).replaceAll('\\', '/'));
}
}
return files;
}
const allSpecs = collectSpecs(rootDir).sort();
const assignedSpecs = allSpecs.filter((_, index) => index % shardTotal === shardIndex - 1);
const specsCsv = assignedSpecs.join(',');
fs.appendFileSync(outputFile, `specs=${specsCsv}\n`);
fs.appendFileSync(outputFile, `spec_count=${assignedSpecs.length}\n`);
fs.appendFileSync(outputFile, `total_specs=${allSpecs.length}\n`);
console.log(`[Shard ${shardIndex}/${shardTotal}] Assigned ${assignedSpecs.length}/${allSpecs.length} specs`);
for (const spec of assignedSpecs) console.log(` - ${spec}`);
EOF
- name: Run integration tests
if: ${{ steps.shard-specs.outputs.spec_count != '0' }}
uses: cypress-io/github-action@c495c3ddffba403ba11be95fffb67e25203b3799 # v7.1.10
with:
working-directory: packages/app
install: false
start: pnpm start
wait-on: 'http://localhost:3000'
browser: ${{ matrix.browser }}
spec: ${{ steps.shard-specs.outputs.specs }}
env:
CI: true
E2E_FIXTURES: '1'
- name: Skip empty shard
if: ${{ steps.shard-specs.outputs.spec_count == '0' }}
run: echo "No specs assigned for this shard; skipping Cypress run."
- name: Upload Cypress artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ !cancelled() }}
with:
name: cypress-${{ matrix.browser }}-shard-${{ matrix.shard }}-report
path: |
packages/app/cypress/screenshots/
retention-days: 1