diff --git a/.github/matchers/rust.json b/.github/matchers/rust.json new file mode 100644 index 0000000..424c540 --- /dev/null +++ b/.github/matchers/rust.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": "cargo-test", + "pattern": [ + { + "regexp": "^.*panicked\\s+at\\s+'(.*)',\\s+(.*):(\\d+):(\\d+)$", + "message": 1, + "file": 2, + "line": 3, + "column": 4 + } + ] + }, + { + "owner": "cargo-fmt", + "pattern": [ + { + "regexp": "^(Diff in (\\S+)) at line (\\d+):", + "message": 1, + "file": 2, + "line": 3 + } + ] + } + ] +} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..c86b758 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,51 @@ +# Copied from Twilight's Lint workflow. +# +# https://github.com/twilight-rs/twilight/blob/trunk/.github/workflows/lint.yml +name: Lint + +on: [push, pull_request] + +jobs: + clippy: + name: Clippy + runs-on: ubuntu-latest + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install toolchain + uses: dtolnay/rust-toolchain@nightly + with: + components: clippy + + - name: Add problem matchers + run: echo "::add-matcher::.github/matchers/rust.json" + + - name: Cache + uses: Swatinem/rust-cache@v2 + + - name: Run clippy + run: cargo clippy --tests -- -D warnings + + rustfmt: + name: Format + runs-on: ubuntu-latest + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install toolchain + uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt + + - name: Add problem matchers + run: echo "::add-matcher::.github/matchers/rust.json" + + - name: Cache + uses: Swatinem/rust-cache@v2 + + - name: Run cargo fmt + run: cargo fmt --all -- --check