Skip to content

Merge pull request #474 from ruby/dependabot/npm_and_yarn/tslib-2.6.3 #1571

Merge pull request #474 from ruby/dependabot/npm_and_yarn/tslib-2.6.3

Merge pull request #474 from ruby/dependabot/npm_and_yarn/tslib-2.6.3 #1571

Workflow file for this run

name: Build ruby.wasm
on:
push:
branches: [main]
tags: ["*"]
paths-ignore:
- "*.md"
- "docs/**"
pull_request:
workflow_call:
inputs:
publish:
type: boolean
description: "Whether to publish or not"
default: true
prerel_name:
type: string
description: "Pre-release name to be released"
required: true
secrets:
NODE_AUTH_TOKEN:
required: true
jobs:
lint:
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
- run: ./bin/setup
- run: bundle exec rake check:type
- run: sudo apt-get install clang-format
- run: ./tools/clang-format-diff.sh
- run: bundle exec rake check:bindgen
- run: git diff --exit-code
build-builder-image:
strategy:
fail-fast: false
matrix:
entry:
- { target: wasm32-unknown-wasip1 }
- { target: wasm32-unknown-emscripten }
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository_owner }}/ruby.wasm/builder/${{ matrix.entry.target }}
- uses: docker/build-push-action@v6
with:
context: builders/${{ matrix.entry.target }}
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-rake-task-matrix:
runs-on: ubuntu-20.04
outputs:
entries: ${{ steps.set-matrix.outputs.entries }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
- run: ./bin/setup
- run: rake ci:pin_build_manifest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
with:
name: build-manifest
path: build_manifest.json
- name: Set matrix
id: set-matrix
run: |
rake ci:rake_task_matrix > matrix.json
echo "entries=$(cat matrix.json)" >> $GITHUB_OUTPUT
rake-tasks:
strategy:
fail-fast: false
matrix:
entry: ${{ fromJson(needs.build-rake-task-matrix.outputs.entries) }}
needs: [build-rake-task-matrix]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/download-artifact@v4
with:
name: build-manifest
- uses: actions/[email protected]
if: ${{ matrix.entry.rubies_cache_key != null }}
with:
path: ./rubies
key: ${{ matrix.entry.rubies_cache_key }}
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
id: builder-image
with:
context: builders/${{ matrix.entry.builder }}
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Setup builder container
run: |
docker run -dit -v "$GITHUB_WORKSPACE:/home/me/build" -w /home/me/build \
-e "ENABLE_GITHUB_ACTIONS_MARKUP=true" \
-e "RUBYWASM_UID=$(id -u)" -e "RUBYWASM_GID=$(id -g)" \
-e "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" \
--name builder \
${{ steps.builder-image.outputs.imageid }} /bin/sh
echo 'docker exec -u me builder "$@"' > ./build-exec
chmod +x ./build-exec
# wait for docker exec to be ready
timeout 10 bash -c 'until ./build-exec bundle config set --local without check; do sleep 1; done'
- run: ./build-exec rustup target add wasm32-wasi # For jco build
- run: ./build-exec ./bin/setup
- run: ./build-exec bundle exec rake compile
- name: Pre-release configuration
run: ./build-exec bundle exec rake ${{ matrix.entry.prerelease }}[${{ inputs.prerel_name }}]
if: ${{ inputs.prerel_name != '' && matrix.entry.prerelease != '' }}
- name: rake ${{ matrix.entry.task }}
run: ./build-exec rake --verbose ${{ matrix.entry.task }}
- uses: ruby/setup-ruby@v1
if: ${{ matrix.entry.test != '' }}
with:
ruby-version: "3.3"
bundler-cache: false
- name: rake ${{ matrix.entry.test }}
run: |
bundle install --with=check --without=development
rake ${{ matrix.entry.test }}
if: ${{ matrix.entry.test != '' }}
- uses: actions/upload-artifact@v4
if: ${{ matrix.entry.artifact }}
with:
name: ${{ matrix.entry.artifact_name }}
path: ${{ matrix.entry.artifact }}
release-artifacts:
needs: [rake-tasks]
runs-on: ubuntu-20.04
if: ${{ startsWith(github.ref, 'refs/tags/') || inputs.publish }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: build-manifest
- uses: actions/download-artifact@v4
with:
path: release
- uses: actions/setup-node@v4
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
- run: ./bin/setup
- run: echo "PREREL_NAME=${{ inputs.prerel_name }}" >> $GITHUB_ENV
- run: bundle exec rake "ci:publish[${PREREL_NAME:-$GITHUB_REF_NAME}]"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}