Skip to content

Commit 6b4d79e

Browse files
authored
Merge pull request #29 from humanspeak/feature-version
CI/CD - Playwright
2 parents 238f9f8 + e32976b commit 6b4d79e

File tree

9 files changed

+249
-36
lines changed

9 files changed

+249
-36
lines changed

.github/workflows/npm-publish.yml

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
runs-on: ubuntu-24.04
4141
strategy:
4242
matrix:
43-
node-version: [20, 22]
43+
node-version: [20, 22, 23]
4444
permissions:
4545
contents: read
4646
packages: write
@@ -89,9 +89,46 @@ jobs:
8989
${{ runner.os }}-node-${{ matrix.node-version }}-
9090
${{ runner.os }}-node-
9191
92+
playwright-tests:
93+
timeout-minutes: 60
94+
runs-on: ubuntu-24.04
95+
steps:
96+
- uses: actions/checkout@v4
97+
with:
98+
persist-credentials: false
99+
token: ${{ secrets.ACTIONS_KEY }}
100+
101+
- uses: actions/setup-node@v4
102+
with:
103+
node-version: 22
104+
105+
- name: Install dependencies
106+
run: npm ci
107+
108+
- name: Install Playwright Browsers
109+
run: npx playwright install --with-deps
110+
111+
- name: Run Playwright tests
112+
run: npm run test:e2e
113+
114+
- name: Upload Playwright Results
115+
if: always()
116+
uses: trunk-io/analytics-uploader@main
117+
with:
118+
junit-paths: junit-playwright.xml
119+
org-slug: ${{ secrets.TRUNK_ORG_SLUG }}
120+
token: ${{ secrets.TRUNK_TOKEN }}
121+
122+
- uses: actions/upload-artifact@v4
123+
if: always()
124+
with:
125+
name: playwright-report
126+
path: playwright-report/
127+
retention-days: 10
128+
92129
# 4. Coverage reporting (depends on tests)
93130
coverage-report:
94-
needs: [build]
131+
needs: [build, playwright-tests]
95132
runs-on: ubuntu-24.04
96133
if: ${{ always() }}
97134
steps:
@@ -103,7 +140,7 @@ jobs:
103140

104141
# 5. Publishing job (main deployment logic)
105142
publish-github-packages:
106-
needs: [build, coverage-report]
143+
needs: [build, playwright-tests, coverage-report]
107144
runs-on: ubuntu-24.04
108145
permissions:
109146
contents: write

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ vite.config.js.timestamp-*
1111
vite.config.ts.timestamp-*
1212
/coverage
1313
junit-vitest.xml
14+
junit-playwright.xml
15+
16+
# Playwright
17+
/test-results/
18+
/playwright-report/
19+
/blob-report/
20+
/playwright/.cache/

package-lock.json

Lines changed: 103 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
"prepublishOnly": "npm run package",
7070
"preview": "vite preview",
7171
"test": "vitest run --coverage",
72+
"test:all": "npm run test && npm run test:e2e",
73+
"test:e2e": "playwright test",
74+
"test:e2e:debug": "playwright test --debug",
75+
"test:e2e:report": "playwright show-report",
76+
"test:e2e:ui": "playwright test --ui",
7277
"test:only": "vitest run",
7378
"test:watch": "vitest"
7479
},
@@ -78,21 +83,22 @@
7883
"@humanspeak/svelte-subscribe": "^5.0.0"
7984
},
8085
"devDependencies": {
86+
"@faker-js/faker": "^9.4.0",
87+
"@playwright/test": "^1.50.0",
8188
"@sveltejs/adapter-auto": "^3.0.0",
8289
"@sveltejs/kit": "^2.0.0",
8390
"@sveltejs/package": "^2.0.0",
8491
"@sveltejs/vite-plugin-svelte": "^3.0.0",
8592
"@testing-library/jest-dom": "^6.1.6",
8693
"@testing-library/svelte": "^4.0.5",
8794
"@types/eslint": "8.56.0",
88-
"@types/faker": "^5.5.9",
95+
"@types/node": "^22.10.10",
8996
"@typescript-eslint/eslint-plugin": "^6.0.0",
9097
"@typescript-eslint/parser": "^6.0.0",
9198
"@vitest/coverage-v8": "^1.1.1",
9299
"eslint": "^8.56.0",
93100
"eslint-config-prettier": "^9.1.0",
94101
"eslint-plugin-svelte": "^2.35.1",
95-
"faker": "^5.5.3",
96102
"prettier": "^3.1.1",
97103
"prettier-plugin-svelte": "^3.1.2",
98104
"publint": "^0.1.9",

playwright.config.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { defineConfig, devices } from '@playwright/test'
2+
3+
export default defineConfig({
4+
testDir: './tests',
5+
reporter: [['junit', { outputFile: 'junit-playwright.xml' }]],
6+
webServer: {
7+
command: 'npm run build && npm run preview',
8+
port: 4173,
9+
timeout: 120000,
10+
reuseExistingServer: !process.env.CI,
11+
stdout: 'pipe',
12+
stderr: 'pipe'
13+
},
14+
use: {
15+
baseURL: 'http://localhost:4173',
16+
trace: 'on-first-retry'
17+
},
18+
timeout: 60000,
19+
projects: [
20+
{
21+
name: 'chromium',
22+
use: { ...devices['Desktop Chrome'] }
23+
},
24+
{
25+
name: 'firefox',
26+
use: { ...devices['Desktop Firefox'] }
27+
},
28+
{
29+
name: 'webkit',
30+
use: { ...devices['Desktop Safari'] }
31+
},
32+
{
33+
name: 'mobile-chrome',
34+
use: { ...devices['Pixel 5'] }
35+
},
36+
{
37+
name: 'mobile-safari',
38+
use: { ...devices['iPhone 12'] }
39+
}
40+
]
41+
})

src/routes/+page.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import { mean, sum } from '../lib/utils/math.js'
2323
import { getShuffled } from './_getShuffled.js'
2424
import { createSamples } from './_createSamples.js'
25+
import { page } from '$app/stores'
2526
import Italic from './_Italic.svelte'
2627
import Profile from './_Profile.svelte'
2728
import Tick from './_Tick.svelte'
@@ -32,7 +33,10 @@
3233
import { getDistinct } from '../lib/utils/array.js'
3334
import SelectIndicator from './_SelectIndicator.svelte'
3435
35-
const data = readable(createSamples(2, 2))
36+
const seed = $page.url.searchParams.get('seed')
37+
const data = readable(
38+
createSamples({ seed: isNaN(Number(seed)) ? undefined : Number(seed) }, 2, 2)
39+
)
3640
3741
let serverSide = false
3842

src/routes/_createSamples.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@ export interface Sample {
77
status: string
88
children?: Sample[]
99
}
10-
export declare const createSamples: (...lengths: number[]) => Sample[]
10+
type CreateSamplesOptions = {
11+
seed?: number
12+
}
13+
export declare const createSamples: (
14+
options?: CreateSamplesOptions,
15+
...lengths: number[]
16+
) => Sample[]
17+
export {}

0 commit comments

Comments
 (0)