Skip to content

Commit

Permalink
ci: refactor (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen authored May 28, 2024
1 parent 791e0cf commit 4eae58f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 40 deletions.
79 changes: 44 additions & 35 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"author": "Pig Fang <[email protected]>",
"license": "MIT",
"repository": "https://github.com/browserslist/browserslist-rs",
"scripts": {
"browserslist": "browserslist"
},
"devDependencies": {
"browserslist": "4.23.0"
},
Expand Down
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.78.0"
profile = "default"
10 changes: 5 additions & 5 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit 4eae58f

Please sign in to comment.