From: Daan De Meyer Date: Wed, 13 Mar 2024 16:20:19 +0000 (+0100) Subject: ci: Do all work on a btrfs filesystem X-Git-Tag: v22~6^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2497%2Fhead;p=thirdparty%2Fmkosi.git ci: Do all work on a btrfs filesystem Let's make sure we take advantage of our COW and subvolume support in CI by doing all work in a btrfs filesystem. Additionally enable compression and user subvolume deletes on the btrfs filesystem to speed things up even more. --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e2c3cd6d..f688d445b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -133,16 +133,30 @@ jobs: - name: Install run: | sudo apt-get update - sudo apt-get install python3-pytest lvm2 cryptsetup-bin + sudo apt-get install python3-pytest lvm2 cryptsetup-bin btrfs-progs # Make sure the latest changes from the pull request are used. sudo ln -svf $PWD/bin/mkosi /usr/bin/mkosi working-directory: ./ + - name: Btrfs + run: | + truncate --size=20G btrfs.raw + mkfs.btrfs btrfs.raw + sudo mkdir -p /mnt/mkosi + LOOP="$(sudo losetup --find --show --direct-io=on btrfs.raw)" + sudo mount "$LOOP" /mnt/mkosi --options compress=zstd,user_subvol_rm_allowed + sudo chown "$(id -u):$(id -g)" /mnt/mkosi + - name: Configure run: | tee mkosi.local.conf < "Image": - self.output_dir = tempfile.TemporaryDirectory(dir="/var/tmp") - os.chown(self.output_dir.name, INVOKING_USER.uid, INVOKING_USER.gid) + self.output_dir = Path(os.getenv("TMPDIR", "/var/tmp")) / uuid.uuid4().hex[:16] return self @@ -79,8 +79,7 @@ class Image: ), *self.options, *options, - "--output-dir", self.output_dir.name, - "--cache-dir", "mkosi.cache", + "--output-dir", self.output_dir, *(f"--kernel-command-line={i}" for i in kcl), "--qemu-vsock=yes", verb, diff --git a/tests/test_initrd.py b/tests/test_initrd.py index c2327734e..6df167ec5 100644 --- a/tests/test_initrd.py +++ b/tests/test_initrd.py @@ -58,7 +58,7 @@ def test_initrd(initrd: Image) -> None: with Image( initrd.config, options=[ - "--initrd", Path(initrd.output_dir.name) / "initrd", + "--initrd", Path(initrd.output_dir) / "initrd", "--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service", "--incremental", "--ephemeral", @@ -93,7 +93,7 @@ def test_initrd_lvm(initrd: Image) -> None: with Image( initrd.config, options=[ - "--initrd", Path(initrd.output_dir.name) / "initrd", + "--initrd", Path(initrd.output_dir) / "initrd", "--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service", "--kernel-command-line=root=LABEL=root", "--kernel-command-line=rw", @@ -104,7 +104,7 @@ def test_initrd_lvm(initrd: Image) -> None: ) as image, contextlib.ExitStack() as stack: image.build(["--format", "directory"]) - drive = Path(image.output_dir.name) / "image.raw" + drive = Path(image.output_dir) / "image.raw" drive.touch() os.truncate(drive, 5000 * 1024**2) @@ -125,7 +125,7 @@ def test_initrd_lvm(initrd: Image) -> None: with tempfile.TemporaryDirectory() as mnt, mount(Path("/dev/vg_mkosi/lv0"), Path(mnt)): # The image might have been built unprivileged so we need to fix the file ownership. Making all the # files owned by root isn't completely correct but good enough for the purposes of the test. - copy_tree(Path(image.output_dir.name) / "image", Path(mnt), preserve=False) + copy_tree(Path(image.output_dir) / "image", Path(mnt), preserve=False) stack.close() @@ -179,7 +179,7 @@ def test_initrd_luks(initrd: Image, passphrase: Path) -> None: with Image( initrd.config, options=[ - "--initrd", Path(initrd.output_dir.name) / "initrd", + "--initrd", Path(initrd.output_dir) / "initrd", "--repart-dir", repartd, "--passphrase", passphrase, "--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service", @@ -201,7 +201,7 @@ def test_initrd_luks_lvm(config: Image.Config, initrd: Image, passphrase: Path) with Image( config, options=[ - "--initrd", Path(initrd.output_dir.name) / "initrd", + "--initrd", Path(initrd.output_dir) / "initrd", "--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service", "--kernel-command-line=root=LABEL=root", "--kernel-command-line=rw", @@ -213,7 +213,7 @@ def test_initrd_luks_lvm(config: Image.Config, initrd: Image, passphrase: Path) ) as image, contextlib.ExitStack() as stack: image.build(["--format", "directory"]) - drive = Path(image.output_dir.name) / "image.raw" + drive = Path(image.output_dir) / "image.raw" drive.touch() os.truncate(drive, 5000 * 1024**2) @@ -248,7 +248,7 @@ def test_initrd_luks_lvm(config: Image.Config, initrd: Image, passphrase: Path) with tempfile.TemporaryDirectory() as mnt, mount(Path("/dev/vg_mkosi/lv0"), Path(mnt)): # The image might have been built unprivileged so we need to fix the file ownership. Making all the # files owned by root isn't completely correct but good enough for the purposes of the test. - copy_tree(Path(image.output_dir.name) / "image", Path(mnt), preserve=False) + copy_tree(Path(image.output_dir) / "image", Path(mnt), preserve=False) stack.close() @@ -268,4 +268,4 @@ def test_initrd_size(initrd: Image) -> None: Distribution.opensuse: 39, }.get(initrd.config.distribution, 48) - assert (Path(initrd.output_dir.name) / "initrd").stat().st_size <= maxsize + assert (Path(initrd.output_dir) / "initrd").stat().st_size <= maxsize diff --git a/tests/test_sysext.py b/tests/test_sysext.py index 39ecec036..122f1c880 100644 --- a/tests/test_sysext.py +++ b/tests/test_sysext.py @@ -24,7 +24,7 @@ def test_sysext(config: Image.Config) -> None: image.config, options=[ "--directory", "", - "--base-tree", Path(image.output_dir.name) / "image", + "--base-tree", Path(image.output_dir) / "image", "--overlay", "--package=dnsmasq", "--format=disk",