Skip to content

Commit

Permalink
add lint ci job
Browse files Browse the repository at this point in the history
  • Loading branch information
willcl-ark committed Nov 1, 2024
1 parent 154f886 commit 9b9160e
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 20 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ on:
tags-ignore:
- '**'
jobs:
lint:
runs-on: [self-hosted, linux, x64]
timeout-minutes: 5
steps:
- name: Checkout repo
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build & test release
env:
NIX_PATH: nixpkgs=channel:nixos-unstable
run: |
nix-shell --command "just lint"
build-and-test:
runs-on: [self-hosted, linux, x64]
timeout-minutes: 20
Expand Down
8 changes: 8 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ test-unit1 suite:
bench:
build/src/bench/bench_bitcoin

# Run the lint job
lint:
#!/usr/bin/env bash
cd test/lint/test_runner/
cargo fmt
cargo clippy
COMMIT_RANGE="$( git rev-list --max-count=1 --merges HEAD )..HEAD" cargo run
# Run the CI workflow
[group('ci')]
run-ci: build-ci bench test
26 changes: 26 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml -o requirements.txt
codespell==2.2.6
# via bitcoin-core-deps (pyproject.toml)
lief==0.13.2
# via bitcoin-core-deps (pyproject.toml)
mypy==1.4.1
# via bitcoin-core-deps (pyproject.toml)
mypy-extensions==1.0.0
# via mypy
psutil==6.1.0
# via pyperf
pyperf==2.8.0
# via bitcoin-core-deps (pyproject.toml)
pyzmq==25.1.0
# via bitcoin-core-deps (pyproject.toml)
ruff==0.5.5
# via bitcoin-core-deps (pyproject.toml)
toml==0.10.2
# via vulture
tomli==2.0.2
# via mypy
typing-extensions==4.12.2
# via mypy
vulture==2.6
# via bitcoin-core-deps (pyproject.toml)
49 changes: 29 additions & 20 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
}:
let
inherit (pkgs.lib) optionals strings;

# Add mlc binary fetching
mlcBinary = pkgs.fetchurl {
url = "https://github.com/becheran/mlc/releases/download/v0.18.0/mlc-x86_64-linux";
sha256 = "sha256-jbdp+UlFybBE+o567L398hbcWHsG8aQGqYYf5h9JRkw=";
};

# Create a derivation for mlc
mlc = pkgs.runCommand "mlc" {} ''
mkdir -p $out/bin
cp ${mlcBinary} $out/bin/mlc
chmod +x $out/bin/mlc
'';

binDirs =
[ "\$PWD/src" ]
++ optionals withGui [ "\$PWD/src/qt" ];
Expand Down Expand Up @@ -46,30 +60,12 @@ in pkgs.mkShell {
# https://github.com/bitcoin/bitcoin/blob/master/doc/productivity.md#cache-compilations-with-ccache
ccache

# generating compile_commands.json for clang-format, clang-tidy, LSPs etc
# https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#running-clang-tidy
# $ a && c && m clean && bear --config src/.bear-tidy-config -- make -j6
clang-tools_18
bear

# for newer cmake building
cmake

# depends
byacc

# functional tests & linting
python3
python3Packages.flake8
python3Packages.lief
python3Packages.autopep8
python3Packages.mypy
python3Packages.requests
python3Packages.pyzmq

# benchmarking
python3Packages.pyperf

# debugging
gdb

Expand All @@ -94,9 +90,16 @@ in pkgs.mkShell {
buildInputs = with pkgs; [
just
bash
];


# lint requirements
cargo
git
mlc
ruff
rustc
shellcheck
uv
];

# Modifies the Nix clang++ wrapper to avoid warning:
# "_FORTIFY_SOURCE requires compiling with optimization (-O)"
Expand All @@ -108,6 +111,11 @@ in pkgs.mkShell {
shellHook = ''
echo "Bitcoin Core build nix-shell"
echo ""
echo "Setting up python venv"
uv venv --python 3.10
source .venv/bin/activate
uv pip install -r pyproject.toml
BCC_EGG=${pkgs.linuxPackages.bcc}/${pkgs.python3.sitePackages}/bcc-${pkgs.linuxPackages.bcc.version}-py3.${pkgs.python3.sourceVersion.minor}.egg
Expand All @@ -121,5 +129,6 @@ in pkgs.mkShell {
echo "adding ${builtins.concatStringsSep ":" binDirs} to \$PATH to make running built binaries more natural"
export PATH=$PATH:${builtins.concatStringsSep ":" binDirs};
'';
}
Loading

0 comments on commit 9b9160e

Please sign in to comment.