Skip to content

βœ” Code Validation #32

βœ” Code Validation

βœ” Code Validation #32

on:
push:
paths:
- '.github/workflows/code_validation.yml' # Run when this workflow changes
- '**/Cargo.toml' # Run when dependencies change
- '**/Cargo.lock' # Run when dependencies change
- '**/src/**'
pull_request:
paths:
- '.github/workflows/code_validation.yml' # Run when this workflow changes
- '**/Cargo.toml' # Run when dependencies change
- '**/Cargo.lock' # Run when dependencies change
- '**/src/**'
branches: [main]
workflow_dispatch: # Run when manually triggered
workflow_call: # Run when called by another workflow
name: βœ” Validate Code Workflow
jobs:
code_validation_job:
name: ${{ matrix.job_name }}
if: |
!startsWith(github.event.head_commit.message, 'chore:')
&& !startsWith(github.event.head_commit.message, 'chore(')
strategy:
fail-fast: false
matrix:
platform:
- linux
- windows
- apple
cpu_architecture:
- x86_64
- aarch64
task:
- fmt
- clippy
- check
- test
exclude:
- platform: windows
cpu_architecture: aarch64
- platform: apple
cpu_architecture: aarch64
include:
- platform: linux
cicd_runner: ubuntu-latest
- platform: windows
cicd_runner: windows-latest
- platform: apple
cicd_runner: macos-latest
- command_base: cross
- compilation_target: x86_64-unknown-linux-gnu
cpu_architecture: x86_64
platform: linux
toolchain: gnu
command_base: cargo
- compilation_target: x86_64-pc-windows-msvc
cpu_architecture: x86_64
platform: windows
toolchain: msvc
command_base: cargo
- compilation_target: x86_64-apple-darwin
cpu_architecture: x86_64
platform: apple
toolchain: darwin
command_base: cargo
- compilation_target: aarch64-unknown-linux-gnu
cpu_architecture: aarch64
platform: linux
toolchain: gnu
- task: fmt
job_name: πŸ“‘ Cargo Fmt Job
rust_toolchain_components: cargo, rustfmt
- task: clippy
job_name: πŸ“Ž Cargo Clippy Job
rust_toolchain_components: cargo, clippy
- task: check
job_name: βœ… Cargo Check Job
rust_toolchain_components: cargo, rustc, rust-std
- task: test
job_name: πŸ§ͺ Cargo Test Job
rust_toolchain_components: cargo, rustc, rust-std
runs-on: ${{ matrix.cicd_runner }}
steps:
- name: 🎟 Checkout Git Repository Step
id: repository_checkout_step
uses: actions/checkout@v4
- name: 🧰 Install Rust Toolchain Step
id: toolchain_install_step
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
targets: ${{ matrix.compilation_target }}
components: ${{ matrix.rust_toolchain_components }}
- name: πŸ”„ Install Cross-Compilation Tools Step
id: cross_install_step
if: ${{ matrix.command_base == 'cross' }}
uses: taiki-e/install-action@v2
with:
tool: cross
- name: πŸ—‚ Setup Cache Step
id: cache_setup_step
uses: Swatinem/rust-cache@v2
- name: ↕️ Install Ubuntu Dependencies Step
id: ubuntu_dependencies_install_step
if: ${{ matrix.cicd_runner == 'ubuntu-latest' && matrix.command_base == 'cargo' }}
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: build-essential libssl-dev libgtk-4-dev
version: 1.0
- name: πŸ“‘ Fmt Step
id: fmt_step
if: ${{ matrix.task == 'fmt' }}
run: cargo fmt --verbose -- --check
- name: πŸ“Ž Clippy Step
id: clippy_step
if: ${{ matrix.task == 'clippy' }}
run: ${{ matrix.command_base }} clippy --workspace --target ${{ matrix.compilation_target }} -- -D warnings
- name: βœ… Check Step
id: check_step
if: ${{ matrix.task == 'check' }}
run: ${{ matrix.command_base }} check --workspace --target ${{ matrix.compilation_target }}
- name: πŸ§ͺ Test Step
id: cargo_test_step
if: ${{ matrix.task == 'test' }}
run: ${{ matrix.command_base }} test --workspace --target ${{ matrix.compilation_target }}