Rust #2295
This file contains 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: Rust | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
schedule: | |
- cron: "28 13 * * *" | |
env: | |
CARGO_TERM_COLOR: always | |
BRANCH: ${{github.head_ref || github.ref_name}} | |
jobs: | |
test: | |
name: Test | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
runs-on: ${{matrix.os}} | |
env: | |
RUSTFLAGS: -A warnings | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout Repository | |
- name: Setup Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: clippy | |
cache: false | |
- name: Rust Cache | |
uses: swatinem/rust-cache@v2 | |
with: | |
key: ${{matrix.os}} | |
- name: Test | |
run: cargo test --all | |
build: | |
name: Build | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
runs-on: ${{matrix.os}} | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout Repository | |
- name: Setup Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Rust Cache | |
uses: swatinem/rust-cache@v2 | |
with: | |
key: ${{matrix.os}} | |
- name: Build Release | |
run: cargo build --release | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-release-${{matrix.os}} | |
path: ./target/release/${{matrix.os == 'windows-latest' && 'ddo-build-planner.exe' || 'ddo-build-planner'}} | |
format: | |
name: Format | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout Repository | |
- name: Setup Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt | |
- name: Rustfmt Check | |
uses: actions-rust-lang/rustfmt@v1 | |
clippy: | |
name: Clippy | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
security-events: write | |
actions: read | |
env: | |
RUSTFLAGS: -D warnings | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: clippy | |
- name: Install Clippy-Sarif | |
uses: baptiste0928/cargo-install@v3 | |
with: | |
crate: clippy-sarif | |
- name: Install Sarif-fmt | |
uses: baptiste0928/cargo-install@v3 | |
with: | |
crate: sarif-fmt | |
- name: Run rust-clippy | |
run: cargo clippy --all --no-deps --all-features --message-format=json | sort | uniq | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt | |
continue-on-error: true | |
- name: Upload analysis results to GitHub | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: rust-clippy-results.sarif | |
wait-for-processing: true | |
cargo-lock: | |
name: Cargo Lock | |
runs-on: ubuntu-latest | |
env: | |
RUSTFLAGS: -A warnings | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Build | |
run: cargo build --all | |
- name: Check if Cargo.lock changed | |
id: verify-changed-files | |
uses: tj-actions/verify-changed-files@v20 | |
with: | |
files: | | |
Cargo.lock | |
- name: Fail if Cargo.lock changed | |
if: steps.verify-changed-files.outputs.files_changed == 'true' | |
run: exit 1 | |
data-serde: | |
name: Data Serialization | |
runs-on: ubuntu-latest | |
env: | |
RUSTFLAGS: -A warnings | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Run Data Script | |
run: cargo run -p data | |
- name: Check if Data Changed | |
id: verify-changed-files | |
uses: tj-actions/verify-changed-files@v20 | |
with: | |
files: | | |
data/data/**/* | |
- name: Fail if Cargo.lock changed | |
if: steps.verify-changed-files.outputs.files_changed == 'true' | |
run: exit 1 | |
finish: | |
name: Finish Checks | |
needs: [clippy, test, build, format, cargo-lock, data-serde] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Finish Checks | |
run: echo "Checks Finished" |