Skip to content

Commit a21fe91

Browse files
authored
Merge branch 'v2' into mszczepanski/feature-flags-cli
2 parents d3c332d + 56e5f40 commit a21fe91

File tree

6 files changed

+268
-17
lines changed

6 files changed

+268
-17
lines changed

.github/workflows/ci.yml

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
on: pull_request
2-
31
name: Continuous Integration
42

3+
on:
4+
pull_request:
5+
56
permissions:
67
contents: read
78

@@ -18,7 +19,6 @@ jobs:
1819
with:
1920
toolchain: stable
2021
components: rustfmt
21-
- uses: Swatinem/rust-cache@v2
2222
# use `--frozen-lockfile` to fail immediately if the committed yarn.lock needs updates
2323
# https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-frozen-lockfile
2424
- run: yarn --frozen-lockfile
@@ -45,31 +45,32 @@ jobs:
4545
PARCEL_BENCHMARK_APIKEY: ${{ secrets.PARCEL_BENCHMARK_APIKEY }}
4646

4747
unit_tests:
48-
name: Unit tests (${{matrix.os}}, Node ${{matrix.node}})
48+
name: Unit tests (${{ matrix.os }}, Node ${{ matrix.node }})
4949
strategy:
5050
matrix:
5151
node: [18, 20]
5252
os: [ubuntu-latest, macos-latest, windows-latest]
53-
runs-on: ${{matrix.os}}
53+
runs-on: ${{ matrix.os }}
5454
steps:
5555
- uses: actions/checkout@v4
5656
- uses: actions/setup-node@v4
5757
with:
5858
cache: yarn
59-
node-version: ${{matrix.node}}
59+
node-version: ${{ matrix.node }}
6060
- uses: dtolnay/rust-toolchain@master
6161
with:
6262
toolchain: stable
63-
components: rustfmt
6463
- uses: Swatinem/rust-cache@v2
64+
with:
65+
shared-key: ${{ matrix.os }}
6566
- name: Bump max inotify watches (Linux only)
67+
if: ${{ runner.os == 'Linux' }}
6668
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p;
67-
if: ${{matrix.os == 'ubuntu-latest'}}
6869
- run: yarn --frozen-lockfile
6970
- run: yarn build-native-release
7071
- run: yarn test:unit
71-
- name: Upload @parcel/rust Linux Binaries artifact
72-
if: ${{matrix.os == 'ubuntu-latest' && matrix.node == 20}}
72+
- name: Upload @parcel/rust artifacts on Linux with Node v20
73+
if: ${{ runner.os == 'Linux' && matrix.node == 20 }}
7374
uses: actions/upload-artifact@v3
7475
with:
7576
name: Rust Linux Binaries
@@ -79,29 +80,30 @@ jobs:
7980
packages/core/rust/*.node
8081
8182
integration_tests:
82-
name: Integration tests (${{matrix.os}}, Node ${{matrix.node}})
83+
name: Integration tests (${{ matrix.os }}, Node ${{ matrix.node }})
8384
strategy:
8485
matrix:
8586
node: [18, 20]
8687
os: [ubuntu-latest, macos-latest, windows-latest]
8788
# These tend to be quite flakey, so one failed instance shouldn't stop
8889
# others from potentially succeeding
8990
fail-fast: false
90-
runs-on: ${{matrix.os}}
91+
runs-on: ${{ matrix.os }}
9192
steps:
9293
- uses: actions/checkout@v4
9394
- uses: actions/setup-node@v4
9495
with:
9596
cache: yarn
96-
node-version: ${{matrix.node}}
97+
node-version: ${{ matrix.node }}
9798
- uses: dtolnay/rust-toolchain@master
9899
with:
99100
toolchain: stable
100-
components: rustfmt
101101
- uses: Swatinem/rust-cache@v2
102+
with:
103+
shared-key: ${{ matrix.os }}
102104
- name: Bump max inotify watches (Linux only)
103105
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p;
104-
if: ${{matrix.os == 'ubuntu-latest'}}
106+
if: ${{ runner.os == 'Linux' }}
105107
- run: yarn --frozen-lockfile
106108
- run: yarn build-native-release
107109
- run: yarn build

.github/workflows/dev-release.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This workflow builds and releases all packages with a dev dist tag. Once published,
2+
# the packages can be installed to streamline the testing and validation of changes, both
3+
# locally and within CI, that have not yet been approved or merged into the main branch.
4+
name: dev-release
5+
6+
on:
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-release:
11+
name: Build and release dev
12+
uses: ./.github/workflows/release.yml
13+
secrets: inherit
14+
with:
15+
release-command: yarn dev:release

.github/workflows/release.yml

+225
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
name: release
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
release-command:
7+
description: 'The command that will release packages as part of the final step'
8+
required: true
9+
type: string
10+
secrets:
11+
GHCR_TOKEN:
12+
required: true
13+
NPM_TOKEN:
14+
required: true
15+
16+
permissions:
17+
contents: read # for actions/checkout
18+
19+
jobs:
20+
build-macos-windows:
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- name: aarch64-apple-darwin
26+
os: macos-latest
27+
target: aarch64-apple-darwin
28+
29+
- name: macos-latest
30+
os: macos-latest
31+
32+
- name: windows-latest
33+
os: windows-latest
34+
name: ${{ matrix.name }}
35+
runs-on: ${{ matrix.os }}
36+
steps:
37+
- uses: actions/checkout@v4
38+
- name: Install Rust
39+
uses: dtolnay/rust-toolchain@master
40+
with:
41+
toolchain: stable
42+
target: ${{ matrix.target }}
43+
- uses: bahmutov/[email protected]
44+
- uses: Swatinem/rust-cache@v2
45+
with:
46+
shared-key: ${{ matrix.name }}
47+
- name: Remove CommandLineTools SDKs
48+
if: ${{ matrix.target == 'aarch64-apple-darwin' }}
49+
run: sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
50+
- name: Build native packages
51+
run: yarn build-native-release
52+
env:
53+
RUST_TARGET: ${{ matrix.target }}
54+
- name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
55+
if: ${{ runner.os == 'macOS' }}
56+
run: strip -x packages/*/*/*.node # Must use -x on macOS. This produces larger results on linux.
57+
- name: Upload artifacts
58+
uses: actions/upload-artifact@v3
59+
with:
60+
name: bindings-${{ matrix.name }}
61+
path: packages/*/*/*.node
62+
- name: Debug
63+
if: ${{ runner.os == 'macOS' }}
64+
run: ls -l packages/*/*/*.node
65+
- name: Smoke test
66+
if: ${{ !matrix.target }}
67+
run: node -e "require('@parcel/rust')"
68+
69+
build-linux-gnu-x64:
70+
name: linux-gnu-x64
71+
runs-on: ubuntu-20.04
72+
container:
73+
image: docker.io/mischnic/centos7-node16
74+
steps:
75+
- uses: actions/checkout@v3
76+
- name: Install yarn
77+
run: npm install --global yarn@1
78+
- name: Install Rust
79+
uses: actions-rs/toolchain@v1
80+
with:
81+
toolchain: stable
82+
profile: minimal
83+
override: true
84+
- uses: bahmutov/[email protected]
85+
- name: Build native packages
86+
run: yarn build-native-release
87+
- name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
88+
run: strip packages/*/*/*.node
89+
- name: Upload artifacts
90+
uses: actions/upload-artifact@v3
91+
with:
92+
name: bindings-linux-gnu-x64
93+
path: packages/*/*/*.node
94+
- name: debug
95+
run: ls -l packages/*/*/*.node
96+
- name: Smoke test
97+
run: node -e 'require("@parcel/rust")'
98+
99+
build-linux-gnu-arm:
100+
strategy:
101+
fail-fast: false
102+
matrix:
103+
include:
104+
- target: arm-unknown-linux-gnueabihf
105+
arch: armhf
106+
strip: arm-linux-gnueabihf-strip
107+
cflags: -mfpu=neon
108+
- target: aarch64-unknown-linux-gnu
109+
arch: arm64
110+
strip: aarch64-linux-gnu-strip
111+
cflags: ''
112+
name: ${{ matrix.target }}
113+
runs-on: ubuntu-20.04
114+
steps:
115+
- uses: actions/checkout@v4
116+
- name: Install Rust
117+
uses: dtolnay/rust-toolchain@master
118+
with:
119+
toolchain: stable
120+
target: ${{ matrix.target }}
121+
- name: Install cross compile toolchains
122+
run: |
123+
sudo apt-get update
124+
sudo apt-get install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y
125+
- uses: bahmutov/[email protected]
126+
- uses: Swatinem/rust-cache@v2
127+
with:
128+
shared-key: ${{ matrix.target }}
129+
- name: Build native packages
130+
run: yarn build-native-release
131+
env:
132+
RUST_TARGET: ${{ matrix.target }}
133+
CFLAGS: ${{ matrix.cflags }}
134+
- name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
135+
run: ${{ matrix.strip }} packages/*/*/*.node
136+
- name: Upload artifacts
137+
uses: actions/upload-artifact@v3
138+
with:
139+
name: bindings-${{ matrix.target }}
140+
path: packages/*/*/*.node
141+
- name: debug
142+
run: ls -l packages/*/*/*.node
143+
- name: Configure binfmt-support
144+
run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
145+
- name: Smoke test
146+
uses: addnab/docker-run-action@v1
147+
with:
148+
image: ghcr.io/devongovett/multiarch-node:node14-${{ matrix.arch }}-focal
149+
options: -v ${{github.workspace}}:/work
150+
run: cd /work && node -e "require('@parcel/rust')"
151+
152+
build-linux-musl:
153+
strategy:
154+
fail-fast: false
155+
matrix:
156+
include:
157+
- target: x86_64-unknown-linux-musl
158+
strip: strip
159+
cflags: -msse4.2
160+
arch: x86_64
161+
- target: aarch64-unknown-linux-musl
162+
strip: aarch64-linux-musl-strip
163+
cflags: ''
164+
arch: aarch64
165+
name: ${{ matrix.target }}
166+
runs-on: ubuntu-20.04
167+
container:
168+
image: ghcr.io/napi-rs/napi-rs/nodejs-rust@sha256:5a99e45446355d25c20e95d35231d84e9ce472280d8c0b1be53281bade905f09
169+
credentials:
170+
username: ${{ github.actor }}
171+
password: ${{ secrets.GHCR_TOKEN }}
172+
steps:
173+
- uses: actions/checkout@v4
174+
- name: Install build tools
175+
run: apk add --no-cache python3 make gcc g++ musl-dev curl
176+
- name: Install Rust
177+
uses: dtolnay/rust-toolchain@master
178+
with:
179+
toolchain: stable
180+
target: ${{ matrix.target }}
181+
- uses: bahmutov/[email protected]
182+
- name: Build native packages
183+
run: yarn build-native-release
184+
env:
185+
RUST_TARGET: ${{ matrix.target }}
186+
CFLAGS: ${{ matrix.cflags }}
187+
- name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
188+
run: ${{ matrix.strip }} packages/*/*/*.node
189+
- name: Upload artifacts
190+
uses: actions/upload-artifact@v3
191+
with:
192+
name: bindings-linux-musl-${{ matrix.arch }}
193+
path: packages/*/*/*.node
194+
- name: debug
195+
run: ls -l packages/*/*/*.node
196+
- name: Smoke test
197+
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
198+
run: node -e 'require("@parcel/rust")'
199+
200+
build-and-release:
201+
runs-on: ubuntu-20.04
202+
name: Build and release
203+
needs:
204+
- build-macos-windows
205+
- build-linux-musl
206+
- build-linux-gnu-arm
207+
steps:
208+
- uses: actions/checkout@v4
209+
with:
210+
fetch-depth: 0
211+
- uses: bahmutov/[email protected]
212+
- name: Build native packages
213+
run: yarn build-native-release
214+
- name: Download artifacts
215+
uses: actions/download-artifact@v3
216+
with:
217+
path: artifacts
218+
- name: Move artifacts
219+
run: for d in artifacts/*/*/*; do cp $d/*.node packages/$(basename $(dirname $d))/$(basename $d); done
220+
- name: Debug
221+
run: ls -l packages/*/*/*.node
222+
- run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
223+
env:
224+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
225+
- run: ${{ inputs.release-command }}

.github/workflows/stale.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
name: 'Close stale issues'
2+
23
on:
34
schedule:
45
- cron: '0 */12 * * *'
56
issue_comment:
67
types: [created]
78

89
permissions: {}
10+
911
jobs:
1012
stale:
1113
permissions:

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"test:integration": "yarn workspace @parcel/integration-tests test",
3131
"test:integration-ci": "yarn workspace @parcel/integration-tests test-ci",
3232
"test": "yarn test:unit && yarn test:integration",
33+
"dev:release": "lerna publish -y --canary --preid dev --dist-tag=dev --exact --force-publish=* --no-git-tag-version --no-push",
3334
"nightly:release": "lerna publish -y --canary --preid nightly --dist-tag=nightly --exact --force-publish=* --no-git-tag-version --no-push",
3435
"tag:prerelease": "lerna version --exact --force-publish=* --no-git-tag-version --no-push && yarn adjust-versions --exact",
3536
"tag:release": "lerna version --exact --force-publish=* --no-git-tag-version --no-push && yarn adjust-versions",

scripts/build-native.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ async function build() {
4343
}
4444
}
4545

46-
// This forces Clang/LLVM to be used as a C compiler instead of GCC.
47-
// This is necessary for cross-compilation for Apple Silicon in GitHub Actions.
46+
// This setup is necessary for cross-compilation for Apple Silicon in GitHub Actions.
4847
function setupMacBuild() {
48+
// This forces Clang/LLVM to be used as a C compiler instead of GCC.
4949
process.env.CC = execSync('xcrun -f clang', {encoding: 'utf8'}).trim();
5050
process.env.CXX = execSync('xcrun -f clang++', {encoding: 'utf8'}).trim();
5151

@@ -54,4 +54,10 @@ function setupMacBuild() {
5454
}).trim();
5555
process.env.CFLAGS = `-isysroot ${sysRoot} -isystem ${sysRoot}`;
5656
process.env.MACOSX_DEPLOYMENT_TARGET = '10.9';
57+
58+
if (process.env.RUST_TARGET === 'aarch64-apple-darwin') {
59+
// Prevents the "<jemalloc>: Unsupported system page size" error when
60+
// requiring parcel-node-bindings.darwin-arm64.node
61+
process.env.JEMALLOC_SYS_WITH_LG_PAGE = 14;
62+
}
5763
}

0 commit comments

Comments
 (0)