Skip to content

Commit 3c0677a

Browse files
authored
Merge pull request #223 from yfyf/release-validation-finalizations
Release validation test finalizations
2 parents 1cca7b8 + 9758ea8 commit 3c0677a

File tree

3 files changed

+68
-15
lines changed

3 files changed

+68
-15
lines changed

.github/workflows/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ jobs:
4444
steps:
4545
- uses: actions/checkout@v4
4646
- uses: ./.github/actions/prep-build-env
47+
- name: Make magic-nix-cache read-only by removing post-build-hook
48+
run: sed -i '/post-build-hook = magic-nix-cache-build-hook/d' $HOME/.config/nix/nix.conf
4749
- run: NIXPKGS_ALLOW_UNFREE=1 nix-build -A driverInteractive ${{ matrix.file }}
4850

4951

Readme.md

+38-3
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,17 @@ Building a complete system takes time, so it is a good idea to test at the compo
105105

106106
### Automated Testing
107107

108-
There are 3 types of tests:
108+
There are 4 types of automated tests:
109109

110110
- unit tests (used in kiosk and controller)
111-
- subcomponent integration tests (see below)
112-
- end-to-end system level tests (see below)
111+
- subcomponent integration tests
112+
- end-to-end system level tests
113+
- release validation tests
114+
115+
All but the last are run on each commit via Github Actions.
116+
117+
See subsections below for more details on each test type.
118+
113119

114120
#### Subcomponent (integration) tests
115121

@@ -150,6 +156,35 @@ run 10x slower. If you see `failed to initialize KVM` in the console logs, it
150156
means there's a problem. See [this (outdated) Github issue](https://github.com/NixOS/nixpkgs/issues/124371#issue-900719073)
151157
for more details.
152158

159+
160+
#### Release validation (self-update) test
161+
162+
The release validation test is used to perform the final _automated_ checks before
163+
manually testing and officially publishing a release.
164+
165+
Currently it tests only one critical path: the self-update scenario from an
166+
earlier release (the 'base' system) to the current/upcoming release (the 'next'
167+
system).
168+
169+
The test does not alter the configuration of the base or next systems' in any way
170+
(e.g. no test-instrumentation.nix extras, which are present in end-to-end
171+
tests).
172+
173+
To run the tests against the previous release, execute:
174+
175+
nix-build testing/release-validation.nix
176+
177+
To test against a specific base system (e.g. `2023.9.1-DISK`), add the flag
178+
`--arg baseSystemVersion '"2023.9.1-DISK"'`.
179+
180+
Compressed base system disk images are created for every tagged release using
181+
`./build release-disk` and the [release](.github/workflows/release-tag.yml)
182+
Github workflow. See the "Test disk" links in [release
183+
summaries](https://github.com/dividat/playos/releases).
184+
185+
For more details, see the comments in
186+
[testing/release-validation.nix](testing/release-validation.nix).
187+
153188
## Deployment
154189

155190
Update bundles are hosted on Amazon S3. The script `bin/deploy-update` will handle signing and uploading of bundle.

testing/release-validation.nix

+28-12
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,22 @@
2424
# - execute "sendkey ctrl-shift-f1" (switch to TTY1)
2525
# - login with "root"
2626
let
27-
baseS3URL = "https://dividat-playos-test-disks.s3.amazonaws.com/by-tag";
27+
# Note: we use HTTP instead of HTTPS, because pkgs.fetchurl fails
28+
# when __structuredAttrs is enabled (due to mysterious OpenSSL/TLS errors)
29+
# and also fails when __structuredAttrs is disabled (due to
30+
# https://github.com/NixOS/nixpkgs/issues/177660).
31+
# HTTP usage is fine since the output hash is fixed and verifies the download.
32+
baseS3URL = "http://dividat-playos-test-disks.s3.amazonaws.com/by-tag";
2833
# Generated via ./build release-disk and .github/workflows/release-tag.yml
2934
# See https://github.com/dividat/playos/releases
3035
diskImageURLs = {
31-
"1.0.0-TEST" = {
32-
url = "${baseS3URL}/playos-disk-1.0.0-TEST.img.zst";
33-
hash = "sha256-7cyStGfsxVyQ2ugkI9XRFnNrnPhd5QRf+oAQxLu3ovM=";
36+
"2023.9.1-DISK" = {
37+
url = "${baseS3URL}/playos-release-disk-2023.9.1-DISK.img.zst";
38+
hash = "sha256-eTyNcDkYSsMUsUHToZJ4tEKag9WSi8gA2SAihFFCqH0=";
39+
};
40+
"2024.7.0-DISK" = {
41+
url = "${baseS3URL}/playos-release-disk-2024.7.0-DISK.img.zst";
42+
hash = "sha256-vJDB99ICt0W1PmONikNY5wwIF7oQU388DzYRgPqkooY=";
3443
};
3544
};
3645
in
@@ -48,9 +57,9 @@ in
4857
kioskUrlDomain ? "kiosk-server.local",
4958

5059
# PlayOS system we are updating from
51-
baseSystemVersion ? "1.0.0-TEST",
60+
baseSystemVersion ? "2024.7.0-DISK",
5261

53-
# A downloadable URL containing a zstd compressed disk image
62+
# A zstd-compressed PlayOS disk image
5463
baseSystemDiskImage ? (pkgs.fetchurl diskImageURLs.${baseSystemVersion})
5564
.overrideAttrs {
5665
__structuredAttrs = true;
@@ -150,20 +159,23 @@ pkgs.testers.runNixOSTest {
150159
"-monitor" "vc"
151160
];
152161

153-
enableOCR = true;
154-
155162
extraPythonPackages = ps: [
156163
ps.colorama
157164
ps.types-colorama
158165
ps.requests
159166
ps.types-requests
160167
ps.tesserocr
168+
ps.pillow
169+
ps.types-pillow
161170
];
162171

163172
testScript = {nodes}: ''
164173
${builtins.readFile ./helpers/nixos-test-script-helpers.py}
165174
${builtins.readFile ./end-to-end/tests/base/proxy-and-update-helpers.py}
166175
import tesserocr # type: ignore
176+
import PIL.Image
177+
import PIL.ImageEnhance
178+
import PIL.ImageOps
167179
import tempfile
168180
import time
169181
import atexit
@@ -191,13 +203,17 @@ extract_base_system_disk("${baseSystemDiskImage}", "${overlayPath}")
191203
playos.start(allow_reboot=True)
192204
sidekick.start()
193205
194-
# Less accurate, but much faster OCR than NixOS `get_screen_text`,
195-
# which takes almost 20 seconds per call.
196-
# Fails to identify white text on dark backgrounds.
206+
# Faster OCR than NixOS `get_screen_text`, which takes almost 20 seconds per
207+
# call. Fails to identify white text on dark backgrounds.
197208
def screenshot_and_ocr(vm):
198209
with tempfile.TemporaryDirectory() as d:
199210
vm.screenshot(d + "/screenshot.png")
200-
return tesserocr.file_to_text(d + "/screenshot.png")
211+
im = PIL.Image.open(d + "/screenshot.png")
212+
im = PIL.ImageOps.grayscale(im)
213+
im = PIL.ImageEnhance.Brightness(im).enhance(1.5)
214+
im = PIL.ImageEnhance.Contrast(im).enhance(4.0)
215+
return tesserocr.image_to_text(im)
216+
201217
202218
def wait_until_passes(test, retries=10, sleep=1):
203219
while True:

0 commit comments

Comments
 (0)