Skip to content

Commit 3563c52

Browse files
authored
ci: improve workflow (#458)
* ci: improve ci workflow to use playwrights chromium and minimal permissions * fix: call playwrights chromium with flags that work and ensure same deps are installed * ci: harden release action by limiting permissions
1 parent c2af15e commit 3563c52

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,20 @@ on:
88
pull_request:
99
branches:
1010
- main
11+
1112
env:
1213
# we call `pnpm playwright install` instead
1314
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
1415

16+
# cancel in-progress runs on new commits to same PR (gitub.event.number)
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
19+
cancel-in-progress: true
20+
21+
# use min permissions
22+
permissions:
23+
contents: read # to fetch code (actions/checkout)
24+
1525
jobs:
1626
# "checks" job runs on linux + 16 only and checks that install, build, lint and audit work
1727
# it also primes the pnpm store cache for linux, important for downstream tests

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ on:
55
branches:
66
- main
77

8+
permissions: {}
9+
810
jobs:
911
release:
12+
permissions:
13+
contents: write # to create release (changesets/action)
14+
pull-requests: write # to create pull request (changesets/action)
1015
# prevents this action from running on forks
1116
if: github.repository == 'sveltejs/vite-plugin-svelte'
1217
name: Release

packages/e2e-tests/vitestGlobalSetup.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ const buildPackagesUnderTest = async () => {
2323
const syncNodeModules = async () => {
2424
// tests use symbolic linked node_modules directories. make sure the workspace is up for it
2525
console.log('syncing node_modules');
26-
await execa(
27-
'pnpm',
28-
['install', '--prefer-frozen-lockfile', '--prefer-offline', '--no-lockfile', '--silent'],
29-
{ stdio: 'inherit' }
30-
);
26+
await execa('pnpm', ['install', '--frozen-lockfile', '--prefer-offline', '--silent'], {
27+
stdio: 'inherit'
28+
});
3129
console.log('syncing node_modules done');
3230
};
3331

packages/e2e-tests/vitestSetup.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,21 @@ beforeAll(
8383
if (!suite.filepath.includes('e2e-tests')) {
8484
return;
8585
}
86+
try {
87+
const wsEndpoint = fs.readFileSync(path.join(DIR, 'wsEndpoint'), 'utf-8');
88+
if (!wsEndpoint) {
89+
throw new Error('wsEndpoint not found');
90+
}
8691

87-
const wsEndpoint = fs.readFileSync(path.join(DIR, 'wsEndpoint'), 'utf-8');
88-
if (!wsEndpoint) {
89-
throw new Error('wsEndpoint not found');
90-
}
92+
browser = await chromium.connect(wsEndpoint);
93+
page = await browser.newPage();
9194

92-
browser = await chromium.connect(wsEndpoint);
93-
page = await browser.newPage();
95+
const testPath = suite.filepath;
96+
const segments = testPath.split('/');
97+
const testName = segments.includes('e2e-tests')
98+
? segments[segments.indexOf('e2e-tests') + 1]
99+
: null;
94100

95-
const testPath = suite.filepath;
96-
const segments = testPath.split('/');
97-
const testName = segments.includes('e2e-tests')
98-
? segments[segments.indexOf('e2e-tests') + 1]
99-
: null;
100-
try {
101101
// if this is a test placed under e2e-tests/xxx/__tests__
102102
// start a vite server in that directory.
103103
if (testName) {

0 commit comments

Comments
 (0)