File tree Expand file tree Collapse file tree 11 files changed +86
-8
lines changed Expand file tree Collapse file tree 11 files changed +86
-8
lines changed Original file line number Diff line number Diff line change 1
1
.cosa
2
2
target
3
3
! target /dev-rootfs
4
+ # These directories don't contribute to our container build
5
+ docs /
6
+ plans /
Original file line number Diff line number Diff line change
1
+ name : Python static analysis
2
+ on : [push, pull_request]
3
+ jobs :
4
+ ruff :
5
+ runs-on : ubuntu-latest
6
+ steps :
7
+ - uses : actions/checkout@v4
8
+ - uses : chartboost/ruff-action@v1
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ test-tmt:
38
38
validate :
39
39
cargo fmt
40
40
cargo clippy
41
+ ruff check
41
42
.PHONY : validate
42
43
43
44
vendor :
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
set -xeu
3
- case " $1 " in
3
+ variant=$1
4
+ # I'm a big fan of nushell for interactive use, and I want to support
5
+ # using it in our test suite because it's better than bash. First,
6
+ # enable EPEL to get it.
7
+ . /usr/lib/os-release
8
+ if echo $ID_LIKE $ID | grep -q centos; then
9
+ dnf config-manager --set-enabled crb
10
+ dnf -y install epel-release epel-next-release
11
+ fi
12
+ # Ensure this is pre-created
13
+ mkdir -p -m 0700 /var/roothome
14
+ mkdir -p ~ /.config/nushell
15
+ echo ' $env.config = { show_banner: false, }' > ~ /.config/nushell/config.nu
16
+ touch ~ /.config/nushell/env.nu
17
+ dnf -y install nu
18
+ # And we also add pytest, to support running tests written in Python
19
+ dnf -y install python3-pytest
20
+ case " $variant " in
4
21
tmt)
5
22
# tmt wants rsync
6
- dnf -y install cloud-init rsync && dnf clean all
23
+ dnf -y install cloud-init rsync
7
24
ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants
8
25
# And tmt wants to write to /usr/local/bin
9
26
rm /usr/local -rf && ln -sr /var/usrlocal /usr/local && mkdir -p /var/usrlocal/bin
@@ -14,3 +31,4 @@ case "$1" in
14
31
echo " Unknown variant: $1 " exit 1
15
32
;;
16
33
esac
34
+ dnf clean all && rm /var/log/* -rf
Original file line number Diff line number Diff line change 1
- # This tmt test just demonstrates local tmt usage.
2
- # We'll hopefully expand it to do more interesting things in the
3
- # future and unify with the other test plans.
1
+ # Run this via `make test-tmt` which will build a container,
2
+ # and a disk image from it.
4
3
provision:
5
4
how: virtual
6
- # Generated by `cargo xtask `
5
+ # Generated by make test-tmt
7
6
image: file://./target/testvm/disk.qcow2
8
7
disk: 20
9
- summary: Basic smoke test
8
+ summary: Execute booted tests
10
9
execute:
11
10
how: tmt
12
- script: bootc status
11
+ # There's currently two dynamic test frameworks; python and nushell.
12
+ # python is well known and understood. nushell is less well known, but
13
+ # is quite nice for running subprocesses and the like while making
14
+ # it easy to parse JSON etc.
15
+ script: |
16
+ set -xeu
17
+ pytest tests/booted/*.py
18
+ ls tests/booted/*-test-*.nu |sort -n | while read t; do nu $t; done
Original file line number Diff line number Diff line change
1
+ __pycache__
Original file line number Diff line number Diff line change
1
+ use std assert
2
+ use tap .nu
3
+
4
+ tap begin " verify bootc status --json looks sane"
5
+
6
+ let st = bootc status -- json | from json
7
+ assert equal $st.apiVersion org.containers.bootc/v1alpha1
8
+ tap ok
Original file line number Diff line number Diff line change
1
+ # Booted tests
2
+
3
+ These are intended to run via tmt; use e.g.
4
+ ` make test-tmt ` .
Original file line number Diff line number Diff line change
1
+ # Tests which are read-only/nondestructive
2
+
3
+ import json
4
+ import subprocess
5
+
6
+ def run (* args ):
7
+ subprocess .check_call (* args )
8
+
9
+ def test_bootc_status ():
10
+ o = subprocess .check_output (["bootc" , "status" , "--json" ])
11
+ st = json .loads (o )
12
+ assert st ['apiVersion' ] == 'org.containers.bootc/v1alpha1'
Original file line number Diff line number Diff line change
1
+ # A simple nushell "library" for the
2
+ # "Test anything protocol":
3
+ # https://testanything.org/tap-version-14-specification.html
4
+ export def begin [description ] {
5
+ print " TAP version 14"
6
+ print $description
7
+ }
8
+
9
+ export def ok [] {
10
+ print " ok"
11
+ }
12
+
13
+ export def fail [] {
14
+ print " not ok"
15
+ }
You can’t perform that action at this time.
0 commit comments