Skip to content

Commit f79c3d0

Browse files
9aoyfi3ework
authored andcommitted
feat: add modern.js to rstest-ecosystem-ci
1 parent 4b434fb commit f79c3d0

File tree

7 files changed

+69
-15
lines changed

7 files changed

+69
-15
lines changed

.github/workflows/rstest-ecosystem-ci-from-commit.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ on:
2929
- rslib
3030
- rsbuild
3131
- rsdoctor
32+
- modernjs
3233
# - examples
3334
suiteRefType:
3435
description: "type of suite ref to use"
@@ -76,8 +77,8 @@ jobs:
7677
strategy:
7778
matrix:
7879
include:
79-
# - suite: modernjs
80-
# os: ubuntu-latest
80+
- suite: modernjs
81+
os: ubuntu-latest
8182
# - suite: plugins
8283
# os: ubuntu-latest
8384
- suite: rspress

.github/workflows/rstest-ecosystem-ci-from-pr.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ on:
3333
- rspress
3434
- rsbuild
3535
- rsdoctor
36+
- modernjs
3637
suiteRefType:
3738
description: "type of suite ref to use"
3839
required: true
@@ -82,6 +83,8 @@ jobs:
8283
os: ubuntu-latest
8384
- suite: rsdoctor
8485
os: ubuntu-latest
86+
- suite: modernjs
87+
os: ubuntu-latest
8588
fail-fast: false
8689
runs-on: ${{ matrix.os }}
8790
name: execute-all (${{ matrix.suite }})

.github/workflows/rstest-ecosystem-ci-selected.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ on:
4040
- rslib
4141
- rsbuild
4242
- rsdoctor
43+
- modernjs
4344
# - examples
4445
suiteRefType:
4546
description: "type of suite ref to use"
@@ -92,6 +93,8 @@ jobs:
9293
os: ubuntu-latest
9394
- suite: rsdoctor
9495
os: ubuntu-latest
96+
- suite: modernjs
97+
os: ubuntu-latest
9598
# - suite: examples
9699
# os: ubuntu-latest
97100
fail-fast: false

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"devDependencies": {
3737
"@antfu/ni": "^0.20.0",
3838
"@biomejs/biome": "^1.9.4",
39-
"@types/node": "^18.15.5",
39+
"@types/node": "^24.10.1",
4040
"@types/semver": "^7.3.13",
4141
"bumpp": "^10.3.2",
4242
"nano-staged": "^0.8.0",

pnpm-lock.yaml

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

tests/rstest/modernjs.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { join } from 'node:path';
2+
import cache from '@actions/cache';
3+
import type { RunOptions } from '../../types';
4+
import { $, runInRepo } from '../../utils';
5+
6+
const isGitHubActions = !!process.env.GITHUB_ACTIONS;
7+
8+
export async function test(options: RunOptions) {
9+
let nxCachePath: string;
10+
let nxCacheKey: string;
11+
12+
await runInRepo({
13+
...options,
14+
repo: 'web-infra-dev/modern.js',
15+
branch: process.env.MODERNJS ?? 'main',
16+
beforeInstall: async () => {
17+
if (isGitHubActions) {
18+
const modernJsDir = join(process.cwd(), 'workspace/modernjs/modern.js');
19+
nxCachePath = join(modernJsDir, '.nx/cache');
20+
const sha = await $`git rev-parse HEAD`;
21+
nxCacheKey = `modernjs-nx-${sha.trim()}`;
22+
const restoreKeys = ['modernjs-nx-'];
23+
const cacheHitKey = await cache.restoreCache(
24+
[nxCachePath],
25+
nxCacheKey,
26+
restoreKeys,
27+
);
28+
if (cacheHitKey) {
29+
console.log(`Cache hit for key: ${cacheHitKey}`);
30+
await $`ls -lah .nx/cache`;
31+
} else {
32+
console.log(
33+
`Cache miss for key: ${nxCacheKey}, proceeding without cache.`,
34+
);
35+
}
36+
}
37+
},
38+
afterInstall: async () => {
39+
if (isGitHubActions) {
40+
console.log('Caching `.nx/cache` directory for future builds.');
41+
await $`ls -lah .nx/cache`;
42+
await cache.saveCache([nxCachePath], nxCacheKey);
43+
}
44+
},
45+
test: ['test:rstest'],
46+
});
47+
}

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"exclude": ["**/node_modules/**"],
44
"compilerOptions": {
55
"target": "esnext",
6-
"module": "nodenext",
7-
"moduleResolution": "node",
6+
"module": "esnext",
7+
"moduleResolution": "bundler",
88
"strict": true,
99
"declaration": true,
1010
"noImplicitOverride": true,

0 commit comments

Comments
 (0)