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 on main #354

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Aslemammad
Copy link
Contributor

Workflow runs for the main branch do not use the pkg.pr.new build, meanwhile the main branch of the vite repo is the place where each commit gets its own pkg.pr.new build which feels a bit wasted.

So this will try to look for pkg.pr.new builds for the main branch.

@sapphi-red
Copy link
Member

@Aslemammad FYI the CI is failing

@Aslemammad
Copy link
Contributor Author

Yes I will tackle it soon.

pkg.scripts.selftestscript =
"[ -d ../../vite/packages/vite/dist ] || (echo 'vite build failed' && exit 1)"
if (options.release?.startsWith('https://pkg.pr.new/vite@')) {
pkg.scripts.selftestscript =
Copy link
Contributor Author

@Aslemammad Aslemammad Jan 26, 2025

Choose a reason for hiding this comment

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

@sapphi-red would love to hear your thoughts on this now that the ci is fixed by this!

Comment on lines -375 to +382
cd(vitePath)
export async function getPermanentRef(repo: string, ref: string) {
try {
const ref = await $`git log -1 --pretty=format:%H`
return ref
const res = await fetch(
`https://api.github.com/repos/${repo}/branches/${ref}`,
)
const {
commit: { sha },
} = (await res.json()) as { commit: { sha: string } }
return sha
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is correct. What we want for the usage in discord-webhook.ts is the commit hash that the ecosystem-ci ran on. This is getting the latest commit hash when the ci finished (i.e. a different hash will be output when a new commit was pushed while the CI is running). (It is fine for the case of ecosystem-ci.ts as it's called before running.)

Comment on lines +27 to 41
if (
options.branch === 'main' &&
options.repo === 'vitejs/vite' &&
!options.commit
) {
const sha = await getPermanentRef(options.repo, options.branch)
if (sha) {
options.commit = sha
}
}
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
Copy link
Member

Choose a reason for hiding this comment

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

By this code, we will sometimes get a prebuilt package and sometimes don't, depending on when the last commit was pushed. I think we should avoid that if possible so that there aren't differences among the runs.

@@ -16,8 +16,13 @@ export async function test(options: RunOptions) {
`invalid checkout, expected package.json with "name":"vite-ecosystem-ci" in ${dir}`,
)
}
pkg.scripts.selftestscript =
"[ -d ../../vite/packages/vite/dist ] || (echo 'vite build failed' && exit 1)"
if (options.release?.startsWith('https://pkg.pr.new/vite@')) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (options.release?.startsWith('https://pkg.pr.new/vite@')) {
if (options.release) {

I guess this should include other releases.

tests/_selftest.ts Outdated Show resolved Hide resolved
@Aslemammad
Copy link
Contributor Author

will resolve the comments asap!

Co-authored-by: 翠 / green <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants