Skip to content

Commit

Permalink
add lint workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ivinjabraham committed Jan 9, 2025
1 parent 9dd4ccb commit 40e77ee
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/matchers/rust.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
51 changes: 51 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 40e77ee

Please sign in to comment.