Skip to content

Migrate npm publishing to trusted publishing #48

Migrate npm publishing to trusted publishing

Migrate npm publishing to trusted publishing #48

Workflow file for this run

name: Rust CI
on:
pull_request:
push:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
check_and_test:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # pin@v4.0.0
with:
version: "8.15.0"
run_install: false
- name: Install Node.js
uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3.9.1
with:
node-version: "20"
cache: 'pnpm'
cache-dependency-path: 'example/pnpm-lock.yaml'
- name: Install dependencies
run: pnpm install --frozen-lockfile
shell: bash
working-directory: example
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
toolchain: stable
components: clippy, rustfmt
targets: wasm32-unknown-unknown
- name: Cache cargo dependencies
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Formatting
run: cargo fmt --all -- --check
continue-on-error: true
- name: Linting
run: cargo clippy --all-targets --all-features -- -D warnings
continue-on-error: true
- name: Run cargo check
run: cargo check --target="wasm32-unknown-unknown" --all-features
continue-on-error: true
- uses: jetli/wasm-pack-action@0d096b08b4e5a7de8c28de67e11e945404e9eefa # v0.4.0
with:
version: 'latest'
- name: Run wasm-pack tests
run: wasm-pack test --node -- --color always # Pass color flag to wasm-pack tests
continue-on-error: true
- name: Build for JS example tests
run: pnpm build
working-directory: example
- name: Run example tests
run: pnpm test
working-directory: example
- name: Run example benchmarks
run: pnpm vitest bench > benchmark-results.txt
working-directory: example
env:
NO_COLOR: 1
- name: Format benchmark results
run: |
echo '```' > temp.txt
cat example/benchmark-results.txt >> temp.txt
echo '```' >> temp.txt
mv temp.txt example/benchmark-results.txt
- uses: marocchino/sticky-pull-request-comment@fcf6fe9e4a0409cd9316a5011435be0f3327f1e1 # pin@v2.3.1
with:
path: 'example/benchmark-results.txt'