diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1735447..3db26cb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,65 +1,74 @@ name: CI on: - push: - branches: - - main - tags-ignore: - - '**' + workflow_dispatch: pull_request: + types: [opened, synchronize] + paths-ignore: + - '**/*.md' + - '!.github/workflows/ci.yml' + push: branches: - main + - "renovate/**" + paths-ignore: + - '**/*.md' + - '!.github/workflows/ci.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: ${{ github.ref_name != 'main' }} + +defaults: + run: + shell: bash jobs: test: - name: test - runs-on: ubuntu-latest + name: Test + strategy: + fail-fast: false + matrix: + include: + # - os: windows-latest + - os: ubuntu-latest + - os: macos-14 + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/cache@v3 + - uses: Boshen/setup-rust@main with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} + save-cache: ${{ github.ref_name == 'main' }} - uses: pnpm/action-setup@v2.2.4 with: version: latest run_install: true - - run: pnpm why caniuse-lite electron-to-chromium node-releases - run: cargo test lint: - name: lint + name: Clippy runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/cache@v3 + - uses: Boshen/setup-rust@main with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} - - run: cargo clippy --all-features - - run: cargo clippy --example inspect - - run: cargo clippy --tests + components: clippy + - run: cargo clippy --all-targets --all-features -- -D warnings wasm: - name: wasm + name: Wasm runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: taiki-e/checkout-action@v1 + - uses: Boshen/setup-rust@main with: - submodules: true - - run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - - run: wasm-pack build --dev --target=web -- --features wasm_bindgen + cache-key: wasm + save-cache: ${{ github.ref_name == 'main' }} + - name: Check + run: | + rustup target add wasm32-unknown-unknown + cargo check --target wasm32-unknown-unknown --features wasm_bindgen diff --git a/package.json b/package.json index 1cc571a..ba328c4 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,9 @@ "author": "Pig Fang ", "license": "MIT", "repository": "https://github.com/browserslist/browserslist-rs", + "scripts": { + "browserslist": "browserslist" + }, "devDependencies": { "browserslist": "4.23.0" }, diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..d2bc0cc --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.78.0" +profile = "default" diff --git a/src/test.rs b/src/test.rs index 5217e74..e2d218a 100644 --- a/src/test.rs +++ b/src/test.rs @@ -2,11 +2,11 @@ use crate::{resolve, Error, Opts}; use std::{path::Path, process::Command}; pub fn run_compare(query: &str, opts: &Opts, cwd: Option<&Path>) { - let mut command = Command::new( - Path::new("./node_modules/.bin/browserslist") - .canonicalize() - .unwrap(), - ); + #[cfg(target_os = "windows")] + let path = "./node_modules/.bin/browserslist.exe"; + #[cfg(not(target_os = "windows"))] + let path = "./node_modules/.bin/browserslist"; + let mut command = Command::new(Path::new(path).canonicalize().unwrap()); if opts.mobile_to_desktop { command.arg("--mobile-to-desktop"); }