Update README to change link [docs.rs] to [docs.rs/~] #1624
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| paths-ignore: | |
| - '**.md' | |
| - 'LICENSE' | |
| pull_request: | |
| paths-ignore: | |
| - '**.md' | |
| - 'LICENSE' | |
| workflow_dispatch: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| ci_targets: "['x86_64-unknown-linux-gnu', 'x86_64-pc-windows-msvc', 'aarch64-apple-darwin', 'x86_64-apple-ios', 'x86_64-unknown-freebsd', 'x86_64-unknown-illumos', 'aarch64-linux-android']" | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| matrix: | |
| strategy: | |
| fail-fast: false | |
| runs-on: ubuntu-latest | |
| outputs: | |
| ci_targets: ${{ steps.generate.outputs.ci_targets }} | |
| steps: | |
| - name: Generate matrix | |
| id: generate | |
| run: echo "ci_targets=${{ env.ci_targets }}" >> $GITHUB_OUTPUT | |
| format: | |
| strategy: | |
| fail-fast: false | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Disable bench dependencies | |
| run: ./.github/workflows/disable-bench-deps.sh | |
| - uses: extractions/setup-just@v3 | |
| - name: Install Rust nightly | |
| run: | | |
| rustup toolchain install nightly | |
| rustup component add rustfmt --toolchain nightly | |
| - name: Restore cargo caches | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Check Rust formatting | |
| run: just fmt --verbose -- --check | |
| - name: Check justfile formatting | |
| run: just --unstable --fmt --check | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ['ubuntu-latest', 'windows-latest', 'macos-latest'] | |
| fn_features: ['', 'log native libsystemd multi-thread runtime-pattern serde serde_json sval'] | |
| cfg_feature: ['', 'flexible-string', 'source-location', 'std-stream-captured'] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set a non-UTC timezone # for detecting issues related to the local timezone | |
| uses: szenius/[email protected] | |
| with: | |
| timezoneLinux: "Asia/Shanghai" | |
| timezoneMacos: "Asia/Shanghai" | |
| timezoneWindows: "China Standard Time" | |
| - name: Disable bench dependencies | |
| run: ./.github/workflows/disable-bench-deps.sh | |
| - uses: extractions/setup-just@v3 | |
| - name: Install dependencies | |
| if: matrix.os == 'ubuntu-latest' | |
| run: sudo bash ./.github/workflows/install-deps.sh | |
| - name: Restore cargo caches | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run tests with selected features | |
| run: cargo test --features "${{ matrix.fn_features }} ${{ matrix.cfg_feature }}" --verbose | |
| - name: Run tests with all features | |
| if: matrix.fn_features == '' && matrix.cfg_feature == '' | |
| run: just test | |
| - name: Run examples | |
| if: matrix.fn_features != '' | |
| run: | | |
| for example in `ls spdlog/examples/*.rs | xargs basename --suffix=.rs`; do | |
| cargo run --features "${{ matrix.fn_features }} ${{ matrix.cfg_feature }}" --example ${example}; | |
| done | |
| clippy: | |
| needs: [matrix] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: ${{ fromJSON(needs.matrix.outputs.ci_targets) }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Disable bench dependencies | |
| if: matrix.target != fromJSON(needs.matrix.outputs.ci_targets)[0] | |
| run: ./.github/workflows/disable-bench-deps.sh | |
| - uses: extractions/setup-just@v3 | |
| - name: Install dependencies | |
| run: sudo bash ./.github/workflows/install-deps.sh | |
| - name: Install Rust nightly | |
| run: | | |
| rustup toolchain install nightly | |
| rustup component add clippy --toolchain nightly | |
| - name: Install Rust target | |
| run: | | |
| rustup target add ${{ matrix.target }} | |
| rustup target add ${{ matrix.target }} --toolchain nightly | |
| echo 'CARGO_BUILD_TARGET=${{ matrix.target }}' >> $GITHUB_ENV | |
| - name: Restore cargo caches | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run clippy | |
| run: just clippy -- -D warnings | |
| - name: Run clippy nightly | |
| run: | | |
| cargo +nightly clippy --all-features --tests --examples | |
| WARNS=$(cargo +nightly clippy --all-features --tests --examples --message-format=json | jq -s '[.[] | select(.reason == "compiler-message")] | length') | |
| if [[ $WARNS -ne 0 ]]; then | |
| echo "::warning title=nightly clippy::Detected $WARNS warnings" | |
| fi | |
| - name: Run clippy nightly for benches | |
| # Not all bench deps support all tier-2 targets | |
| if: matrix.target == fromJSON(needs.matrix.outputs.ci_targets)[0] | |
| run: | | |
| cargo +nightly clippy --all-features --benches -- -A clippy::incompatible_msrv | |
| WARNS=$(cargo +nightly clippy --all-features --benches --message-format=json -- -A clippy::incompatible_msrv | jq -s '[.[] | select(.reason == "compiler-message")] | length') | |
| if [[ $WARNS -ne 0 ]]; then | |
| echo "::warning title=nightly clippy::Detected $WARNS warnings" | |
| fi | |
| check: | |
| needs: [matrix] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: ${{ fromJSON(needs.matrix.outputs.ci_targets) }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Disable bench dependencies | |
| run: ./.github/workflows/disable-bench-deps.sh | |
| - uses: extractions/setup-just@v3 | |
| - name: Install dependencies | |
| run: sudo bash ./.github/workflows/install-deps.sh | |
| - name: Install Rust target | |
| run: | | |
| rustup target add ${{ matrix.target }} | |
| echo 'CARGO_BUILD_TARGET=${{ matrix.target }}' >> $GITHUB_ENV | |
| - name: Restore cargo caches | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run check | |
| run: just check --verbose | |
| check-doc: | |
| strategy: | |
| fail-fast: false | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Disable bench dependencies | |
| run: ./.github/workflows/disable-bench-deps.sh | |
| - uses: extractions/setup-just@v3 | |
| - name: Install dependencies | |
| run: sudo bash ./.github/workflows/install-deps.sh | |
| - name: Install Rust nightly | |
| run: rustup toolchain install nightly | |
| - name: Restore cargo caches | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run rustdoc nightly | |
| run: | | |
| RUSTDOCFLAGS='-D warnings -A rustdoc::broken-intra-doc-links' | |
| just _doc-default-features --verbose | |
| RUSTDOCFLAGS='-D warnings' | |
| just doc --verbose | |
| check-msrv: | |
| needs: [matrix] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: ${{ fromJSON(needs.matrix.outputs.ci_targets) }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Disable bench dependencies | |
| run: ./.github/workflows/disable-bench-deps.sh | |
| - name: Install dependencies | |
| run: sudo bash ./.github/workflows/install-deps.sh | |
| - name: Install Rust nightly | |
| run: rustup toolchain install nightly | |
| - name: Read rust-version from Cargo.toml | |
| run: | | |
| MSRV=$(yq '.workspace.package.rust-version' ./Cargo.toml) | |
| echo $MSRV | |
| echo "MSRV=$MSRV" >> $GITHUB_ENV | |
| - name: Install Rust ${{ env.MSRV }} | |
| run: rustup toolchain install ${{ env.MSRV }} | |
| - name: Install Rust target | |
| run: | | |
| rustup target add ${{ matrix.target }} --toolchain nightly | |
| rustup target add ${{ matrix.target }} --toolchain ${{ env.MSRV }} | |
| echo 'CARGO_BUILD_TARGET=${{ matrix.target }}' >> $GITHUB_ENV | |
| - name: Restore cargo caches | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Avoid dev-dependencies | |
| run: | | |
| # Some dev-dependencies require a newer version of Rust, but it doesn't matter for MSRV check | |
| # This is a workaround for the cargo nightly option `-Z avoid-dev-deps` | |
| perl -pi -e 's/\[dev-dependencies]/[workaround-avoid-dev-deps]/g' ./spdlog/Cargo.toml | |
| - name: Downgrade dependencies to minimal versions | |
| run: cargo +nightly update -Z minimal-versions | |
| - name: Check MSRV for core with Rust ${{ env.MSRV }} | |
| run: cargo +${{ env.MSRV }} check --locked --all-features --verbose | |
| test-native-linux: | |
| strategy: | |
| fail-fast: false | |
| runs-on: 'ubuntu-latest' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Disable bench dependencies | |
| run: ./.github/workflows/disable-bench-deps.sh | |
| - name: Install dependencies | |
| run: sudo bash ./.github/workflows/install-deps.sh | |
| - name: Restore cargo caches | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Build example | |
| run: bash ./spdlog/tests/native/linux.sh build | |
| - name: Run and test | |
| run: bash ./spdlog/tests/native/linux.sh run | |
| test-native-windows: | |
| strategy: | |
| fail-fast: false | |
| runs-on: 'windows-latest' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Disable bench dependencies | |
| run: ./.github/workflows/disable-bench-deps.sh | |
| - name: Install DebugView | |
| run: choco install dbgview | |
| - name: Restore cargo caches | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Build example | |
| run: bash ./spdlog/tests/native/windows.sh build | |
| - name: Run and test | |
| run: bash ./spdlog/tests/native/windows.sh run | |
| test-native-android: | |
| strategy: | |
| fail-fast: false | |
| runs-on: 'ubuntu-latest' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Disable bench dependencies | |
| run: ./.github/workflows/disable-bench-deps.sh | |
| - name: Restore cargo caches | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install cross | |
| run: cargo install cross --git https://github.com/cross-rs/cross --verbose | |
| - name: Build example | |
| run: bash ./spdlog/tests/native/android.sh build | |
| - name: Enable KVM | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: Run emulator and test | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: 29 | |
| arch: x86_64 | |
| script: bash ./spdlog/tests/native/android.sh run | |
| bench: | |
| needs: [test, check] | |
| strategy: | |
| fail-fast: false | |
| runs-on: 'ubuntu-latest' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Disable bench dependencies | |
| run: ./.github/workflows/disable-bench-deps.sh | |
| - uses: extractions/setup-just@v3 | |
| - name: Install Rust nightly | |
| run: rustup toolchain install nightly | |
| - name: Restore cargo caches | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run benchmark | |
| run: | | |
| just bench \ | |
| --bench spdlog-rs \ | |
| --bench spdlog-rs-pattern \ | |
| --bench spdlog-rs-log-crate-proxy \ | |
| | tee bench-results.txt | |
| - name: Discard irrelevant changes | |
| run: git checkout -- spdlog/Cargo.toml | |
| - name: Process results | |
| uses: benchmark-action/github-action-benchmark@v1 | |
| with: | |
| name: spdlog-rs on Linux | |
| tool: cargo | |
| output-file-path: bench-results.txt | |
| benchmark-data-dir-path: docs/dev/benchmarks | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| summary-always: true | |
| comment-on-alert: true | |
| alert-comment-cc-users: '@SpriteOvO' | |
| - name: Push results to GitHub Pages branch | |
| if: github.event_name != 'pull_request' && (github.ref_name == 'main' || github.ref_name == 'main-dev') | |
| run: git push 'https://${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git' gh-pages:gh-pages |