Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pkg.pr.new #313

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a test, i wonder how we should get the viteMajor when we do not have the vite repo since we didn't set it up in commit mode.

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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viteCommit option for later in the test so we generate a tarball link from it.

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)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a test too, since we do not have the repo anymore in commit mode, i just tried logging the vite version.

I think there should be a condition here.

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
Loading