Skip to content

Commit 1be2828

Browse files
committed
feat(ci): integrate more tools for linting
1 parent 65c7f6b commit 1be2828

File tree

5 files changed

+121
-32
lines changed

5 files changed

+121
-32
lines changed

.github/workflows/ci.yml

+77-31
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,6 @@ on:
1111
- cron: "0 0 * * 0"
1212

1313
jobs:
14-
lint:
15-
name: Lint
16-
runs-on: ubuntu-latest
17-
18-
steps:
19-
- name: Checkout the repository
20-
uses: actions/checkout@v4
21-
22-
- name: Install dependencies
23-
run: |
24-
sudo apt-get update
25-
sudo apt-get install -y \
26-
--no-install-recommends \
27-
--allow-unauthenticated \
28-
libasound2-dev \
29-
libxi-dev \
30-
libxtst-dev \
31-
pkg-config
32-
33-
- name: Install Rust toolchain
34-
uses: dtolnay/rust-toolchain@stable
35-
36-
- name: Cache Cargo dependencies
37-
uses: Swatinem/rust-cache@v2
38-
39-
- name: Check formatting
40-
run: cargo fmt --all -- --check
41-
42-
- name: Check lints
43-
run: cargo clippy -- -D warnings
44-
4514
build:
4615
name: Build on ${{ matrix.build.OS }} (${{ matrix.build.TARGET }})
4716
runs-on: ${{ matrix.build.OS }}
@@ -98,3 +67,80 @@ jobs:
9867
with:
9968
name: daktilo-${{ matrix.build.TARGET }}-assets
10069
path: target/debug/daktilo*
70+
71+
lint:
72+
name: Lint
73+
runs-on: ubuntu-latest
74+
75+
steps:
76+
- name: Checkout the repository
77+
if: github.event_name != 'pull_request'
78+
uses: actions/checkout@v4
79+
80+
- name: Checkout the repository
81+
if: github.event_name == 'pull_request'
82+
uses: actions/checkout@v4
83+
with:
84+
ref: ${{ github.event.pull_request.head.sha }}
85+
86+
- name: Install dependencies
87+
run: |
88+
sudo apt-get update
89+
sudo apt-get install -y \
90+
--no-install-recommends \
91+
--allow-unauthenticated \
92+
libasound2-dev \
93+
libxi-dev \
94+
libxtst-dev \
95+
pkg-config
96+
97+
- name: Install Rust toolchain
98+
uses: dtolnay/rust-toolchain@stable
99+
with:
100+
components: rustfmt, clippy
101+
102+
- name: Cache Cargo dependencies
103+
uses: Swatinem/rust-cache@v2
104+
105+
- name: Check formatting
106+
run: cargo fmt --all -- --check
107+
108+
- name: Check lints
109+
run: cargo clippy -- -D warnings
110+
111+
- name: Run cargo-deny
112+
uses: EmbarkStudios/cargo-deny-action@v1
113+
with:
114+
command: check licenses sources
115+
116+
- name: Run cargo-audit
117+
uses: actions-rs/audit-check@v1
118+
with:
119+
token: ${{ secrets.GITHUB_TOKEN }}
120+
121+
- name: Run committed
122+
uses: crate-ci/committed@master
123+
with:
124+
args: "-vv"
125+
commits: "HEAD"
126+
127+
- name: Run lychee
128+
uses: lycheeverse/lychee-action@v1
129+
with:
130+
args: -v *.md
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
134+
- name: Check typos
135+
uses: crate-ci/typos@master
136+
137+
- name: Run cargo-msrv
138+
shell: bash
139+
run: |
140+
curl -s 'https://api.github.com/repos/foresterre/cargo-msrv/releases' | \
141+
jq -r "[.[] | select(.prerelease == false)][0].assets[] | \
142+
select(.name | ascii_downcase | test(\"linux.*x86_64|x86_64.*linux\")).browser_download_url" | \
143+
wget -qi -
144+
tar -xvf cargo-msrv*.tar* -C ~/.cargo/bin/ cargo-msrv
145+
printf "%s" "Checking MSRV..."
146+
cargo msrv --output-format json verify | tail -n 1 | jq --exit-status '.success'

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ homepage = "https://github.com/orhun/daktilo"
99
repository = "https://github.com/orhun/daktilo"
1010
keywords = ["typewriter", "keyboard", "nostalgic", "type"]
1111
categories = ["command-line-utilities", "multimedia"]
12-
edition = "2021"
1312
default-run = "daktilo"
13+
rust-version = "1.70.0"
14+
edition = "2021"
1415

1516
[[bin]]
1617
name = "daktilo-completions"

committed.toml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# configuration for https://github.com/crate-ci/committed
2+
3+
# https://www.conventionalcommits.org
4+
style = "conventional"
5+
# allow merge commits
6+
merge_commit = true
7+
# subject is not required to be capitalized
8+
subject_capitalized = false
9+
# subject should start with an imperative verb
10+
imperative_subject = true
11+
# subject should not end with a punctuation
12+
subject_not_punctuated = true
13+
# disable line length
14+
line_length = 0
15+
# disable subject length
16+
subject_length = 0

deny.toml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# configuration for https://github.com/EmbarkStudios/cargo-deny
2+
3+
[licenses]
4+
default = "deny"
5+
unlicensed = "deny"
6+
copyleft = "deny"
7+
confidence-threshold = 0.8
8+
allow = [
9+
"MIT",
10+
"Apache-2.0",
11+
"Unicode-DFS-2016",
12+
"MPL-2.0",
13+
"ISC",
14+
"BSD-3-Clause",
15+
]
16+
17+
[sources]
18+
unknown-registry = "deny"
19+
unknown-git = "warn"
20+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]

rustfmt.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# configuration for https://rust-lang.github.io/rustfmt/
2+
3+
edition = "2021"
4+
max_width = 100
5+
use_field_init_shorthand = true
6+
use_try_shorthand = true

0 commit comments

Comments
 (0)