Skip to content

Commit 69395c3

Browse files
committed
Updates to build sys and CONTRIBUTING.md
The emphasis here is on trying to have the `Justfile` be the default entrypoint, wrapping other tools. - Replace mentions of podman-bootc with bcvk since I hope the latter supercedes the former - Unify the unit test entrypoint - Set up /var/tmp as a tmpdir to fix the etc merge test (otherwise, selinux failures w/tmp) - Run the unit+container tests in integration.yml - Have `just validate` run in a container Signed-off-by: Colin Walters <[email protected]>
1 parent 25f9b81 commit 69395c3

File tree

8 files changed

+157
-87
lines changed

8 files changed

+157
-87
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,21 @@ concurrency:
1818
cancel-in-progress: true
1919

2020
jobs:
21-
tests:
22-
runs-on: ubuntu-latest
23-
container: quay.io/coreos-assembler/fcos-buildroot:testing-devel
24-
steps:
25-
- uses: actions/checkout@v4
26-
- name: Install deps
27-
run: ./ci/installdeps.sh
28-
- name: Mark git checkout as safe
29-
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
30-
# xref containers/containers-image-proxy-rs
31-
- name: Cache Dependencies
32-
uses: Swatinem/rust-cache@v2
33-
with:
34-
key: "tests"
35-
- name: make validate-rust
36-
# the ruff checks are covered via a dedicated action
37-
run: make validate-rust
38-
- name: Run tests
39-
run: cargo test -- --nocapture --quiet
40-
- name: Manpage generation
41-
run: cargo xtask update-generated
42-
- name: Clippy (gate on correctness and suspicous)
43-
run: make validate-rust
44-
fedora-container-tests:
21+
# Wrapper for validation
22+
validate:
4523
runs-on: ubuntu-24.04
4624
steps:
4725
- name: Get a newer podman for heredoc support (from debian testing)
4826
run: |
4927
set -eux
5028
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
5129
sudo apt update
52-
sudo apt install -y crun/testing podman/testing skopeo/testing
53-
- name: Installdeps
54-
run: sudo apt update && sudo apt install just
30+
sudo apt install -y crun/testing podman/testing skopeo/testing just
5531
- uses: actions/checkout@v4
56-
- name: Build and run container integration tests
57-
run: |
58-
sudo just build
59-
sudo just run-container-integration run-container-external-tests
32+
- name: Free up disk space on runner
33+
run: sudo ./ci/clean-gha-runner.sh
34+
- name: Validate (default)
35+
run: just validate
6036
container-continuous:
6137
runs-on: ubuntu-24.04
6238
steps:
@@ -65,10 +41,12 @@ jobs:
6541
set -eux
6642
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
6743
sudo apt update
68-
sudo apt install -y crun/testing podman/testing skopeo/testing
44+
sudo apt install -y crun/testing podman/testing skopeo/testing just
6945
- name: Installdeps
7046
run: sudo apt update && sudo apt install just
7147
- uses: actions/checkout@v4
48+
- name: Free up disk space on runner
49+
run: sudo ./ci/clean-gha-runner.sh
7250
- name: Build with continuous repo enabled
7351
run: sudo just build --build-arg=continuous_repo=1
7452
cargo-deny:
@@ -89,7 +67,7 @@ jobs:
8967
set -eux
9068
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
9169
sudo apt update
92-
sudo apt install -y crun/testing podman/testing skopeo/testing
70+
sudo apt install -y crun/testing podman/testing skopeo/testing just
9371
- name: Checkout repository
9472
uses: actions/checkout@v4
9573
- name: Free up disk space on runner

.github/workflows/integration.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030
3131
- uses: actions/checkout@v4
3232

33+
- name: Free up disk space on runner
34+
run: sudo ./ci/clean-gha-runner.sh
35+
3336
- name: Set architecture variable
3437
id: set_arch
3538
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
@@ -38,6 +41,10 @@ jobs:
3841
run: |
3942
sudo tests/build.sh ${{ matrix.test_os }}
4043
44+
- name: Run container tests
45+
run:
46+
sudo just test-container
47+
4148
- name: Archive disk image
4249
uses: actions/upload-artifact@v4
4350
with:
@@ -52,11 +59,14 @@ jobs:
5259
matrix:
5360
test_os: [fedora-42, fedora-43, centos-9, centos-10]
5461

55-
runs-on: ubuntu-latest
62+
runs-on: ubuntu-24.04
5663

5764
steps:
5865
- uses: actions/checkout@v4
5966

67+
- name: Free up disk space on runner
68+
run: sudo ./ci/clean-gha-runner.sh
69+
6070
- name: Set architecture variable
6171
id: set_arch
6272
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
@@ -65,7 +75,7 @@ jobs:
6575
run: |
6676
sudo apt-get update
6777
# see https://tmt.readthedocs.io/en/stable/overview.html#install
68-
sudo apt install -y libkrb5-dev pkg-config libvirt-dev genisoimage qemu-kvm qemu-utils libvirt-daemon-system
78+
sudo apt install -y libkrb5-dev pkg-config libvirt-dev genisoimage qemu-kvm qemu-utils libvirt-daemon-system just
6979
pip install --user "tmt[provision-virtual]"
7080
7181
- name: Create folder to save disk image
@@ -87,9 +97,9 @@ jobs:
8797
- name: Workaround https://github.com/teemtee/testcloud/issues/18
8898
run: sudo rm -f /usr/bin/chcon && sudo ln -sr /usr/bin/true /usr/bin/chcon
8999

90-
- name: Run test
100+
- name: Run all TMT tests
91101
run: |
92-
tests/run-tmt.sh
102+
just test-tmt-nobuild
93103
94104
- name: Archive TMT logs
95105
if: always()

CONTRIBUTING.md

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,47 +34,68 @@ accepted!
3434
- A development environment (toolbox or a host) with a Rust and C compiler, etc.
3535
While this isn't specific to bootc, you will find the experience of working on Rust
3636
is greatly aided with use of e.g. [rust-analyzer](https://github.com/rust-lang/rust-analyzer/).
37-
- An installation of [podman-bootc](https://github.com/containers/podman-bootc-cli)
38-
which note on Linux requires that you set up "podman machine". This document
39-
assumes you have the environment variable `CONTAINER_CONNECTION` set to your
40-
podman machine's name.
37+
- Install [bcvk](https://github.com/bootc-dev/bcvk).
4138

4239
## Ensure you're familiar with a bootc system
4340

4441
Worth stating: before you start diving into the code you should understand using
4542
the system as a user and how it works. See the user documentation for that.
4643

47-
## Creating your edit-compile-debug cycle
44+
## Understanding the Justfile
4845

4946
Edit the source code; a simple thing to do is add e.g.
50-
`eprintln!("hello world);` into `run_from_opt` in [lib/src/cli.rs](lib/src/cli.rs).
47+
`eprintln!("hello world");` into `run_from_opt` in [crates/lib/src/cli.rs](cli.rs).
5148
You can run `make` or `cargo build` to build that locally. However, a key
5249
next step is to get that binary into a bootc container image.
5350

54-
Use e.g. `podman build -t localhost/bootc -f hack/Containerfile .`.
51+
Running `just` defaults to `just build` which will build a container
52+
from the current source code; the result will be named `localhost/bootc`.
5553

56-
From there, you can create and spawn a VM from that container image
57-
with your modified bootc code in exactly the same way as a systems operator
58-
would test their own bootc images:
54+
### Running an interactive shell in an environment from the container
5955

60-
```
61-
$ podman-bootc run localhost/bootc
62-
```
56+
You can of course `podman run --rm -ti localhost/bootc bash` to get a shell,
57+
and try running `bootc`.
58+
59+
### Running container-oriented integration tests
60+
61+
`just test-container`
62+
63+
### Running (TMT) integration tests
64+
65+
A common cycle here is you'll edit e.g. `deploy.rs` and want to run the
66+
tests that perform an upgrade:
67+
68+
`just test-tmt-one test-20-local-upgrade`
6369

6470
### Faster iteration cycles
6571

66-
You don't need to create a whole new VM for each change, of course.
67-
<https://github.com/containers/podman-bootc/pull/36> is an outstanding
68-
PR to add virtiofsd support, which would allow easily accessing the locally-built
69-
binaries. Another avenue we'll likely investigate is supporting podman-bootc
70-
accessing the container images which currently live in the podman-machine VM,
71-
or having a local registry which frontends the built container images.
72-
73-
A simple hack though (assuming your development environment is compatible
74-
with the target container host) is to just run a webserver on the host, e.g.
75-
`python3 -m http.server` or whatever, and then from the podman-bootc guest
76-
run `bootc usroverlay` once, and
77-
`curl -L -o /usr/bin/bootc http://10.0.1.2:8080/target/release/bootc && restorecon /usr/bin/bootc`.
72+
The test cycle currently builds a disk image and creates a new ephemeral
73+
VM for each test run.
74+
75+
You can shortcut some iteration cycles by having a more persistent
76+
environment where you run bootc.
77+
78+
#### Upgrading from the container image
79+
80+
One good approach is to create a persistent target virtual machine via e.g.
81+
`bcvk libvirt run` (or a cloud VM), and then after doing a `just build` and getting
82+
a container image, you can directly upgrade to that image.
83+
84+
For the local case, check out [cstor-dist](https://github.com/cgwalters/cstor-dist).
85+
Another alternative is mounting via virtiofs (see e.g. [this PR to bcvk](https://github.com/bootc-dev/bcvk/pull/16)).
86+
If you're using libvirt, see [this document](https://libvirt.org/kbase/virtiofs.html).
87+
88+
#### Running bootc against a live environment
89+
90+
If your development environment host is also a bootc system (e.g. a
91+
workstation or a virtual server) one way to shortcut some cycles is just
92+
to directly run the output of the built binary against your host.
93+
94+
Say for example your host is a Fedora 42 workstation (based on bootc),
95+
then you can `cargo b --release` directly in a Fedora 42 container
96+
or even on your host system, and then directly run e.g. `./target/release/bootc upgrade`
97+
etc.
98+
7899

79100
### Debugging via lldb
80101

Dockerfile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ARG initramfs=0
4444
# This installs our package dependencies, and we want to cache it independently of the rest.
4545
# Basically we don't want changing a .rs file to blow out the cache of packages. So we only
4646
# copy files necessary
47-
COPY contrib/packaging/bootc.spec /tmp/bootc.spec
47+
COPY contrib/packaging /tmp/packaging
4848
RUN <<EORUN
4949
set -xeuo pipefail
5050
. /usr/lib/os-release
@@ -54,9 +54,11 @@ case $ID in
5454
esac
5555
# Handle version skew, xref https://gitlab.com/redhat/centos-stream/containers/bootc/-/issues/1174
5656
dnf -y distro-sync ostree{,-libs} systemd
57-
dnf -y builddep /tmp/bootc.spec
58-
# Extra dependencies
59-
dnf -y install git-core
57+
# Install base build requirements
58+
dnf -y builddep /tmp/packaging/bootc.spec
59+
# And extra packages
60+
grep -Ev -e '^#' /tmp/packaging/fedora-extra.txt | xargs dnf -y install
61+
rm /tmp/packaging -rf
6062
EORUN
6163
# Now copy the rest of the source
6264
COPY --from=src /src /src
@@ -72,11 +74,16 @@ if test "${initramfs:-}" = 1; then
7274
fi
7375
EORUN
7476

75-
# This "build" just runs our unit tests
77+
# This "build" includes our unit tests
7678
FROM build as units
77-
ARG unitargs
78-
RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome \
79-
cargo test --locked $unitargs
79+
# A place that we're more likely to be able to set xattrs
80+
VOLUME /var/tmp
81+
ENV TMPDIR=/var/tmp
82+
RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome make install-unit-tests
83+
84+
# This just does syntax checking
85+
FROM build as validate
86+
RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome make validate
8087

8188
# The final image that derives from the original base and adds the release binaries
8289
FROM base

Justfile

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# The default entrypoint to working on this project.
22
# Commands here typically wrap e.g. `podman build` or
3-
# other tools which might launch e.g. VMs.
3+
# other tools like `bcvk` which might launch local virtual machines.
44
#
5-
# See also `Makefile`.
5+
# See also `Makefile` and `xtask.rs`. Commands which end in `-local`
6+
# skip containerization or virtualization.
7+
8+
# --------------------------------------------------------------------
69

710
# Build the container image from current sources.
811
# Note commonly you might want to override the base image via e.g.
@@ -20,16 +23,47 @@ build-integration-test-image *ARGS:
2023
build-install-test-image: build-integration-test-image
2124
cd hack && podman build -t localhost/bootc-integration-install -f Containerfile.drop-lbis
2225

23-
# Run container integration tests
24-
run-container-integration: build-integration-test-image
25-
podman run --rm localhost/bootc-integration bootc-integration-tests container
26-
27-
# These tests may spawn their own container images.
26+
# These tests accept the container image as input, and may spawn it.
2827
run-container-external-tests:
2928
./tests/container/run localhost/bootc
3029

31-
unittest *ARGS:
32-
podman build --jobs=4 --target units -t localhost/bootc-units --build-arg=unitargs={{ARGS}} .
30+
# We build the unit tests into a container image
31+
build-units:
32+
podman build --jobs=4 --target units -t localhost/bootc-units .
33+
34+
# Perform validation (build, linting) in a container build environment
35+
validate:
36+
podman build --jobs=4 --target validate .
37+
38+
# Directly run validation (build, linting) using host tools
39+
validate-local:
40+
make validate
41+
42+
# This generates a disk image (using bcvk) from the default container
43+
build-disk *ARGS:
44+
./tests/build.sh {{ARGS}}
45+
46+
# The tests which run a fully booted bootc system (i.e. where in place
47+
# updates are supported) as if it were a production environment use
48+
# https://github.com/teemtee/tmt.
49+
#
50+
# This task runs *all* of the tmt-based tests targeting the disk image generated
51+
# in the previous step.
52+
test-tmt *ARGS: build-disk
53+
./tests/run-tmt.sh {{ARGS}}
54+
55+
# Like test-tmt but assumes that a disk image is already built
56+
test-tmt-nobuild *ARGS:
57+
./tests/run-tmt.sh {{ARGS}}
58+
59+
# Run just one tmt test: `just test-tmt-one test-20-local-upgrade`
60+
test-tmt-one PLAN: build-disk
61+
./tests/run-tmt.sh plan --name {{PLAN}}
62+
63+
# Run tests (unit and integration) that are containerized
64+
test-container: build-units build-integration-test-image
65+
podman run --rm --read-only localhost/bootc-units /usr/bin/bootc-units
66+
podman run --rm localhost/bootc-integration bootc-integration-tests container
3367

3468
# Update all generated files (man pages and JSON schemas)
3569
#

Makefile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
# operate as part of "a build" that results in a bootc binary
99
# plus data files. The two key operations are `make`
1010
# and `make install`.
11-
# We expect code run from here is inside a container with low
11+
# We expect code run from here is (or can be) inside a container with low
1212
# privileges - running as a nonzero UID even.
13+
#
14+
# Understanding Makefile vs xtask.rs: Basically use xtask.rs if what
15+
# you're doing would turn into a mess of bash code, whether inline here
16+
# or externally in e.g. ./ci/somebashmess.sh etc.
1317

1418
prefix ?= /usr
1519

@@ -89,6 +93,16 @@ install-all: install install-ostree-hooks
8993
bin-archive: all
9094
$(MAKE) install DESTDIR=tmp-install && $(TAR_REPRODUCIBLE) --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf
9195

96+
build-unit-tests:
97+
cargo t --no-run
98+
99+
# We separate the build of the unit tests from actually running them in some cases
100+
install-unit-tests: build-unit-tests
101+
cargo t --no-run --frozen
102+
install -D -m 0755 -t $(DESTDIR)/usr/lib/bootc/units/ $$(cargo t --no-run --message-format=json | jq -r 'select(.profile.test == true and .executable != null) | .executable')
103+
install -d -m 0755 /usr/bin/
104+
echo -e '#!/bin/bash\nset -xeuo pipefail\nfor f in /usr/lib/bootc/units/*; do echo $$f && $$f; done' > $(DESTDIR)/usr/bin/bootc-units && chmod a+x $(DESTDIR)/usr/bin/bootc-units
105+
92106
test-bin-archive: all
93107
$(MAKE) install-all DESTDIR=tmp-install && $(TAR_REPRODUCIBLE) --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf
94108

@@ -98,23 +112,19 @@ test-bin-archive: all
98112
# We intentionally don't gate on this for local builds in cargo.toml
99113
# because it impedes iteration speed.
100114
CLIPPY_CONFIG = -A clippy::all -D clippy::correctness -D clippy::suspicious -D clippy::disallowed-methods -Dunused_imports -Ddead_code
101-
validate-rust:
115+
validate:
102116
cargo fmt -- --check -l
103117
cargo test --no-run
104118
(cd crates/ostree-ext && cargo check --no-default-features)
105119
(cd crates/lib && cargo check --no-default-features)
106120
cargo check --features=composefs-backend
107121
cargo clippy -- $(CLIPPY_CONFIG)
108122
env RUSTDOCFLAGS='-D warnings' cargo doc --lib
109-
.PHONY: validate-rust
123+
.PHONY: validate
110124
fix-rust:
111125
cargo clippy --fix --allow-dirty -- $(CLIPPY_CONFIG)
112126
.PHONY: fix-rust
113127

114-
validate: validate-rust
115-
ruff check
116-
.PHONY: validate
117-
118128
update-generated:
119129
cargo xtask update-generated
120130
.PHONY: update-generated

0 commit comments

Comments
 (0)