Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CI #144

Merged
merged 29 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b4b88df
first pass
b-ma Dec 23, 2024
b3e8b42
Merge branch 'main' into chore/refactor-ci
b-ma Dec 23, 2024
ccd58da
notes
b-ma Dec 24, 2024
e485254
ci: extract checks from build workflow
b-ma Dec 24, 2024
6598c15
ci: test in branch
b-ma Dec 24, 2024
d5f8481
ci: fix node version
b-ma Dec 24, 2024
6d6afbe
ci: install deps + harmonize naming
b-ma Dec 24, 2024
6be1d77
ci: install deps + harmonize naming
b-ma Dec 24, 2024
012b31f
ci: check if we can run the tests on macos-latest
b-ma Dec 24, 2024
a62d6f0
ci: check if we can run the tests on macos-latest
b-ma Dec 24, 2024
8309c7e
ci: avoid checking jack feature on macos runner
b-ma Dec 24, 2024
8136cec
ci: do not try to access mic in ci tests
b-ma Dec 24, 2024
3d4c159
ci: matrix-build first pass
b-ma Dec 24, 2024
3ea6e8f
ci: allow test in branch
b-ma Dec 24, 2024
0f7d131
ci: allow test in branch
b-ma Dec 24, 2024
ff041a3
ci: install deps and fmt
b-ma Dec 24, 2024
5cc5359
ci: some fix
b-ma Dec 24, 2024
da57f8c
ci: some fix
b-ma Dec 24, 2024
4fc255b
ci: try to find windows build
b-ma Dec 24, 2024
05d3b68
ci: different build prefix accroding to platform
b-ma Dec 24, 2024
3028633
chore: add pre-build scripts
b-ma Dec 24, 2024
c0a6d02
chore: add Cross.toml
b-ma Dec 24, 2024
a1dda6d
ci: add linux-arm-gnueabihf target
b-ma Dec 24, 2024
fb59e94
ci: target armv7 instead of arm (v6)
b-ma Dec 24, 2024
068c149
ci: back to previous platform builds
b-ma Dec 24, 2024
9a5a9db
fix: always add target with rustup
b-ma Dec 24, 2024
61f7e9b
chore: review local build handling
b-ma Dec 26, 2024
64f90f5
cleaning
b-ma Dec 26, 2024
719961d
ci: clean testing conditions
b-ma Jan 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .cargo/config.toml

This file was deleted.

9 changes: 3 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.js]
indent_size = 2

[*.mjs]
indent_size = 2
[*.rs]
indent_size = 4

[*.md]
trim_trailing_whitespace = false
142 changes: 0 additions & 142 deletions .github/workflows/build.yml

This file was deleted.

140 changes: 140 additions & 0 deletions .github/workflows/matrix-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: matrix-build
env:
DEBUG: napi:*
PROJECT_NAME: node-web-audio-api
CARGO_BUILD_NAME: node_web_audio_api
MACOSX_DEPLOYMENT_TARGET: '10.13'
CARGO_TERM_COLOR: always

on:
push:
tags:
- '*'
workflow_dispatch:

jobs:
verify-build:
uses: ./.github/workflows/verify-build.yaml

matrix-build:
needs: verify-build
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: darwin-arm64
runner: macos-latest
target: aarch64-apple-darwin
command: cargo

- name: darwin-x64
runner: macos-latest
target: x86_64-apple-darwin
command: cargo

- name: win32-arm64-msvc
runner: windows-latest
target: aarch64-pc-windows-msvc
command: cargo

- name: win32-x64-msvc
runner: windows-latest
target: x86_64-pc-windows-msvc
command: cargo

- name: linux-arm64-gnu
runner: ubuntu-latest
target: aarch64-unknown-linux-gnu
command: cross

- name: linux-x64-gnu
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
command: cross

- name: linux-arm-gnueabihf
runner: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
command: cross

name: build - ${{ matrix.name }}
steps:
- name: Check out repository
uses: actions/checkout@v4

# node is only used to generate the files, can use host architecture
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

# only install cross (via cargo-binstall) if we need it
- name: Install Cross
if: matrix.command == 'cross'
shell: bash
run: |
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall --no-confirm cross

- name: Generate Cargo.lock
run: cargo generate-lockfile

- name: Install Deps
run: npm install

- name: Re-generate files from IDL
run: npm run generate

- name: Build Binary
shell: bash
run: |
rustup target add ${{ matrix.target }}

if [[ "${{ matrix.runner }}" == "ubuntu-latest" ]]; then
echo "Build with Jack feature"
${{ matrix.command }} build --locked --features jack --release --target ${{ matrix.target }}
else
${{ matrix.command }} build --locked --release --target ${{ matrix.target }}
fi

- name: Rename Binary
shell: bash
run: |
BIN_PREFIX=""
BIN_SUFFIX=""

if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then
BIN_PREFIX=""
BIN_SUFFIX=".dll"
elif [[ "${{ matrix.runner }}" == "macos-latest" ]]; then
BIN_PREFIX="lib"
BIN_SUFFIX=".dylib"
elif [[ "${{ matrix.runner }}" == "ubuntu-latest" ]]; then
BIN_PREFIX="lib"
BIN_SUFFIX=".so"
fi

ls -al target/${{ matrix.target }}/release/

# The built binary output location
BIN_OUTPUT="target/${{ matrix.target }}/release/${BIN_PREFIX}${CARGO_BUILD_NAME}${BIN_SUFFIX}"

# Define a better name for the final binary
BIN_RELEASE="${PROJECT_NAME}.${{ matrix.name }}.node"

# Move the built binary where you want it
mv "${BIN_OUTPUT}" "./${BIN_RELEASE}"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.name }}
path: ${{ env.PROJECT_NAME }}.${{ matrix.name }}.node
if-no-files-found: error

66 changes: 66 additions & 0 deletions .github/workflows/verify-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: verify-build
env:
MACOSX_DEPLOYMENT_TARGET: '10.13'
CARGO_TERM_COLOR: always

# read-only repo token, no access to secrets
permissions:
contents: read

# no access to secrets
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
workflow_call: # make the job callable by matrix-build

jobs:
verify-build:
# run on macos-latest which seems to have a soundcard available
runs-on: macos-latest

steps:
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22

- name: Check out repository
uses: actions/checkout@v4

- name: Generate Cargo.lock
run: cargo generate-lockfile

# restore cargo cache from previous runs
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
# The cache should not be shared between different workflows and jobs.
shared-key: ${{ github.workflow }}-${{ github.job }}

- name: Install Deps
run: npm install

# check it builds
- name: Build
run: npm run build

# run checks and tests
- name: Clippy
# run: cargo clippy --all-features -- -D warnings
run: cargo clippy --all-targets -- -D warnings
- name: Fmt
run: cargo fmt -- --check --color always
- name: Lint
run: npm run lint
- name: Test
run: npm run test:ci

Loading