CI: add clippy check #63
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
pull_request: | |
push: | |
branches: [main, master] | |
env: | |
CARGO_INCREMENTAL: 1 | |
CARGO_NET_RETRY: 10 | |
RUSTUP_MAX_RETRIES: 10 | |
CARGO_TERM_COLOR: always | |
CARGO_TERM_PROGRESS_WHEN: never | |
# logging: | |
# RUST_LOG: trace | |
CARGO_PLAYDATE_LOG: trace | |
jobs: | |
api: | |
name: API | |
defaults: | |
run: | |
shell: bash | |
needs: format | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- macos-latest | |
- ubuntu-latest | |
# - windows-latest | |
sdk: | |
- latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache | |
uses: Swatinem/[email protected] | |
with: { shared-key: "tests" } | |
- name: Config | |
run: | | |
mkdir -p .cargo | |
cp -rf .github/config.toml .cargo/config.toml | |
- name: Install Playdate SDK ${{ matrix.sdk }} | |
id: sdk | |
uses: pd-rs/get-playdate-sdk@main | |
with: | |
version: ${{ matrix.sdk }} | |
- name: SDK ${{ steps.sdk.outputs.version }} installed | |
run: which pdc && pdc --version | |
- name: Test Crates | |
run: | | |
FEATURES_1=bindgen-runtime | |
FEATURES_2=bindgen-runtime,bindings-derive-debug,bindings-documentation,error-ctx | |
cargo test -p=playdate-sys --features=$FEATURES_1 -- --nocapture | |
cargo test -p=playdate-sys --features=$FEATURES_2 -- --nocapture | |
cargo test -p=playdate-fs --lib --no-default-features --features=$FEATURES_1 -- --nocapture | |
cargo test -p=playdate-fs --lib --no-default-features --features=$FEATURES_2 -- --nocapture | |
cargo test -p=playdate-sound --lib --no-default-features --features=$FEATURES_1 -- --nocapture | |
cargo test -p=playdate-sound --lib --no-default-features --features=$FEATURES_2 -- --nocapture | |
cargo test -p=playdate-color --lib --no-default-features --features=$FEATURES_1 -- --nocapture | |
cargo test -p=playdate-color --lib --no-default-features --features=$FEATURES_2 -- --nocapture | |
cargo test -p=playdate-controls --lib --no-default-features --features=$FEATURES_1 -- --nocapture | |
cargo test -p=playdate-controls --lib --no-default-features --features=$FEATURES_2 -- --nocapture | |
cargo test -p=playdate-menu --lib --no-default-features --features=$FEATURES_1 -- --nocapture | |
cargo test -p=playdate-menu --lib --no-default-features --features=$FEATURES_2 -- --nocapture | |
cargo test -p=playdate-graphics --lib --no-default-features --features=$FEATURES_1 -- --nocapture | |
cargo test -p=playdate-graphics --lib --no-default-features --features=$FEATURES_2 -- --nocapture | |
- name: Examples | |
run: | | |
FEATURES=bindgen-runtime,bindings-derive-debug | |
cargo build --target=thumbv7em-none-eabihf -p=playdate-fs --examples --features=$FEATURES -Zbuild-std | |
cargo build --target=thumbv7em-none-eabihf -p=playdate-controls --examples --features=$FEATURES -Zbuild-std | |
cargo build --target=thumbv7em-none-eabihf -p=playdate-color --examples --features=$FEATURES -Zbuild-std | |
cargo build --target=thumbv7em-none-eabihf -p=playdate-sound --examples --features=$FEATURES -Zbuild-std | |
cargo build --target=thumbv7em-none-eabihf -p=playdate-menu --examples --features=$FEATURES -Zbuild-std | |
cargo build --target=thumbv7em-none-eabihf -p=playdate-graphics --examples --features=$FEATURES -Zbuild-std | |
# Imitate docs.rs environment | |
- name: Test in no-sdk environment | |
env: | |
DOCS_RS: 1 | |
PLAYDATE_SDK_PATH: 0 | |
IGNORE_EXISTING_PLAYDATE_SDK: 1 | |
run: | | |
cargo doc -p=playdate-sys -v --target=thumbv7em-none-eabihf --features=bindings-documentation,bindings-derive-default,bindings-derive-eq,bindings-derive-copy,bindings-derive-debug,bindings-derive-hash,bindings-derive-ord,bindings-derive-partialeq,bindings-derive-partialord | |
tools: | |
name: Tools | |
defaults: | |
run: | |
shell: bash | |
needs: format | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- macos-latest | |
# - ubuntu-latest | |
# - windows-latest | |
sdk: | |
- latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache | |
uses: Swatinem/[email protected] | |
with: { shared-key: "tests" } | |
- name: Config | |
run: | | |
mkdir -p .cargo | |
cp -rf .github/config.toml .cargo/config.toml | |
- name: Install Playdate SDK ${{ matrix.sdk }} | |
id: sdk | |
uses: pd-rs/get-playdate-sdk@main | |
with: | |
version: ${{ matrix.sdk }} | |
- name: SDK ${{ steps.sdk.outputs.version }} installed | |
run: which pdc && pdc --version | |
- name: Check | |
run: cargo check --tests -p=cargo-playdate --all-features | |
- name: Test Utils | |
run: | | |
cargo test -p=playdate-build-utils --all-features | |
cargo test -p=playdate-build --all-features | |
cargo test -p=playdate-tool --all-features | |
- name: Test | |
run: | | |
cargo test -p=cargo-playdate -- --nocapture --test-threads=1 | |
rm -rf ./target/tmp | |
use-tool: | |
name: Examples | |
defaults: | |
run: | |
shell: bash | |
needs: format | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- macos-latest | |
# - ubuntu-latest | |
# - windows-latest | |
sdk: | |
- latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache | |
uses: Swatinem/[email protected] | |
with: | |
shared-key: "tests" | |
save-if: false | |
- name: Config | |
run: | | |
mkdir -p .cargo | |
cp -rf .github/config.toml .cargo/config.toml | |
- name: Install Playdate SDK ${{ matrix.sdk }} | |
id: sdk | |
uses: pd-rs/get-playdate-sdk@main | |
with: | |
version: ${{ matrix.sdk }} | |
- name: SDK ${{ steps.sdk.outputs.version }} installed | |
run: which pdc && pdc --version | |
- name: Install | |
run: cargo install --path=./cargo --debug | |
- name: Examples | |
run: | | |
FEATURES=bindgen-runtime,bindings-derive-debug | |
cargo playdate package --simulator --device -p=playdate-sys --examples --features=$FEATURES | |
cargo playdate package --simulator --device -p=playdate-fs --examples --features=$FEATURES | |
cargo playdate package --simulator --device -p=playdate-controls --examples --features=$FEATURES | |
cargo playdate package --simulator --device -p=playdate-color --examples --features=$FEATURES | |
cargo playdate package --simulator --device -p=playdate-sound --examples --features=$FEATURES | |
cargo playdate package --simulator --device -p=playdate-menu --examples --features=$FEATURES | |
cargo playdate package --simulator --device -p=playdate-graphics --examples --features=$FEATURES | |
# TODO: build crankstart with examples for compatibility test | |
# TODO: determine whats changed, so test that crate(s) only, maybe with deps. | |
# Probably use tj-actions/changed-files for it. | |
clippy: | |
name: Clippy | |
if: github.event_name == 'pull_request' | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
contents: read | |
pull-requests: write | |
security-events: write | |
actions: read | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
steps: | |
- uses: actions/checkout@v4 | |
# with: fetch-depth: 2 | |
- name: Cache | |
uses: Swatinem/[email protected] | |
with: | |
shared-key: "clippy" | |
- name: Install Clippy | |
run: rustup component add clippy | |
- name: Install Playdate SDK | |
id: sdk | |
uses: pd-rs/get-playdate-sdk@main | |
with: | |
version: latest | |
- name: SDK ${{ steps.sdk.outputs.version }} installed | |
run: which pdc && pdc --version | |
# this one for review-lints | |
- name: API | |
continue-on-error: true | |
uses: clechasseur/rs-clippy-check@v3 | |
with: | |
toolchain: nightly | |
args: >- | |
-p=playdate-sys | |
-p=playdate-fs | |
-p=playdate-controls | |
-p=playdate-color | |
-p=playdate-sound | |
-p=playdate-menu | |
-p=playdate-graphics | |
--no-deps | |
--no-default-features | |
--features=bindgen-runtime,bindings-derive-debug | |
--lib | |
-- | |
-Wclippy::correctness | |
-Wclippy::suspicious | |
-Wclippy::complexity | |
-Wclippy::nursery | |
-Wclippy::perf | |
-Wclippy::cargo | |
-Aclippy::style | |
-Aclippy::restriction | |
# this one for suggestions | |
- name: API (fix) | |
run: >- | |
cargo clippy | |
-p=playdate-sys | |
-p=playdate-fs | |
-p=playdate-controls | |
-p=playdate-color | |
-p=playdate-sound | |
-p=playdate-menu | |
-p=playdate-graphics | |
--no-default-features | |
--features=bindgen-runtime,bindings-derive-debug | |
--lib | |
--fix | |
-- | |
-Wclippy::correctness | |
-Wclippy::suspicious | |
-Wclippy::complexity | |
-Wclippy::nursery | |
-Wclippy::perf | |
-Wclippy::cargo | |
-Aclippy::style | |
-Aclippy::restriction | |
- name: Suggestions | |
uses: reviewdog/action-suggester@v1 | |
with: | |
filter_mode: diff_context | |
fail_on_error: false | |
tool_name: Clippy | |
cleanup: false | |
format: | |
name: Format | |
defaults: | |
run: | |
shell: bash | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: clechasseur/rs-fmt-check@v2 | |
with: | |
toolchain: nightly | |
- name: Check | |
if: ${{ github.event_name != 'pull_request' }} | |
run: cargo fmt -- --check |