Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

miscellaneous cleaning #299

Merged
merged 7 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{
pkgs ? import <nixpkgs> { },
}:

pkgs.python3.pkgs.buildPythonApplication {
pkgs.python3Packages.buildPythonApplication {
pname = "nix-update";
version = "1.5.2";
src = ./.;
pyproject = true;
buildInputs = [ pkgs.makeWrapper ];
nativeBuildInputs = [ pkgs.python3.pkgs.setuptools ];
nativeCheckInputs = [
pkgs.python3.pkgs.pytest
# technically not test inputs, but we need it for development in PATH
build-system = [ pkgs.python3Packages.setuptools ];
nativeBuildInputs = [
pkgs.nixVersions.stable
pkgs.nix-prefetch-git
];
nativeCheckInputs = [
pkgs.python3Packages.pytest
pkgs.python3Packages.pytest-xdist
];
checkPhase = ''
PYTHONPATH= $out/bin/nix-update --help
'';
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Homepage = "https://github.com/Mic92/nix-update"
[project.scripts]
nix-update = "nix_update:main"

[tool.pytest.ini_options]
addopts = "-v -n auto"

[tool.ruff]
target-version = "py311"
line-length = 88
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cargo_lock_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_main(helpers: conftest.Helpers) -> None:
"--commit",
"cargoLock.update",
"--version",
"v0.4.7",
"0.7.3",
]
)
subprocess.run(
Expand All @@ -39,4 +39,4 @@ def test_main(helpers: conftest.Helpers) -> None:
check=True,
).stdout.strip()
print(diff)
assert "https://github.com/astral-sh/ruff/compare/v0.4.5...v0.4.7" in diff
assert "https://github.com/astral-sh/ruff/compare/0.7.0...0.7.3" in diff
9 changes: 9 additions & 0 deletions tests/test_flake.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ def test_main(helpers: conftest.Helpers) -> None:
print(commit)
assert f"crate: 8.0.0 -> {version}" in commit
assert "https://diff.rs/fd-find/8.0.0/" in commit

diff = subprocess.run(
["git", "-C", path, "show"],
text=True,
stdout=subprocess.PIPE,
check=True,
).stdout.strip()
print(diff)
assert "https://diff.rs/fd-find/8.0.0/10.2.0" in diff
11 changes: 7 additions & 4 deletions tests/testpkgs/cargo-lock-update/default.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
{ rustPlatform, fetchFromGitHub }:

{
rustPlatform,
fetchFromGitHub,
}:
rustPlatform.buildRustPackage rec {
pname = "ruff";
version = "0.4.5";
version = "0.7.0";

src = fetchFromGitHub {
owner = "astral-sh";
repo = pname;
rev = "v${version}";
rev = version;
hash = "sha256-+8JKzKKWPQEanU2mh8p5sRjnoU6DawTQQi43qRXVXIg=";
};

cargoLock = {
lockFile = src + "/Cargo.lock";
outputHashes = {
"lsp-types-0.95.1" = "sha256-8Oh299exWXVi6A39pALOISNfp8XBya8z+KT/Z7suRxQ=";
"salsa-0.18.0" = "sha256-vuLgeaqIL8U+5PUHJaGdovHFapAMGGQ9nPAMJJnxz/o=";
};
};
}
3 changes: 1 addition & 2 deletions tests/testpkgs/crate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
fetchCrate,
hello,
}:

rustPlatform.buildRustPackage rec {
pname = "fd-find";
version = "8.0.0";
Expand All @@ -13,7 +12,7 @@ rustPlatform.buildRustPackage rec {
sha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};

cargoSha256 = "sha256-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=";
cargoHash = "sha256-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=";

passthru.tests = {
foo = hello;
Expand Down
5 changes: 4 additions & 1 deletion tests/testpkgs/flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
outputs =
{ self, nixpkgs }:
{
self,
nixpkgs,
}:
{
packages = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (system: {
crate = nixpkgs.legacyPackages.${system}.callPackage (self + "/crate.nix") { };
Expand Down