Skip to content

Commit

Permalink
Merge pull request #6 from willcl-ark/lint-in-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
willcl-ark authored Nov 5, 2024
2 parents fcb01ea + 7213602 commit 017a633
Show file tree
Hide file tree
Showing 6 changed files with 376 additions and 20 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ on:
tags-ignore:
- '**'
jobs:
lint:
runs-on: [self-hosted, linux, x64]
timeout-minutes: 5
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- 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:
needs: lint
runs-on: [self-hosted, linux, x64]
timeout-minutes: 20
steps:
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
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[project]
name = "bitcoin-core-deps"
version = "0.1.0"
dependencies = [
"codespell==2.2.6",
"lief==0.13.2",
"mypy==1.4.1",
"pyzmq==25.1.0",
# Removing in favour of packaged nixpkgs bin which is not dynamically linked
# "ruff==0.5.5",
"vulture==2.6",
"pyperf"
]
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)
54 changes: 34 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,18 @@ in pkgs.mkShell {
buildInputs = with pkgs; [
just
bash
];


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

# Modifies the Nix clang++ wrapper to avoid warning:
# "_FORTIFY_SOURCE requires compiling with optimization (-O)"
Expand All @@ -108,6 +113,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 +131,9 @@ in pkgs.mkShell {
echo "adding ${builtins.concatStringsSep ":" binDirs} to \$PATH to make running built binaries more natural"
export PATH=$PATH:${builtins.concatStringsSep ":" binDirs};
rustup default stable
rustup component add rustfmt
'';
}
Loading

0 comments on commit 017a633

Please sign in to comment.