diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b7a75ff --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: build + +on: + push: + branches: [main] + paths: ["maze-server/**", ".github/workflows/build.yml"] + pull_request: + paths: ["maze-server/**", ".github/workflows/build.yml"] + workflow_dispatch: + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + - os: macos-latest + target: aarch64-apple-darwin + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Cache cargo registry and build artifacts + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + maze-server/target + key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('maze-server/**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-${{ matrix.target }}-cargo- + + - name: Build (debug) + working-directory: maze-server + run: cargo build --locked --target ${{ matrix.target }} + + - name: Run tests + working-directory: maze-server + run: cargo test --locked --target ${{ matrix.target }} + + - name: Build (release) + working-directory: maze-server + run: cargo build --locked --release --target ${{ matrix.target }} + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: maze-server-${{ matrix.target }} + path: maze-server/target/${{ matrix.target }}/release/maze-server* + if-no-files-found: error