Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ecosystem-ci-selected.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ on:
vite_plugin_react_repo:
description: "vite-plugin-react repository to use"
type: string
rolldownRef:
description: "rolldown commit sha to use from pkg.pr.new"
type: string
suite:
description: "testsuite to run"
required: true
Expand Down Expand Up @@ -101,12 +104,14 @@ jobs:
pnpm tsx ecosystem-ci.ts
"--$REF_TYPE" "$REF"
--repo "$REPO"
${ROLLDOWN_REF:+--rolldown-ref "$ROLLDOWN_REF"}
"$SUITE"
id: ecosystem-ci-run
env:
REF_TYPE: ${{ inputs.refType }}
REF: ${{ inputs.ref }}
REPO: ${{ inputs.repo }}
ROLLDOWN_REF: ${{ inputs.rolldownRef }}
SUITE: ${{ inputs.suite }}
VITE_PLUGIN_REACT_REF: ${{ inputs.vite_plugin_react_ref }}
VITE_PLUGIN_REACT_REPO: ${{ inputs.vite_plugin_react_repo }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ecosystem-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ on:
required: true
type: string
default: "vitejs/vite"
rolldownRef:
description: "rolldown commit sha to use from pkg.pr.new"
type: string
sendDiscordReport:
description: "send results to discord"
type: boolean
Expand Down Expand Up @@ -98,12 +101,14 @@ jobs:
pnpm tsx ecosystem-ci.ts
"--$REF_TYPE" "$REF"
--repo "$REPO"
${ROLLDOWN_REF:+--rolldown-ref "$ROLLDOWN_REF"}
"$SUITE"
id: ecosystem-ci-run
env:
REF_TYPE: ${{ inputs.refType || github.event.client_payload.refType || 'branch' }}
REF: ${{ inputs.ref || github.event.client_payload.ref || 'main' }}
REPO: ${{ inputs.repo || github.event.client_payload.repo || 'vitejs/vite' }}
ROLLDOWN_REF: ${{ inputs.rolldownRef || github.event.client_payload.rolldownRef }}
SUITE: ${{ matrix.suite }}
- if: always() && (inputs.sendDiscordReport || github.event_name != 'workflow_dispatch')
run: pnpm tsx discord-webhook.ts
Expand Down
21 changes: 19 additions & 2 deletions ecosystem-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ cli
.option('--tag <tag>', 'vite tag to use')
.option('--commit <commit>', 'vite commit sha to use')
.option('--release <version>', 'vite release to use from npm registry')
.option(
'--rolldown-ref <commit>',
'rolldown commit sha to use from pkg.pr.new',
)
.action(async (suites, options: CommandOptions) => {
if (options.commit) {
const url = `https://pkg.pr.new/vite@${options.commit}`
//eslint-disable-next-line n/no-unsupported-features/node-builtins
const { status } = await fetch(url)
if (status === 200) {
options.release = url
Expand All @@ -34,12 +37,25 @@ cli
console.log(`continuous release available on ${url}`)
}
}
let rolldownRelease: string | undefined
if (options.rolldownRef) {
const url = `https://pkg.pr.new/rolldown@${options.rolldownRef}`
const { status } = await fetch(url)
if (status === 200) {
rolldownRelease = url
console.log(`rolldown continuous release available on ${url}`)
} else {
throw new Error(
`rolldown continuous release not found for ref ${options.rolldownRef} (HTTP ${status}): ${url}`,
)
}
}
const { root, vitePath, workspace } = await setupEnvironment()
const suitesToRun = getSuitesToRun(suites, root)
let viteMajor
if (!options.release) {
await setupViteRepo(options)
await buildVite({ verify: options.verify })
await buildVite({ verify: options.verify, rolldownRelease })
viteMajor = parseViteMajor(vitePath)
} else {
viteMajor = parseMajorVersion(options.release)
Expand All @@ -50,6 +66,7 @@ cli
viteMajor,
workspace,
release: options.release,
rolldownRelease,
verify: options.verify,
skipGit: false,
}
Expand Down
2 changes: 2 additions & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface RunOptions {
verify?: boolean
skipGit?: boolean
release?: string
rolldownRelease?: string
agent?: (typeof AGENTS)[number]
build?: Task | Task[]
test?: Task | Task[]
Expand All @@ -34,6 +35,7 @@ export interface CommandOptions {
release?: string
verify?: boolean
skipGit?: boolean
rolldownRef?: string
}

export interface RepoOptions {
Expand Down
36 changes: 34 additions & 2 deletions utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ export async function runInRepo(options: RunOptions & RepoOptions) {
...localOverrides,
}
}
if (options.rolldownRelease) {
overrides.rolldown = options.rolldownRelease
}
await applyPackageOverrides(agent, dir, pkg, overrides)
await beforeBuildCommand?.(pkg.scripts)
await buildCommand?.(pkg.scripts)
Expand Down Expand Up @@ -414,12 +417,41 @@ export async function getPermanentRef() {
}
}

export async function buildVite({ verify = false }) {
export async function buildVite({
verify = false,
rolldownRelease,
}: { verify?: boolean; rolldownRelease?: string } = {}) {
cd(vitePath)

const frozenInstall = getCommand('pnpm', 'frozen')
const runBuild = getCommand('pnpm', 'run', ['build'])
const runTest = getCommand('pnpm', 'run', ['test'])
await $`${serializeCommand(frozenInstall)}`

if (rolldownRelease) {
// Override rolldown in vite's monorepo so it builds against the specified version
const pnpmWorkspaceFile = path.join(vitePath, 'pnpm-workspace.yaml')
Comment thread
sapphi-red marked this conversation as resolved.
Outdated
if (!fs.existsSync(pnpmWorkspaceFile)) {
throw new Error(
`pnpm-workspace.yaml not found in vite repo, expected at ${pnpmWorkspaceFile}`,
)
}
let content = await fs.promises.readFile(pnpmWorkspaceFile, 'utf-8')
// Replace existing rolldown override value
const rolldownPattern = /^(\s+rolldown:\s+).+$/m
if (!rolldownPattern.test(content)) {
throw new Error(`rolldown override not found in ${pnpmWorkspaceFile}`)
}
content = content.replace(
rolldownPattern,
`$1${JSON.stringify(rolldownRelease)}`,
)
await fs.promises.writeFile(pnpmWorkspaceFile, content, 'utf-8')
console.log(`overriding rolldown in vite repo with ${rolldownRelease}`)

await $`pnpm install --no-frozen-lockfile`
Comment thread
sapphi-red marked this conversation as resolved.
Outdated
} else {
await $`${serializeCommand(frozenInstall)}`
}
await $`${serializeCommand(runBuild)}`
if (verify) {
await $`${serializeCommand(runTest)}`
Expand Down
Loading