Skip to content

Commit 17a26d3

Browse files
authored
chore(ci): enhance CI pipeline with playwright container and adjust job dependencies (#739)
1 parent 5812061 commit 17a26d3

File tree

9 files changed

+120
-99
lines changed

9 files changed

+120
-99
lines changed

.github/workflows/ci-pipeline.yml

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
3434
setup:
3535
name: Setup Dependencies
36-
needs: check_changes
36+
needs: [check_changes]
3737
if: ${{ needs.check_changes.outputs.exists == 'true' }}
3838
runs-on: ubuntu-latest
3939
steps:
@@ -50,6 +50,7 @@ jobs:
5050
lookup-only: true
5151

5252
- name: Setup Node.js
53+
if: steps.check-node-modules-cache.outputs.cache-hit != 'true'
5354
uses: actions/setup-node@v4
5455
with:
5556
node-version: lts/*
@@ -66,22 +67,24 @@ jobs:
6667

6768
quality_checks:
6869
name: ${{ matrix.name }}
69-
needs: [check_changes, setup]
70+
needs: [setup]
7071
if: ${{ needs.check_changes.outputs.exists == 'true' }}
7172
runs-on: ubuntu-latest
7273
strategy:
7374
matrix:
7475
include:
75-
- check: lint
76-
name: Lint
77-
- check: format
78-
name: Format
79-
- check: test
80-
name: Test
81-
- check: spell
82-
name: Spell Check
83-
- check: build
84-
name: Build
76+
- name: Lint
77+
check: lint
78+
- name: Format
79+
check: format
80+
- name: Test
81+
check: test
82+
- name: Build
83+
check: build
84+
- name: TypeScript
85+
check: typecheck
86+
- name: Spell Check
87+
check: spell
8588
steps:
8689
- uses: actions/checkout@v4
8790

@@ -119,11 +122,22 @@ jobs:
119122
- name: Run ${{ matrix.name }}
120123
run: pnpm exec turbo run ${{ matrix.check }}
121124

125+
- name: Upload Build Artifact
126+
if: matrix.name == 'Build'
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: build-dist-${{ github.sha }}
130+
path: dist/
131+
132+
# We should depend on quality checks to save CI running time.
122133
playwright:
123134
name: Playwright Tests
124-
needs: [check_changes, setup]
135+
needs: [setup, quality_checks]
125136
if: ${{ needs.check_changes.outputs.exists == 'true' }}
126137
runs-on: ubuntu-latest
138+
container:
139+
image: mcr.microsoft.com/playwright:v1.54.1-noble
140+
options: --user 1001
127141
steps:
128142
- uses: actions/checkout@v4
129143
with:
@@ -146,10 +160,12 @@ jobs:
146160
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
147161
restore-keys: ${{ runner.os }}-node-modules-
148162

149-
- name: Setup Node.js
150-
uses: actions/setup-node@v4
163+
- name: Download Build Artifact
164+
uses: actions/download-artifact@v4
151165
with:
152-
node-version: lts/*
166+
path: dist/
167+
pattern: build-dist*
168+
merge-multiple: true
153169

154170
- name: Setup pnpm
155171
uses: pnpm/action-setup@v4
@@ -160,16 +176,6 @@ jobs:
160176
if: steps.cache.outputs.cache-hit != 'true'
161177
run: pnpm install --frozen-lockfile
162178

163-
- name: Cache Playwright Browsers
164-
uses: actions/cache@v4
165-
with:
166-
path: ~/.cache/ms-playwright
167-
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
168-
restore-keys: ${{ runner.os }}-playwright-
169-
170-
- name: Install Playwright Browsers
171-
run: pnpm exec playwright install --with-deps
172-
173179
- name: Run Playwright Tests
174180
run: pnpm exec turbo run test:playwright
175181
timeout-minutes: 10

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ npm-debug.log*
3333

3434
# cache
3535
.eslintcache
36+
.cspellcache
3637
# Turborepo
3738
.turbo

lefthook.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
pre-commit:
22
piped: true
3+
exclude:
4+
- pnpm-lock.yaml
35
commands:
46
prettier:
57
priority: 1
@@ -36,7 +38,7 @@ cspell:
3638
base:
3739
glob: "*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,d.ts,astro,json,yaml,yml,md,mdx}"
3840
run: |
39-
pnpm cspell {staged_files}
41+
pnpm cspell {staged_files} --cache --cache-strategy=content --cache-location=.cspellcache
4042
stage_fixed: true
4143

4244
commit-msg:

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"scripts": {
1010
"dev": "astro dev --port 3000",
1111
"start": "astro preview --port 3000",
12-
"build": "astro check && astro build",
12+
"build": "astro build",
1313
"preview": "astro preview --port 3000",
1414
"wrangler": "wrangler",
15-
"astro": "astro",
15+
"typecheck": "astro check",
1616
"lint": "eslint . --max-warnings=0 --cache",
1717
"lint:fix": "eslint . --fix",
1818
"spell": "cspell \"**/*.{ts,tsx,js,jsx,astro,md,json,yml,yaml}\"",

playwright.config.ts

Lines changed: 21 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,38 @@
11
import { defineConfig, devices } from '@playwright/test'
22

3-
/**
4-
* Read environment variables from file.
5-
* https://github.com/motdotla/dotenv
6-
*/
7-
// import dotenv from 'dotenv';
8-
// import path from 'path';
9-
// dotenv.config({ path: path.resolve(__dirname, '.env') });
10-
11-
/**
12-
* See https://playwright.dev/docs/test-configuration.
13-
*/
143
export default defineConfig({
154
testDir: './src/tests',
165
testIgnore: ['**.test.ts'],
176
fullyParallel: true,
187
forbidOnly: Boolean(process.env.CI),
198
retries: process.env.CI ? 2 : 0,
20-
/* Opt out of parallel tests on CI. */
219
workers: process.env.CI ? 1 : undefined,
2210
reporter: 'html',
2311
use: {
2412
baseURL: 'http://localhost:3000',
2513
trace: 'on-first-retry',
2614
},
27-
28-
/* Configure projects for major browsers */
29-
projects: [
30-
{
31-
name: 'chromium',
32-
use: { ...devices['Desktop Chrome'] },
33-
},
34-
35-
{
36-
name: 'firefox',
37-
use: { ...devices['Desktop Firefox'] },
38-
},
39-
40-
{
41-
name: 'webkit',
42-
use: { ...devices['Desktop Safari'] },
43-
},
44-
45-
/* Test against mobile viewports. */
46-
// {
47-
// name: 'Mobile Chrome',
48-
// use: { ...devices['Pixel 5'] },
49-
// },
50-
// {
51-
// name: 'Mobile Safari',
52-
// use: { ...devices['iPhone 12'] },
53-
// },
54-
55-
/* Test against branded browsers. */
56-
// {
57-
// name: 'Microsoft Edge',
58-
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
59-
// },
60-
// {
61-
// name: 'Google Chrome',
62-
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
63-
// },
64-
],
65-
66-
/* Run your local dev server before starting the tests */
15+
projects: process.env.CI
16+
? [
17+
{
18+
name: 'firefox',
19+
use: { ...devices['Desktop Firefox'] },
20+
},
21+
]
22+
: [
23+
{
24+
name: 'chromium',
25+
use: { ...devices['Desktop Chrome'] },
26+
},
27+
{
28+
name: 'firefox',
29+
use: { ...devices['Desktop Firefox'] },
30+
},
31+
{
32+
name: 'webkit',
33+
use: { ...devices['Desktop Safari'] },
34+
},
35+
],
6736
webServer: {
6837
command: process.env.CI ? 'npm run start' : 'npm run dev',
6938
url: 'http://localhost:3000',

src/components/Sponsors.astro

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
---
2-
import h3 from '~/components/Description.astro'
2+
import Image from 'astro/components/Image.astro'
3+
import blacksmithLogo from '~/assets/sponsors/blacksmith-logo-dark.svg'
4+
import crowdinLogo from '~/assets/sponsors/crowdin-logo-dark.svg'
5+
import tutaLogo from '~/assets/sponsors/tutaLogo-dark.svg'
36
import { getLocale, getUI } from '~/utils/i18n'
47
58
const locale = getLocale(Astro)
69
7-
import tutaLogo from '~/assets/sponsors/tutaLogo-dark.svg'
8-
import blacksmithLogo from '~/assets/sponsors/blacksmith-logo-dark.svg'
9-
import crowdinLogo from '~/assets/sponsors/crowdin-logo-dark.svg'
10-
11-
import Image from 'astro/components/Image.astro'
1210
const { showSponsors = true } = Astro.props
1311
1412
const {

src/components/download/release-data.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,52 @@ export function getReleasesWithChecksums(locale: string) {
5959
}
6060
}
6161
}
62+
63+
export function getReleases(locale: string) {
64+
const {
65+
routes: {
66+
download: {
67+
links: { macos, windows, linux },
68+
},
69+
},
70+
} = getUI(locale)
71+
72+
return {
73+
macos: {
74+
universal: {
75+
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.macos-universal.dmg',
76+
label: macos.universal,
77+
},
78+
},
79+
windows: {
80+
x86_64: {
81+
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.installer.exe',
82+
label: windows['64bit'],
83+
},
84+
arm64: {
85+
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.installer-arm64.exe',
86+
label: windows.ARM64,
87+
},
88+
},
89+
linux: {
90+
x86_64: {
91+
tarball: {
92+
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.linux-x86_64.tar.xz',
93+
label: linux.x86_64,
94+
},
95+
},
96+
aarch64: {
97+
tarball: {
98+
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.linux-aarch64.tar.xz',
99+
label: linux.aarch64,
100+
},
101+
},
102+
flathub: {
103+
all: {
104+
link: 'https://flathub.org/apps/app.zen_browser.zen',
105+
label: linux.flathub,
106+
},
107+
},
108+
},
109+
}
110+
}

src/pages/[...locale]/download.astro

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
---
2-
import Description from '~/components/Description.astro'
3-
import DownloadScript from '~/components/download/DownloadScript.astro'
4-
import PlatformDownload from '~/components/download/PlatformDownload.astro'
5-
import { getReleasesWithChecksums } from '~/components/download/release-data'
6-
import Layout from '~/layouts/Layout.astro'
7-
import { getChecksums } from '~/utils/githubChecksums'
8-
import { getLocale, getUI } from '~/utils/i18n'
9-
102
import { icon, library } from '@fortawesome/fontawesome-svg-core'
113
import { faApple, faGithub, faLinux, faWindows } from '@fortawesome/free-brands-svg-icons'
124
import Image from 'astro/components/Image.astro'
13-
145
import AppIconDark from '~/assets/app-icon-dark.png'
156
import AppIconLight from '~/assets/app-icon-light.png'
7+
import Description from '~/components/Description.astro'
8+
import DownloadScript from '~/components/download/DownloadScript.astro'
9+
import PlatformDownload from '~/components/download/PlatformDownload.astro'
10+
import { getReleases } from '~/components/download/release-data'
11+
import Layout from '~/layouts/Layout.astro'
12+
import { getLocale, getUI } from '~/utils/i18n'
1613
1714
export { getStaticPaths } from '~/utils/i18n'
1815
@@ -27,8 +24,7 @@ const windowsIcon = icon({ prefix: 'fab', iconName: 'windows' })
2724
const linuxIcon = icon({ prefix: 'fab', iconName: 'linux' })
2825
const appleIcon = icon({ prefix: 'fab', iconName: 'apple' })
2926
30-
const checksums = await getChecksums()
31-
const releases = getReleasesWithChecksums(locale)(checksums)
27+
const releases = getReleases(locale)
3228
3329
const platformDescriptions = download.platformDescriptions
3430
---

turbo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "https://turborepo.com/schema.json",
3+
"globalPassThroughEnv": ["PLAYWRIGHT_*"],
34
"tasks": {
45
"dev": {
56
"cache": false,
@@ -33,7 +34,6 @@
3334
},
3435
"test:playwright": {
3536
"cache": true,
36-
"dependsOn": ["build"],
3737
"inputs": ["src"],
3838
"outputs": ["playwright-report/**", "test-results/**"]
3939
}

0 commit comments

Comments
 (0)