Skip to content

evm

evm #317

Workflow file for this run

name: napi
on:
push:
branches: [main]
pull_request:
env:
DEBUG: napi:*
APP_NAME: three_em_node
MACOSX_DEPLOYMENT_TARGET: '10.13'
jobs:
build:
name: build / ${{ matrix.target }} / node ${{ matrix.node }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
node: [14, 16]
include:
- os: macos-latest
target: x86_64-apple-darwin
arch: x64
build: yarn build-release; strip -x *.node
use_sysroot: false
- os: windows-latest
target: x86_64-pc-windows-msvc
arch: x64
build: yarn build-release
use_sysroot: false
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
arch: x64
build: yarn build --release
use_sysroot: true
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
architecture: ${{ matrix.arch }}
cache: 'yarn'
cache-dependency-path: js/napi/yarn.lock
- uses: dtolnay/rust-toolchain@stable
- name: Use Rust Cache
uses: Swatinem/rust-cache@v1
- name: Set up incremental LTO and sysroot build
if: matrix.use_sysroot || startsWith(matrix.os, 'ubuntu')
run: |
# Avoid running man-db triggers, which sometimes takes several minutes
# to complete.
sudo apt-get remove --purge -y man-db
# Install clang-14, lld-14, and debootstrap.
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" |
sudo dd of=/etc/apt/sources.list.d/llvm-toolchain-focal-14.list
curl https://apt.llvm.org/llvm-snapshot.gpg.key |
gpg --dearmor |
sudo dd of=/etc/apt/trusted.gpg.d/llvm-snapshot.gpg
sudo apt-get update
sudo apt-get install --no-install-recommends debootstrap \
clang-14 lld-14
# Create ubuntu-16.04 sysroot environment, which is used to avoid
# depending on a very recent version of glibc.
# `libc6-dev` is required for building any C source files.
# `file` and `make` are needed to build libffi-sys.
# `curl` is needed to build rusty_v8.
sudo debootstrap \
--include=ca-certificates,curl,file,libc6-dev,make \
--no-merged-usr --variant=minbase xenial /sysroot \
http://azure.archive.ubuntu.com/ubuntu
sudo mount --rbind /dev /sysroot/dev
sudo mount --rbind /sys /sysroot/sys
sudo mount --rbind /home /sysroot/home
sudo mount -t proc /proc /sysroot/proc
# Configure the build environment. Both Rust and Clang will produce
# llvm bitcode only, so we can use lld's incremental LTO support.
cat >> $GITHUB_ENV << __0
CARGO_PROFILE_BENCH_INCREMENTAL=false
CARGO_PROFILE_BENCH_LTO=false
CARGO_PROFILE_RELEASE_INCREMENTAL=false
CARGO_PROFILE_RELEASE_LTO=false
RUSTFLAGS<<__1
-C linker-plugin-lto=true
-C linker=clang-14
-C link-arg=-fuse-ld=lld-14
-C link-arg=--sysroot=/sysroot
-C link-arg=-Wl,--allow-shlib-undefined
-C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache
-C link-arg=-Wl,--thinlto-cache-policy,cache_size_bytes=700m
${{ env.RUSTFLAGS }}
__1
RUSTDOCFLAGS<<__1
-C linker-plugin-lto=true
-C linker=clang-14
-C link-arg=-fuse-ld=lld-14
-C link-arg=--sysroot=/sysroot
-C link-arg=-Wl,--allow-shlib-undefined
-C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache
-C link-arg=-Wl,--thinlto-cache-policy,cache_size_bytes=700m
${{ env.RUSTFLAGS }}
__1
CC=clang-14
CFLAGS=-flto=thin --sysroot=/sysroot
__0
- name: Install Node Dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: ./js/napi
useLockFile: false
- name: Build
working-directory: ./js/napi
run: ${{ matrix.build }}
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings-${{ matrix.target }}
path: ./js/napi/${{ env.APP_NAME }}.*.node
if-no-files-found: error
test:
name: test / ${{ matrix.target }} / node ${{ matrix.node }}
needs: [build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node: [14, 16]
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: yarn
cache-dependency-path: js/napi/yarn.lock
- name: Install Node Dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: ./js/napi
useLockFile: false
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: bindings-${{ matrix.target }}
path: ./js/napi
- name: List packages
working-directory: ./js/napi
run: ls -R .
- name: Test bindings
working-directory: ./js/napi
run: yarn test
publish:
name: publish
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
cache-dependency-path: js/napi/yarn.lock
- name: Install Node Dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: ./js/napi
useLockFile: false
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
path: ./js/napi/artifacts
- name: Move artifacts
working-directory: ./js/napi
run: yarn artifacts
- name: List packages
working-directory: ./js/napi
run: ls -R ./npm
shell: bash
- name: Publish
working-directory: ./js/napi
run: |
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag next --access public
else
echo "Not a release, skipping publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}