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
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6aef1eb
Add release CI pipeline
wusyong Feb 29, 2024
ad84256
Rename CI pipeline
wusyong Feb 29, 2024
c5bf7c2
Update CI trigger condition
wusyong Feb 29, 2024
d3e69ac
Merge CI into one file
wusyong Feb 29, 2024
7c1b25a
Add release steps
wusyong Feb 29, 2024
a29f3a0
Merge pull request #13 from wusyong/mozjs_release_patch
wusyong Mar 1, 2024
83793f4
Update widnow target arguments
wusyong Mar 1, 2024
d150367
Simplify release workflow
wusyong Mar 1, 2024
0737a22
Merge pull request #17 from wusyong/mozjs_patch
wusyong Mar 1, 2024
0b3f0b5
Add release check CI
wusyong Mar 2, 2024
9790c30
Update trigger condition and remove deps
wusyong Mar 4, 2024
2e0efed
Add CARGO_TARGET_DIR on Windows job
wusyong Mar 4, 2024
3c94562
Merge pull request #21 from wusyong/gh
wusyong Mar 4, 2024
a8370a3
Merge all jobs in release into one
wusyong Mar 4, 2024
2076043
Merge pull request #24 from wusyong/onejob
wusyong Mar 4, 2024
d84ff44
Check from artifact as well
wusyong Mar 4, 2024
3800976
Extract --features
wusyong Mar 4, 2024
dee33e6
Rename MOZJS_ARCHIVE path
wusyong Mar 4, 2024
72f6675
Merge pull request #27 from wusyong/ar
wusyong Mar 4, 2024
94afc62
Fix missed matrix.features
wusyong Mar 4, 2024
713e84e
Update release jobs
wusyong Mar 5, 2024
495e7e5
Merge pull request #29 from wusyong/rj
wusyong Mar 5, 2024
b154d0a
Update release tag name and check if exist before release
wusyong Mar 6, 2024
3241ac0
Merge pull request #31 from wusyong/ct
wusyong Mar 6, 2024
8d7ed20
Update release job to check remote tags
wusyong Mar 9, 2024
fb6869e
Simplify release job steps instead
wusyong Mar 9, 2024
a58bfe9
Revert latest commit
wusyong Mar 9, 2024
21f9113
Merge branch 'main' into mozjs_release
sagudev Mar 9, 2024
3809e36
Fix tag variable
wusyong Mar 9, 2024
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
107 changes: 107 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

name: Version Release Check

on:
release:
types: [published]
workflow_call:
inputs:
release-tag:
required: true
type: string

env:
RUST_BACKTRACE: 1
SHELL: /bin/bash
CARGO_INCREMENTAL: 0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository_owner }}/mozjs
MOZJS_ARCHIVE: libmozjs.tar.gz

jobs:
release-tag:
runs-on: ubuntu-latest
steps:
- id: tag-name
run: |
if [[ '${{ inputs.release-tag }}' != '' ]]; then
echo "RELEASE_TAG=${{ inputs.release-tag }}" >> ${GITHUB_OUTPUT}
elif [[ '${{ github.event_name }}' == 'release' ]]; then
echo "RELEASE_TAG=${{ github.ref_name }}" >> ${GITHUB_OUTPUT}
fi
outputs:
release-tag: ${{ steps.tag-name.outputs.RELEASE_TAG }}

mac:
strategy:
fail-fast: false
matrix:
features: ["--features streams"]
platform:
- { target: aarch64-apple-darwin, os: macos-14 }
- { target: x86_64-apple-darwin, os: macos-13 }
runs-on: ${{ matrix.platform.os }}
needs: release-tag
steps:
- uses: actions/checkout@v4
- name: Download prebuilt mozjs
run: |
curl -L https://github.com/${REPO}/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-${{ matrix.platform.target }}.tar.gz -o libmozjs.tar.gz
- name: Build
run: |
cargo build --verbose ${{ matrix.features }}
cargo test --tests --examples --verbose ${{ matrix.features }}

linux:
runs-on: ubuntu-latest
needs: release-tag
strategy:
fail-fast: false
matrix:
features: ["--features streams"]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Download prebuilt mozjs
run: |
curl -L https://github.com/${REPO}/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-x86_64-unknown-linux-gnu.tar.gz -o libmozjs.tar.gz
- name: Build
run: |
cargo build --verbose ${{ matrix.features }}
cargo test --tests --examples --verbose ${{ matrix.features }}

windows:
runs-on: windows-latest
needs: release-tag
strategy:
fail-fast: false
matrix:
features: ["--features streams"]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Download prebuilt mozjs
run: |
curl -L https://github.com/${{ github.repository_owner }}/mozjs/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-x86_64-pc-windows-msvc.tar.gz -o libmozjs.tar.gz
- name: Build Windows
shell: cmd
run: |
cargo build --verbose ${{ matrix.features }}
cargo test --tests --examples --verbose ${{ matrix.features }}

build_result:
name: Result
runs-on: ubuntu-latest
needs:
["linux", "mac", "windows"]
if: ${{ always() }}
steps:
- name: Mark the job as successful
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
run: exit 0
- name: Mark the job as unsuccessful
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1

61 changes: 56 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ env:
RUST_BACKTRACE: 1
SHELL: /bin/bash
CARGO_INCREMENTAL: 0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MOZJS_CREATE_ARCHIVE: 1

jobs:
mac:
runs-on: macos-13
strategy:
fail-fast: false
matrix:
features: ["--features debugmozjs", ""]
features: ["--features debugmozjs", "--features streams"]
platform:
- { target: aarch64-apple-darwin, os: macos-14 }
- { target: x86_64-apple-darwin, os: macos-13 }
runs-on: ${{ matrix.platform.os }}
env:
RUSTC_WRAPPER: sccache
CCACHE: sccache
Expand All @@ -41,6 +46,13 @@ jobs:
run: |
cargo build --verbose ${{ matrix.features }}
cargo test --tests --examples --verbose ${{ matrix.features }}
- name: Upload artifact
if: ${{ contains(matrix.features, '--features streams') }}
uses: actions/upload-artifact@v4
with:
path: ./target/libmozjs-${{ matrix.platform.target }}.tar.gz
name: libmozjs-${{ matrix.platform.target }}.tar.gz

linux:
env:
RUSTC_WRAPPER: "sccache"
Expand All @@ -50,7 +62,7 @@ jobs:
strategy:
fail-fast: false
matrix:
features: ["--features debugmozjs", ""]
features: ["--features debugmozjs", "--features streams"]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -65,17 +77,23 @@ jobs:
cargo test --tests --examples --verbose ${{ matrix.features }}
- name: Check wrappers integrity
# we generate wrappers only without debugmozjs
if: ${{ matrix.features == '' }}
if: ${{ matrix.features == '--features streams' }}
run: |
bash ./mozjs/src/generate_wrappers.sh
git diff --quiet --exit-code
- name: Upload artifact
if: ${{ contains(matrix.features, '--features streams') }}
uses: actions/upload-artifact@v4
with:
path: ./target/libmozjs-x86_64-unknown-linux-gnu.tar.gz
name: libmozjs-x86_64-unknown-linux-gnu.tar.gz

windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
features: ["--features debugmozjs", ""]
features: ["--features debugmozjs", "--features streams"]
target: ["x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc"]
env:
LINKER: "lld-link.exe"
Expand Down Expand Up @@ -104,6 +122,12 @@ jobs:
shell: cmd
run: |
cargo test --tests --examples --verbose --target ${{ matrix.target }} ${{ matrix.features }}
- name: Upload artifact
if: ${{ !contains(matrix.target, 'aarch64') && contains(matrix.features, '--features streams') }}
uses: actions/upload-artifact@v4
with:
path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz
name: libmozjs-x86_64-pc-windows-msvc.tar.gz

android:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -178,3 +202,30 @@ jobs:
- name: Mark the job as unsuccessful
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1

publish-release:
name: Publish release
runs-on: ubuntu-latest
needs: build_result
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- id: release
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).

gh release create ${RELEASE_TAG} ./*.tar.gz
echo "RELEASE_TAG=${RELEASE_TAG}" >> ${GITHUB_OUTPUT}
outputs:
release-tag: ${{ steps.release.outputs.RELEASE_TAG }}

verify-release:
name: Verify release
needs: publish-release
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
uses: ./.github/workflows/release.yml
with:
release-tag: ${{ needs.publish-release.outputs.release-tag }}

Loading