Skip to content

Commit

Permalink
Refactor Github Actions testing and prebuilding
Browse files Browse the repository at this point in the history
This commit changes the current way of testing + prebuilding native
addons on Githugb Actions by introducing the following changes:

* Separate the test workflow (run on any push) from the prebuilding
  workflow (run only on new tags).

* Use prebuildify-cross to compile native addons for two architectures
  (x64, arm64) and for two different libc implementations (glibc, musl)
  on Linux.

* Upgrade to v3 of the checkout and setup-node actions.

* Prebuild the native addon and test on x64 Windows too.

* Use compiler defaults for C++ version on MacOS.
  • Loading branch information
jeffesquivels committed Aug 16, 2023
1 parent 47d3180 commit 80651c4
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 63 deletions.
84 changes: 28 additions & 56 deletions .github/workflows/prebuild.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,58 @@
name: Test and Prebuild
name: Prebuild binary addons
on: [push]
jobs:
build-test-macos:
build-macos:
if: startsWith(github.ref, 'refs/tags/')
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 12
- run: npm install
- run: npm test
node-version: 20
- run: npm install --ignore-scripts
- run: npm run prebuild
if: startsWith(github.ref, 'refs/tags/')
- run: npm run prebuild-arm64
if: startsWith(github.ref, 'refs/tags/')
env:
PREBUILD_ARCH: x64
- run: npm run prebuild
env:
PREBUILD_ARCH: arm64
- run: tar --create --format ustar --verbose --file=prebuild-darwin.tar -C prebuilds .
if: startsWith(github.ref, 'refs/tags/')
- name: Prebuild
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: prebuild-darwin.tar
build-linux:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-18.04
container: quay.io/pypa/manylinux2014_x86_64
runs-on: ubuntu-20.04
steps:
- run: ldd --version ldd
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 12
- run: npm install
- run: npm run prebuild
- run: npm test
node-version: 20
- run: npm install --ignore-scripts
- run: npm run prebuild-linux-x64
- run: npm run prebuild-linux-arm64-glibc
- run: npm run prebuild-linux-arm64-musl
- run: tar --create --verbose --file=prebuild-linux.tar -C prebuilds .
- name: Prebuild
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: prebuild-linux.tar
build-alpine:
runs-on: ubuntu-18.04
container: node:12.22-alpine
steps:
- run: apk add python3 py3-pip build-base
- uses: actions/checkout@v2
- run: npm install
- run: npm run prebuild-musl
- run: npm test
- run: tar --create --verbose --file=prebuild-alpine.tar -C prebuilds .
- name: Prebuild
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: prebuild-alpine.tar
build-linux-arm64:
build-windows:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-18.04
container: quay.io/pypa/manylinux_2_24_x86_64
runs-on: windows-2019
steps:
- run: apt-get update
- run: apt-get install -y gcc-aarch64-linux-gnu
- run: apt-get install -y g++-aarch64-linux-gnu
- run: ldd --version ldd
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 12
- run: npm install
- run: npm run prebuild-arm64
if: startsWith(github.ref, 'refs/tags/')
env:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
- run: tar --create --verbose --file=prebuild-linux-arm64.tar -C prebuilds .
node-version: 20
- run: npm install --ignore-scripts
- run: npm run prebuild
- run: tar --create --verbose --file=prebuild-windows.tar -C prebuilds .
- name: Prebuild
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: prebuild-linux-arm64.tar
files: prebuild-windows.tar
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test
on: [push]
jobs:
test-macos:
runs-on: macos-11
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20
- run: npm install
- run: npm test
test-linux:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20
- run: npm install
- run: npm test
test-windows:
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20
- run: npm install
- run: npm test
2 changes: 0 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@
}]
],
"xcode_settings": {
"OTHER_CPLUSPLUSFLAGS" : ["-std=c++14"],
"MACOSX_DEPLOYMENT_TARGET": "10.7",
"OTHER_LDFLAGS": ["-std=c++14"],
"CLANG_CXX_LIBRARY": "libc++"
}
}],
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
"scripts": {
"install": "node-gyp-build",
"recompile": "node-gyp build",
"before-publish": "prebuildify-ci download && prebuildify --target 20.0.0 && prebuildify --target 18.0.0 && prebuildify --target 17.1.0 && prebuildify --target 16.13.0 && prebuildify --target 15.5.0 && prebuildify --target 14.17.6 && prebuildify --target 12.22.7 && prebuildify --target [email protected]",
"prebuild": "prebuildify --target 20.0.0 && prebuildify --target 18.0.0 && prebuildify --target 17.1.0 && prebuildify --target 16.13.0 && prebuildify --target 15.5.0 && prebuildify --target 14.17.6 && prebuildify --target 12.22.7 && prebuildify --target [email protected]",
"prebuild-musl": "prebuildify --target 20.0.0 --libc musl --tag-libc && prebuildify --target 18.0.0 --libc musl --tag-libc && prebuildify --target 17.1.0 --libc musl --tag-libc && prebuildify --target 16.13.0 --libc musl --tag-libc && prebuildify --target 14.17.6 --libc musl --tag-libc && prebuildify --target 12.22.7 --libc musl --tag-libc",
"prebuild-arm64": "prebuildify --arch=arm64 --target 20.0.0 --libc musl && prebuildify --arch=arm64 --target 18.0.0 --libc musl && prebuildify --arch=arm64 --target 17.1.0 --libc musl && prebuildify --arch=arm64 --target 16.13.0 && prebuildify --arch=arm64 --target 14.17.6 && prebuildify --arch=arm64 --target [email protected]",
"test": "./node_modules/.bin/mocha test/**.test.js --recursive",
"before-publish": "prebuildify-ci download && prebuildify -t 20.0.0 -t 18.0.0 -t 17.1.0 -t 16.13.0 -t 15.5.0 -t 14.17.6 -t 12.22.7 -t [email protected]",
"prebuild": "prebuildify -t 20.0.0 -t 18.0.0 -t 17.1.0 -t 16.13.0 -t 15.5.0 -t 14.17.6 -t 12.22.7 -t [email protected]",
"prebuild-linux-x64": "prebuildify-cross -i centos7-devtoolset7 -i alpine -t 20.0.0 -t 18.0.0 -t 17.1.0 -t 16.13.0 -t 15.5.0 -t 14.17.6 -t 12.22.7 -t [email protected]",
"prebuild-linux-arm64-glibc": "prebuildify-cross --tag-libc -i linux-arm64-lts -t 20.0.0 -t 18.0.0 -t 17.1.0 -t 16.13.0 -t 15.5.0 -t 14.17.6 -t 12.22.7 -t [email protected]",
"prebuild-linux-arm64-musl": "prebuildify-cross --libc musl --tag-libc -i linux-arm64-musl -t 20.0.0 -t 18.0.0 -t 17.1.0 -t 16.13.0 -t 15.5.0 -t 14.17.6 -t 12.22.7 -t [email protected]",
"test": "mocha test/**.test.js --recursive",
"benchmark": "node ./benchmark/index.js"
},
"gypfile": true,
Expand All @@ -53,6 +54,7 @@
"node-gyp": "^9.4.0",
"prebuildify": "^5.0.0",
"prebuildify-ci": "^1.0.5",
"prebuildify-cross": "^5.0.0",
"rimraf": "^3.0.2",
"jshint": "^2.12.0"
}
Expand Down

0 comments on commit 80651c4

Please sign in to comment.