mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 14:36:15 -05:00
ci: verify Nix packages within the Build workflow
This commit is contained in:
5 files changed
+180
-205
No files matched your search
+47
@@ -0,0 +1,47 @@
|
||||
let
|
||||
source = builtins.getEnv "GP_SOURCE";
|
||||
system = builtins.getEnv "NIX_SYSTEM";
|
||||
nixpkgsRef = builtins.getEnv "NIXPKGS";
|
||||
gp = builtins.getFlake ("git+file://" + source + "?submodules=1");
|
||||
nixpkgs = if nixpkgsRef == "locked" then gp.inputs.nixpkgs
|
||||
else builtins.getFlake ("github:NixOS/nixpkgs/" + nixpkgsRef);
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
unpack = name: variable:
|
||||
let
|
||||
archive = builtins.path {
|
||||
path = builtins.toPath (builtins.getEnv variable);
|
||||
inherit name;
|
||||
};
|
||||
in pkgs.runCommand name { nativeBuildInputs = [ pkgs.libarchive ]; } ''
|
||||
mkdir -p "$out"
|
||||
bsdtar --extract --file ${archive} --directory "$out" --strip-components 1
|
||||
'';
|
||||
binaries = unpack "gp-ci-binaries" "GP_BINARY_ARCHIVE";
|
||||
gui = unpack "gp-ci-gui" "GP_GUI_ARCHIVE";
|
||||
sourcePackage = gp.packages.${system}.fromSource.override { inherit gui; };
|
||||
prebuiltPackage = gp.packages.${system}.prebuilt.override { inherit binaries gui; };
|
||||
hostSystem = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
gp.nixosModules.default
|
||||
({ options, ... }: {
|
||||
programs.globalprotect-openconnect = {
|
||||
enable = true;
|
||||
package = options.programs.globalprotect-openconnect.package.default.override {
|
||||
inherit binaries gui;
|
||||
};
|
||||
};
|
||||
system.stateVersion = "25.11";
|
||||
})
|
||||
];
|
||||
};
|
||||
modulePackage = hostSystem.config.programs.globalprotect-openconnect.package;
|
||||
in {
|
||||
source = sourcePackage;
|
||||
prebuilt = prebuiltPackage;
|
||||
module = assert builtins.elem modulePackage hostSystem.config.environment.systemPackages;
|
||||
assert hostSystem.config.services.ayatana-indicators.enable;
|
||||
modulePackage;
|
||||
runtime-source = import ./tests/native-runtime.nix { inherit pkgs; package = sourcePackage; };
|
||||
runtime-prebuilt = import ./tests/native-runtime.nix { inherit pkgs; package = prebuiltPackage; };
|
||||
}
|
||||
@@ -25,11 +25,6 @@ let
|
||||
pathlib.Path("/tmp/gp-gui-ready").write_text(str(os.getpid()))
|
||||
sys.stdin.buffer.read()
|
||||
'';
|
||||
testPackage = package.overrideAttrs (old: {
|
||||
postInstall = (old.postInstall or "") + ''
|
||||
install -m755 ${guiProbe} $out/bin/gpgui
|
||||
'';
|
||||
});
|
||||
hostCollector = pkgs.writeShellScriptBin "clamscan" ''
|
||||
echo 'ClamAV 1.4.0/27123/Mon Oct 7 00:00:00 2026'
|
||||
'';
|
||||
@@ -37,7 +32,7 @@ in
|
||||
pkgs.testers.runNixOSTest {
|
||||
name = "gp-native-runtime-${package.pname}";
|
||||
nodes.machine = {
|
||||
environment.systemPackages = [ testPackage hostCollector ];
|
||||
environment.systemPackages = [ package hostCollector ];
|
||||
users.users.alice = { isNormalUser = true; uid = 1000; };
|
||||
security.polkit.enable = true;
|
||||
security.polkit.extraConfig = ''
|
||||
@@ -58,13 +53,13 @@ pkgs.testers.runNixOSTest {
|
||||
|
||||
machine.start()
|
||||
machine.wait_for_unit("polkit.service")
|
||||
package = "${testPackage}"
|
||||
package = "${package}"
|
||||
|
||||
def as_alice(command):
|
||||
return machine.succeed("su - alice -c " + shlex.quote(command))
|
||||
|
||||
# Exercise real host pkexec, private credential pipes and launcher cancellation.
|
||||
command = package + "/bin/gpclient --lock-file /tmp/gp-client.lock launch-gui"
|
||||
command = "GP_GUI_BINARY=${guiProbe} " + package + "/bin/gpclient --lock-file /tmp/gp-client.lock launch-gui"
|
||||
as_alice(command + " > /tmp/gp-client-output 2>&1 & echo $! > /tmp/gp-client-pid")
|
||||
machine.wait_until_succeeds("test -s /tmp/gp-gui-ready")
|
||||
service_pid = machine.succeed("cut -d: -f1 /var/run/gpservice.lock").strip()
|
||||
|
||||
Reference in new issue
Block a user