From 326f225a1eb46b3aeb09396a74f2b5b05200d319 Mon Sep 17 00:00:00 2001 From: Niklas Wojtkowiak Date: Sun, 5 Jan 2025 01:28:58 -0500 Subject: [PATCH] i most definetly got this first try and did not git reset ~8 --- .github/workflows/build.yml | 57 +++++++++++++++++++++ .github/workflows/rust.yml | 98 +++++++++++++------------------------ 2 files changed, 91 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..2da34870 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: Build Artifacts + +on: + push: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + name: Build project + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: macos-14 + target: aarch64-apple-darwin + executable: target/aarch64-apple-darwin/release/ferrumc + upload_path: target/aarch64-apple-darwin/release/ferrumc + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + executable: target/x86_64-unknown-linux-gnu/release/ferrumc + upload_path: target/x86_64-unknown-linux-gnu/release/ferrumc + - os: windows-latest + target: x86_64-pc-windows-msvc + executable: target/x86_64-pc-windows-msvc/release/ferrumc.exe + upload_path: target/x86_64-pc-windows-msvc/release/ferrumc.exe + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Install Rust nightly + uses: dtolnay/rust-toolchain@nightly + with: + targets: ${{ matrix.target }} + + - name: Build + run: cargo build --release --target ${{ matrix.target }} --verbose + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: build-artifacts-${{ matrix.os }} + path: ${{ matrix.upload_path }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 39ce75ea..6262757a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,91 +1,66 @@ -name: Rust - +name: Rust CI on: pull_request: branches: [ "master", "rewrite/v3" ] push: branches: [ "master", "rewrite/v3" ] workflow_dispatch: - env: CARGO_TERM_COLOR: always - +defaults: + run: + shell: bash jobs: format: - name: Check code formatting + name: Check Code Formatting runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- - name: Install Rust nightly uses: dtolnay/rust-toolchain@nightly - - - name: Install rustfmt - run: rustup component add rustfmt - + with: + components: rustfmt - name: Run cargo fmt run: cargo fmt --all -- --check - clippy: name: Run Clippy runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - - - name: Restore cargo cache + - name: Cache dependencies uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git + target key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo- - - name: Install Rust nightly uses: dtolnay/rust-toolchain@nightly - - - name: Install clippy - run: rustup component add clippy - + with: + components: clippy - name: Run Clippy - run: cargo clippy --all-targets -- -Dwarnings - + run: cargo clippy --all-targets -- -D warnings security: - name: Check for security vulnerabilities + name: Check Security Vulnerabilities runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - - - name: Install Rust nightly - uses: dtolnay/rust-toolchain@nightly - - - name: Install audit - run: cargo install cargo-audit - - - name: Run cargo audit - run: cargo install cargo-audit && cargo audit - - build: - name: Build project - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: macos-14 - target: aarch64-apple-darwin - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - - os: windows-latest - target: x86_64-pc-windows-msvc - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Cache dependencies uses: actions/cache@v3 with: @@ -96,17 +71,16 @@ jobs: key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo- - - name: Install Rust nightly uses: dtolnay/rust-toolchain@nightly - with: - targets: ${{ matrix.target }} - - - name: Build - run: cargo build --release --target ${{ matrix.target }} --verbose - + - name: Install and Run Cargo Audit + run: | + if ! command -v cargo-audit &> /dev/null; then + cargo install cargo-audit + fi + cargo audit test: - name: Run tests + name: Run Tests runs-on: ${{ matrix.os }} strategy: matrix: @@ -117,11 +91,9 @@ jobs: target: x86_64-unknown-linux-gnu - os: windows-latest target: x86_64-pc-windows-msvc - steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Cache dependencies uses: actions/cache@v3 with: @@ -129,14 +101,12 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-cargo- - + ${{ matrix.os }}-cargo- - name: Install Rust nightly uses: dtolnay/rust-toolchain@nightly with: targets: ${{ matrix.target }} - - - name: Run tests - run: cargo test --target ${{ matrix.target }} --verbose + - name: Run Tests + run: cargo test --target ${{ matrix.target }} --verbose \ No newline at end of file