-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from lulu-berlin/testing
Bootstrap testing
- Loading branch information
Showing
10 changed files
with
494 additions
and
2 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,13 @@ | ||
name: "Test the nixos Python job module" | ||
on: | ||
pull_request: | ||
push: | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: cachix/install-nix-action@v27 | ||
with: | ||
github_access_token: ${{ secrets.GITHUB_TOKEN }} | ||
- run: nix run |
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 |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
build/ | ||
*.kdev4 | ||
*.qmlc | ||
.vscode/ | ||
.vscode/ | ||
**/__pycache__/ |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,34 @@ | ||
{ | ||
description = "Testing calamares-nixos-extensions"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
}; | ||
|
||
outputs = { nixpkgs, ... }: | ||
let | ||
system = "x86_64-linux"; | ||
|
||
pkgs = import nixpkgs { | ||
inherit system; | ||
}; | ||
|
||
packages = [ | ||
(pkgs.python3.withPackages (pp: with pp; [ pytest pytest-mock ])) | ||
]; | ||
in | ||
{ | ||
packages.${system}.default = pkgs.writeShellApplication { | ||
name = "test-nixos-install"; | ||
runtimeInputs = packages; | ||
text = '' | ||
#!${pkgs.stdenv.shell} | ||
pytest -vv testing | ||
''; | ||
}; | ||
|
||
devShells.${system}.default = pkgs.mkShell { | ||
inherit packages; | ||
}; | ||
}; | ||
} |
Empty file.
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,162 @@ | ||
import os | ||
import sys | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def mock_translation_gettext(mocker): | ||
return mocker.Mock( | ||
"gettext.translation().gettext", | ||
# Return the translation key as the translation | ||
side_effect=lambda t: t, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def mock_gettext_translation(mocker, mock_translation_gettext): | ||
mock_translation_object = mocker.Mock("gettext.translation()") | ||
mock_translation_object.gettext = mock_translation_gettext | ||
|
||
return mocker.Mock("gettext.translation", return_value=mock_translation_object) | ||
|
||
|
||
@pytest.fixture | ||
def globalstorage(): | ||
return { | ||
"rootMountPoint": "/mnt/root", | ||
"firmwareType": "efi", | ||
"partitions": [], | ||
"keyboardLayout": "us", | ||
"username": "username", | ||
"fullname": "fullname", | ||
} | ||
|
||
|
||
@pytest.fixture | ||
def mock_check_output(mocker): | ||
return mocker.Mock(name="subprocess.check_output") | ||
|
||
|
||
@pytest.fixture | ||
def mock_getoutput(mocker): | ||
return mocker.Mock( | ||
name="subprocess.getoutput", | ||
# subprocess.getoutput() is only called to get the output of `nixos-version` so it is hard-coded here. | ||
return_value="24.05.20240815.c3d4ac7 (Uakari)", | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def mock_Popen(mocker): | ||
mock_Popen_inst = mocker.Mock("Popen()") | ||
mock_Popen_inst.stdout = mocker.Mock("Popen().stdout") | ||
mock_Popen_inst.stdout.readline = mocker.Mock( | ||
"Popen().stdout.readline", | ||
# Make Popen print nothing (empty bytes) to stdout | ||
return_value=b"", | ||
) | ||
mock_Popen_inst.wait = mocker.Mock( | ||
"Popen().wait", | ||
# Make Popen().wait() give a returncode of 0 | ||
return_value=0, | ||
) | ||
return mocker.Mock(name="subprocess.Popen", return_value=mock_Popen_inst) | ||
|
||
|
||
@pytest.fixture | ||
def mock_libcalamares(mocker, globalstorage): | ||
mock_libcalamares = mocker.Mock("libcalamares") | ||
|
||
mock_libcalamares.globalstorage = mocker.Mock("libcalamares.globalstorage") | ||
mock_libcalamares.globalstorage.value = mocker.Mock( | ||
"libcalamares.globalstorage.value" | ||
) | ||
mock_libcalamares.globalstorage.value.side_effect = lambda k: globalstorage.get(k) | ||
|
||
mock_libcalamares.utils = mocker.Mock("libcalamares.utils") | ||
mock_libcalamares.utils.gettext = mocker.Mock("libcalamares.utils.gettext") | ||
mock_libcalamares.utils.gettext_path = mocker.Mock( | ||
"libcalamares.utils.gettext_path" | ||
) | ||
mock_libcalamares.utils.gettext_languages = mocker.Mock( | ||
"libcalamares.utils.gettext_languages" | ||
) | ||
mock_libcalamares.utils.warning = mocker.Mock("libcalamares.utils.warning") | ||
mock_libcalamares.utils.debug = mocker.Mock("libcalamares.utils.debug") | ||
mock_libcalamares.utils.host_env_process_output = mocker.Mock( | ||
"libcalamares.utils.host_env_process_output" | ||
) | ||
|
||
mock_libcalamares.job = mocker.Mock("libcalamares.job") | ||
mock_libcalamares.job.setprogress = mocker.Mock("libcalamares.job.setprogress") | ||
|
||
return mock_libcalamares | ||
|
||
|
||
@pytest.fixture | ||
def mock_open_hwconf(mocker): | ||
return mocker.Mock('open("hardware-configuration.nix")') | ||
|
||
|
||
@pytest.fixture | ||
def mock_open_kbdmodelmap(mocker): | ||
return mocker.Mock('open("kbd-model-map")') | ||
|
||
|
||
@pytest.fixture | ||
def mock_open(mocker, mock_open_hwconf, mock_open_kbdmodelmap): | ||
testing_dir = os.path.dirname(__file__) | ||
|
||
hwconf_txt = "" | ||
with open(os.path.join(testing_dir, "hardware-configuration.nix"), "r") as hwconf: | ||
hwconf_txt = hwconf.read() | ||
|
||
kbdmodelmap_txt = "" | ||
with open(os.path.join(testing_dir, "kbd-model-map"), "r") as kbdmodelmap: | ||
kbdmodelmap_txt = kbdmodelmap.read() | ||
|
||
mock_open = mocker.Mock("open") | ||
|
||
def fake_open(*args): | ||
file, mode, *_ = args | ||
|
||
assert mode == "r", "open() called without the 'r' mode" | ||
|
||
if file.endswith("hardware-configuration.nix"): | ||
return mocker.mock_open(mock=mock_open_hwconf, read_data=hwconf_txt)(*args) | ||
elif file.endswith("kbd-model-map"): | ||
return mocker.mock_open( | ||
mock=mock_open_kbdmodelmap, read_data=kbdmodelmap_txt | ||
)(*args) | ||
else: | ||
raise AssertionError(f"open() called with unexpected file '{file}'") | ||
|
||
mock_open.side_effect = fake_open | ||
|
||
return mock_open | ||
|
||
|
||
@pytest.fixture | ||
def run( | ||
mocker, | ||
mock_gettext_translation, | ||
mock_libcalamares, | ||
mock_check_output, | ||
mock_getoutput, | ||
mock_Popen, | ||
mock_open, | ||
): | ||
sys.modules["libcalamares"] = mock_libcalamares | ||
|
||
mocker.patch("gettext.translation", mock_gettext_translation) | ||
|
||
mocker.patch("subprocess.check_output", mock_check_output) | ||
mocker.patch("subprocess.getoutput", mock_getoutput) | ||
mocker.patch("subprocess.Popen", mock_Popen) | ||
|
||
mocker.patch("builtins.open", mock_open) | ||
|
||
from modules.nixos.main import run | ||
|
||
return run |
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,31 @@ | ||
# Do not modify this file! It was generated by ‘nixos-generate-config’ | ||
# and may be overwritten by future invocations. Please make changes | ||
# to /etc/nixos/configuration.nix instead. | ||
{ config, lib, pkgs, modulesPath, ... }: | ||
|
||
{ | ||
imports = | ||
[ (modulesPath + "/installer/scan/not-detected.nix") | ||
]; | ||
|
||
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usbhid" ]; | ||
boot.initrd.kernelModules = [ ]; | ||
boot.kernelModules = [ "kvm-amd" ]; | ||
boot.extraModulePackages = [ ]; | ||
|
||
swapDevices = [ ]; | ||
|
||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking | ||
# (the default) this is the recommended approach. When using systemd-networkd it's | ||
# still possible to use this option, but it's recommended to use it in conjunction | ||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`. | ||
networking.useDHCP = lib.mkDefault true; | ||
# networking.interfaces.docker0.useDHCP = lib.mkDefault true; | ||
# networking.interfaces.veth1a64ca3.useDHCP = lib.mkDefault true; | ||
# networking.interfaces.vethb5290db.useDHCP = lib.mkDefault true; | ||
# networking.interfaces.vethf60304e.useDHCP = lib.mkDefault true; | ||
# networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true; | ||
|
||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; | ||
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; | ||
} |
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,72 @@ | ||
# Originally generated from system-config-keyboard's model list. | ||
# consolelayout xlayout xmodel xvariant xoptions | ||
sg ch pc105 de_nodeadkeys terminate:ctrl_alt_bksp | ||
nl nl pc105 - terminate:ctrl_alt_bksp | ||
mk-utf mk,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll | ||
trq tr pc105 - terminate:ctrl_alt_bksp | ||
uk gb pc105 - terminate:ctrl_alt_bksp | ||
is-latin1 is pc105 - terminate:ctrl_alt_bksp | ||
de de pc105 - terminate:ctrl_alt_bksp | ||
la-latin1 latam pc105 - terminate:ctrl_alt_bksp | ||
us us pc105+inet - terminate:ctrl_alt_bksp | ||
ko kr pc105 - terminate:ctrl_alt_bksp | ||
ro-std ro pc105 std terminate:ctrl_alt_bksp | ||
de-latin1 de pc105 - terminate:ctrl_alt_bksp | ||
slovene si pc105 - terminate:ctrl_alt_bksp | ||
hu hu pc105 - terminate:ctrl_alt_bksp | ||
jp106 jp jp106 - terminate:ctrl_alt_bksp | ||
croat hr pc105 - terminate:ctrl_alt_bksp | ||
it2 it pc105 - terminate:ctrl_alt_bksp | ||
hu101 hu pc105 qwerty terminate:ctrl_alt_bksp | ||
sr-latin rs pc105 latin terminate:ctrl_alt_bksp | ||
fi fi pc105 - terminate:ctrl_alt_bksp | ||
fr_CH ch pc105 fr terminate:ctrl_alt_bksp | ||
dk-latin1 dk pc105 - terminate:ctrl_alt_bksp | ||
fr fr pc105 - terminate:ctrl_alt_bksp | ||
it it pc105 - terminate:ctrl_alt_bksp | ||
ua-utf ua,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll | ||
fr-latin1 fr pc105 - terminate:ctrl_alt_bksp | ||
sg-latin1 ch pc105 de_nodeadkeys terminate:ctrl_alt_bksp | ||
be-latin1 be pc105 - terminate:ctrl_alt_bksp | ||
dk dk pc105 - terminate:ctrl_alt_bksp | ||
fr-pc fr pc105 - terminate:ctrl_alt_bksp | ||
bg_pho-utf8 bg,us pc105 ,phonetic terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll | ||
it-ibm it pc105 - terminate:ctrl_alt_bksp | ||
cz-us-qwertz cz,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll | ||
cz-qwerty cz,us pc105 qwerty, terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll | ||
br-abnt2 br abnt2 - terminate:ctrl_alt_bksp | ||
ro ro pc105 - terminate:ctrl_alt_bksp | ||
us-acentos us pc105 intl terminate:ctrl_alt_bksp | ||
pt-latin1 pt pc105 - terminate:ctrl_alt_bksp | ||
ro-std-cedilla ro pc105 std_cedilla terminate:ctrl_alt_bksp | ||
tj_alt-UTF8 tj pc105 - terminate:ctrl_alt_bksp | ||
de-latin1-nodeadkeys de pc105 nodeadkeys terminate:ctrl_alt_bksp | ||
no no pc105 - terminate:ctrl_alt_bksp | ||
bg_bds-utf8 bg,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll | ||
dvorak us pc105 dvorak terminate:ctrl_alt_bksp | ||
dvorak us pc105 dvorak-alt-intl terminate:ctrl_alt_bksp | ||
ru ru,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll | ||
cz-lat2 cz pc105 qwerty terminate:ctrl_alt_bksp | ||
pl2 pl pc105 - terminate:ctrl_alt_bksp | ||
es es pc105 - terminate:ctrl_alt_bksp | ||
ro-cedilla ro pc105 cedilla terminate:ctrl_alt_bksp | ||
ie ie pc105 - terminate:ctrl_alt_bksp | ||
et ee pc105 - terminate:ctrl_alt_bksp | ||
sk-qwerty sk pc105 qwerty terminate:ctrl_alt_bksp | ||
sk-qwertz sk pc105 - terminate:ctrl_alt_bksp | ||
fr-latin9 fr pc105 latin9 terminate:ctrl_alt_bksp | ||
fr_CH-latin1 ch pc105 fr terminate:ctrl_alt_bksp | ||
cf ca pc105 - terminate:ctrl_alt_bksp | ||
sv-latin1 se pc105 - terminate:ctrl_alt_bksp | ||
sr-cy rs pc105 - terminate:ctrl_alt_bksp | ||
gr gr,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll | ||
by by,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll | ||
il il pc105 - terminate:ctrl_alt_bksp | ||
kazakh kz,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll | ||
lt.baltic lt pc105 - terminate:ctrl_alt_bksp | ||
lt.l4 lt pc105 - terminate:ctrl_alt_bksp | ||
lt lt pc105 - terminate:ctrl_alt_bksp | ||
khmer kh,us pc105 - terminate:ctrl_alt_bksp | ||
es-dvorak es microsoftpro dvorak terminate:ctrl_alt_bksp | ||
lv lv pc105 apostrophe terminate:ctrl_alt_bksp | ||
lv-tilde lv pc105 tilde terminate:ctrl_alt_bksp |
Oops, something went wrong.