-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add a test for packages with subpackages
- Loading branch information
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import subprocess | ||
from pathlib import Path | ||
|
||
import conftest | ||
|
||
from nix_update.options import Options | ||
from nix_update.update import update | ||
|
||
|
||
def test_update(helpers: conftest.Helpers) -> None: | ||
with helpers.testpkgs() as path: | ||
opts = Options(attribute="subpackage", subpackages=["autobrr-web"], import_path=str(path)) | ||
update(opts) | ||
|
||
def get_attr(attr: str) -> str: | ||
return subprocess.run( | ||
[ | ||
"nix", | ||
"eval", | ||
"--raw", | ||
"--extra-experimental-features", | ||
"nix-command", | ||
"-f", | ||
path, | ||
attr, | ||
], | ||
text=True, | ||
stdout=subprocess.PIPE, | ||
).stdout.strip() | ||
|
||
subpackage_hash = get_attr("subpackage.autobrr-web.pnpmDeps.outputHash") | ||
assert subpackage_hash != "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" | ||
|
||
src_hash = get_attr("subpackage.src.outputHash") | ||
assert src_hash != "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" | ||
|
||
gomodules_hash = get_attr("subpackage.goModules.outputHash") | ||
assert src_hash != "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" | ||
|
||
version = get_attr("subpackage.version") | ||
assert tuple(map(int, version.split("."))) >= (1, 53, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
lib, | ||
buildGoModule, | ||
fetchFromGitHub, | ||
stdenvNoCC, | ||
nix-update-script, | ||
nodejs, | ||
pnpm_9, | ||
typescript, | ||
}: | ||
|
||
let | ||
pname = "autobrr"; | ||
version = "1.53.0"; | ||
src = fetchFromGitHub { | ||
owner = "autobrr"; | ||
repo = "autobrr"; | ||
rev = "v${version}"; | ||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; | ||
}; | ||
|
||
autobrr-web = stdenvNoCC.mkDerivation { | ||
pname = "${pname}-web"; | ||
inherit src version; | ||
|
||
nativeBuildInputs = [ | ||
nodejs | ||
pnpm_9.configHook | ||
typescript | ||
]; | ||
|
||
sourceRoot = "${src.name}/web"; | ||
|
||
pnpmDeps = pnpm_9.fetchDeps { | ||
inherit (autobrr-web) | ||
pname | ||
version | ||
src | ||
sourceRoot | ||
; | ||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; | ||
}; | ||
|
||
postBuild = '' | ||
pnpm run build | ||
''; | ||
|
||
installPhase = '' | ||
cp -r dist $out | ||
''; | ||
}; | ||
in | ||
buildGoModule rec { | ||
inherit | ||
autobrr-web | ||
pname | ||
version | ||
src | ||
; | ||
|
||
vendorHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; | ||
|
||
preBuild = '' | ||
cp -r ${autobrr-web}/* web/dist | ||
''; | ||
} |