From 20e63ff88fb660775ea87f5ebe52e81a432eca4f Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 12 Dec 2024 14:05:07 +0100 Subject: [PATCH 1/3] flake.lock: Update --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 2a988a0b..f03e18fa 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1727826117, - "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", + "lastModified": 1733312601, + "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", + "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", "type": "github" }, "original": { @@ -22,11 +22,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1728279793, - "narHash": "sha256-W3D5YpNrUVTFPVU4jiEiboaaUDShaiH5fRl9aJLqUnU=", + "lastModified": 1733749988, + "narHash": "sha256-+5qdtgXceqhK5ZR1YbP1fAUsweBIrhL38726oIEAtDs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f85a2d005e83542784a755ca8da112f4f65c4aa4", + "rev": "bc27f0fde01ce4e1bfec1ab122d72b7380278e68", "type": "github" }, "original": { @@ -50,11 +50,11 @@ ] }, "locked": { - "lastModified": 1727984844, - "narHash": "sha256-xpRqITAoD8rHlXQafYZOLvUXCF6cnZkPfoq67ThN0Hc=", + "lastModified": 1733761991, + "narHash": "sha256-s4DalCDepD22jtKL5Nw6f4LP5UwoMcPzPZgHWjAfqbQ=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "4446c7a6fc0775df028c5a3f6727945ba8400e64", + "rev": "0ce9d149d99bc383d1f2d85f31f6ebd146e46085", "type": "github" }, "original": { From ee48ddfbec96157351d5f13747c35b1f7c7f7be8 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 12 Dec 2024 14:06:08 +0100 Subject: [PATCH 2/3] Reformat code base --- .github/workflows/test.yml | 30 +++++++++++++++--------------- default.nix | 32 +++++++++++++++++++------------- nixpkgs_review/cli/comments.py | 7 ++++--- nixpkgs_review/cli/pr.py | 7 ++++--- 4 files changed, 42 insertions(+), 34 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 50c29362..775df639 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,21 +13,21 @@ jobs: tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v30 - with: - extra_nix_config: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - - run: nix build - - run: nix develop -c pytest -s . + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v30 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - run: nix build + - run: nix develop -c pytest -s . build-flake: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v30 - with: - extra_nix_config: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - - name: List flake structure - run: nix flake show - - run: nix flake check -vL + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v30 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: List flake structure + run: nix flake show + - run: nix flake check -vL diff --git a/default.nix b/default.nix index 4c423dcd..e48eb93b 100644 --- a/default.nix +++ b/default.nix @@ -18,16 +18,19 @@ python3.pkgs.buildPythonApplication { nativeBuildInputs = [ installShellFiles ] ++ lib.optional withAutocomplete python3.pkgs.argcomplete; propagatedBuildInputs = [ python3.pkgs.argcomplete ]; - nativeCheckInputs = [ - python3.pkgs.setuptools - python3.pkgs.pylint - glibcLocales + nativeCheckInputs = + [ + python3.pkgs.setuptools + python3.pkgs.pylint + glibcLocales - # needed for interactive unittests - python3.pkgs.pytest - pkgs.nixVersions.stable or nix_2_4 - git - ] ++ lib.optional withSandboxSupport bubblewrap ++ lib.optional withNom' nix-output-monitor; + # needed for interactive unittests + python3.pkgs.pytest + pkgs.nixVersions.stable or nix_2_4 + git + ] + ++ lib.optional withSandboxSupport bubblewrap + ++ lib.optional withNom' nix-output-monitor; checkPhase = '' echo -e "\x1b[32m## run nixpkgs-review --help\x1b[0m" @@ -36,10 +39,13 @@ python3.pkgs.buildPythonApplication { ''; makeWrapperArgs = let - binPath = [ - pkgs.nixVersions.stable or nix_2_4 - git - ] ++ lib.optional withSandboxSupport bubblewrap ++ lib.optional withNom' nix-output-monitor; + binPath = + [ + pkgs.nixVersions.stable or nix_2_4 + git + ] + ++ lib.optional withSandboxSupport bubblewrap + ++ lib.optional withNom' nix-output-monitor; in [ "--prefix PATH : ${lib.makeBinPath binPath}" diff --git a/nixpkgs_review/cli/comments.py b/nixpkgs_review/cli/comments.py index 02fcb2c2..eb3f1757 100644 --- a/nixpkgs_review/cli/comments.py +++ b/nixpkgs_review/cli/comments.py @@ -1,4 +1,5 @@ import argparse +import string from dataclasses import dataclass, field from datetime import datetime from typing import Any @@ -8,10 +9,10 @@ def comments_query(pr: int) -> str: - return """ + return string.Template(""" { repository(owner: "NixOS", name: "nixpkgs") { - pullRequest(number: %d) { + pullRequest(number: $pr) { author { login } body createdAt @@ -46,7 +47,7 @@ def comments_query(pr: int) -> str: } } } -""" % (pr) +""").substitute(pr=pr) @dataclass diff --git a/nixpkgs_review/cli/pr.py b/nixpkgs_review/cli/pr.py index d92b5063..1ca349b4 100644 --- a/nixpkgs_review/cli/pr.py +++ b/nixpkgs_review/cli/pr.py @@ -60,9 +60,10 @@ def pr_command(args: argparse.Namespace) -> str: allow = AllowedFeatures(args.allow) builddir = None - with Buildenv( - allow.aliases, args.extra_nixpkgs_config - ) as nixpkgs_config, ExitStack() as stack: + with ( + Buildenv(allow.aliases, args.extra_nixpkgs_config) as nixpkgs_config, + ExitStack() as stack, + ): review = None for pr in prs: builddir = stack.enter_context(Builddir(f"pr-{pr}")) From 032eca4efa903d842a619ecfe0fb4201a5b9b216 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 12 Dec 2024 14:16:31 +0100 Subject: [PATCH 3/3] treefmt: cosmetic change --- treefmt.nix | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/treefmt.nix b/treefmt.nix index 87f0b10d..78074c80 100644 --- a/treefmt.nix +++ b/treefmt.nix @@ -1,4 +1,7 @@ -{ lib, inputs, ... }: +{ + inputs, + ... +}: { imports = [ inputs.treefmt-nix.flakeModule @@ -11,20 +14,23 @@ # Used to find the project root projectRootFile = "flake.lock"; - programs.deno.enable = - pkgs.lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.deno && !pkgs.deno.meta.broken; - programs.ruff.format = true; - programs.ruff.check = true; - programs.mypy.enable = true; - programs.nixfmt.enable = pkgs.lib.meta.availableOn pkgs.stdenv.buildPlatform pkgs.nixfmt-rfc-style.compiler; - programs.deadnix.enable = true; - - programs.mypy.directories = { - "." = { - directory = "."; - extraPythonPackages = [ - pkgs.python3.pkgs.pytest - ]; + programs = { + deno.enable = + pkgs.lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.deno && !pkgs.deno.meta.broken; + ruff = { + format = true; + check = true; + }; + mypy.enable = true; + nixfmt.enable = pkgs.lib.meta.availableOn pkgs.stdenv.buildPlatform pkgs.nixfmt-rfc-style.compiler; + deadnix.enable = true; + mypy.directories = { + "." = { + directory = "."; + extraPythonPackages = [ + pkgs.python3Packages.pytest + ]; + }; }; }; };