Skip to content

ci

ci #1223

Workflow file for this run

name: ci
on:
pull_request: {}
push:
branches:
- master
schedule: [cron: "40 1 * * *"]
jobs:
commitsar:
name: Verify commit messages
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: aevea/commitsar@v0.20.1
pre-commit:
name: Generic pre-commit checks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-python@v4
with:
python-version: 3.9
- run: pip install pre-commit
- run: SKIP=fmt,cargo-check,clippy pre-commit run --all-files
test-stable:
name: Test (stable)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.11
cache: 'pip'
cache-dependency-path: '**/requirements-*.txt'
- name: Start background server
run: |
python -m pip install -r ./css-inline/tests/requirements-test.txt
# Starts the server in background
python ./css-inline/tests/server.py &
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: css-inline
- run: cargo test --no-fail-fast
working-directory: ./css-inline
fmt:
name: Rustfmt
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --all -- --check
working-directory: ./css-inline
- run: cargo fmt --all -- --check
working-directory: ./profiler
- run: cargo fmt --all -- --check
working-directory: ./bindings/c
- run: cargo fmt --all -- --check
working-directory: ./bindings/python
- run: cargo fmt --all -- --check
working-directory: ./bindings/ruby
- run: cargo fmt --all -- --check
working-directory: ./bindings/wasm
clippy:
name: Clippy
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
css-inline
bindings/python
bindings/ruby
bindings/wasm
bindings/c
- name: Rust
run: cargo clippy -- -D warnings
working-directory: ./css-inline
- name: Profiler
run: cargo clippy -- -D warnings
working-directory: ./profiler
- name: Python
run: cargo clippy -- -D warnings
working-directory: ./bindings/python
- name: Ruby
run: cargo clippy -- -D warnings
working-directory: ./bindings/ruby
- name: WASM
run: cargo clippy -- -D warnings
working-directory: ./bindings/wasm
- name: C
run: cargo clippy -- -D warnings
working-directory: ./bindings/c
msrv:
name: MSRV
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.63"
- uses: Swatinem/rust-cache@v2
with:
workspaces: css-inline
- run: cargo build
working-directory: ./css-inline
test-python:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: bindings/python
key: ${{ matrix.os }}-${{ matrix.python-version }}
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: 'pip'
cache-dependency-path: '**/requirements-*.txt'
- run: python -m pip install -r requirements/dev.txt
working-directory: ./bindings/python
- name: Run ${{ matrix.python }} tox job
run: tox -e py
working-directory: ./bindings/python
test-ruby:
strategy:
fail-fast: false
matrix:
os: [
ubuntu-22.04,
macos-12,
# Temporary disabled due to compiler errors on newer windows-2022 image
# windows-2022
]
ruby-version: ['2.7', '3.2']
name: Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Ruby & Rust
uses: oxidize-rb/actions/setup-ruby-and-rust@main
with:
ruby-version: ${{ matrix.ruby-version }}
rubygems: "latest"
bundler-cache: true
cargo-cache: true
cache-version: v1
working-directory: ./bindings/ruby
- run: bundle exec rake test
working-directory: ./bindings/ruby
test-wasm:
name: Tests for WASM crate
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: bindings/wasm
cache-all-crates: "true"
- name: Install wasm-pack
uses: actions-rs/cargo@v1
with:
command: install
args: wasm-pack
- name: Run tests
run: wasm-pack test --node --release
working-directory: ./bindings/wasm
test-wasm-typescript:
name: TypeScript tests for WASM crate
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
css-inline
bindings/wasm
cache-all-crates: "true"
- name: Install wasm-pack
uses: actions-rs/cargo@v1
with:
command: install
args: wasm-pack
- name: Build package
run: wasm-pack build -t nodejs
working-directory: ./bindings/wasm
- name: Install dependencies
run: npm install
working-directory: ./bindings/wasm
- name: Run tests
run: npm run test
working-directory: ./bindings/wasm
test-c:
name: Tests for C crate
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build
working-directory: ./bindings/c
- name: Run tests
run: |
gcc -c -I. tests/main.c
gcc main.o target/debug/libcss_inline.so -o out
./out
working-directory: ./bindings/c
features:
name: Check features
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: css-inline
cache-all-crates: "true"
- uses: taiki-e/install-action@cargo-hack
- run: cargo hack check --feature-powerset --lib
working-directory: ./css-inline
coverage:
name: Code coverage
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: css-inline
cache-all-crates: "true"
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@cargo-hack
- uses: actions/setup-python@v4
with:
python-version: 3.11
cache: 'pip'
cache-dependency-path: '**/requirements-*.txt'
- name: Start background server
run: |
python -m pip install -r ./css-inline/tests/requirements-test.txt
# Starts the server in background
python ./css-inline/tests/server.py &
- name: Run tests
run: cargo hack llvm-cov --no-report --feature-powerset
working-directory: ./css-inline
- name: Generate coverage reports
run: cargo llvm-cov report --lcov --output-path lcov.info
working-directory: ./css-inline
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: ${{ env.GITHUB_REPOSITORY }} == 'Stranger6667/css-inline'
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: coverage
files: lcov.info
fail_ci_if_error: true
fuzz:
name: Fuzz
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
with:
workspaces: css-inline
cache-all-crates: "true"
- run: cargo install cargo-fuzz
- run: cargo fuzz run inline -- -max_total_time=60
working-directory: ./css-inline