diff --git a/.github/problem_matchers.json b/.github/problem_matchers.json new file mode 100644 index 0000000..4b59491 --- /dev/null +++ b/.github/problem_matchers.json @@ -0,0 +1,44 @@ +{ + "problemMatcher": [ + { + "owner": "cargo-common", + "pattern": [ + { + "regexp": "^(warning|warn|error)(\\[(\\S*)\\])?: (.*)$", + "severity": 1, + "message": 4, + "code": 3 + }, + { + "regexp": "^\\s+-->\\s(\\S+):(\\d+):(\\d+)$", + "file": 1, + "line": 2, + "column": 3 + } + ] + }, + { + "owner": "compiler-panic", + "pattern": [ + { + "regexp": "error: internal compiler error: (.*):(\\d+):(\\d+): (.*)$", + "message": 4, + "file": 1, + "line": 2, + "column": 3 + } + ] + }, + { + "owner": "cargo-fmt", + "pattern": [ + { + "regexp": "^(Diff in (\\S+)) at line (\\d+):", + "message": 1, + "file": 2, + "line": 3 + } + ] + } + ] +} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..908543b --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,61 @@ +name: Rust + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + formatting: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Rust + run: | + set -euo pipefail + rustup default beta + rustup component add rustfmt + - name: Add problem matchers + run: echo "::add-matcher::.github/problem_matchers.json" + - name: Check Rust formatting + run: cargo fmt --check + clippy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Rust + run: | + set -euo pipefail + rustup default beta + rustup component add clippy + - name: Add problem matchers + run: echo "::add-matcher::.github/problem_matchers.json" + - name: Run Clippy + run: cargo clippy -- -Dwarnings + checks: + strategy: + fail-fast: true + matrix: + rust-version: [ "stable", "beta", "nightly" ] + os: [ "ubuntu-latest", "windows-latest", "macos-latest" ] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Rust + run: | + set -euo pipefail + rustup default ${{ matrix.rust-version }} + - name: Add problem matchers + run: echo "::add-matcher::.github/problem_matchers.json" + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose +