Skip to content

Commit 5a5b67e

Browse files
committed
chore(github): add a fuller smoke test to CI checks
1 parent db8b6f6 commit 5a5b67e

3 files changed

Lines changed: 92 additions & 17 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ on:
1111
- v14-alpha
1212

1313
jobs:
14-
lint-and-test:
15-
name: Lint and test
14+
build-for-npm:
15+
name: Build packages
1616
runs-on: ubuntu-22.04
1717
steps:
1818
- name: Checkout
@@ -26,10 +26,18 @@ jobs:
2626
components: rustfmt, clippy
2727
- name: Set up cargo cache
2828
uses: Swatinem/rust-cache@v2
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: "20"
33+
- name: Install npm dependencies
34+
run: npm install
2935
- name: Install just
3036
uses: extractions/setup-just@v1
3137
with:
3238
just-version: 1.35.0
39+
- name: Install jq
40+
run: sudo apt-get update && sudo apt-get install -y jq
3341
- name: Check cargo
3442
run: just check-cargo
3543
- name: Lint formatting
@@ -38,3 +46,34 @@ jobs:
3846
run: just check-clippy
3947
- name: Cargo test
4048
run: just test
49+
- name: Build npm packages
50+
run: just build-for-platform linux-x64-glibc
51+
- name: Upload npm packages
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: npm-packages
55+
path: npm/
56+
57+
smoke-test:
58+
name: Smoke Test Node.js ${{ matrix.node-version }})
59+
runs-on: ubuntu-22.04
60+
needs: build-for-npm
61+
strategy:
62+
matrix:
63+
node-version: [16, 18, 20, 22]
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v4
67+
- name: Setup Node.js ${{ matrix.node-version }}
68+
uses: actions/setup-node@v4
69+
with:
70+
node-version: ${{ matrix.node-version }}
71+
- name: Download npm packages
72+
uses: actions/download-artifact@v4
73+
with:
74+
name: npm-packages
75+
path: npm/
76+
- name: Smoke test
77+
run: |
78+
cd fixtures/fluid-framework
79+
../../npm/packages/syncpack/index.cjs --dependencies jest

.github/workflows/matrix.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,31 @@
22
{
33
"NAME": "linux-x64-glibc",
44
"OS": "ubuntu-22.04",
5-
"RUN_LOCALLY": true,
65
"TARGET": "x86_64-unknown-linux-gnu"
76
},
87
{
98
"NAME": "linux-arm64-glibc",
109
"OS": "ubuntu-22.04",
11-
"RUN_LOCALLY": false,
1210
"TARGET": "aarch64-unknown-linux-gnu"
1311
},
1412
{
1513
"NAME": "win32-x64-msvc",
1614
"OS": "windows-2022",
17-
"RUN_LOCALLY": false,
1815
"TARGET": "x86_64-pc-windows-msvc"
1916
},
2017
{
2118
"NAME": "win32-arm64-msvc",
2219
"OS": "windows-2022",
23-
"RUN_LOCALLY": false,
2420
"TARGET": "aarch64-pc-windows-msvc"
2521
},
2622
{
2723
"NAME": "darwin-x64",
2824
"OS": "macos-13",
29-
"RUN_LOCALLY": false,
3025
"TARGET": "x86_64-apple-darwin"
3126
},
3227
{
3328
"NAME": "darwin-arm64",
3429
"OS": "macos-13",
35-
"RUN_LOCALLY": false,
3630
"TARGET": "aarch64-apple-darwin"
3731
}
3832
]

justfile

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ no_pattern := ""
77
default:
88
just --list
99

10+
# List all available platforms from matrix.json
11+
list-platforms:
12+
#!/usr/bin/env bash
13+
set -euxo pipefail
14+
15+
echo "Available platforms:"
16+
cat .github/workflows/matrix.json | jq -r '.[] | "\(.NAME) (target: \(.TARGET), os: \(.OS))"'
17+
1018
# ==============================================================================
1119
# Onboarding
1220
# ==============================================================================
@@ -162,36 +170,70 @@ watch-fluid:
162170
# Build
163171
# ==============================================================================
164172

165-
# Build the npm package and rust binary package for mac
166-
build-local:
173+
174+
175+
# Build the npm package and rust binary package for a specific platform
176+
build-for-platform name:
167177
#!/usr/bin/env bash
168178
set -euxo pipefail
169179

180+
# Read platform details from matrix.json
181+
PLATFORM_JSON=$(cat .github/workflows/matrix.json | jq -r --arg name "{{name}}" '.[] | select(.NAME == $name)')
182+
183+
if [ -z "$PLATFORM_JSON" ]; then
184+
echo "Platform '{{name}}' not found in matrix.json"
185+
exit 1
186+
fi
187+
188+
TARGET=$(echo "$PLATFORM_JSON" | jq -r '.TARGET')
189+
OS=$(echo "$PLATFORM_JSON" | jq -r '.OS')
190+
191+
echo "Building for platform: {{name}}"
192+
echo "Target: $TARGET"
193+
echo "OS: $OS"
194+
170195
rm -rf npm/packages
171-
cargo build --release --locked --target x86_64-apple-darwin
172-
just --dotenv-filename .env.darwin-x64 create-npm-binary-package
173-
just --dotenv-filename .env.darwin-x64 create-npm-root-package
174-
just patch-local
196+
cargo build --release --locked --target "$TARGET"
197+
198+
# Set environment variables for npm package creation
199+
export TARGET="$TARGET"
200+
export NODE_PKG_NAME="syncpack-{{name}}"
201+
export NODE_PKG_DIR_PATH="npm/packages/syncpack-{{name}}"
202+
export RUST_BINARY_PATH="target/$TARGET/release/syncpack$(if [[ "$TARGET" == *"windows"* ]]; then echo ".exe"; fi)"
203+
export NODE_PKG_RUST_BINARY_PATH="$NODE_PKG_DIR_PATH/bin/syncpack$(if [[ "$TARGET" == *"windows"* ]]; then echo ".exe"; fi)"
204+
export NODE_OS=$(echo "{{name}}" | cut -d'-' -f1)
205+
export NODE_ARCH=$(echo "{{name}}" | cut -d'-' -f2)
206+
export NODE_ROOT_PKG_DIR_PATH="npm/packages/syncpack"
207+
208+
just create-npm-binary-package
209+
just create-npm-root-package
210+
just patch-for-platform {{name}}
175211
cd npm/packages/syncpack
176212
npm install
177213

178-
# Modify the local package.json file to only have a mac optionalDependency
179-
patch-local:
214+
# Modify the local package.json file to only have the specified platform's optionalDependency
215+
patch-for-platform name:
180216
#!/usr/bin/env node
181217
const fs = require("fs");
182218
const path = require("path");
183219
const srcPath = path.resolve("npm/packages/syncpack/package.json");
184220
const pkg = require(srcPath);
221+
const platformName = "{{name}}";
222+
const optionalDepName = `syncpack-${platformName}`;
185223
const nextPkg = {
186224
...pkg,
187225
optionalDependencies: {
188-
"syncpack-darwin-x64": "file:../syncpack-darwin-x64"
226+
[optionalDepName]: `file:../${optionalDepName}`
189227
}
190228
};
191229
const json = JSON.stringify(nextPkg, null, 2);
192230
console.log(json);
193231
fs.writeFileSync(srcPath, json);
194232

233+
# Modify the local package.json file to only have a mac optionalDependency (legacy command)
234+
patch-local:
235+
just patch-for-platform darwin-x64
236+
195237
# Build a rust binary and corresponding npm package for a specific target
196238
build-binary-package:
197239
just create-rust-binary

0 commit comments

Comments
 (0)