diff --git a/.github/actions/build-rspack/action.yaml b/.github/actions/build-rspack/action.yaml index aaa77f2..95c5889 100644 --- a/.github/actions/build-rspack/action.yaml +++ b/.github/actions/build-rspack/action.yaml @@ -19,7 +19,7 @@ outputs: runs: using: composite steps: - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: 22 - shell: bash @@ -35,6 +35,7 @@ runs: repository: ${{ inputs.repository }} path: ${{ inputs.path }} ref: ${{ inputs.ref }} + - uses: actions/download-artifact@v4 with: name: binding-linux-x64-gnu diff --git a/.github/actions/prepare-rspack-binding/action.yaml b/.github/actions/prepare-rspack-binding/action.yaml index 79151bd..c76281f 100644 --- a/.github/actions/prepare-rspack-binding/action.yaml +++ b/.github/actions/prepare-rspack-binding/action.yaml @@ -16,7 +16,7 @@ inputs: node-version: description: 'The version of Node.js to set up' required: true - default: '18' + default: '22' outputs: artifact-name: description: 'The name of the uploaded artifact' @@ -29,7 +29,7 @@ runs: repository: ${{ inputs.repository }} path: ${{ inputs.path }} ref: ${{ inputs.ref }} - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: ${{ inputs.node-version }} - shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f19ac2d..938001f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - suite: rstest os: ubuntu-latest - suite: rspress - os: macos-latest + os: ubuntu-latest - suite: plugins os: ubuntu-latest - suite: modernjs @@ -52,7 +52,7 @@ jobs: - suite: rstest os: ubuntu-latest - suite: rspress - os: macos-latest + os: ubuntu-latest - suite: rsdoctor os: ubuntu-latest fail-fast: false @@ -155,7 +155,7 @@ jobs: # - suite: nx # os: ubuntu-22.04 - suite: rspress - os: macos-latest + os: ubuntu-22.04 - suite: rsbuild os: ubuntu-22.04 - suite: examples diff --git a/.github/workflows/rsbuild-ecosystem-ci-from-commit.yml b/.github/workflows/rsbuild-ecosystem-ci-from-commit.yml index ae56667..2dc7916 100644 --- a/.github/workflows/rsbuild-ecosystem-ci-from-commit.yml +++ b/.github/workflows/rsbuild-ecosystem-ci-from-commit.yml @@ -52,7 +52,7 @@ on: jobs: execute-selected-suite: - runs-on: ${{ inputs.suite == 'rspress' && 'macos-latest' || 'ubuntu-latest' }} + runs-on: ubuntu-latest if: "inputs.suite != '-'" steps: - uses: actions/checkout@v5 @@ -80,7 +80,7 @@ jobs: - suite: rstest os: ubuntu-latest - suite: rspress - os: macos-latest + os: ubuntu-latest - suite: plugins os: ubuntu-latest - suite: modernjs diff --git a/.github/workflows/rsbuild-ecosystem-ci-from-pr.yml b/.github/workflows/rsbuild-ecosystem-ci-from-pr.yml index 1da7895..dc4b671 100644 --- a/.github/workflows/rsbuild-ecosystem-ci-from-pr.yml +++ b/.github/workflows/rsbuild-ecosystem-ci-from-pr.yml @@ -52,7 +52,7 @@ on: jobs: execute-selected-suite: - runs-on: ${{ inputs.suite == 'rspress' && 'macos-latest' || 'ubuntu-latest' }} + runs-on: ubuntu-latest if: "inputs.suite != '-'" steps: - uses: actions/checkout@v5 @@ -80,7 +80,7 @@ jobs: - suite: rstest os: ubuntu-latest - suite: rspress - os: macos-latest + os: ubuntu-latest - suite: plugins os: ubuntu-latest - suite: modernjs diff --git a/.github/workflows/rsbuild-ecosystem-ci-selected.yml b/.github/workflows/rsbuild-ecosystem-ci-selected.yml index b28031f..b188294 100644 --- a/.github/workflows/rsbuild-ecosystem-ci-selected.yml +++ b/.github/workflows/rsbuild-ecosystem-ci-selected.yml @@ -59,7 +59,7 @@ on: jobs: execute-selected-suite: - runs-on: ${{ inputs.suite == 'rspress' && 'macos-latest' || 'ubuntu-latest' }} + runs-on: ubuntu-latest if: "inputs.suite != '-'" steps: - uses: actions/checkout@v5 @@ -87,7 +87,7 @@ jobs: - suite: rstest os: ubuntu-latest - suite: rspress - os: macos-latest + os: ubuntu-latest - suite: plugins os: ubuntu-latest - suite: modernjs diff --git a/.github/workflows/rslib-ecosystem-ci-from-commit.yml b/.github/workflows/rslib-ecosystem-ci-from-commit.yml index d7633c6..0a077a7 100644 --- a/.github/workflows/rslib-ecosystem-ci-from-commit.yml +++ b/.github/workflows/rslib-ecosystem-ci-from-commit.yml @@ -52,7 +52,7 @@ on: jobs: execute-selected-suite: - runs-on: ${{ inputs.suite == 'rspress' && 'macos-latest' || 'ubuntu-latest' }} + runs-on: ubuntu-latest if: "inputs.suite != '-'" steps: - uses: actions/checkout@v5 @@ -82,7 +82,7 @@ jobs: - suite: rstest os: ubuntu-latest - suite: rspress - os: macos-latest + os: ubuntu-latest - suite: rsdoctor os: ubuntu-latest fail-fast: false diff --git a/.github/workflows/rslib-ecosystem-ci-from-pr.yml b/.github/workflows/rslib-ecosystem-ci-from-pr.yml index bca90d3..7f7f6e4 100644 --- a/.github/workflows/rslib-ecosystem-ci-from-pr.yml +++ b/.github/workflows/rslib-ecosystem-ci-from-pr.yml @@ -52,7 +52,7 @@ on: jobs: execute-selected-suite: - runs-on: ${{ inputs.suite == 'rspress' && 'macos-latest' || 'ubuntu-latest' }} + runs-on: ubuntu-latest if: "inputs.suite != '-'" steps: - uses: actions/checkout@v5 @@ -82,7 +82,7 @@ jobs: - suite: rstest os: ubuntu-latest - suite: rspress - os: macos-latest + os: ubuntu-latest - suite: rsdoctor os: ubuntu-latest fail-fast: false diff --git a/.github/workflows/rslib-ecosystem-ci-selected.yml b/.github/workflows/rslib-ecosystem-ci-selected.yml index 8607117..8203015 100644 --- a/.github/workflows/rslib-ecosystem-ci-selected.yml +++ b/.github/workflows/rslib-ecosystem-ci-selected.yml @@ -58,7 +58,7 @@ on: jobs: execute-selected-suite: - runs-on: ${{ inputs.suite == 'rspress' && 'macos-latest' || 'ubuntu-latest' }} + runs-on: ubuntu-latest if: "inputs.suite != '-'" steps: - uses: actions/checkout@v5 @@ -88,7 +88,7 @@ jobs: - suite: rstest os: ubuntu-latest - suite: rspress - os: macos-latest + os: ubuntu-latest - suite: rsdoctor os: ubuntu-latest fail-fast: false diff --git a/.github/workflows/rspack-ecosystem-ci-from-commit.yml b/.github/workflows/rspack-ecosystem-ci-from-commit.yml index 04d29e2..e604d21 100644 --- a/.github/workflows/rspack-ecosystem-ci-from-commit.yml +++ b/.github/workflows/rspack-ecosystem-ci-from-commit.yml @@ -70,7 +70,7 @@ jobs: ref: ${{ inputs.commitSHA }} execute-selected-suite: - runs-on: ${{ inputs.suite == 'rspress' && 'macos-latest' || 'ubuntu-22.04' }} + runs-on: ubuntu-22.04 needs: [get-runner-labels, prepare-binding] if: "inputs.suite != '-'" steps: @@ -104,7 +104,7 @@ jobs: - suite: rsdoctor os: ubuntu-22.04 - suite: rspress - os: macos-latest + os: ubuntu-22.04 - suite: rslib os: ubuntu-22.04 - suite: rstest diff --git a/.github/workflows/rspack-ecosystem-ci-from-pr.yml b/.github/workflows/rspack-ecosystem-ci-from-pr.yml index 4a47e2a..6b82be7 100644 --- a/.github/workflows/rspack-ecosystem-ci-from-pr.yml +++ b/.github/workflows/rspack-ecosystem-ci-from-pr.yml @@ -74,7 +74,7 @@ jobs: ref: ${{ inputs.branchName }} execute-selected-suite: - runs-on: ${{ inputs.suite == 'rspress' && 'macos-latest' || 'ubuntu-22.04' }} + runs-on: ubuntu-22.04 needs: prepare-binding if: "inputs.suite != '-'" steps: @@ -104,7 +104,7 @@ jobs: # - suite: nx # os: ubuntu-22.04 - suite: rspress - os: macos-latest + os: ubuntu-22.04 - suite: rslib os: ubuntu-22.04 - suite: rstest diff --git a/.github/workflows/rspack-ecosystem-ci-selected.yml b/.github/workflows/rspack-ecosystem-ci-selected.yml index 2fdd95b..200dab5 100644 --- a/.github/workflows/rspack-ecosystem-ci-selected.yml +++ b/.github/workflows/rspack-ecosystem-ci-selected.yml @@ -80,7 +80,7 @@ jobs: execute-selected-suite: needs: prepare-binding - runs-on: ${{ inputs.suite == 'rspress' && 'macos-latest' || 'ubuntu-22.04' }} + runs-on: ubuntu-22.04 if: "inputs.suite != '-'" steps: - uses: actions/checkout@v4 @@ -109,7 +109,7 @@ jobs: # - suite: nx # os: ubuntu-22.04 - suite: rspress - os: macos-latest + os: ubuntu-22.04 - suite: rslib os: ubuntu-22.04 - suite: rstest diff --git a/tests/rsbuild/plugins.ts b/tests/rsbuild/plugins.ts index f045cad..242838f 100644 --- a/tests/rsbuild/plugins.ts +++ b/tests/rsbuild/plugins.ts @@ -82,7 +82,7 @@ export async function test(options: RunOptions) { }, overrides: { // not override rslib's rsbuild version - '@rslib/core>@rsbuild/core': 'latest', + '@rslib/core>@rsbuild/core': '1.7.3', }, test: [ 'build', diff --git a/utils.ts b/utils.ts index a4e5fb8..948c6af 100644 --- a/utils.ts +++ b/utils.ts @@ -65,6 +65,9 @@ interface RspackPackageData { let rspackPackageData: RspackPackageData | null = null; +const RSLIB_RSBUILD_COMPAT_VERSION = '1.7.3'; +const RSLIB_RSPACK_COMPAT_VERSION = '1.7.6'; + export function cd(dir: string) { cwd = path.resolve(cwd, dir); } @@ -328,12 +331,24 @@ async function getRspackPackageData(): Promise { name: pkg.name, directory: path.join(stackPath, pkg.directory), }); + const normalizeAndFilterExisting = (pkgList: RspackPackageInfo[]) => + pkgList.map(normalize).filter((pkg) => { + if (fs.existsSync(pkg.directory)) { + return true; + } + console.warn( + `[ecosystem-ci] skip missing rspack package override: ${pkg.name} -> ${pkg.directory}`, + ); + return false; + }); rspackPackageData = { - npm: npm[ - optionalKey as 'darwin-arm64' | 'darwin-x64' | 'linux-x64' | 'win32-x64' - ].map(normalize), - binding: binding.map(normalize), - packages: packages.map(normalize), + npm: normalizeAndFilterExisting( + npm[ + optionalKey as 'darwin-arm64' | 'darwin-x64' | 'linux-x64' | 'win32-x64' + ], + ), + binding: normalizeAndFilterExisting(binding), + packages: normalizeAndFilterExisting(packages), }; return rspackPackageData; } @@ -462,6 +477,9 @@ export async function runInRepo(options: RunOptions & RepoOptions) { overrides[pkgInfo.name] ||= pkgInfo.directory; } } + if (activeStack === 'rsbuild') { + overrides['@rslib/core>@rsbuild/core'] ||= RSLIB_RSBUILD_COMPAT_VERSION; + } await applyPackageOverrides({ dir, pkg, @@ -503,6 +521,18 @@ export async function runInRepo(options: RunOptions & RepoOptions) { overrides[pkgInfo.name] ||= pkgInfo.directory; } } + overrides['@rslib/core>@rsbuild/core'] ||= RSLIB_RSBUILD_COMPAT_VERSION; + overrides[ + `@rsbuild/core@${RSLIB_RSBUILD_COMPAT_VERSION}>@rspack/core` + ] ||= RSLIB_RSPACK_COMPAT_VERSION; + overrides[ + `@rspack/core@${RSLIB_RSPACK_COMPAT_VERSION}>@rspack/binding` + ] ||= RSLIB_RSPACK_COMPAT_VERSION; + for (const pkgInfo of npm) { + overrides[ + `@rspack/binding@${RSLIB_RSPACK_COMPAT_VERSION}>${pkgInfo.name}` + ] ||= RSLIB_RSPACK_COMPAT_VERSION; + } await applyPackageOverrides({ dir, pkg, @@ -714,6 +744,15 @@ async function applyPackageOverrides({ }; devDependencyStrategy?: 'all' | 'local'; }) { + const isValidManifestDepName = (name: string): boolean => { + if (name.includes('>')) { + return false; + } + if (name.startsWith('@')) { + return name.indexOf('@', 1) === -1; + } + return !name.includes('@'); + }; const useFileProtocol = (v: string) => isLocalOverride(v) ? `file:${path.resolve(v)}` : v; const normalizedOverrides = Object.fromEntries( @@ -724,10 +763,16 @@ async function applyPackageOverrides({ const devOverrides = devDependencyStrategy === 'all' - ? normalizedOverrides + ? Object.fromEntries( + Object.entries(normalizedOverrides).filter(([key]) => + isValidManifestDepName(key), + ), + ) : Object.fromEntries( - Object.entries(normalizedOverrides).filter(([_key, value]) => - (value as string).startsWith('file:'), + Object.entries(normalizedOverrides).filter( + ([key, value]) => + isValidManifestDepName(key) && + (value as string).startsWith('file:'), ), );