Template
Compare commits
1
Commits
566a55a252
...
32d1e2cd29
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32d1e2cd29 |
@@ -0,0 +1,2 @@
|
|||||||
|
[registries.gitea]
|
||||||
|
index = "sparse+https://gitea.example.com/api/packages/crates/cargo/"
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
name: Crossplatform Linting && Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, master ]
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Linting
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Project
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
components: rustfmt, clippy
|
||||||
|
|
||||||
|
- name: Install cargo sort
|
||||||
|
uses: taiki-e/install-action@v2
|
||||||
|
with:
|
||||||
|
tool: cargo-sort
|
||||||
|
|
||||||
|
- name: Install cargo machete
|
||||||
|
uses: taiki-e/install-action@v2
|
||||||
|
with:
|
||||||
|
tool: cargo-machete
|
||||||
|
|
||||||
|
- name: Check formatting
|
||||||
|
run: cargo fmt --check
|
||||||
|
|
||||||
|
- name: Check import sorting
|
||||||
|
run: cargo sort --workspace --grouped --check --check-format
|
||||||
|
|
||||||
|
- name: Check for unused dependencies
|
||||||
|
run: cargo machete
|
||||||
|
|
||||||
|
- name: Clippy for Linux x86 (GNU ONLY)
|
||||||
|
run: |
|
||||||
|
cargo clippy --target x86_64-unknown-linux-gnu -- -D warnings
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: lint
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Project
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: x86_64-unknown-linux-musl
|
||||||
|
|
||||||
|
- name: Build for Linux x86 (GNU and MUSL)
|
||||||
|
run: |
|
||||||
|
cargo build --target x86_64-unknown-linux-gnu --release --locked
|
||||||
|
cargo build --target x86_64-unknown-linux-musl --release --locked
|
||||||
|
|
||||||
|
|
||||||
|
cross_build_linux:
|
||||||
|
name: Cross-Build-Linux
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [lint, build]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Project
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Crosscompile for aarch64 linux, windows, macos
|
||||||
|
uses: zijiren233/cargo-cross@v1
|
||||||
|
with:
|
||||||
|
targets: |
|
||||||
|
aarch64-unknown-linux-musl
|
||||||
|
aarch64-unknown-linux-gnu
|
||||||
|
|
||||||
|
cross_build_windows:
|
||||||
|
name: Cross-Build-Windows
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [lint, build]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Project
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Crosscompile for targets
|
||||||
|
uses: zijiren233/cargo-cross@v1
|
||||||
|
with:
|
||||||
|
targets: |
|
||||||
|
x86_64-pc-windows-gnu
|
||||||
|
|
||||||
|
cross_Build_osx:
|
||||||
|
name: Cross-Build-MacOS
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [lint, build]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Project
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
|
||||||
|
# CrossCheck for MacOS first, which checks for a valid rust project on MacOS
|
||||||
|
- name: Crosscheck for MacOS
|
||||||
|
uses: zijiren233/cargo-cross@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
targets: |
|
||||||
|
aarch64-apple-darwin
|
||||||
|
|
||||||
|
|
||||||
|
# MacOS is known for having a problematic linker step from linux, we should not fail the job if this fails, but this Workflow ALSO has the seperate cargo check
|
||||||
|
- name: Crosscompile for targets
|
||||||
|
continue-on-error: true
|
||||||
|
uses: zijiren233/cargo-cross@v1
|
||||||
|
with:
|
||||||
|
targets: |
|
||||||
|
aarch64-apple-darwin
|
||||||
|
|
||||||
|
test_linux:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build, lint]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Project
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: x86_64-unknown-linux-musl
|
||||||
|
|
||||||
|
- name: Test for Linux x86 (GNU and MUSL)
|
||||||
|
run: |
|
||||||
|
cargo test --target x86_64-unknown-linux-gnu --release --locked
|
||||||
|
cargo test --target x86_64-unknown-linux-musl --release --locked
|
||||||
|
|
||||||
|
|
||||||
Generated
+11
@@ -0,0 +1,11 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "example_bin"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "example_lib"
|
||||||
|
version = "0.1.0"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[workspace]
|
||||||
|
resolver = "3"
|
||||||
|
members = ["example_bin", "example_lib"]
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "example_bin"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "example_lib"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
pub fn add(left: u64, right: u64) -> u64 {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
let result = add(2, 2);
|
||||||
|
assert_eq!(result, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user