Skip to content

set-output is derprecated, seeing if this corrects an issue in build … #332

set-output is derprecated, seeing if this corrects an issue in build …

set-output is derprecated, seeing if this corrects an issue in build … #332

Workflow file for this run

name: Build
on:
- pull_request
- push
jobs:
rubocop:
name: Lint (Rubocop)
runs-on: ubuntu-20.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-20.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-20.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@v3
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)
outputs:
GEM_VERSION: ${{ steps.set-metadata.outputs.GEM_VERSION }}
runs-on: macos-12
env:
TARGET_PLATFORM: ${{ matrix.platform }}-darwin
RUBY_TARGET_PLATFORM: ${{ matrix.platform }}-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=$(cat ruby_platform)" >> $GITHUB_OUTPUT
./libexec/metadata gem_platform | tee gem_platform
echo "GEM_PLATFORM=$(cat gem_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 }}
- name: Test V8 in C++
if: matrix.platform != 'arm64'
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@v3
with:
name: v8-${{ steps.set-metadata.outputs.LIBV8_VERSION }}-${{ steps.set-metadata.outputs.GEM_PLATFORM }}
path: vendor
- name: Upload gem
uses: actions/upload-artifact@v3
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
include:
- platform: amd64
libc: musl
name: Build (linux)
outputs:
GEM_VERSION: ${{ steps.set-metadata.outputs.GEM_VERSION }}
runs-on: ubuntu-20.04
steps:
- name: Set cross-compilation platform
id: platform
run: |
case ${{ matrix.platform }} in
amd64)
case ${{ matrix.libc }} in
gnu)
echo 'x86_64-linux-gnu'
;;
musl)
echo 'x86_64-alpine-linux-musl'
;;
esac
;;
arm64)
echo 'aarch64-linux-gnu'
;;
esac | tee target_platform
case ${{ matrix.platform }} in
amd64)
case ${{ matrix.libc }} in
gnu)
echo 'x86_64-linux'
;;
musl)
echo 'x86_64-linux-musl'
;;
esac
;;
arm64)
echo 'aarch64-linux'
;;
esac | tee ruby_target_platform
echo "::set-output name=target_platform::$(cat target_platform)"
echo "::set-output name=ruby_target_platform::$(cat ruby_target_platform)"
- 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}" --platform linux/amd64 -e RUBY_TARGET_PLATFORM=${{ steps.platform.outputs.ruby_target_platform }} -e TARGET_PLATFORM=${{ steps.platform.outputs.target_platform }} $(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: Install Debian cross-compiler
if: ${{ matrix.libc == 'gnu' && matrix.platform != 'amd64' }}
run: |
docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apt-get install -y binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- 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 }}
- 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[${{ steps.platform.outputs.ruby_target_platform }}]
- name: Upload V8
uses: actions/upload-artifact@v3
with:
name: v8-${{ steps.set-metadata.outputs.LIBV8_VERSION }}-${{ steps.platform.outputs.ruby_target_platform }}
path: vendor
- name: Upload gem
uses: actions/upload-artifact@v3
with:
name: gem-${{ steps.set-metadata.outputs.GEM_VERSION }}-${{ steps.platform.outputs.ruby_target_platform }}
path: pkg
test-ruby:
strategy:
fail-fast: false
matrix:
platform:
- amd64
# other platforms would need emulation, which is way too slow
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
name: Test (ruby) (${{ matrix.container.version }}, ${{ matrix.platform }}, ${{ matrix.container.libc }})
needs: build-ruby
runs-on: ubuntu-20.04
container: ${{ matrix.container.image }}
steps:
- name: Install Alpine system dependencies
if: ${{ matrix.container.libc == 'musl' }}
run: apk add --no-cache build-base linux-headers bash python3 git curl tar
- name: Update Rubygems and Bundler
run: |
gem update --system 3.3.26
gem install bundler -v '~> 2.3.26'
- name: Set metadata
id: set-metadata
run: |
ruby -e 'puts Gem.platforms.last.to_s' | tee gem_platform
echo "::set-output name=GEM_PLATFORM::$(cat gem_platform)"
- name: Download a single artifact
uses: actions/download-artifact@v3
with:
name: gem-${{ needs.build-ruby.outputs.GEM_VERSION }}-ruby
path: pkg
- name: Install gem
run: gem install --verbose pkg/libv8-node-${{ needs.build-ruby.outputs.GEM_VERSION }}.gem
- name: Test with mini_racer
run: |
export BUNDLE_FORCE_RUBY_PLATFORM=y
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-ruby.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
bundle exec rake test
test-darwin:
strategy:
fail-fast: false
matrix:
platform:
- x86_64
# arm64
name: Test (darwin)
needs: build-darwin
runs-on: macos-12
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@v3
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
bundle exec rake test
test-linux:
strategy:
fail-fast: false
matrix:
version:
- '3.1'
- '3.2'
- '3.3'
platform:
- amd64
# arm64
# arm
# ppc64le
# s390x
libc:
- gnu
- musl
include:
- version: '3.1'
platform: 'arm64'
libc: 'gnu'
- version: '3.2'
platform: 'arm64'
libc: 'gnu'
- version: '3.3'
platform: 'arm64'
libc: 'gnu'
name: Test (linux)
needs: build-linux
runs-on: ubuntu-20.04
steps:
- name: Enable ${{ matrix.platform }} platform
id: qemu
if: ${{ matrix.platform != 'amd64' }}
run: |
docker run --privileged --rm tonistiigi/binfmt:latest --install ${{ matrix.platform }} | tee platforms.json
echo "::set-output name=platforms::$(cat platforms.json)"
- 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}" --platform linux/${{ matrix.platform }} $(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++
- 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@v3
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