-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
base: main
Are you sure you want to change the base?
Conversation
@Aslemammad FYI the CI is failing |
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 = |
There was a problem hiding this comment.
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!
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 |
There was a problem hiding this comment.
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.)
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 |
There was a problem hiding this comment.
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@')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (options.release?.startsWith('https://pkg.pr.new/vite@')) { | |
if (options.release) { |
I guess this should include other release
s.
will resolve the comments asap! |
Co-authored-by: 翠 / green <[email protected]>
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.