Skip to content

Commit fafd7cf

Browse files
committed
fix: rspress preview URL
1 parent b3d64d7 commit fafd7cf

File tree

11 files changed

+41
-30
lines changed

11 files changed

+41
-30
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ on:
2424
type: choice
2525
options:
2626
- "-"
27-
- netlify
2827
- rsbuild
2928
- rslib
3029
- rspack
@@ -78,8 +77,6 @@ jobs:
7877
strategy:
7978
matrix:
8079
include:
81-
- suite: netlify
82-
os: ubuntu-latest
8380
- suite: rsbuild
8481
os: ubuntu-latest
8582
- suite: rslib

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ on:
2929
type: choice
3030
options:
3131
- "-"
32-
- netlify
3332
- rsbuild
3433
- rslib
3534
- rspack
@@ -75,8 +74,6 @@ jobs:
7574
strategy:
7675
matrix:
7776
include:
78-
- suite: netlify
79-
os: ubuntu-latest
8077
- suite: rsbuild
8178
os: ubuntu-latest
8279
- suite: rslib

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ on:
3535
type: choice
3636
options:
3737
- "-"
38-
- netlify
3938
- rsbuild
4039
- rslib
4140
- rspack
@@ -87,8 +86,6 @@ jobs:
8786
strategy:
8887
matrix:
8988
include:
90-
- suite: netlify
91-
os: ubuntu-latest
9289
- suite: rsbuild
9390
os: ubuntu-latest
9491
- suite: rslib

ecosystem-ci.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const STACK_CHOICES: Stack[] = [
2222
'rslib',
2323
'rsdoctor',
2424
'rslint',
25+
'rspress',
2526
];
2627

2728
const cli = cac();
@@ -85,6 +86,7 @@ registerBuildAlias('build-rstest', 'rstest');
8586
registerBuildAlias('build-rslib', 'rslib');
8687
registerBuildAlias('build-rsdoctor', 'rsdoctor');
8788
registerBuildAlias('build-rslint', 'rslint');
89+
registerBuildAlias('build-rspress', 'rspress');
8890

8991
cli
9092
.command(
@@ -316,5 +318,8 @@ function assignStackAliases(
316318
} else if (stack === 'rslint') {
317319
runOptions.rslintPath = stackPath;
318320
runOptions.rslintMajor = stackMajor;
321+
} else if (stack === 'rspress') {
322+
runOptions.rspressPath = stackPath;
323+
runOptions.rspressMajor = stackMajor;
319324
}
320325
}

tests/rspress/rsbuild.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import type { RunOptions } from '../../types';
22
import { cd, runInRepo } from '../../utils';
3-
import { deployPreviewToNetlify } from './netlify';
3+
import { MESSAGE, deployPreviewToNetlify } from './utils/_netlify';
44

5-
const MESSAGE = 'rspress-rsbuild-preview';
65
const SITE_ID_ENV = 'RSPRESS_NETLIFY_SITE_ID_RSBUILD';
76

87
export async function test(options: RunOptions) {

tests/rspress/rslib.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import type { RunOptions } from '../../types';
22
import { cd, runInRepo } from '../../utils';
3-
import { deployPreviewToNetlify } from './netlify';
3+
import { MESSAGE, deployPreviewToNetlify } from './utils/_netlify';
44

5-
const MESSAGE = 'rspress-rslib-preview';
65
const SITE_ID_ENV = 'RSPRESS_NETLIFY_SITE_ID_RSLIB';
76

87
export async function test(options: RunOptions) {

tests/rspress/rspack.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import type { RunOptions } from '../../types';
22
import { cd, runInRepo } from '../../utils';
3-
import { deployPreviewToNetlify } from './netlify';
3+
import { MESSAGE, deployPreviewToNetlify } from './utils/_netlify';
44

5-
const MESSAGE = 'rspress-rspack-preview';
65
const SITE_ID_ENV = 'RSPRESS_NETLIFY_SITE_ID_RSPACK';
76

87
export async function test(options: RunOptions) {
98
await runInRepo({
109
...options,
1110
repo: 'web-infra-dev/rspack',
1211
branch: process.env.RSTEST ?? 'main',
13-
build: ['build:cli:release'],
12+
build: ['echo "Build step placeholder for rspack"'],
1413
beforeTest: async () => {
1514
cd('./website');
1615
},

tests/rspress/rstest.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import type { RunOptions } from '../../types';
22
import { cd, runInRepo } from '../../utils';
3-
import { deployPreviewToNetlify } from './netlify';
3+
import { MESSAGE, deployPreviewToNetlify } from './utils/_netlify';
44

5-
const MESSAGE = 'rspress-rstest-preview';
65
const SITE_ID_ENV = 'RSPRESS_NETLIFY_SITE_ID_RSTEST';
76

87
export async function test(options: RunOptions) {
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { $ } from '../../utils';
1+
import { $ } from '../../../utils';
22

33
interface DeployOptions {
44
alias?: string;
@@ -10,19 +10,28 @@ interface DeployOptions {
1010
const DEFAULT_OUTPUT_DIR = 'dist';
1111
const DEFAULT_NETLIFY_CLI = 'netlify-cli@17.38.1';
1212
const DEFAULT_ALIAS = process.env.RSPRESS_NETLIFY_ALIAS ?? 'ecosystem-ci';
13+
export const MESSAGE = `${process.env.ECOSYSTEM_CI_TYPE}:${process.env.ECOSYSTEM_CI_REF}`;
1314

1415
export async function deployPreviewToNetlify(options: DeployOptions) {
1516
const { message, outputDir = DEFAULT_OUTPUT_DIR, siteIdEnvVar } = options;
16-
const alias = options.alias ?? DEFAULT_ALIAS;
17+
const defaultAlias =
18+
process.env.ECOSYSTEM_CI_TYPE === 'commit'
19+
? DEFAULT_ALIAS
20+
: (process.env.ECOSYSTEM_CI_REF ?? DEFAULT_ALIAS);
21+
const alias = options.alias ?? defaultAlias;
1722
const authToken = process.env.NETLIFY_AUTH_TOKEN;
1823
const siteId = siteIdEnvVar ? process.env[siteIdEnvVar] : undefined;
24+
const missingVars: string[] = [];
25+
if (!authToken) {
26+
missingVars.push('NETLIFY_AUTH_TOKEN');
27+
}
28+
if (!siteId) {
29+
missingVars.push(siteIdEnvVar || 'site ID');
30+
}
1931

20-
if (!authToken || !siteId) {
21-
const siteHint = siteIdEnvVar
22-
? `${siteIdEnvVar} or NETLIFY_SITE_ID`
23-
: 'NETLIFY_SITE_ID';
32+
if (missingVars.length > 0) {
2433
console.log(
25-
`[rspress][netlify] Missing NETLIFY_AUTH_TOKEN or ${siteHint}, skip deploying alias ${alias}`,
34+
`[rspress][netlify] Missing ${missingVars.join(', ')}, skip deploying alias ${alias}`,
2635
);
2736
return;
2837
}

types.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export type Stack =
77
| 'rstest'
88
| 'rslib'
99
| 'rsdoctor'
10-
| 'rslint';
10+
| 'rslint'
11+
| 'rspress';
1112

1213
export interface EnvironmentData {
1314
stack: Stack;
@@ -23,6 +24,7 @@ export interface EnvironmentData {
2324
rslibPath?: string;
2425
rsdoctorPath?: string;
2526
rslintPath?: string;
27+
rspressPath?: string;
2628
}
2729

2830
export interface RunOptions {
@@ -39,12 +41,14 @@ export interface RunOptions {
3941
rslibPath?: string;
4042
rsdoctorPath?: string;
4143
rslintPath?: string;
44+
rspressPath?: string;
4245
rsbuildMajor?: number;
4346
rspackMajor?: number;
4447
rstestMajor?: number;
4548
rslibMajor?: number;
4649
rsdoctorMajor?: number;
4750
rslintMajor?: number;
51+
rspressMajor?: number;
4852
verify?: boolean;
4953
skipGit?: boolean;
5054
release?: string;

0 commit comments

Comments
 (0)