Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Aslemammad committed Jun 12, 2024
1 parent dc8ef84 commit 3355a10
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ecosystem-ci-from-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ on:
required: true
type: string
default: "vitejs/vite"
commit:
description: "vite commit sha to use"
type: string
suite:
description: "testsuite to run. runs all testsuits when `-`."
required: false
Expand Down Expand Up @@ -112,6 +115,7 @@ jobs:
pnpm tsx ecosystem-ci.ts
--branch ${{ inputs.branchName }}
--repo ${{ inputs.repo }}
--commit ${{ inputs.commit }}
${{ inputs.suite }}
- id: get-ref
if: always()
Expand Down
11 changes: 7 additions & 4 deletions ecosystem-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ cli
.action(async (suites, options: CommandOptions) => {
const { root, vitePath, workspace } = await setupEnvironment()
const suitesToRun = getSuitesToRun(suites, root)
let viteMajor
let viteMajor = 5
if (!options.release) {
await setupViteRepo(options)
await buildVite({ verify: options.verify })
viteMajor = parseViteMajor(vitePath)
if (!options.commit) {
await setupViteRepo(options)
await buildVite({ verify: options.verify })
viteMajor = parseViteMajor(vitePath)
}
} else {
viteMajor = parseMajorVersion(options.release)
}
const runOptions: RunOptions = {
root,
viteCommit: options.commit,
vitePath,
viteMajor,
workspace,
Expand Down
2 changes: 1 addition & 1 deletion tests/_selftest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function test(options: RunOptions) {
)
}
pkg.scripts.selftestscript =
"[ -d ../../vite/packages/vite/dist ] || (echo 'vite build failed' && exit 1)"
"pnpm vite -v || (echo 'vite build failed' && exit 1)"
await fs.promises.writeFile(
pkgFile,
JSON.stringify(pkg, null, 2),
Expand Down
1 change: 1 addition & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface EnvironmentData {
export interface RunOptions {
workspace: string
root: string
viteCommit?: string
vitePath: string
viteMajor: number
verify?: boolean
Expand Down
46 changes: 29 additions & 17 deletions utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export async function runInRepo(options: RunOptions & RepoOptions) {
repo,
branch,
tag,
viteCommit,
commit,
skipGit,
verify,
Expand Down Expand Up @@ -260,6 +261,15 @@ export async function runInRepo(options: RunOptions & RepoOptions) {
await testCommand?.(pkg.scripts)
}
let overrides = options.overrides || {}

if (viteCommit) {
overrides.vite ||= `https://pkg.pr.new/vitejs/vite/vite@${viteCommit}`

// TODO: continuous releases are not enabled for @vitejs/plugin-legacy is the vite monorepo
// overrides[`@vitejs/plugin-legacy`] ||=
// `https://pkg.pr.new/vitejs/vite/@vitejs/plugin-legacy@${viteCommit}`
}

if (options.release) {
if (overrides.vite && overrides.vite !== options.release) {
throw new Error(
Expand All @@ -271,24 +281,26 @@ export async function runInRepo(options: RunOptions & RepoOptions) {
} else {
overrides.vite ||= `${options.vitePath}/packages/vite`

overrides[`@vitejs/plugin-legacy`] ||=
`${options.vitePath}/packages/plugin-legacy`

const vitePackageInfo = await getVitePackageInfo(options.vitePath)
// skip if `overrides.rollup` is `false`
if (
vitePackageInfo.dependencies.rollup?.version &&
overrides.rollup !== false
) {
overrides.rollup = vitePackageInfo.dependencies.rollup.version
}
// overrides[`@vitejs/plugin-legacy`] ||=
// `${options.vitePath}/packages/plugin-legacy`

if (!viteCommit) {
const vitePackageInfo = await getVitePackageInfo(options.vitePath)
// skip if `overrides.rollup` is `false`
if (
vitePackageInfo.dependencies.rollup?.version &&
overrides.rollup !== false
) {
overrides.rollup = vitePackageInfo.dependencies.rollup.version
}

// build and apply local overrides
const localOverrides = await buildOverrides(pkg, options, overrides)
cd(dir) // buildOverrides changed dir, change it back
overrides = {
...overrides,
...localOverrides,
// build and apply local overrides
const localOverrides = await buildOverrides(pkg, options, overrides)
cd(dir) // buildOverrides changed dir, change it back
overrides = {
...overrides,
...localOverrides,
}
}
}
await applyPackageOverrides(dir, pkg, overrides)
Expand Down

0 comments on commit 3355a10

Please sign in to comment.