Skip to content

Commit

Permalink
ci: add more fmt check for ci (#24)
Browse files Browse the repository at this point in the history
Co-authored-by: pk5ls20 <pk5ls20@outlook.com>
  • Loading branch information
ulic-youthlic and pk5ls20 authored Feb 20, 2025
1 parent 5615317 commit 4eb78e2
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[target.x86_64-pc-windows-msvc]
linker = "rust-lld"
linker = "rust-lld"
74 changes: 74 additions & 0 deletions .justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
default:
@just --list

info:
@echo JUST PATH: {{ just_executable() }}
@echo GIT PATH: {{ require('git') }}
@echo CARGO PATH: {{ require('cargo') }}
@echo GREP PATH: {{ require('grep') }}
@echo XARGS PATH: {{ require('xargs') }}
@echo TYPOS PATH: {{ require('typos') }}
@echo DENO PATH: {{ require('deno') }}
@echo TAPLO PATH: {{ require('taplo') }}
@echo SHFMT PATH: {{ require('shfmt') }}

check: info typoCheck fmtCheck clippyCheck buildCheck docCheck testCheck

typoCheck:
typos -c ./typos.toml

fmtCheck: rustFmtCheck justFmtCheck mdFmtCheck tomlFmtCheck ymlFmtCheck shFmtCheck

fmt: rustFmt justFmt mdFmt tomlFmt ymlFmt shFmt

buildCheck:
cargo build --locked

clippyCheck:
cargo clippy --locked --all-targets -- --deny warnings

docCheck:
cargo doc --no-deps --locked

testCheck:
cargo test --locked

rustFmtCheck:
cargo fmt --check

rustFmt:
cargo fmt

justFmtCheck:
just --unstable --fmt --check

justFmt:
just --unstable --fmt

mdFmtCheck:
git ls-files | grep -E '^.*\.(md|MD)$' | xargs deno fmt --check --ext md

mdFmt:
git ls-files | grep -E '^.*\.(md|MD)$' | xargs deno fmt --ext md

ymlFmtCheck:
git ls-files | grep -E '^.*\.yml$' | xargs deno fmt --check --ext yml

ymlFmt:
git ls-files | grep -E '^.*\.yml$' | xargs deno fmt --ext yml

tomlFmtCheck:
git ls-files | grep -E '^.*\.toml$' | xargs taplo format --check

tomlFmt:
git ls-files | grep -E '^.*\.toml$' | xargs taplo format

shFmt:
git ls-files | grep -E '^scripts/.*$' | xargs shfmt -p -s -i 2 -ci -sr -kp -fn -w

shFmtCheck:
git ls-files | grep -E '^scripts/.*$' | xargs shfmt -p -s -i 2 -ci -sr -kp -fn -d

alias c := check
alias i := info
alias f := fmt
1 change: 1 addition & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

19 changes: 11 additions & 8 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
</div>

> [!NOTE]\
> This project is originally frozen in [radicle](https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z4QZVPDxLbGgd1oHFsjtJLQYtZ8ma)

> [!WARNING]
> This project is still in active development. The internal and external interfaces are still unstable
> This project is originally frozen in
> [radicle](https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z4QZVPDxLbGgd1oHFsjtJLQYtZ8ma)
> [!WARNING]\
> This project is still in active development. The internal and external
> interfaces are still unstable
## Disclaimer

[See Lagrange.Core](https://github.com/LagrangeDev/Lagrange.Core#disclaimer)

## Features List

| Protocol | Support | Login | Support | Messages | Support | Operations | Support | Events | Support |
|----------|:-------:|--------------------------------|:-------:|:--------------|:-------:|:------------------|:-------:|:--------------------|:-------:|
| -------- | :-----: | ------------------------------ | :-----: | :------------ | :-----: | :---------------- | :-----: | :------------------ | :-----: |
| Windows | 🔴 | QrCode | 🟢 | BounceFace | 🔴 | Poke | 🔴 | ~~Captcha~~ | 🔴 |
| macOS | 🔴 | ~~Password~~ | 🔴 | Face | 🟡 [^1] | Recall | 🔴 | BotOnline | 🟢 |
| Linux | 🟢 | EasyLogin | 🟡 | File | 🟡[^1] | Leave Group | 🔴 | BotOffline | 🟢 |
Expand All @@ -47,6 +48,8 @@
[^1]: Only implemented event parsing

## References
- All projects in [LagrangeDev](https://github.com/lagrangeDev) (and their twin projects)

- All projects in [LagrangeDev](https://github.com/lagrangeDev) (and their twin
projects)
- [lz1998/ricq](https://github.com/lz1998/ricq)
- [inmes-dev/qqbot.rs](https://github.com/inmes-dev/qqbot.rs)
- [inmes-dev/qqbot.rs](https://github.com/inmes-dev/qqbot.rs)
64 changes: 59 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,65 @@
};
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
checkTypo =
typoCheck =
pkgs.runCommandNoCCLocal "check-typo"
{
src = ./.;
nativeBuildInputs = with pkgs; [ typos ];
nativeBuildInputs = with pkgs; [
typos
];
}
''
mkdir -p $out
cd $src && typos -c $src/typos.toml
cd $src
typos --config ./typos.toml
'';
fmtCheck =
let
restFmtCheck =
pkgs.runCommandNoCCLocal "check-fmt"
{
src = ./.;
nativeBuildInputs = with pkgs; [
taplo
nixfmt-rfc-style
deno
just
shfmt
];
}
''
mkdir -p $out
cd $src
# just
echo '==> just format check'
just --unstable --fmt --check
# markdown
echo '==> markdown format check'
find . -type f -regextype egrep -regex '^.*\.(md|MD)$' -exec deno fmt --check --ext md {} +
# toml
echo '==> toml format check'
find . -type f -regextype egrep -regex '^.*\.toml$' -exec taplo format --check {} +
# yaml
echo '==> yaml format check'
find . -type f -regextype egrep -regex '^.*\.yml$' -exec deno fmt --check --ext yml {} +
# nix
echo '==> nix format check'
find . -type f -regextype egrep -regex '^.*\.nix$' -exec nixfmt --check {} +
# sh
echo '==> sh format check'
cd ./scripts && find . -type f -executable -exec shfmt -p -s -d -i 2 -ci -sr -kp -fn '{}' +
'';
in
pkgs.symlinkJoin {
name = "fmtCheck";
paths = [
restFmtCheck
(craneLib.cargoFmt commonArgs)
];
};
in
{
packages = {
Expand All @@ -134,7 +182,7 @@
};
checks = {
inherit (self.packages."${system}") mania;
typo = checkTypo;
typo = typoCheck;
audit = craneLib.cargoAudit (
commonArgs
// {
Expand All @@ -148,7 +196,7 @@
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
);
fmt = craneLib.cargoFmt commonArgs;
fmt = fmtCheck;
doc = craneLib.cargoDoc (
commonArgs
// {
Expand All @@ -169,6 +217,12 @@
cargo-flamegraph
cargo-tarpaulin
lldb

taplo
nixfmt-rfc-style
deno
just
shfmt
];
shellHook = '''';
};
Expand Down
4 changes: 3 additions & 1 deletion mania/src/core/protos/README.MD
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
## Protos
The vast majority of the proto files originate from [LagrangeDev/LagrangeProto](https://github.com/LagrangeDev/LagrangeProto).

The vast majority of the proto files originate from
[LagrangeDev/LagrangeProto](https://github.com/LagrangeDev/LagrangeProto).
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly"
channel = "nightly"
22 changes: 1 addition & 21 deletions scripts/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,4 @@
set -o errexit
set -o nounset

BLUE="\033[0;34m"
RED="\033[0;31m"
NC="\033[0m"
log() {
printf "%b==>%b %s\n" "$1" "$2" "$3"
}
raise_error() {
log "$RED" "$NC" "$1" 1>&2
exit 1
}
info() {
log "$BLUE" "$NC" "$1"
}

info "Running typos..."
typos -c typos.toml || raise_error "Typos check failed!"

info "Checking code formatting..."
cargo fmt --check || raise_error "Code formatting issues found. Please run 'cargo fmt' to format your code."

info "Pre-commit checks passed!"
just info typoCheck fmtCheck
34 changes: 1 addition & 33 deletions scripts/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,4 @@
set -o errexit
set -o nounset

BLUE="\033[0;34m"
RED="\033[0;31m"
NC="\033[0m"
log() {
printf "%b==>%b %s\n" "$1" "$2" "$3"
}
raise_error() {
log "$RED" "$NC" "$1" 1>&2
exit 1
}
info() {
log "$BLUE" "$NC" "$1"
}

info "Running typos..."
typos -c typos.toml || raise_error "Typos check failed!"

info "Checking code formatting..."
cargo fmt --check || raise_error "Code formatting issues found. Please run 'cargo fmt' to format your code."

info "Building project..."
cargo build --locked || raise_error "Build failed!"

info "Running cargo clippy..."
cargo clippy --locked --all-targets -- --deny warnings || raise_error "Clippy check failed!"

info "Building documentation..."
cargo doc --no-deps --locked || raise_error "Documentation build failed!"

info "Running tests..."
cargo test --locked || raise_error "Tests failed!"

info "Pre-push checks passed!"
just check

0 comments on commit 4eb78e2

Please sign in to comment.