Skip to content

Commit

Permalink
feat(updater): add Node.js bindings (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
amr-crabnebula authored Nov 30, 2023
1 parent 4ff227e commit 7c8e3b7
Show file tree
Hide file tree
Showing 131 changed files with 3,215 additions and 3,162 deletions.
18 changes: 18 additions & 0 deletions .changes/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@
"prepublish": [],
"publish": [],
"postpublish": []
},
"cargo-packager-updater": {
"path": "./crates/updater",
"manager": "rust",
"assets": [
{
"path": "${ pkg.path }/target/package/cargo-packager-updater-${ pkgFile.version }.crate",
"name": "${ pkg.pkg }-${ pkgFile.version }.crate"
}
]
},
"@crabnebula/updater": {
"path": "./bindings/updater/nodejs",
"manager": "javascript",
"dependencies": ["cargo-packager-updater"],
"prepublish": [],
"publish": [],
"postpublish": []
}
}
}
47 changes: 47 additions & 0 deletions .github/workflows/check-nodejs-bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Check Node.js bindings

on:
push:
branches:
- main
paths:
- ".github/workflows/check-nodejs-bindings.yml"
- "crates/packager/**"
- "crates/updater/**"
- "bindings/*/nodejs/**"
pull_request:
branches:
- main
paths:
- ".github/workflows/check-nodejs-bindings.yml"
- "crates/packager/**"
- "crates/updater/**"
- "bindings/*/nodejs/**"

env:
RUST_BACKTRACE: 1
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ${{ matrix.platform }}

strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v4
- uses: Swatinem/rust-cache@v2
- run: pnpm install
- run: pnpm build
64 changes: 0 additions & 64 deletions .github/workflows/check-packager-binding.yml

This file was deleted.

20 changes: 15 additions & 5 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check Rust
name: Check

on:
push:
Expand All @@ -21,7 +21,18 @@ concurrency:
cancel-in-progress: true

jobs:
fmt:
prettier:
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: latest
- run: pnpm install
- run: pnpm format:check
rustfmt:
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
runs-on: ubuntu-latest

Expand All @@ -30,8 +41,7 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
- run: cargo fmt --all -- --check

clippy:
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
Expand All @@ -56,7 +66,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --workspace --all-targets --all-features -- -D warnings

test:
rust-test:
strategy:
fail-fast: false
matrix:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/covector-version-or-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,25 @@ jobs:
with:
event-type: publish-packager-nodejs
client-payload: '{"releaseId": "${{ steps.cliReleaseId.outputs.result }}" }'

- name: Get `@crabnebula/updater` release id
uses: actions/github-script@v7
id: updaterReleaseId
if: |
steps.covector.outputs.successfulPublish == 'true' &&
contains(steps.covector.outputs.packagesPublished, '@crabnebula/updater')
with:
result-encoding: string
script: |
const output = `${{ toJSON(steps.covector.outputs) }}`;
const [_, id] = /"-crabnebula-updater-releaseId": "([0-9]+)"/g.exec(output);
return id;
- name: Trigger `@crabnebula/updater` publishing workflow
if: |
steps.covector.outputs.successfulPublish == 'true' &&
contains(steps.covector.outputs.packagesPublished, '@crabnebula/updater')
uses: peter-evans/repository-dispatch@v2
with:
event-type: publish-updater-nodejs
client-payload: '{"releaseId": "${{ steps.updaterReleaseId.outputs.result }}" }'
44 changes: 42 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ on:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
run-integration-tests:
test-rust:
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
runs-on: ${{ matrix.platform }}

strategy:
Expand All @@ -19,11 +24,46 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: install webkit2gtk
- name: install fuse
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y fuse libfuse2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --test '*' -- --ignored --nocapture

test-nodejs:
runs-on: ${{ matrix.platform }}

strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v4
- uses: Swatinem/rust-cache@v2
- run: pnpm install
- run: pnpm build
- name: packager integration tests
run: |
cd bindings/packager/nodejs
pnpm test
timeout-minutes: 30
- name: install fuse
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y fuse libfuse2
- name: updater integration tests
if: matrix.platform != 'macos-latest'
run: |
cd bindings/updater/nodejs
pnpm test
timeout-minutes: 30
Loading

0 comments on commit 7c8e3b7

Please sign in to comment.