From 46b7c416b4f6bcdd404ef0a2a499ad8211ef790b Mon Sep 17 00:00:00 2001 From: Alexander Koz Date: Mon, 11 Sep 2023 17:19:50 +0400 Subject: [PATCH] CI: improvements (#7) * add rustfmt suggestions for pr-review * other jobs requires format check * CI speed up and improvements, upd deps --- .github/workflows/tests.yml | 80 ++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d592b108..e297030b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,10 +16,11 @@ env: jobs: api: + name: API defaults: run: shell: bash - + needs: format runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -32,9 +33,10 @@ jobs: - latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2.6.2 + with: { shared-key: "tests" } - name: Config run: | @@ -97,10 +99,11 @@ jobs: 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 @@ -113,9 +116,10 @@ jobs: - latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2.6.2 + with: { shared-key: "tests" } - name: Config run: | @@ -145,6 +149,45 @@ jobs: 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/rust-cache@v2.6.2 + 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 @@ -152,17 +195,18 @@ jobs: run: | FEATURES=bindgen-runtime,bindings-derive-debug - cargo playdate package --simulator --device -p=playdate-sys --examples - cargo playdate package --simulator --device -p=playdate-fs --examples - cargo playdate package --simulator --device -p=playdate-controls --examples - cargo playdate package --simulator --device -p=playdate-color --examples - cargo playdate package --simulator --device -p=playdate-sound --examples - cargo playdate package --simulator --device -p=playdate-menu --examples - cargo playdate package --simulator --device -p=playdate-graphics --examples + 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 format: + name: Format defaults: run: shell: bash @@ -170,6 +214,14 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - 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