Skip to content

Commit c697bc2

Browse files
authored
Merge pull request #9 from mkpro118/maintainence
Update CI linting and pre-commit hooks, rustfmt 2024, test tweaks
2 parents bbae8da + 1b0808b commit c697bc2

File tree

6 files changed

+144
-22
lines changed

6 files changed

+144
-22
lines changed

.github/.codecov.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
## Codecov configuration for a Rust project
2+
#
3+
# This file tells Codecov how to post status checks and comments on
4+
# pull requests. It lives in the root of the repository so that
5+
# Codecov can automatically pick it up. According to Codecov’s
6+
# documentation, repository‑level configuration must be stored in a
7+
# `codecov.yml` or `.codecov.yml` file at the root, `dev/`, or
8+
# `.github/` directory of the repository.
9+
10+
# Show a project‑wide coverage status on every pull request. By
11+
# default Codecov only posts coverage for the lines changed in the PR
12+
# (“patch” coverage). The `coverage.status.project` section below
13+
# enables an additional status check for the entire project. Setting
14+
# `target: auto` means the required coverage is based on the base
15+
# commit’s coverage; `threshold: 0%` means no drop in coverage is
16+
# tolerated; and `base: auto` makes Codecov choose the correct base
17+
# commit.
18+
coverage:
19+
status:
20+
project:
21+
default:
22+
# Use the base commit’s coverage as the target. This causes
23+
# Codecov to flag decreases in overall coverage on a pull
24+
# request. You can change this to a fixed number (e.g. 80%)
25+
# if your project has a minimum coverage requirement.
26+
target: auto
27+
# Allow no percentage drop from the target; increase this if
28+
# minor drops should still pass. Thresholds are specified as
29+
# percentages (e.g. 1% would allow the coverage to drop by
30+
# one percentage point).
31+
threshold: 0%
32+
# Use Codecov’s default base selection for comparisons. The
33+
# `base` key is deprecated but remains in examples to clarify
34+
# behavior.
35+
base: auto
36+
37+
# Configure the pull request comment so that Codecov includes project
38+
# coverage information. Without this, the comment only shows the
39+
# coverage of the changed lines. The options below follow the
40+
# example in Codecov’s common configuration recipes:
41+
comment:
42+
# The order in which information is shown in the PR comment. The
43+
# "diff" section shows changes to lines in the pull request, the
44+
# "flags" section lists flag‑specific coverage if you use flags, and
45+
# the "files" section lists files and their coverage. Including
46+
# "files" ensures that project‑wide coverage appears in the comment.
47+
layout: "diff, flags, files"
48+
# Use default behavior; this means Codecov will always post a
49+
# comment when coverage reports are uploaded.
50+
behavior: default
51+
# Post the comment even if coverage did not change. Set this to
52+
# true if you only want comments on coverage changes.
53+
require_changes: false
54+
# Allow comments when no base coverage report exists.
55+
require_base: false
56+
# Require a coverage report on the head commit before posting a
57+
# comment.
58+
require_head: true
59+
# Show project coverage in the comment. Setting this to true hides
60+
# project coverage and only shows the patch coverage; leaving it
61+
# false makes the project coverage visible.
62+
hide_project_coverage: false

.github/workflows/lint.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,19 @@ jobs:
4545
clippy:
4646
name: Clippy
4747
runs-on: ubuntu-latest
48+
permissions: write-all
4849
steps:
4950
- uses: actions/checkout@v5
50-
- uses: dtolnay/rust-toolchain@stable
51+
- uses: actions-rs/toolchain@v1
5152
with:
53+
toolchain: stable
5254
components: clippy
53-
- name: Cache
54-
uses: actions/cache@v3
55-
with:
56-
path: |
57-
~/.cargo/bin/
58-
~/.cargo/registry/index/
59-
~/.cargo/registry/cache/
60-
~/.cargo/git/db/
61-
target/
62-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
55+
override: true
6356
- uses: actions-rs/clippy-check@v1
6457
with:
6558
token: ${{ secrets.GITHUB_TOKEN }}
66-
args: --all-features --tests -- -F clippy::pedantic
59+
args: "--all-features --tests -- -F clippy::pedantic"
60+
name: Clippy Output
6761

6862
audit:
6963
name: Security Audit

.github/workflows/test.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
name: Test
2-
on: [push, pull_request]
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths:
7+
- "src/**/*"
8+
- "tests/**/*"
9+
- ".github/workflows/test.yml"
10+
push:
11+
paths:
12+
- ".github/workflows/test.yml"
313

414
env:
515
CARGO_TERM_COLOR: always
616

717
jobs:
818
test:
9-
name: Test ${{ matrix.rust }} on ${{ matrix.os }}
19+
name: Test ${{ matrix.rust }} on ${{ matrix.os }} ${{ matrix.feature }}
1020
runs-on: ${{ matrix.os }}
1121
strategy:
1222
matrix:
@@ -32,13 +42,14 @@ jobs:
3242
run: cargo test --workspace ${{ matrix.feature }}
3343

3444
coverage:
35-
name: Code coverage
45+
name: Code coverage (ubuntu + stable + default features)
3646
runs-on: ubuntu-latest
47+
needs: test
3748
steps:
3849
- name: Checkout code
3950
uses: actions/checkout@v5
4051

41-
- name: Install Rust toolchain
52+
- name: Install Rust toolchain (stable + llvm-tools)
4253
uses: dtolnay/rust-toolchain@stable
4354
with:
4455
components: llvm-tools-preview

.pre-commit-config.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: fmt
5+
name: fmt
6+
entry: cargo
7+
args:
8+
- --quiet
9+
- fmt
10+
- --
11+
- --color
12+
- never
13+
- --quiet
14+
- --files-with-diff
15+
language: system
16+
types: [file, rust]
17+
stages: [pre-commit]
18+
- id: check
19+
name: check
20+
entry: cargo
21+
args:
22+
- --quiet
23+
- check
24+
- --color
25+
- never
26+
- --tests
27+
language: system
28+
types: [file, rust]
29+
pass_filenames: false
30+
stages: [pre-commit]
31+
- id: clippy
32+
name: clippy
33+
entry: cargo
34+
args:
35+
- clippy
36+
- --all-features
37+
- --tests
38+
- --
39+
- -F
40+
- "clippy::pedantic"
41+
language: system
42+
types: [file, rust]
43+
pass_filenames: false
44+
stages: [pre-push]

.rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
max_width=80
2+
style_edition="2024"

src/core/parser/lexer.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,12 @@ impl TokenRecognizer for IdentifierRecognizer {
826826
start: pos.clone(),
827827
end: pos,
828828
};
829-
return Err(LexError::new(format!("Default parser does not support non-ASCII characters in identifiers (found \"{ch}\")"),span) );
829+
return Err(LexError::new(
830+
format!(
831+
"Default parser does not support non-ASCII characters in identifiers (found \"{ch}\")"
832+
),
833+
span,
834+
));
830835
}
831836
if ch.is_alphanumeric() || ch == '_' {
832837
identifier.push(ch);
@@ -908,6 +913,7 @@ impl Lexer {
908913

909914
#[cfg(test)]
910915
mod tests {
916+
#![expect(clippy::unwrap_used)]
911917
use super::*;
912918

913919
#[test]
@@ -1196,9 +1202,11 @@ mod tests {
11961202
fn test_unicode_characters() {
11971203
let mut lexer = Lexer::default_for_input("non_asciî");
11981204
assert!(lexer.next_token().is_err());
1199-
assert!(lexer
1200-
.next_token()
1201-
.is_err_and(|LexError { message, .. }| message.contains('î')));
1205+
assert!(
1206+
lexer
1207+
.next_token()
1208+
.is_err_and(|LexError { message, .. }| message.contains('î'))
1209+
);
12021210
}
12031211

12041212
#[test]
@@ -1405,8 +1413,10 @@ mod tests {
14051413
"relation" , "title" , "User" ,
14061414
];
14071415
for identifier in expected_identifiers {
1408-
assert!(token_types
1409-
.contains(&&TokenType::Identifier(identifier.to_owned())));
1416+
assert!(
1417+
token_types
1418+
.contains(&&TokenType::Identifier(identifier.to_owned()))
1419+
);
14101420
}
14111421
}
14121422

0 commit comments

Comments
 (0)