Skip to content

chore: linux musl build (cross-compile improvements) #10

chore: linux musl build (cross-compile improvements)

chore: linux musl build (cross-compile improvements) #10

Workflow file for this run

name: Lint the code
on:
push:
branches:
- main
paths:
- ".github/**/*"
- "**.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"
pull_request:
branches:
- main
paths:
- ".github/**/*"
- "**.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"
jobs:
linting:
name: Lint on ${{ matrix.os }} for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- armv7-unknown-linux-musleabihf
- arm-unknown-linux-musleabihf
- x86_64-pc-windows-msvc
- x86_64-apple-darwin
- aarch64-apple-darwin
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
- os: ubuntu-latest
target: arm-unknown-linux-musleabihf
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
targets: ${{ matrix.target }}
- name: Install cargo-sonar
uses: taiki-e/install-action@v2
with:
tool: cargo-sonar
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: lint-${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
lint-${{ runner.os }}-cargo-${{ matrix.target }}-
${{ runner.os }}-cargo-${{ matrix.target }}-
- name: Install cargo-sort
run: cargo install cargo-sort || exit 0
if: matrix.target != 'x86_64-pc-windows-msvc'
# ----- Actual linting logic ------
# These lines should mirror the `just lint` command.
- name: cargo fmt
run: cargo fmt --all -- --check
- name: cargo sort
run: cargo sort --workspace --check
# Don't run cargo-sort on windows, as the formatting behavior seems to be slightly different:
# https://github.com/DevinR528/cargo-sort/issues/56
if: matrix.target != 'x86_64-pc-windows-msvc'
- name: cargo clippy
run: |
cargo clippy --workspace -- -D warnings --message-format json > clippy-report.json
cargo sonar --clippy --clippy-path clippy-report.json
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: -Dsonar.externalIssuesReportPaths=sonar-issues.json
# -Dcommunity.rust.lcov.reportPaths=.coverage/lcov.info