diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..c2c8f03 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,36 @@ +name: Build & Test + +on: + workflow_call: + inputs: + os: + required: true + type: string + additional-setup: + required: false + type: string + +jobs: + run: + runs-on: ${{ inputs.os }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Additional Setup (if specified) + if: ${{ inputs.additional-setup != '' }} + run: ${{ inputs.additional-setup }} + + - name: Run Tests + run: cargo test --release + + - name: Build + run: cargo build --release diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a01f0d2..7a43f4d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,24 +1,47 @@ name: Rust -on: - push: - branches: [ "master", "ci" ] - pull_request: - branches: [ "master" ] +on: [pull_request] env: CARGO_TERM_COLOR: always jobs: - build: - + fmt: + name: Rustfmt runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - run: cargo fmt --all -- --check + clippy: + name: Clippy + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Initialize Submodules - run: git submodule update --init --recursive - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - run: cargo clippy -- -D warnings + + linux-build-test: + name: Build and Test (Linux) + uses: ./.github/workflows/build-and-test.yml + with: + os: ubuntu-latest + + macos-build-test: + name: Build and Test (macOS) + uses: ./.github/workflows/build-and-test.yml + with: + os: macos-latest + + windows-build-test: + name: Build and Test (Windows) + uses: ./.github/workflows/build-and-test.yml + with: + os: windows-latest