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

Add prebuilt mozjs archive CI #454

Merged
merged 29 commits into from
Mar 9, 2024
Merged

Add prebuilt mozjs archive CI #454

merged 29 commits into from
Mar 9, 2024

Conversation

wusyong
Copy link
Member

@wusyong wusyong commented Feb 29, 2024

Another part of #439. This PR adds a CI pipeline to publish prebuilt mozjs archive.
I've tried to run it and created a working version release: https://github.com/wusyong/mozjs/releases/tag/2024-02-29
I set the workflow trigger on the main branch update since there are few commits for this repo.
Let me know if there's preferred condition.

Copy link
Member

@sagudev sagudev left a comment

Choose a reason for hiding this comment

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

I am not really fan of doing manual uploads using curl commands. We should use actions to make this less complex. You can take a look how this is done in servo: https://github.com/servo/servo/blob/main/.github/workflows/nightly.yml. In servo we also mark releases that are not full as draft (and mark them as final if all runs succeed).

I think mac-arm and x86 could be merged into one job with matrix.

@sagudev
Copy link
Member

sagudev commented Feb 29, 2024

Furthermore I think we can simply use main workflow insted of adding new one and add MOZJS_CRATE_ARCHIVE=1 to main (as it does not change an compilation only adds packaging step), the upload archives as artifects and if run as done on landing (push to main) actually release artifacts as GitHub release. This should avoid us repeating a lot of lines and allow faster testing of ARCHIVES (as they are stored as artifacts also on forks).

@sagudev
Copy link
Member

sagudev commented Feb 29, 2024

Then there is also option to start CI on release, that could check that archives actually work.

@wusyong
Copy link
Member Author

wusyong commented Feb 29, 2024

Alright! Let me move the workflow into main one. I use curl because I didn't find any action could move action artifact to release asset, and actions/upload-release-asset is unmaintained. Do you have any recommended action that can upload artifact first and then move to release asset later? Edit: I think I can create two steps instead. Let me test them a bit later.

@sagudev
Copy link
Member

sagudev commented Mar 1, 2024

I am not sure we want to do releases on forks. Only on servo/servo would be enough (but only for push to main, we would want to make release for every PR). There is github.event_name for this IIRC.

Also to simplify things even more, instead of firstly creating draft release we should just do normal run uploading archives as artifacts (already done). Then at the end do release job that would download all artifacts and upload them all to the release.

Also upload-release-asset@v1 seems to be unmaintained, maybe we can do this by gh command.

@wusyong
Copy link
Member Author

wusyong commented Mar 1, 2024

I need github.repository_owner to test on my own fork. I can make it only releases on servo/mozjs.

Also to simplify things even more, instead of firstly creating draft release we should just do normal run uploading archives as artifacts (already done).

I'll simplify the workflow a bit. I also aware of gh command but have some trouble with multiple build steps. Maybe it can be easier if the release workflow is simplified.

@wusyong
Copy link
Member Author

wusyong commented Mar 1, 2024

Tested and released by simplified job. Let me know if there is something need improved.
I'll work on a CI job to verify release asset can be built and tested.

@wusyong
Copy link
Member Author

wusyong commented Mar 2, 2024

There are some restrictions on recursive calls on workflow and auto release. So I chose workflow_call to create another workflow to check release binaries. Here's the successful action that creates a release and verify on my fork.

I think that's all for the workflow that can create releases and then verify it when the release is published. Let me know if I still miss or need to fix something.

@wusyong wusyong requested a review from sagudev March 2, 2024 11:05
@sagudev
Copy link
Member

sagudev commented Mar 3, 2024

There are some restrictions on recursive calls on workflow and auto release.

I completely forgot about those. Does it fail running release CI job or does it just not get run. If it's the later case we might still want to have it trigger on release (in addition to workflow call) in case we do manual release.

@wusyong
Copy link
Member Author

wusyong commented Mar 4, 2024

I completely forgot about those. Does it fail running release CI job or does it just not get run. If it's the later case we might still want to have it trigger on release (in addition to workflow call) in case we do manual release.

It won't be triggered to run. I'll add the condition to trigger on manual release.

@wusyong wusyong requested a review from sagudev March 5, 2024 07:03
- id: release
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
run: |
RELEASE_TAG=$(date "+%F-%H-%M")
Copy link
Member

Choose a reason for hiding this comment

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

This could be problematic, if we have two updates in a day (it happens sometimes), so using commit hash might be better, but I don't know how we could bake this info in for #450. Can we get dependency commit hash using cargo without baking it in.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

@wusyong wusyong Mar 6, 2024

Choose a reason for hiding this comment

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

CARGO_PKG_VERSION seems like a better approach. I also hope this repo can provide version release again.
I'll update release job to use mozjs_sys's CARGO_PKG_VERSION, and it will skip the release if the version is already exist.

Copy link
Member

Choose a reason for hiding this comment

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

I think CARGO_PKG_VERSION is actually the only way to go and because we moved all .c* files to mozjs-sys, the only thing that needs versions bumps is mozjs-sys when there are any C/C++ file changes.

It would be nice to make CI check for this too, but I think this can be done as a followup if (ever) needed. For now I think it would be enough if we test always latest release on push to main (instead of testing release only if it's new).

@wusyong wusyong requested a review from sagudev March 6, 2024 07:21
@sagudev
Copy link
Member

sagudev commented Mar 8, 2024

We should not fail here, right?

a release with the same tag name already exists: mozjs-sys-v0.68.2

https://github.com/sagudev/mozjs/actions/runs/8207125754/job/22448383805#step:5:11

@sagudev
Copy link
Member

sagudev commented Mar 8, 2024

I think we should just skip release creation in this case, but still verify it.

@wusyong
Copy link
Member Author

wusyong commented Mar 9, 2024

We should not fail here, right?

a release with the same tag name already exists: mozjs-sys-v0.68.2

https://github.com/sagudev/mozjs/actions/runs/8207125754/job/22448383805#step:5:11

This SO question looks similar to us. I'll add git fetch --tags before checking.

@sagudev
Copy link
Member

sagudev commented Mar 9, 2024

We should not fail here, right?

a release with the same tag name already exists: mozjs-sys-v0.68.2

https://github.com/sagudev/mozjs/actions/runs/8207125754/job/22448383805#step:5:11

This SO question looks similar to us. I'll add git fetch --tags before checking.

I am not sure this will solve it. I simply run workflow twice (second time with empty commit), both times on main. I think we just need to not fail in this case. So maybe something like gh create release ... || exit 0.

Comment on lines 207 to 209
if git show-ref --tags --verify --quiet "refs/tags/${RELEASE_TAG}"; then
RELEASE_TAG=''
fi
Copy link
Member

Choose a reason for hiding this comment

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

Or did you refer to that code? In that case we can simply remove this and make next step to not fail, which will ensure to test all merged commits with latest release available.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh sorry I didn't read your comments before pushing. gh create release ... || exit 0 seems simpler. I'll update it.

Copy link
Member

@sagudev sagudev Mar 9, 2024

Choose a reason for hiding this comment

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

What you did is actually way better, because using || we hide all gh create release failures.

Copy link
Member Author

@wusyong wusyong Mar 9, 2024

Choose a reason for hiding this comment

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

ah okay! Let me revert it. 😅

Edit: Here's my run with second try: https://github.com/wusyong/mozjs/actions/runs/8212872566

RELEASE_TAG=mozjs-sys-v$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "mozjs_sys") | .version')
git fetch --tags --quiet
if ! git show-ref --tags --verify --quiet "refs/tags/${RELEASE_TAG}" ; then
gh release create ${{ steps.check-tag.outputs.RELEASE_TAG }} ./*.tar.gz
Copy link
Member

Choose a reason for hiding this comment

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

${{ steps.check-tag.outputs.RELEASE_TAG }} is not available here yet (step is not finished), but ${RELEASE_TAG} should work. https://github.com/sagudev/mozjs/actions/runs/8213051004/job/22464164401#step:4:5

Copy link
Member

@sagudev sagudev left a comment

Choose a reason for hiding this comment

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

Thanks for all your great work!

I can't wait to start using this work in servo.

@sagudev sagudev enabled auto-merge March 9, 2024 09:50
@sagudev sagudev added this pull request to the merge queue Mar 9, 2024
Merged via the queue into servo:main with commit 20f7934 Mar 9, 2024
40 checks passed
@wusyong
Copy link
Member Author

wusyong commented Mar 9, 2024

@sagudev Thanks for reviewing the PR too! I'll have to work on multi webview suppoer PR next.
But once it's done, I'll get back and update #450.

@wusyong wusyong deleted the mozjs_release branch March 9, 2024 10:39
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