From c31c517edbc5e0af558ce82dc49b7e3d9c3de4a2 Mon Sep 17 00:00:00 2001 From: Mahor Foruzesh Date: Tue, 9 Jul 2024 07:54:24 +0000 Subject: [PATCH] build: run ci for all supported targets --- .github/workflows/ci.yaml | 79 +++++++++++++++++++++++----------- .github/workflows/release.yaml | 10 ++--- src/config.rs | 3 ++ src/utils.rs | 3 ++ 4 files changed, 64 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f0538b1..8333b8b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,28 +49,6 @@ jobs: id: cargo-fmt run: cargo fmt --all -- --check - - name: Check build - if: success() || failure() - id: cargo-check - run: cargo check --profile=ci --locked - - - name: Check lints - if: success() || failure() - id: cargo-clippy - run: cargo clippy --profile=ci --locked - - - name: Check tests - if: success() - id: cargo-test - run: cargo test --profile=ci --locked - - - name: Check documents - if: success() - id: cargo-doc - run: cargo doc --profile=ci --locked --no-deps - - # create check runs for pull requests - - name: Check file size if: (success() || failure()) && github.event_name == 'pull_request' id: lfs @@ -79,6 +57,8 @@ jobs: filesizelimit: 256000 sendComment: false + # create check runs for pull requests + - uses: LouisBrunner/checks-action@v2.0.0 if: (success() || failure()) && github.event_name == 'pull_request' with: @@ -107,30 +87,77 @@ jobs: name: Check formatting conclusion: ${{ steps.cargo-fmt.outcome }} + check-target: + name: Check target + timeout-minutes: 2 + strategy: + fail-fast: false + matrix: + include: + - { os: ubuntu-latest, target: aarch64-unknown-linux-gnu } + - { os: ubuntu-latest, target: aarch64-unknown-linux-musl } + - { os: ubuntu-latest, target: x86_64-unknown-linux-gnu } + - { os: ubuntu-latest, target: x86_64-unknown-linux-musl } + # - { os: windows-latest, target: aarch64-pc-windows-msvc } + # - { os: windows-latest, target: x86_64-pc-windows-msvc } + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: true + cache-on-failure: true + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Check build + if: success() || failure() + id: cargo-check + run: cargo check --profile=ci --locked --target ${{ matrix.target }} + + - name: Check lints + if: success() || failure() + id: cargo-clippy + run: cargo clippy --profile=ci --locked --target ${{ matrix.target }} + + - name: Check tests + if: success() + id: cargo-test + run: cargo test --profile=ci --locked --target ${{ matrix.target }} + + - name: Check documents + if: success() + id: cargo-doc + run: cargo doc --profile=ci --locked --target ${{ matrix.target }} --no-deps + + # create check runs for pull requests + - uses: LouisBrunner/checks-action@v2.0.0 if: (success() || failure()) && github.event_name == 'pull_request' with: token: ${{ secrets.GITHUB_TOKEN }} - name: Check build + name: Check build ${{ matrix.target }} conclusion: ${{ steps.cargo-check.outcome }} - uses: LouisBrunner/checks-action@v2.0.0 if: (success() || failure()) && github.event_name == 'pull_request' with: token: ${{ secrets.GITHUB_TOKEN }} - name: Check lints + name: Check lints ${{ matrix.target }} conclusion: ${{ steps.cargo-clippy.outcome }} - uses: LouisBrunner/checks-action@v2.0.0 if: (success() || failure()) && github.event_name == 'pull_request' with: token: ${{ secrets.GITHUB_TOKEN }} - name: Check tests + name: Check tests ${{ matrix.target }} conclusion: ${{ steps.cargo-test.outcome }} - uses: LouisBrunner/checks-action@v2.0.0 if: (success() || failure()) && github.event_name == 'pull_request' with: token: ${{ secrets.GITHUB_TOKEN }} - name: Check documents + name: Check documents ${{ matrix.target }} conclusion: ${{ steps.cargo-doc.outcome }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 62421a7..8333a7d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -13,8 +13,8 @@ env: # RUSTDOCFLAGS: -D warnings jobs: - pre-release: - name: Pre-release + release: + name: Release if: github.event_name == 'create' timeout-minutes: 5 permissions: @@ -60,9 +60,9 @@ jobs: changelog: CHANGELOG.md token: ${{ secrets.GITHUB_TOKEN }} - release: - name: Release - needs: pre-release + release-target: + name: Release target + needs: release timeout-minutes: 10 permissions: # required for taiki-e/upload-rust-binary-action diff --git a/src/config.rs b/src/config.rs index 592c7f1..dcc87f8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -42,6 +42,7 @@ use crate::{ use chrono::{DateTime, Local}; use clap::ColorChoice; use clap::Parser; +#[cfg(unix)] use const_format::formatcp; use serde::{de, Deserialize, Deserializer}; use std::{ @@ -58,7 +59,9 @@ pub const FADE_STEPS: u8 = 40; pub const DEFAULT_SLEEP_DURATION: u64 = 5000; pub const DEFAULT_SLEEP_DURATION_SHORT: u64 = 100; +#[cfg(unix_without_macos)] pub const RANDR_MINOR_VERSION_MIN: u32 = 3; +#[cfg(unix_without_macos)] pub const RANDR_MAJOR_VERSION: u32 = 1; /// Merge of cli arguments and config files from highest priority to lowest: diff --git a/src/utils.rs b/src/utils.rs index e0465cc..3b31ee5 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -76,6 +76,7 @@ impl InjectErr for Result { } /// Shortcut for inject_err().map_err(..) on Result types +#[cfg(unix_without_macos)] pub trait InjectMapErr { fn inject_map_err(self, f: O) -> Result where @@ -83,6 +84,8 @@ pub trait InjectMapErr { F1: CoprodInjector, O: FnOnce(F1) -> F2; } + +#[cfg(unix_without_macos)] impl InjectMapErr for Result { #[inline(always)] fn inject_map_err(self, f: O) -> Result