Skip to content

Commit 2611028

Browse files
committed
chore: run CI on windows
1 parent 7066925 commit 2611028

File tree

15 files changed

+208
-126
lines changed

15 files changed

+208
-126
lines changed

.github/workflows/verify.yml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Verify changes
33
on: pull_request
44

55
jobs:
6-
verify:
7-
name: Verify changes
6+
verify-linux:
7+
name: Verify linux
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
@@ -32,6 +32,9 @@ jobs:
3232
- name: Install dependencies
3333
run: yarn --frozen-lockfile
3434

35+
- name: Build packages
36+
run: yarn build
37+
3538
# build for production in CI to make sure tests can run with production build
3639
- name: Build for production
3740
run: yarn build:production
@@ -41,6 +44,39 @@ jobs:
4144

4245
- name: Test
4346
run: yarn test
47+
48+
verify-windows:
49+
name: Verify windows
50+
runs-on: windows-latest
51+
steps:
52+
- uses: actions/checkout@v2
53+
54+
- name: Setup Node 12.x
55+
uses: actions/setup-node@v1
56+
with:
57+
node-version: 12.x
58+
59+
- name: Get yarn cache directory path
60+
id: yarn-cache-dir-path
61+
run: echo "::set-output name=dir::$(yarn cache dir)"
62+
63+
- uses: actions/cache@v2
64+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
65+
with:
66+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
67+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
68+
restore-keys: |
69+
${{ runner.os }}-yarn-
70+
71+
- name: Install dependencies
72+
run: yarn --frozen-lockfile
73+
74+
- name: Build
75+
run: yarn build
76+
77+
- name: Test
78+
run: yarn test:windows
79+
4480
verify-browserstack:
4581
name: Verify browserstack
4682
runs-on: ubuntu-latest
@@ -67,6 +103,9 @@ jobs:
67103
- name: Install dependencies
68104
run: yarn --frozen-lockfile
69105

106+
- name: Build packages
107+
run: yarn build
108+
70109
- name: Test
71110
run: |
72111
cd packages/test-runner-browserstack

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "MIT",
55
"scripts": {
66
"build": "rimraf packages/*/tsconfig.tsbuildinfo && tsc --build",
7-
"build:production": "node scripts/workspaces-scripts.mjs build:production",
7+
"build:production": "node scripts/workspaces-scripts-bin.mjs build:production",
88
"build:site": "rocket-build",
99
"build:watch": "rimraf packages/*/tsconfig.tsbuildinfo && tsc --build --watch",
1010
"format": "npm run format:eslint && npm run format:prettier",
@@ -14,12 +14,13 @@
1414
"lint": "npm run lint:eslint && npm run lint:prettier",
1515
"lint:eslint": "eslint --ext .ts,.js .",
1616
"lint:prettier": "node node_modules/prettier/bin-prettier.js \"**/*.{ts,js,md}\" --check --ignore-path .eslintignore",
17-
"postinstall": "yarn install-puppeteer-firefox && yarn build && patch-package",
17+
"postinstall": "patch-package",
1818
"reinstall-workspace": "rimraf packages/*/node_modules && rimraf node_modules && yarn install && yarn build",
1919
"release": "changeset publish && yarn format",
2020
"start": "rocket-start",
21-
"start:build":"es-dev-server --root-dir _site --compatibility none --open",
22-
"test": "node scripts/workspaces-scripts.mjs test:ci",
21+
"start:build": "es-dev-server --root-dir _site --compatibility none --open",
22+
"test": "node scripts/workspaces-scripts-bin.mjs test:ci",
23+
"test:windows": "node scripts/runWindowsTests.mjs",
2324
"update-dependency": "node scripts/update-dependency.js",
2425
"update-package-configs": "ts-node scripts/update-package-configs.ts"
2526
},

packages/dev-server-core/src/plugins/mimeTypesPlugin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import picoMatch from 'picomatch';
2-
import { isAbsolute, posix } from 'path';
2+
import { isAbsolute, posix, sep } from 'path';
33

44
import { MimeTypeMappings } from '../DevServerCoreConfig';
55
import { Plugin } from '../Plugin';
@@ -25,9 +25,10 @@ export function mimeTypesPlugin(mappings: MimeTypeMappings): Plugin {
2525

2626
serverStart({ config }) {
2727
({ rootDir } = config);
28+
const matcherBaseDir = config.rootDir.split(sep).join('/');
2829

2930
for (const [pattern, mimeType] of Object.entries(mappings)) {
30-
matchers.push({ fn: createMatcher(rootDir, pattern), mimeType });
31+
matchers.push({ fn: createMatcher(matcherBaseDir, pattern), mimeType });
3132
}
3233
},
3334

packages/dev-server-core/test/tests/plugins/mimeTypesPlugin.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fetch from 'node-fetch';
33

44
import { createTestServer } from '../helpers';
55

6-
describe.only('mimeTypesPLugin', () => {
6+
describe('mimeTypesPLugin', () => {
77
it('can configure mime types for files', async () => {
88
const { server, host } = await createTestServer({
99
mimeTypes: {

packages/dev-server-esbuild/test/ts.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { expectIncludes, expectNotIncludes } from '@web/dev-server-core/src/test
77
import { esbuildPlugin } from '../src/esbuildPlugin';
88

99
describe('esbuildPlugin TS', function () {
10+
this.timeout(5000);
11+
1012
it('transforms .ts files', async () => {
1113
const { server, host } = await createTestServer({
1214
rootDir: __dirname,

packages/dev-server-esbuild/test/tsx.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { expectIncludes, expectNotIncludes } from '@web/dev-server-core/src/test
66
import { esbuildPlugin } from '../src/esbuildPlugin';
77

88
describe('esbuildPlugin TSX', function () {
9+
this.timeout(5000);
10+
911
it('transforms .tsx files', async () => {
1012
const { server, host } = await createTestServer({
1113
rootDir: __dirname,

packages/dev-server-rollup/src/rollupAdapter.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ import {
88
PluginError,
99
PluginSyntaxError,
1010
Context,
11+
getRequestFilePath,
1112
} from '@web/dev-server-core';
12-
import { queryAll, predicates, getTextContent } from '@web/dev-server-core/dist/dom5';
13-
import { parse as parseHtml } from 'parse5';
13+
import {
14+
queryAll,
15+
predicates,
16+
getTextContent,
17+
setTextContent,
18+
} from '@web/dev-server-core/dist/dom5';
19+
import { parse as parseHtml, serialize as serializeHtml } from 'parse5';
1420
import { Plugin as RollupPlugin, TransformPluginContext } from 'rollup';
1521
import { InputOptions } from 'rollup';
1622
import { red, yellow } from 'chalk';
@@ -257,7 +263,8 @@ export function rollupAdapter(
257263
),
258264
);
259265

260-
const filePath = path.join(rootDir, context.path);
266+
const filePath = getRequestFilePath(context, rootDir);
267+
let transformed = false;
261268
try {
262269
for (const node of inlineModuleNodes) {
263270
const code = getTextContent(node);
@@ -287,11 +294,14 @@ export function rollupAdapter(
287294

288295
if (transformedCode) {
289296
transformedFiles.add(context.path);
290-
context.body = context.body.replace(code, transformedCode);
297+
setTextContent(node, transformedCode);
298+
transformed = true;
291299
}
292300
}
293301

294-
return context.body;
302+
if (transformed) {
303+
return serializeHtml(documentAst);
304+
}
295305
} catch (error) {
296306
throw wrapRollupError(filePath, context, error);
297307
}
Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import path from 'path';
2+
import { platform } from 'os';
23
import { runTests } from '@web/test-runner-core/dist/test-helpers';
34
import { chromeLauncher } from '@web/test-runner-chrome';
45
import { playwrightLauncher } from '@web/test-runner-playwright';
56
import { testRunnerServer } from '@web/test-runner-server';
67

78
import { emulateMediaPlugin } from '../../src/emulateMediaPlugin';
89

9-
describe.only('setViewportPlugin', function test() {
10+
describe('emulateMediaPlugin', function test() {
1011
this.timeout(20000);
1112

1213
it('can emulate media on puppeteer', async () => {
@@ -21,20 +22,23 @@ describe.only('setViewportPlugin', function test() {
2122
);
2223
});
2324

24-
it('can emulate media on playwright', async () => {
25-
await runTests(
26-
{
27-
browsers: [
28-
playwrightLauncher({ product: 'chromium' }),
29-
playwrightLauncher({ product: 'firefox' }),
30-
// TODO: make webkit work in the CI
31-
// playwrightLauncher({ product: 'webkit' }),
32-
],
33-
server: testRunnerServer({
34-
plugins: [emulateMediaPlugin()],
35-
}),
36-
},
37-
[path.join(__dirname, 'browser-test.js')],
38-
);
39-
});
25+
// playwright doesn't work on windows VM right now
26+
if (platform() !== 'win32') {
27+
it('can emulate media on playwright', async () => {
28+
await runTests(
29+
{
30+
browsers: [
31+
playwrightLauncher({ product: 'chromium' }),
32+
playwrightLauncher({ product: 'firefox' }),
33+
// TODO: make webkit work in the CI
34+
// playwrightLauncher({ product: 'webkit' }),
35+
],
36+
server: testRunnerServer({
37+
plugins: [emulateMediaPlugin()],
38+
}),
39+
},
40+
[path.join(__dirname, 'browser-test.js')],
41+
);
42+
});
43+
}
4044
});
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from 'path';
2+
import { platform } from 'os';
23
import { runTests } from '@web/test-runner-core/dist/test-helpers';
34
import { chromeLauncher } from '@web/test-runner-chrome';
45
import { playwrightLauncher } from '@web/test-runner-playwright';
@@ -21,20 +22,23 @@ describe('setViewportPlugin', function test() {
2122
);
2223
});
2324

24-
it('can set the viewport on playwright', async () => {
25-
await runTests(
26-
{
27-
browsers: [
28-
playwrightLauncher({ product: 'chromium' }),
29-
playwrightLauncher({ product: 'firefox' }),
30-
// TODO: make webkit work in the CI
31-
// playwrightLauncher({ product: 'webkit' }),
32-
],
33-
server: testRunnerServer({
34-
plugins: [setViewportPlugin()],
35-
}),
36-
},
37-
[path.join(__dirname, 'browser-test.js')],
38-
);
39-
});
25+
// playwright doesn't work on windows VM right now
26+
if (platform() !== 'win32') {
27+
it('can set the viewport on playwright', async () => {
28+
await runTests(
29+
{
30+
browsers: [
31+
playwrightLauncher({ product: 'chromium' }),
32+
playwrightLauncher({ product: 'firefox' }),
33+
// TODO: make webkit work in the CI
34+
// playwrightLauncher({ product: 'webkit' }),
35+
],
36+
server: testRunnerServer({
37+
plugins: [setViewportPlugin()],
38+
}),
39+
},
40+
[path.join(__dirname, 'browser-test.js')],
41+
);
42+
});
43+
}
4044
});

packages/test-runner-core/test/src/runner/TestScheduler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe('TestScheduler', () => {
251251
const [scheduler, sessions, session1] = createTestFixture('1');
252252
scheduler.schedule(1, [session1]);
253253

254-
await timeout(7);
254+
await timeout(8);
255255

256256
const finalSession1 = sessions.get(session1.id)!;
257257
expect(finalSession1.status).to.equal(SESSION_STATUS.FINISHED);

0 commit comments

Comments
 (0)