Skip to content

Commit

Permalink
ci: add multiple platform build (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit authored Sep 19, 2023
1 parent df86f71 commit de74953
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ runs:
toolchain: ${{ inputs.toolchain }}
targets: ${{ inputs.targets }}
components: ${{ inputs.components }}
- name: Add Targets
if: ${{ inputs.targets }}
run: rustup target add ${{ inputs.targets }}
shell: bash
- uses: Swatinem/rust-cache@v2
55 changes: 45 additions & 10 deletions .github/workflows/y-octo-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,50 @@ on:
env:
DEBUG: napi:*
COVERAGE: true
MACOSX_DEPLOYMENT_TARGET: "10.13"

jobs:
build-node:
name: Build Node Binding
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
settings:
- target: x86_64-apple-darwin
host: macos-latest
# - target: aarch64-apple-darwin
# host: macos-latest
- target: x86_64-pc-windows-msvc
host: windows-latest
# - target: aarch64-pc-windows-msvc
# host: windows-latest
- target: x86_64-unknown-linux-gnu
host: ubuntu-latest
# - target: aarch64-unknown-linux-gnu
# host: ubuntu-latest
# - target: x86_64-unknown-linux-musl
# host: ubuntu-latest
# - target: aarch64-unknown-linux-musl
# host: ubuntu-latest
runs-on: ${{ matrix.settings.host }}
env:
RUSTFLAGS: "-C debuginfo=1"
environment: development

steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: ./.github/actions/setup-node
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
target: "x86_64-unknown-linux-gnu"
targets: ${{ matrix.settings.target }}
- name: Build node binding
run: yarn build:node
run: yarn build:node --target ${{ matrix.settings.target }}
- name: Upload y-octo.node
uses: actions/upload-artifact@v3
with:
name: y-octo.node
path: ./y-octo-node/y-octo.linux-x64-gnu.node
name: y-octo.${{ matrix.settings.target }}.node
path: ./y-octo-node/*.node
if-no-files-found: error

test-node:
Expand Down Expand Up @@ -65,25 +85,40 @@ jobs:

node-binding-test:
name: Node Binding Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
settings:
- target: x86_64-apple-darwin
host: macos-latest
- target: x86_64-unknown-linux-gnu
host: ubuntu-latest
- target: x86_64-pc-windows-msvc
host: windows-latest
runs-on: ${{ matrix.settings.host }}
needs: build-node
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: ./.github/actions/setup-node
- name: Download y-octo.node
- name: Download y-octo.${{ matrix.settings.target }}.node
uses: actions/download-artifact@v3
with:
name: y-octo.node
name: y-octo.${{ matrix.settings.target }}.node
path: ./y-octo-node
- name: Run node binding tests
run: ls -lah & ls -lah tests
working-directory: y-octo-node
shell: bash
- name: Run node binding tests
run: yarn test:node:coverage
working-directory: y-octo-node
shell: bash
- name: Upload server test coverage results
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./y-octo-node/.coverage/lcov.info
flags: node-binding-test
name: y-octo
name: y-octo.${{ matrix.settings.target }}.node
fail_ci_if_error: false
2 changes: 1 addition & 1 deletion y-octo-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ crate-type = ["cdylib"]
anyhow = "1"
napi = { version = "2", features = ["anyhow", "napi4"] }
napi-derive = "2"
y-octo = { path = "../y-octo", features = ["large_refs"] }
y-octo = { workspace = true, features = ["large_refs"] }

[build-dependencies]
napi-build = "2"
4 changes: 3 additions & 1 deletion y-octo-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"triples": {
"additional": [
"aarch64-apple-darwin",
"aarch64-pc-windows-msvc",
"aarch64-unknown-linux-gnu",
"aarch64-pc-windows-msvc"
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl"
]
},
"ts": {
Expand Down
16 changes: 10 additions & 6 deletions y-octo-node/scripts/run-test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ const env = {
};

if (process.argv[2] === "all") {
const cp = spawn("node", [...sharedArgs, resolve(testDir, "*")], {
cwd: root,
env,
stdio: "inherit",
shell: true,
});
const cp = spawn(
"node",
[...sharedArgs, ...files.map((f) => resolve(testDir, f))],
{
cwd: root,
env,
stdio: "inherit",
shell: true,
},
);
cp.on("exit", (code) => {
process.exit(code ?? 0);
});
Expand Down

0 comments on commit de74953

Please sign in to comment.