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

Release disk and validation test fixes #218

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .github/workflows/gen-release-summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ echo -e "

## Artifacts

- Test disk: [https://dividat-playos-test-disks.s3.amazonaws.com/by-tag/playos-disk-$RELEASE_TAG.img.zst](https://dividat-playos-test-disks.s3.amazonaws.com/by-tag/playos-disk-$RELEASE_TAG.img.zst)
- Test disk: [https://dividat-playos-test-disks.s3.amazonaws.com/by-tag/playos-release-disk-$RELEASE_TAG.img.zst](https://dividat-playos-test-disks.s3.amazonaws.com/by-tag/playos-release-disk-$RELEASE_TAG.img.zst)

## Changelog

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/upload-test-disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RELEASE_TAG="$1"

set -euo pipefail
set -x
disk_path="$(readlink ./result/playos-disk-$RELEASE_TAG.img)"
target_url="s3://dividat-playos-test-disks/by-tag/playos-disk-$RELEASE_TAG.img.zst"
echo "Compressing and uploading test disk to: $target_url"
zstd --stdout "$disk_path" | aws s3 cp - "$target_url"
disk_path="$(readlink ./result/playos-release-disk-$RELEASE_TAG.img.zst)"
target_url="s3://dividat-playos-test-disks/by-tag/playos-release-disk-$RELEASE_TAG.img.zst"
echo "Uploading test disk to: $target_url"
aws s3 cp "$disk_path" "$target_url"
11 changes: 9 additions & 2 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,22 @@ elif [ "$TARGET" == "test-e2e" ]; then
# builds a disk to be used as a base image in ./testing/release-validation.nix
elif [ "$TARGET" == "release-disk" ]; then

echo -e "
Building release disk image for release validation tests.

Note: requires around 30GiB of free space for storing the intermediate disk
images. The final compressed disk image is much smaller (~4 GiB).
"

(set -x; nix-build \
--arg kioskUrl "http://kiosk-server.local/" \
--arg updateUrl "http://update-server.local/" \
--arg buildVm false \
--arg buildInstaller false \
--arg buildBundle false \
--arg buildLive false \
--arg buildDisk true \
--arg extraModules '[ ./testing/system/passwordless-root.nix ]'
--arg buildDisk false \
--arg buildReleaseDisk true
)

elif [ "$TARGET" == "all" ]; then
Expand Down
30 changes: 16 additions & 14 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ in

, applicationPath ? ./application.nix

# extra modules to include in the systemImage, used in ./build release-disk
, extraModules ? [ ]

##### Allow disabling the build of unused artifacts when developing/testing #####
, buildVm ? true
, buildInstaller ? true
, buildBundle ? true
, buildDisk ? true
, buildReleaseDisk ? false
, buildLive ? true
, buildTest ? false
}:
Expand All @@ -40,7 +38,8 @@ let
});

# lib.makeScope returns consistent set of packages that depend on each other
mkComponents = { application, rescueSystemOpts ? {}, diskBuildEnabled ? buildDisk }: (with pkgs; lib.makeScope newScope (self: with self; {
mkComponents = { application, extraModules ? [ ], rescueSystemOpts ? {}, diskBuildEnabled ? buildDisk }:
(with pkgs; lib.makeScope newScope (self: with self; {

inherit updateUrl deployUrl kioskUrl;
inherit (application) version safeProductName fullProductName;
Expand Down Expand Up @@ -111,19 +110,19 @@ let

testComponents = mkComponents {
diskBuildEnabled = true;
application = {
inherit (application) safeProductName fullProductName greeting overlays;
version = "${application.version}-TEST";
module = {
imports = [
application.module
./testing/end-to-end/profile.nix
];
};
};
application = application // { version = "${application.version}-TEST"; };
extraModules = [ ./testing/end-to-end/profile.nix ];
rescueSystemOpts = { squashfsCompressionOpts = "-no-compression"; };
};

releaseDiskComponents = mkComponents {
inherit application;
extraModules = [ ./testing/system/passwordless-root.nix ];
};

releaseDisk = pkgs.callPackage ./testing/disk/release.nix {
inherit (releaseDiskComponents) install-playos;
};
in

with pkgs; stdenv.mkDerivation {
Expand Down Expand Up @@ -154,6 +153,9 @@ with pkgs; stdenv.mkDerivation {
+ lib.optionalString buildDisk ''
ln -s ${components.disk} $out/${components.safeProductName}-disk-${components.version}.img
''
+ lib.optionalString buildReleaseDisk ''
ln -s ${releaseDisk} $out/${components.safeProductName}-release-disk-${components.version}.img.zst
''
# Installer ISO image
+ lib.optionalString buildInstaller ''
ln -s ${components.installer}/iso/${components.safeProductName}-installer-${components.version}.iso $out/${components.safeProductName}-installer-${components.version}.iso
Expand Down
52 changes: 52 additions & 0 deletions testing/disk/release.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Similarly to testing/disk/default.nix, this builds a disk image containing
# a full PlayOS installation, with these differences:
# - It uses default system and boot partition sizes. Total disk size is ~20 GiB
# - It produces a (sparsified) qcow2 image rather than a raw one. This reduces
# the image size to ~8GiB
# - It compresses the final image using zstd to reduce disk usage.
# Final compressed file size is around ~4GiB.
{ pkgs
, lib
, install-playos
}:
with pkgs;
with lib;
let
# all sizes in MiB
partSizes = {
boot = 525; # 525 MiB (matches install-playos default)
system = 1024 * 9; # 9 GiB (install-playos default - 1GiB)
data = 400; # 400 MiB (same as testing/disk/default.nix)
};
diskSizeMiB = 8 + partSizes."boot" + partSizes."data" + (partSizes."system" * 2) + 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In testing/disk/default.nix, diskSizeMiB is:

diskSizeMiB = 10 + bootPartSizeMiB + dataPartSizeMiB + systemPartSizeMiB*2;

Is there a reason to have 9 additional MiB here, and 10 in the other file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I am not sure why I set it to 10 in testing/disk/default.nix - probably did it without much thought.

Here the +8MiB and +1MiB match the initial disk alignment sector size and extra space requirements as defined in install-playos.py.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update testing/disk/default.nix and use the same logic, using 8 + … + 1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do it in a separate PR, it is not related to these changes.

in
vmTools.runInLinuxVM (
runCommand "build-playos-release-disk"
{
buildInputs = [install-playos];

preVM = ''
diskImage=nixos.raw
truncate -s ${toString diskSizeMiB}MiB $diskImage
'';

postVM = ''
mkdir -p $out
${pkgs.qemu}/bin/qemu-img convert -f raw -O qcow2 $diskImage $out/playos-disk.img
rm $diskImage
${pkgs.zstd}/bin/zstd --rm -f $out/playos-disk.img -o $out/playos-disk.img.zst
diskImage=$out/playos-disk.img.zst
'';
memSize = 1024;
}
''
# machine-id of development image is hardcoded.
install-playos \
--device /dev/vda \
--machine-id "f414cca8312548d29689ebf287fb67e0" \
--partition-size-boot ${toString partSizes."boot"} \
--partition-size-system ${toString partSizes."system"} \
--partition-size-data ${toString partSizes."data"} \
--no-confirm
''
) + "/playos-disk.img.zst"