wip #23
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 | |
| on: | |
| - pull_request | |
| - push | |
| jobs: | |
| rubocop: | |
| name: Lint (Rubocop) | |
| runs-on: ubuntu-24.04 | |
| container: ruby:3.1 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Bundle | |
| run: bundle install | |
| - name: Rubocop | |
| run: bundle exec rubocop -f simple | |
| shellcheck: | |
| name: Lint (Shellcheck) | |
| runs-on: ubuntu-24.04 | |
| container: debian:10 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Install shellcheck | |
| run: apt-get update && apt-get install -y shellcheck | |
| - name: Shellcheck | |
| run: shellcheck libexec/* | |
| build-ruby: | |
| name: Build (ruby) | |
| outputs: | |
| GEM_VERSION: ${{ steps.set-metadata.outputs.GEM_VERSION }} | |
| runs-on: ubuntu-24.04 | |
| container: ruby:3.1 | |
| steps: | |
| - name: Update Rubygems and Bundler | |
| run: | | |
| gem update --system 3.3.26 | |
| gem install bundler -v '~> 2.3.26' | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Bundle | |
| run: bundle install | |
| - name: Set metadata | |
| id: set-metadata | |
| run: | | |
| ./libexec/metadata ruby_platform | tee ruby_platform | |
| echo "::set-output name=RUBY_PLATFORM::$(cat ruby_platform)" | |
| ./libexec/metadata gem_platform | tee gem_platform | |
| echo "::set-output name=GEM_PLATFORM::$(cat gem_platform)" | |
| ./libexec/metadata gem_version | tee gem_version | |
| echo "::set-output name=GEM_VERSION::$(cat gem_version)" | |
| ./libexec/metadata node_version | tee node_version | |
| echo "::set-output name=NODE_VERSION::$(cat node_version)" | |
| ./libexec/metadata libv8_version | tee libv8_version | |
| echo "::set-output name=LIBV8_VERSION::$(cat libv8_version)" | |
| - name: Download Node.js | |
| run: | | |
| ./libexec/download-node ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| - name: Extract Node.js | |
| run: | | |
| ./libexec/extract-node ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| - name: Validate V8 version | |
| run: | | |
| ./libexec/metadata libv8_version_h | tee libv8_version_h | |
| diff libv8_version_h libv8_version | |
| - name: Build gem | |
| run: | | |
| bundle exec rake build | |
| - name: Upload gem | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gem-${{ steps.set-metadata.outputs.GEM_VERSION }}-ruby | |
| path: pkg | |
| build-darwin: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - x86_64 | |
| # arm64 | |
| name: Build (darwin) (arm64) | |
| outputs: | |
| GEM_VERSION: ${{ steps.set-metadata.outputs.GEM_VERSION }} | |
| # intel: macos-15-large, arm: macos-15 or macos-15-xlarge | |
| runs-on: macos-15 #-xlarge | |
| env: | |
| TARGET_PLATFORM: arm64-darwin | |
| RUBY_TARGET_PLATFORM: arm64-darwin | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Bundle | |
| run: bundle install | |
| - name: Set metadata | |
| id: set-metadata | |
| run: | | |
| ./libexec/metadata ruby_platform | tee ruby_platform | |
| echo "RUBY_PLATFORM=$RUBY_TARGET_PLATFORM" >> $GITHUB_OUTPUT | |
| ./libexec/metadata gem_platform | tee gem_platform | |
| echo "GEM_PLATFORM=$TARGET_PLATFORM" >> $GITHUB_OUTPUT | |
| ./libexec/metadata gem_version | tee gem_version | |
| echo "GEM_VERSION=$(cat gem_version)" >> $GITHUB_OUTPUT | |
| ./libexec/metadata node_version | tee node_version | |
| echo "NODE_VERSION=$(cat node_version)" >> $GITHUB_OUTPUT | |
| ./libexec/metadata libv8_version | tee libv8_version | |
| echo "LIBV8_VERSION=$(cat libv8_version)" >> $GITHUB_OUTPUT | |
| - name: Download Node.js | |
| run: | | |
| ./libexec/download-node ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| - name: Extract Node.js | |
| run: | | |
| ./libexec/extract-node ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| - name: Validate V8 version | |
| run: | | |
| ./libexec/metadata libv8_version_h | tee libv8_version_h | |
| diff libv8_version_h libv8_version | |
| - name: Build V8 | |
| run: | | |
| ./libexec/build-libv8 ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| - name: Build Monolith | |
| run: | | |
| ./libexec/build-monolith ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| - name: Inject V8 | |
| run: | | |
| ./libexec/inject-libv8 ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| # FIXME: Why did we start skipping those tests since node-18? | |
| # See https://github.com/rubyjs/libv8-node/pull/46 | |
| # - name: Test V8 in C++ | |
| # run: | | |
| # cd test/gtest | |
| # cmake -S . -B build | |
| # cd build | |
| # cmake --build . | |
| # ./c_v8_tests | |
| - name: Build binary gem | |
| run: | | |
| bundle exec rake binary | |
| - name: Upload V8 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: v8-${{ steps.set-metadata.outputs.LIBV8_VERSION }}-${{ steps.set-metadata.outputs.GEM_PLATFORM }} | |
| path: vendor | |
| - name: Upload gem | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gem-${{ steps.set-metadata.outputs.GEM_VERSION }}-${{ steps.set-metadata.outputs.GEM_PLATFORM }} | |
| path: pkg | |
| build-linux: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - amd64 | |
| - arm64 | |
| # arm | |
| # ppc64le | |
| # s390x | |
| libc: | |
| - gnu | |
| - musl | |
| name: Build (linux) | |
| outputs: | |
| GEM_VERSION: ${{ steps.set-metadata.outputs.GEM_VERSION }} | |
| runs-on: ${{ matrix.platform == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }} | |
| steps: | |
| - name: Start container | |
| id: container | |
| run: | | |
| case ${{ matrix.libc }} in | |
| gnu) | |
| echo 'ruby:3.1' | |
| ;; | |
| musl) | |
| echo 'ruby:3.1-alpine' | |
| ;; | |
| esac | tee container_image | |
| echo "::set-output name=image::$(cat container_image)" | |
| docker run --rm -d -v "${PWD}":"${PWD}" -w "${PWD}" $(cat container_image) /bin/sleep 64d | tee container_id | |
| docker exec -w "${PWD}" $(cat container_id) uname -a | |
| echo "::set-output name=id::$(cat container_id)" | |
| - name: Install Alpine system dependencies | |
| if: ${{ matrix.libc == 'musl' }} | |
| run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apk add --no-cache build-base linux-headers bash python3 git curl tar cmake clang ccache | |
| - name: Install Debian system dependencies | |
| if: ${{ matrix.libc == 'gnu' }} | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apt-get update | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apt-get install -y cmake clang ccache | |
| - name: Update Rubygems and Bundler | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} gem update --system 3.3.26 | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} gem install bundler -v '~> 2.3.26' | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Bundle | |
| run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle install | |
| - name: Set metadata | |
| id: set-metadata | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/metadata ruby_platform | tee ruby_platform | |
| echo "::set-output name=RUBY_PLATFORM::$(cat ruby_platform)" | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/metadata gem_platform | tee gem_platform | |
| echo "::set-output name=GEM_PLATFORM::$(cat gem_platform)" | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/metadata gem_version | tee gem_version | |
| echo "::set-output name=GEM_VERSION::$(cat gem_version)" | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/metadata node_version | tee node_version | |
| echo "::set-output name=NODE_VERSION::$(cat node_version)" | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/metadata libv8_version | tee libv8_version | |
| echo "::set-output name=LIBV8_VERSION::$(cat libv8_version)" | |
| - name: Download Node.js | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/download-node ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| - name: Extract Node.js | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/extract-node ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| - name: Validate V8 version | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/metadata libv8_version_h | tee libv8_version_h | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} diff libv8_version_h libv8_version | |
| - name: Build V8 | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/build-libv8 ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| - name: Build Monolith | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/build-monolith ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| - name: Inject V8 | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/inject-libv8 ${{ steps.set-metadata.outputs.NODE_VERSION }} | |
| # FIXME: Why did we start skipping those tests since node-18? | |
| # See https://github.com/rubyjs/libv8-node/pull/46 | |
| - name: Test V8 in C++ | |
| if: matrix.platform != 'arm64' | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bash -c "cd test/gtest && cmake -S . -B build && cd build && cmake --build . && ctest" | |
| - name: Build binary gem | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle exec rake binary | |
| - name: Upload V8 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: v8-${{ steps.set-metadata.outputs.LIBV8_VERSION }}-${{ steps.set-metadata.outputs.GEM_PLATFORM }} | |
| path: vendor | |
| - name: Upload gem | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gem-${{ steps.set-metadata.outputs.GEM_VERSION }}-${{ steps.set-metadata.outputs.GEM_PLATFORM }} | |
| path: pkg | |
| test-ruby: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - amd64 | |
| - arm64 | |
| container: | |
| - image: ruby:3.1 | |
| version: '3.1' | |
| libc: gnu | |
| - image: ruby:3.1-alpine | |
| version: '3.1' | |
| libc: musl | |
| - image: ruby:3.2 | |
| version: '3.2' | |
| libc: gnu | |
| - image: ruby:3.2-alpine | |
| version: '3.2' | |
| libc: musl | |
| - image: ruby:3.3 | |
| version: '3.3' | |
| libc: gnu | |
| - image: ruby:3.3-alpine | |
| version: '3.3' | |
| libc: musl | |
| - image: ruby:3.4 | |
| version: '3.4' | |
| libc: gnu | |
| - image: ruby:3.4-alpine | |
| version: '3.4' | |
| libc: musl | |
| name: Test (ruby) (${{ matrix.container.version }}, ${{ matrix.platform }}, ${{ matrix.container.libc }}) | |
| needs: build-ruby | |
| runs-on: ${{ matrix.platform == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }} | |
| steps: | |
| - name: Start container | |
| id: container | |
| run: | | |
| docker run --rm -d -v "${PWD}":"${PWD}" -w "${PWD}" ${{ matrix.container.image }} /bin/sleep 64d | tee container_id | |
| docker exec $(cat container_id) uname -a | |
| echo "id=$(cat container_id)" >> $GITHUB_OUTPUT | |
| - name: Install Alpine system dependencies | |
| if: ${{ matrix.container.libc == 'musl' }} | |
| run: | | |
| docker exec ${{ steps.container.outputs.id }} apk add --no-cache build-base linux-headers bash python3 git curl tar tzdata | |
| - name: Update Rubygems and Bundler | |
| run: | | |
| docker exec ${{ steps.container.outputs.id }} gem update --system 3.3.26 | |
| docker exec ${{ steps.container.outputs.id }} gem install bundler -v '~> 2.3.26' | |
| - name: Set metadata | |
| id: set-metadata | |
| run: | | |
| docker exec ${{ steps.container.outputs.id }} ruby -e 'puts Gem.platforms.last.to_s' | tee gem_platform | |
| echo "GEM_PLATFORM=$(cat gem_platform)" | |
| - name: Download a single artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: gem-${{ needs.build-ruby.outputs.GEM_VERSION }}-ruby | |
| path: pkg | |
| - name: Install gem | |
| run: | | |
| docker exec ${{ steps.container.outputs.id }} gem install --verbose pkg/libv8-node-${{ needs.build-ruby.outputs.GEM_VERSION }}.gem | |
| - name: Test with mini_racer | |
| run: | | |
| pwd | |
| ls -la | |
| ls -la test/mini_racer_integration | |
| docker exec -e LIBV8_NODE_VERSION=${{ needs.build-ruby.outputs.GEM_VERSION }} ${{ steps.container.outputs.id }} test/mini_racer_integration | |
| test-darwin: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - x86_64 | |
| # arm64 | |
| name: Test (darwin) | |
| needs: build-darwin | |
| # intel: macos-15-large, arm: macos-15 or macos-15-xlarge | |
| runs-on: macos-15-xlarge | |
| steps: | |
| - name: Set metadata | |
| id: set-metadata | |
| run: | | |
| ruby -e 'puts Gem.platforms.last.to_s.gsub(/-darwin-?\d+/, "-darwin")' | tee gem_platform | |
| echo "::set-output name=GEM_PLATFORM::$(cat gem_platform)" | |
| - name: Download a single artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: gem-${{ needs.build-darwin.outputs.GEM_VERSION }}-${{ steps.set-metadata.outputs.GEM_PLATFORM }} | |
| path: pkg | |
| - name: Install gem | |
| run: gem install pkg/libv8-node-${{ needs.build-darwin.outputs.GEM_VERSION }}-${{ steps.set-metadata.outputs.GEM_PLATFORM }}.gem | |
| - name: Test with mini_racer | |
| run: | | |
| git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1 | |
| cd test/mini_racer | |
| ruby -i -ne '$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"${{ needs.build-darwin.outputs.GEM_VERSION }}\"\n") : print' lib/mini_racer/version.rb | |
| ruby -i -ne '$_ =~ /spec.required_ruby_version/ ? "" : print' mini_racer.gemspec | |
| bundle install | |
| bundle exec rake compile | |
| VERBOSE_MINITEST=true bundle exec rake test | |
| test-linux: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: | |
| - '3.1' | |
| - '3.2' | |
| - '3.3' | |
| - '3.4' | |
| platform: | |
| - amd64 | |
| - arm64 | |
| # arm | |
| # ppc64le | |
| # s390x | |
| libc: | |
| - gnu | |
| - musl | |
| name: Test (linux) | |
| needs: build-linux | |
| runs-on: ${{ matrix.platform == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }} | |
| steps: | |
| - name: Start container | |
| id: container | |
| run: | | |
| case ${{ matrix.libc }} in | |
| gnu) | |
| echo 'ruby:${{ matrix.version }}' | |
| ;; | |
| musl) | |
| echo 'ruby:${{ matrix.version }}-alpine' | |
| ;; | |
| esac | tee container_image | |
| echo "::set-output name=image::$(cat container_image)" | |
| docker run --rm -d -v "${PWD}":"${PWD}" -w "${PWD}" $(cat container_image) /bin/sleep 64d | tee container_id | |
| docker exec -w "${PWD}" $(cat container_id) uname -a | |
| echo "::set-output name=id::$(cat container_id)" | |
| - name: Install Alpine system dependencies | |
| if: ${{ matrix.libc == 'musl' }} | |
| run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apk add --no-cache build-base git libstdc++ tzdata | |
| - name: Update Rubygems and Bundler | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} gem update --system 3.3.26 | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} gem install bundler -v '~> 2.3.26' | |
| - name: Set metadata | |
| id: set-metadata | |
| run: | | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ruby -e 'puts Gem::Platform.local.tap { |p| RUBY_PLATFORM =~ /musl/ && p.version.nil? and p.instance_eval { @version = "musl" } }.to_s' | tee gem_platform | |
| echo "::set-output name=GEM_PLATFORM::$(cat gem_platform)" | |
| - name: Download a single artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: gem-${{ needs.build-linux.outputs.GEM_VERSION }}-${{ steps.set-metadata.outputs.GEM_PLATFORM }} | |
| path: pkg | |
| - name: Install gem | |
| run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} gem install pkg/libv8-node-${{ needs.build-linux.outputs.GEM_VERSION }}-${{ steps.set-metadata.outputs.GEM_PLATFORM }}.gem | |
| - name: Test with mini_racer | |
| run: | | |
| git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1 | |
| cd test/mini_racer | |
| ruby -i -ne '$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"${{ needs.build-linux.outputs.GEM_VERSION }}\"\n") : print' lib/mini_racer/version.rb | |
| ruby -i -ne '$_ =~ /spec.required_ruby_version/ ? "" : print' mini_racer.gemspec | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle install | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle exec rake compile | |
| docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle exec rake test --trace |