Update to newer JSC and use Bun's fork #142
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build jsc-android and test | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| publish: | |
| description: 'Publish npm packages after build/test succeed' | |
| type: boolean | |
| default: false | |
| npm-tag: | |
| description: 'npm dist-tag' | |
| required: false | |
| default: latest | |
| dry-run: | |
| description: 'Run npm publish in dry-run mode' | |
| type: boolean | |
| default: true | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }} | |
| ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }} | |
| NDK_VERSION_27: '27.1.12297006' | |
| NDK_VERSION_28: '28.2.13676358' | |
| NDK_VERSION_29: '29.0.14206865' | |
| BUILD_CACHE_VERSION: v1 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: 🧹 Cleanup GitHub Linux runner disk space | |
| uses: ./.github/actions/cleanup-linux-disk-space | |
| - name: 🔨 Use JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: ⬢ Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Compute build cache key | |
| id: build-hash | |
| run: | | |
| HASH=$(node scripts/build-hash.js) | |
| echo "hash=$HASH" >> "$GITHUB_OUTPUT" | |
| - name: Restore JSC build artifacts | |
| id: cache-dist | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| dist-ndk27 | |
| dist-ndk27.unstripped | |
| dist-ndk28 | |
| dist-ndk28.unstripped | |
| dist-ndk29 | |
| dist-ndk29.unstripped | |
| key: jsc-dist-${{ env.BUILD_CACHE_VERSION }}-${{ steps.build-hash.outputs.hash }} | |
| - name: Restore WebKit sources | |
| id: cache-download | |
| uses: actions/cache@v4 | |
| with: | |
| path: build/download | |
| key: jsc-download-${{ env.BUILD_CACHE_VERSION }}-${{ steps.build-hash.outputs.hash }} | |
| restore-keys: | | |
| jsc-download-${{ env.BUILD_CACHE_VERSION }}- | |
| - name: Install packages | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install coreutils curl git wget python3 ruby gperf ccache -y | |
| shell: bash | |
| - name: Restore ccache | |
| id: cache-ccache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/ccache | |
| key: ccache-${{ env.BUILD_CACHE_VERSION }}-${{ runner.os }}-${{ env.NDK_VERSION_27 }}-${{ env.NDK_VERSION_28 }}-${{ env.NDK_VERSION_29 }}-${{ steps.build-hash.outputs.hash }} | |
| restore-keys: | | |
| ccache-${{ env.BUILD_CACHE_VERSION }}-${{ runner.os }}-${{ env.NDK_VERSION_27 }}-${{ env.NDK_VERSION_28 }}-${{ env.NDK_VERSION_29 }}- | |
| - name: Configure ccache | |
| run: | | |
| mkdir -p ~/.cache/ccache | |
| if command -v ccache >/dev/null 2>&1; then | |
| ccache --max-size=5G | |
| ccache --zero-stats || true | |
| fi | |
| shell: bash | |
| - name: Cache Android NDK r27 | |
| id: cache-ndk-27 | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.ANDROID_HOME }}/ndk/${{ env.NDK_VERSION_27 }} | |
| key: android-ndk-${{ runner.os }}-${{ env.NDK_VERSION_27 }} | |
| - name: Cache Android NDK r28 | |
| id: cache-ndk-28 | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.ANDROID_HOME }}/ndk/${{ env.NDK_VERSION_28 }} | |
| key: android-ndk-${{ runner.os }}-${{ env.NDK_VERSION_28 }} | |
| - name: Cache Android NDK r29 | |
| id: cache-ndk-29 | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.ANDROID_HOME }}/ndk/${{ env.NDK_VERSION_29 }} | |
| key: android-ndk-${{ runner.os }}-${{ env.NDK_VERSION_29 }} | |
| - name: Install Android packages | |
| run: | | |
| export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools | |
| yes | sdkmanager --licenses || true | |
| sdkmanager "cmake;3.22.1" | |
| for version in "${NDK_VERSION_27}" "${NDK_VERSION_28}" "${NDK_VERSION_29}"; do | |
| if [[ -z "$version" ]]; then | |
| continue | |
| fi | |
| if [[ ! -d "${ANDROID_HOME}/ndk/${version}" ]]; then | |
| sdkmanager "ndk;${version}" | |
| fi | |
| UNICODE_DIR="${ANDROID_HOME}/ndk/${version}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/unicode" | |
| if [[ -d "${UNICODE_DIR}" ]]; then | |
| mv "${UNICODE_DIR}" "${UNICODE_DIR}2" | |
| fi | |
| done | |
| echo "ANDROID_NDK=$ANDROID_HOME/ndk/${NDK_VERSION_27}" >> $GITHUB_ENV | |
| echo "PATH=$PATH" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| shell: bash | |
| - name: Clean previous build outputs | |
| if: steps.cache-dist.outputs.cache-hit != 'true' | |
| run: | | |
| rm -rf dist dist.unstripped dist-ndk* build/target* build/compiled* build/cppruntime* | |
| shell: bash | |
| - name: Download sources | |
| if: steps.cache-download.outputs.cache-hit != 'true' | |
| run: yarn download | |
| shell: bash | |
| - name: Build | |
| if: steps.cache-dist.outputs.cache-hit != 'true' | |
| run: | | |
| variants=(ndk27 ndk28c ndk29) | |
| for variant in "${variants[@]}"; do | |
| case "$variant" in | |
| ndk27) | |
| export ANDROID_NDK="$ANDROID_HOME/ndk/${NDK_VERSION_27}" | |
| ;; | |
| ndk28c) | |
| export ANDROID_NDK="$ANDROID_HOME/ndk/${NDK_VERSION_28}" | |
| ;; | |
| ndk29) | |
| export ANDROID_NDK="$ANDROID_HOME/ndk/${NDK_VERSION_29}" | |
| ;; | |
| *) | |
| echo "Unknown variant $variant" >&2 | |
| exit 1 | |
| esac | |
| if [[ ! -d "$ANDROID_NDK" ]]; then | |
| echo "Android NDK not found at $ANDROID_NDK for variant $variant" >&2 | |
| exit 1 | |
| fi | |
| export JSC_NDK_VARIANT="$variant" | |
| yarn start | |
| done | |
| shell: bash | |
| - name: Show ccache stats | |
| if: steps.cache-dist.outputs.cache-hit != 'true' | |
| run: | | |
| if command -v ccache >/dev/null 2>&1; then | |
| ccache --show-stats | |
| fi | |
| shell: bash | |
| - name: Archive | |
| run: | | |
| rm -rf archive | |
| mkdir -p archive | |
| shopt -s nullglob | |
| found=0 | |
| for dir in dist-ndk*; do | |
| if [[ -d "$dir" ]]; then | |
| cp -R "$dir" archive/ | |
| found=1 | |
| fi | |
| done | |
| shopt -u nullglob | |
| if [[ $found -eq 0 ]]; then | |
| echo "No distribution directories were produced." >&2 | |
| exit 1 | |
| fi | |
| shell: bash | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: archive | |
| path: archive | |
| test: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: 🧹 Cleanup GitHub Linux runner disk space | |
| uses: ./.github/actions/cleanup-linux-disk-space | |
| - name: ⬢ Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: 🔨 Use JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: archive | |
| path: archive | |
| - name: Extract archive | |
| run: | | |
| shopt -s nullglob | |
| for dir in archive/dist-ndk*; do | |
| dest=$(basename "$dir") | |
| mv "$dir" "$dest" | |
| done | |
| shopt -u nullglob | |
| rmdir archive | |
| shell: bash | |
| - name: 🍺 Install Maestro | |
| run: | | |
| curl -Ls "https://get.maestro.mobile.dev" | bash | |
| echo "${HOME}/.maestro/bin" >> $GITHUB_PATH | |
| - name: Install node packages | |
| run: yarn install --frozen-lockfile | |
| working-directory: test | |
| - name: ⚙️ Enable KVM for Android virtualization | |
| shell: bash | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: Run test | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: 24 | |
| arch: x86_64 | |
| target: google_apis | |
| working-directory: test | |
| script: | | |
| export JSC_GRADLE_DIST_PATH=../../dist-ndk27 | |
| npx expo run:android --variant release --no-bundler | |
| adb logcat -c | |
| set +e | |
| maestro test maestro.yaml | |
| STATUS=$? | |
| if [ $STATUS -eq 0 ]; then | |
| for variant in ndk27 ndk28c ndk29; do | |
| ../scripts/run-js-smoketest.sh "$variant" | |
| EXIT_CODE=$? | |
| if [ $EXIT_CODE -ne 0 ]; then | |
| STATUS=$EXIT_CODE | |
| break | |
| fi | |
| done | |
| fi | |
| adb logcat -d > adb.log | |
| exit $STATUS | |
| - name: Upload failed artifacts | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: failure_artifacts | |
| path: | | |
| $HOME/.maestro/tests/**/* | |
| test/android/app/build/outputs/apk/release/app-release.apk | |
| test/adb.log | |
| publish: | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true' | |
| needs: | |
| - build | |
| - test | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: npm-publish | |
| url: https://www.npmjs.com/package/jsc-android | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: ⬢ Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: archive | |
| path: archive | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| shell: bash | |
| - name: Verify npm token availability | |
| if: github.event.inputs.dry-run != 'true' | |
| run: | | |
| if [[ -z "${NPM_TOKEN:-}" ]]; then | |
| echo "NPM_TOKEN secret is required for publishing." >&2 | |
| exit 1 | |
| fi | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| shell: bash | |
| - name: Publish packages | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NPM_CONFIG_PROVENANCE: 'true' | |
| run: | | |
| TAG="${{ github.event.inputs.npm-tag }}" | |
| DRY_RUN="${{ github.event.inputs.dry-run }}" | |
| PUBLISH_ARGS=("-T" "$TAG") | |
| if [[ "$DRY_RUN" == 'true' ]]; then | |
| PUBLISH_ARGS+=("--dry-run") | |
| fi | |
| node scripts/publish.js "${PUBLISH_ARGS[@]}" archive | |
| shell: bash |