Skip to content

Commit aef5d4c

Browse files
committed
ci: split jobs
1 parent 8e6fb27 commit aef5d4c

File tree

7 files changed

+94
-22
lines changed

7 files changed

+94
-22
lines changed

.githooks/pre-commit

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
# Run cargo clippy with the specified lint settings
4+
echo "Running cargo clippy..."
5+
cargo clippy --all-targets -- -D warnings -W clippy::pedantic -W clippy::nursery -W clippy::style -W clippy::complexity -W clippy::perf -W clippy::suspicious -W clippy::correctness
6+
7+
# Check if clippy succeeded
8+
if [ $? -ne 0 ]; then
9+
echo "Clippy found issues. Commit aborted."
10+
exit 1
11+
fi
12+
13+
echo "Clippy checks passed. Proceeding with commit."
14+
exit 0

.githooks/setup-hooks.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
# Set the hooks directory
4+
git config core.hooksPath .githooks
5+
6+
# Make the pre-commit hook executable
7+
chmod +x .githooks/pre-commit
8+
9+
echo "Git hooks configured successfully."

.github/workflows/format.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Rust Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
format:
14+
name: Format
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Rust toolchain
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
components: rustfmt, clippy
23+
24+
- name: Run clippy
25+
run: |
26+
cargo clippy \
27+
--all-targets \
28+
-- -D warnings \
29+
-W clippy::pedantic \
30+
-W clippy::nursery \
31+
-W clippy::style \
32+
-W clippy::complexity \
33+
-W clippy::perf \
34+
-W clippy::suspicious \
35+
-W clippy::correctness
36+
37+
- name: Check formatting
38+
run: cargo fmt --all -- --check

.github/workflows/test.yaml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,8 @@ jobs:
1818

1919
- name: Install Rust toolchain
2020
uses: dtolnay/rust-toolchain@stable
21-
with:
22-
components: rustfmt, clippy
2321

2422
- name: Cache dependencies
2523
uses: Swatinem/rust-cache@v2
26-
27-
- name: Run clippy
28-
run: |
29-
cargo clippy \
30-
--all-targets \
31-
-- -D warnings \
32-
-W clippy::pedantic \
33-
-W clippy::nursery \
34-
-W clippy::style \
35-
-W clippy::complexity \
36-
-W clippy::perf \
37-
-W clippy::suspicious \
38-
-W clippy::correctness
39-
4024
- name: Run tests
4125
run: cargo test --verbose
42-
43-
- name: Check formatting
44-
run: cargo fmt --all -- --check

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/target
22
**/*.rs.bk
33
.env
4-
.vscode/
54
logs/

.vscode/settings.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"rust-analyzer.check.command": "clippy",
3+
"rust-analyzer.check.extraArgs": [
4+
"--",
5+
"-D",
6+
"warnings",
7+
"-W",
8+
"clippy::pedantic",
9+
"-W",
10+
"clippy::nursery",
11+
"-W",
12+
"clippy::style",
13+
"-W",
14+
"clippy::complexity",
15+
"-W",
16+
"clippy::perf",
17+
"-W",
18+
"clippy::suspicious",
19+
"-W",
20+
"clippy::correctness"
21+
],
22+
"[toml]": {
23+
"editor.defaultFormatter": "tamasfe.even-better-toml",
24+
"editor.formatOnSave": true
25+
},
26+
"evenBetterToml.formatter.alignEntries": true,
27+
"evenBetterToml.formatter.arrayTrailingComma": true,
28+
"evenBetterToml.formatter.columnWidth": 100,
29+
"evenBetterToml.formatter.indentString": " ",
30+
"evenBetterToml.formatter.reorderKeys": true
31+
}

src/service/node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use libp2p::{
1111
tcp, yamux, PeerId, StreamProtocol, SwarmBuilder,
1212
};
1313
use libp2p_stream as stream;
14-
use once_cell::sync::Lazy;
1514
use serde::{Deserialize, Serialize};
1615
use std::{
1716
collections::{hash_map, HashMap},
1817
error::Error,
18+
sync::LazyLock,
1919
time::Duration,
2020
};
2121
use tokio::sync::Semaphore;
@@ -42,7 +42,7 @@ const JUNKANOO_FILE_PROTOCOL: StreamProtocol = StreamProtocol::new("/junkanoo/st
4242

4343
// Limit concurrent transfers to prevent resource exhaustion
4444
// This can be tuned based on system capabilities and requirements
45-
static TRANSFER_SEMAPHORE: Lazy<Semaphore> = Lazy::new(|| Semaphore::new(4));
45+
static TRANSFER_SEMAPHORE: LazyLock<Semaphore> = LazyLock::new(|| Semaphore::new(4));
4646

4747
/// Creates the network components, namely:
4848
///

0 commit comments

Comments
 (0)