Skip to content

Commit 017a633

Browse files
authored
Merge pull request #6 from willcl-ark/lint-in-ci
2 parents fcb01ea + 7213602 commit 017a633

File tree

6 files changed

+376
-20
lines changed

6 files changed

+376
-20
lines changed

.github/workflows/ci.yml

+17
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,24 @@ on:
77
tags-ignore:
88
- '**'
99
jobs:
10+
lint:
11+
runs-on: [self-hosted, linux, x64]
12+
timeout-minutes: 5
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- uses: cachix/install-nix-action@v27
19+
with:
20+
nix_path: nixpkgs=channel:nixos-unstable
21+
- name: Build & test release
22+
env:
23+
NIX_PATH: nixpkgs=channel:nixos-unstable
24+
run: |
25+
nix-shell --command "just lint"
1026
build-and-test:
27+
needs: lint
1128
runs-on: [self-hosted, linux, x64]
1229
timeout-minutes: 20
1330
steps:

justfile

+8
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ test-unit1 suite:
6262
bench:
6363
build/src/bench/bench_bitcoin
6464

65+
# Run the lint job
66+
lint:
67+
#!/usr/bin/env bash
68+
cd test/lint/test_runner/
69+
cargo fmt
70+
cargo clippy
71+
COMMIT_RANGE="$( git rev-list --max-count=1 --merges HEAD )..HEAD" cargo run
72+
6573
# Run the CI workflow
6674
[group('ci')]
6775
run-ci: build-ci bench test

pyproject.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[project]
2+
name = "bitcoin-core-deps"
3+
version = "0.1.0"
4+
dependencies = [
5+
"codespell==2.2.6",
6+
"lief==0.13.2",
7+
"mypy==1.4.1",
8+
"pyzmq==25.1.0",
9+
# Removing in favour of packaged nixpkgs bin which is not dynamically linked
10+
# "ruff==0.5.5",
11+
"vulture==2.6",
12+
"pyperf"
13+
]

requirements.txt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile pyproject.toml -o requirements.txt
3+
codespell==2.2.6
4+
# via bitcoin-core-deps (pyproject.toml)
5+
lief==0.13.2
6+
# via bitcoin-core-deps (pyproject.toml)
7+
mypy==1.4.1
8+
# via bitcoin-core-deps (pyproject.toml)
9+
mypy-extensions==1.0.0
10+
# via mypy
11+
psutil==6.1.0
12+
# via pyperf
13+
pyperf==2.8.0
14+
# via bitcoin-core-deps (pyproject.toml)
15+
pyzmq==25.1.0
16+
# via bitcoin-core-deps (pyproject.toml)
17+
ruff==0.5.5
18+
# via bitcoin-core-deps (pyproject.toml)
19+
toml==0.10.2
20+
# via vulture
21+
tomli==2.0.2
22+
# via mypy
23+
typing-extensions==4.12.2
24+
# via mypy
25+
vulture==2.6
26+
# via bitcoin-core-deps (pyproject.toml)

shell.nix

+34-20
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@
99
}:
1010
let
1111
inherit (pkgs.lib) optionals strings;
12+
13+
# Add mlc binary fetching
14+
mlcBinary = pkgs.fetchurl {
15+
url = "https://github.com/becheran/mlc/releases/download/v0.18.0/mlc-x86_64-linux";
16+
sha256 = "sha256-jbdp+UlFybBE+o567L398hbcWHsG8aQGqYYf5h9JRkw=";
17+
};
18+
19+
# Create a derivation for mlc
20+
mlc = pkgs.runCommand "mlc" {} ''
21+
mkdir -p $out/bin
22+
cp ${mlcBinary} $out/bin/mlc
23+
chmod +x $out/bin/mlc
24+
'';
25+
1226
binDirs =
1327
[ "\$PWD/src" ]
1428
++ optionals withGui [ "\$PWD/src/qt" ];
@@ -46,30 +60,12 @@ in pkgs.mkShell {
4660
# https://github.com/bitcoin/bitcoin/blob/master/doc/productivity.md#cache-compilations-with-ccache
4761
ccache
4862

49-
# generating compile_commands.json for clang-format, clang-tidy, LSPs etc
50-
# https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#running-clang-tidy
51-
# $ a && c && m clean && bear --config src/.bear-tidy-config -- make -j6
52-
clang-tools_18
53-
bear
54-
5563
# for newer cmake building
5664
cmake
5765

5866
# depends
5967
byacc
6068

61-
# functional tests & linting
62-
python3
63-
python3Packages.flake8
64-
python3Packages.lief
65-
python3Packages.autopep8
66-
python3Packages.mypy
67-
python3Packages.requests
68-
python3Packages.pyzmq
69-
70-
# benchmarking
71-
python3Packages.pyperf
72-
7369
# debugging
7470
gdb
7571

@@ -94,9 +90,18 @@ in pkgs.mkShell {
9490
buildInputs = with pkgs; [
9591
just
9692
bash
97-
];
98-
9993

94+
# lint requirements
95+
cargo
96+
git
97+
mlc
98+
ruff
99+
rustc
100+
rustup
101+
shellcheck
102+
python310
103+
uv
104+
];
100105

101106
# Modifies the Nix clang++ wrapper to avoid warning:
102107
# "_FORTIFY_SOURCE requires compiling with optimization (-O)"
@@ -108,6 +113,11 @@ in pkgs.mkShell {
108113
shellHook = ''
109114
echo "Bitcoin Core build nix-shell"
110115
echo ""
116+
echo "Setting up python venv"
117+
118+
uv venv --python 3.10
119+
source .venv/bin/activate
120+
uv pip install -r pyproject.toml
111121
112122
BCC_EGG=${pkgs.linuxPackages.bcc}/${pkgs.python3.sitePackages}/bcc-${pkgs.linuxPackages.bcc.version}-py3.${pkgs.python3.sourceVersion.minor}.egg
113123
@@ -121,5 +131,9 @@ in pkgs.mkShell {
121131
122132
echo "adding ${builtins.concatStringsSep ":" binDirs} to \$PATH to make running built binaries more natural"
123133
export PATH=$PATH:${builtins.concatStringsSep ":" binDirs};
134+
135+
rustup default stable
136+
rustup component add rustfmt
137+
124138
'';
125139
}

0 commit comments

Comments
 (0)