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 cfbd97c commit 3c489be
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 14 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
47 changes: 33 additions & 14 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 @@ -39,6 +53,9 @@ in pkgs.mkShell {
sqlite
clang_18

# lint requirements
mlc

# tests
hexdump

Expand All @@ -58,18 +75,6 @@ in pkgs.mkShell {
# 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,10 +99,12 @@ in pkgs.mkShell {
buildInputs = with pkgs; [
just
bash
uv
cargo
rustc
shellcheck
];



# Modifies the Nix clang++ wrapper to avoid warning:
# "_FORTIFY_SOURCE requires compiling with optimization (-O)"
hardeningDisable = if withDebug then [ "all" ] else [ ];
Expand All @@ -121,5 +128,17 @@ in pkgs.mkShell {
echo "adding ${builtins.concatStringsSep ":" binDirs} to \$PATH to make running built binaries more natural"
export PATH=$PATH:${builtins.concatStringsSep ":" binDirs};
echo "Setting up python venv"
uv venv --python 3.10
source .venv/bin/activate
uv pip install codespell==2.2.6
uv pip install lief==0.13.2
uv pip install mypy==1.4.1
uv pip install pyzmq==25.1.0
uv pip install ruff==0.5.5
uv pip install vulture==2.6
uv pip install pyperf
'';
}

0 comments on commit 3c489be

Please sign in to comment.