Commit graph

744 commits

Author SHA1 Message Date
Major Hayden
73429035bc CI: Use RHEL 8 CDN image
Now that we have a fully subscribed RHEL 8 image, let's use that instead
of RHEL 8.2 nightlies.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-28 07:00:00 +02:00
Jacob Kozol
9cbedc0496 sources: fix break when secrets is None
When the urls' secrets field is not set, an error is thrown when trying
to get the name of the secrets. The secrets now have a default value of
{} when they are checked for the name.
2020-05-24 11:08:05 +02:00
Major Hayden
89b9e541e2
Add sudo to dnf list command
Bringing over the fix from ansible-osbuild
2020-05-22 14:04:26 -05:00
Major Hayden
0640610f54 Remove RPM builds in GitHub Workflows
We are now building RPMs via mock in Jenkins, so we don't need these RPM
build jobs in GitHub Workflows.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-22 09:00:01 -05:00
Major Hayden
d8c43bc0e7 Build in a mock chroot first
Build the RPMs in a mock using a simple script so that ansible-osbuild
can focus fully on deployment rather than compiling RPMs.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-22 10:41:10 +02:00
Major Hayden
53ba692dbe GH Actions: Use upstream Fedora containers
Work around the quay.io issues by using the standard Fedora containers.
Also, make most of the dnf operations a little quieter to make it easier
to find problems.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-22 10:39:51 +02:00
Christian Kellner
2fa594f334 15
This completes the development of osbuild version 15.
2020-05-20 21:44:58 +02:00
Christian Kellner
b696eba640 NEWS.md: update for osbuild version 15
Major changes are the new assembler, support for passing client
certificates to access Red Hat content in the files source and
the shiny new ManifestPreProcessor.
2020-05-20 21:44:58 +02:00
Christian Kellner
7c9b44ce88 assemblers: add new org.osbuild.oci-archive
Add a new assembler that takes a tree and creates a Open Container
Initiative[2] image according to the OCI image format[2]. The final
result is a tarball, aka a "orci-archive", that can be pulled into
podman with `podman pull oci-archive:<archive>`. Currently the only
required options are `filename` and `architecture`.

[1] https://www.opencontainers.org/
[2 ]https://github.com/opencontainers/image-spec/
2020-05-20 20:05:22 +02:00
Christian Kellner
869973dc68 pipeline: drop {tree, output}_id from --inspect js
We want to get rid of `tree_id` and `output_id` because the they
are now considered internals of the store and clients should not
use them directly. NB: they are still there indirectly as the id
of the last stage and the assembler.
Also, the `output_id` was never correct here, because it was the
`tree_id` as well. Ups.
2020-05-20 18:54:56 +02:00
David Rheinsberg
7dcc946fe2 test: add F32 manifests and a manifest-preprocessor
This adds F32 manifests in ./test/data/. To avoid magically deducing the
package list out of the void, this adds a ManifestPreProcessor (MPP)
called `./tools/mpp-depsolve.py`. What this does is it takes a manifest
on stdin, modifies it, and produces a manifest on stdout.

The `mpp-depsolve.py` preprocessor takes a manifest and modifies all the
`org.osbuild.rpm` stages. It parses a new option to that stage called
`mpp-depsolve`, which contains a package-list, a repo-list, and dnf
metadata. It then drops this `mpp-depsolve` option (since it would be an
invalid manifest otherwise), depsolves the packages, inserts a proper
"packages" option as well as appends the correct paths to the sources
entry.

With this in place, this adds `mpp-f32-base.json` and
`mpp-f32-build.json` in ./test/data/manifests/. These will then be used
as base F32 manifests for our test-suite.

Lastly, this adds `./test/data/README.md` as a place to document the
files we place in `./test/data/`, since most of the files do not allow
for comments.
2020-05-20 18:54:38 +02:00
David Rheinsberg
0ffae822ce ci: run test-src with ghci
Use the GHCI image to run `make test-src`. This makes sure all our
dependencies are available (including `dnf`, `hawkey`, and other python
packages).
2020-05-20 18:54:38 +02:00
Jacob Kozol
372b1174f2 sources: add rhsm secret support to files
When osbuild is given a manifest, the sources' urls can contain fields
for both a url path and a secret for that url. If the secret is
org.osbuild.rhsm the system's rhsm certificates are retrieved. These
certs are included when the files are curled.
2020-05-20 18:52:35 +02:00
Jacob Kozol
2309b54eb3 sources: reduce whitespace in files cp command 2020-05-20 18:52:35 +02:00
Christian Kellner
192430bd30 assemblers/ostree.commit: support archiving
Introduce a new `tar` option, which when given together with the
required `tar.filename` option, will result in the output of the
assembler being a tarball that contains the repo and the compose
information (`compose.json`).
Requires the `tar` command to be present in the build root. Modify
the sample to use that option and include the tar for the build
pipeline.
2020-05-20 14:47:40 +02:00
David Rheinsberg
c84f5280c1 test: convert to new osbuild executor
Convert the pipeline tests to the new osbuild executor. This will remove
the last users of the "output_id" and "tree_id" identifiers from
osbuild.
2020-05-20 14:44:43 +02:00
David Rheinsberg
845148993c test: add tree-diff accessor
The `tree-diff` tool currently requires access to our local checkout,
since we do not install the tool. Provide accessors in `TestBase` so we
do not hard-code the path everywhere.
2020-05-20 14:44:43 +02:00
David Rheinsberg
20beabf431 test: add new osbuild executor
Add a new OSBuild class to `./test/test.py`. This class is an extension
of `./test/osbuildtest.py`, but no longer requires the `output_id` and
`tree_id` identifiers of osbuild.

Furthermore, this new executor uses context-managers to make sure any
temporary object is only accessed for a contained time-frame.
2020-05-20 14:44:43 +02:00
David Rheinsberg
9dfa0e8a61 pipeline: only copy output if there is any
Make sure to verify that the pipeline actually produced any output
before attempting to copy it out. This fixes osbuild running with
`--output-directory` but without assembler.
2020-05-20 14:44:43 +02:00
Christian Kellner
1896047bae sources: pass the library dir to the sources
The idea is that source can themselves spawn other modules, esp.
new secrets modules. For this they need to know the library dir,
aka 'libdir' throughout the osbuild source. Therefore change the
SourceServer to directly get the library directory instead of
just the sub-directory to the sources. Then pass the library
directory to via the JSON API to the source.
Adjust all usage of the SourceServer, including the tests.
2020-05-20 14:43:33 +02:00
Major Hayden
5620d5080a CI: Remove old jenkins.osbuild.org configuation
Signed-off-by: Major Hayden <major@redhat.com>
2020-05-18 09:30:39 -05:00
Major Hayden
05802951eb CI: Add image testing on Fedora 32
Signed-off-by: Major Hayden <major@redhat.com>
2020-05-18 09:30:39 -05:00
Major Hayden
96d3b7aa9d Bring jenkinsfile in line with osbuild-composer
Add the artifact preservation bits from the osbuild-composer jenkinsfile
and use the shared `run_tests()` function to avoid repeating ourselves.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-15 17:50:45 +02:00
Major Hayden
9f060bdc83 Enable testing on RHEL 8.2
Signed-off-by: Major Hayden <major@redhat.com>
2020-05-15 17:50:45 +02:00
David Rheinsberg
5d1519758f news: reformat according to markdown
The NEWS file currently uses non-markdown indentation, but uses the
markdown file-format. Since both GitHub-Repository-Viewer and the
Release Pages can display proper markdown, lets just re-indent the file
according to the markdown specs.

While at it, also switch out the list-indicator in front of the
timestamp to a proper hyphen, to avoid it being rendered as list.
2020-05-15 09:34:44 +02:00
Major Hayden
7e8ff16d7c CI: Use Jenkins' merged repo for testing
When Jenkins clones a repository for testing, it does the base clone
first and then merges the code from the PR afterwards. This ensures that
the code merges properly and is tested properly, but it also makes a SHA
that only exists inside Jenkins. 😢

Tell ansible-osbuild to use the repository that Jenkins made so that the
SHA is valid.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-14 09:01:45 -05:00
Major Hayden
6b9cd099f5
Quick fix: switch jenkins > schutzbot in CI
The `jenkins/` directory has been removed in `osbuild-composer`.
2020-05-13 16:36:32 -05:00
Major Hayden
b613afb168 CI: Build RPMs in a mock chroot
Tell ansible-osbuild to build osbuild/osbuild-composer RPMs in a mock
chroot and install them from there instead of building them with
Ansible.

This brings us closer to how koji and brew build RPMs.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-13 16:19:32 -05:00
David Rheinsberg
134376d8da ci: move test_boot to github-actions
Move the `test_boot` test from Travis over to the Github-Actions based
CI. This is the last test on Travis, and the Travis CI can now be
disabled, if we so wish.

This test leaves a valid `travis.yml` file around, since Travis will
still be enabled on the repository. We should first disable Travis and
then drop this file, if we want to get rid of it.
2020-05-13 22:00:27 +02:00
David Rheinsberg
cd95a8a167 ci: use osbuild/containers images
Use the images provided by `osbuild/containers` tagged as GHCI (GitHub
CI). These images are fully under our control, cached on the GitHub
infrastructure, and prepared to run `systemd-nspawn` and friends in a
docker container.

The GHCI infrastructure is versioned. New updates to the CI
infrastructure are not automatically picked up. Instead, the `v1` tag
has to be explicitly redirected to new image builds to deploy them. If
a new deployment causes CI failures, we can simply redirect the `v1` tag
back to the previous image builds and get the previous behavior back.

The `osbuild/containers` repository contains the required
infrastructure for this logic. If new dependencies are required in the
CI environment, the respective Dockerfiles must be updated. As a
temporary workaround (e.g., as part of a PR that introduces this), you
can simply add `dnf install -y <package>` to the required entries in
`.github/workflows/*`.
2020-05-13 22:00:27 +02:00
David Rheinsberg
15e4d0d3a1 test/assemblers: do not fail on modprobe failure
This changes the `modprobe nbd` invocation to be non-fatal on failure,
since it might very well fail on reasonable setups. `modprobe` fails if
it cannot find a module in `/lib/modules`, even if it could reasonably
well figure out whether a module is already loaded. The reason is that
it needs the metadata from the module file to find the required modules
parameters.

If you have `nbd` already loaded but not mapped in `/lib/modules`, the
current call will cause test failures, even though the test would run
smoothly.

Fix this by never requiring `modprobe nbd` to succeed, but instead rely
on the tests failing if accessing `nbd` fails.
2020-05-13 22:00:27 +02:00
David Rheinsberg
ad50259ace test: drop unused 'testing-rpms'
This drops the directory './test/testing-rpms'. The directory was
introduced in:

    commit d975effc42
    Author: Martin Sehnoutka <sehnoutka.martin@gmail.com>
    Date:   Thu Jul 25 11:12:27 2019 +0200

        improve vagrant test and its documentation

It used to be the automatic target directory to store rpms created via
`make copy-rpms-to-test`. This target no longer exists. It was dropped
in:

    commit 59b7b545b2
    Author: Lars Karlitski <lars@karlitski.net>
    Date:   Fri Mar 6 11:07:52 2020 +0100

        Makefile: remove vagrant rules
2020-05-13 22:00:27 +02:00
David Rheinsberg
082b840d94 test: integrate pylint into the test infrastructure
Introduce a third test-group called `src` alongside `mod` and `run.
This will contain tests that run against the source code of osbuild.

This initial commit introduces `test/src/test_pylint.py` which will run
the python linter against all our sources.
2020-05-13 14:26:05 +02:00
David Rheinsberg
b830bb7480 test: convert os-release-tests to test-data
Use the new `locate_test_data()` helper to get access to test-data.
Guard the test with `have_test_data()` to skip it in case test-data
access is not available.
2020-05-13 14:26:05 +02:00
David Rheinsberg
5c0e6f5964 test: convert to shared helpers
Use the `can_modify_immutable()` helper from the TestBase parent class
so we do not duplicate the code in multiple places. Similarly, make use
of the `have_rpm_ostree()` helper.
2020-05-13 14:26:05 +02:00
David Rheinsberg
851d949027 test: add base class for tests
Add a new base class called `TestBase` to our test-suite. This allows
sharing common code between our tests without requiring them to import
each other. Furthermore, it paves the way towards executing all our
tests as part of the `unittest` framework, including pylint and others.

For now, this adds the following features to `TestBase`:

  * Common test-guards that are shared between our tests, like
    `can_modify_immutable()` or `have_rpm_ostree()`.

  * Accessors to the test-checkout. This is `have_test_checkout()` to
    check whether the running test has a repository checkout, and
    `locate_test_checkout()` to get a path to the repository checkout.
    This will allow us to put pylint and friends into the unittest
    framework, guard them properly, and still allow running the tests
    from a global install which might not have access to a checkout.

    For now, we always assume we run from a checkout.

  * Accessors to test-data. If we start installing tests as a module
    into the system, we cannot bundle test-data together with code.
    Therefore, two accessors `have_test_data()` and `locate_test_data()`
    are implemented to guard access to test data. If a checkout is
    available, it will be used to locate test-data.

    In the future, we want to be able to pass a separate path to the
    test-data, thus allowing us to install tests into a system.
2020-05-13 14:26:05 +02:00
David Rheinsberg
d4f40362ec buildroot: drop kwargs from buildroot.run()
Drop the `kwargs` forwarding from buildroot.run() to subprocess.run().
We do not use it other than for `stdin=subprocess.DEVNULL`. Set that
option directly instead.

Doing the kwargs forwarding mixes the argument namespaces and is very
hard to read. It is not clear from the call-site which argument goes to
buildroot.run() and which to subprocess.run().

Lastly, it requires us to manually fetch `check` just to make pylint
happy. Lets just drop this dance and make the API explicit.
2020-05-13 14:17:30 +02:00
Christian Kellner
016d520dda meta: use draft 4 of jsonschema to validate
We currently don't seem to use anything that requires us to use
the draft 7 of the specification. The minimum version that we
need is draft 4, which is also supported by the python-jsonschema
version in RHEL 8.2 (which is 2.6.0).
2020-05-12 22:00:38 +02:00
Christian Kellner
20a4ba45c6 schema/osbuild1.json: convert to draft4 standard
The 'required' array with an empty is the only thing that requires
this to be draft6 (or higher) [1]. Remove that and downgrade the
schema to draft4 [2].
[1] https://json-schema.org/draft-06/json-schema-release-notes.html
[2] https://json-schema.org/specification-links.html#draft-4
2020-05-12 22:00:38 +02:00
David Rheinsberg
bc437520cd tmpfs: drop unused module
The osbuild/tmpfs.py module is unused. Drop it.
2020-05-12 11:14:16 +02:00
Major Hayden
6e2865fc63 Test with internal Jenkins in parallel
Attempt osbuild testing on the internal Jenkins deployment with
nodes that are destroyed after each use. The internal Jenkins looks for
a Jenkinsfile inside the `schutzbot` directory.

Let's not remove the `jenkins` directory (used by jenkins.osbuild.org)
yet until we know the internal Jenkins is stable and performs well.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-12 08:09:44 +02:00
David Rheinsberg
8a195d7502 util/ctx: extract suppress_oserror()
Extract the `suppress_oserror()` function from the ObjectManager and
make it available as utility for other code as well.

This also adds a bunch of tests that verify it works as expected.
2020-05-11 18:05:12 +02:00
David Rheinsberg
6e02488a9f test/boot: use -chardev file over -chardev stdio
This changes `-chardev stdio` to `-chardev file` and uses a temporary
file to communicate with QEMU.

This fixes an issue where `-chardev stdio` hangs if `STDIN` is not a
TTY. I could not figure out how to make it work without a TTY, and it
does not print any meaningful diagnostics. Problem is, in CI and other
automated runners, we do not necessarily have a TTY as STDIN.

This just switches to a temporary file, which seems to work under all
circumstances.
2020-05-07 20:27:26 +02:00
David Rheinsberg
19c74c3e8d cli: drop --build-env argument
Drop the --build-env command-line argument. It is not used by anything.
Furthermore, our manifests now allow embedding build-environments, so
there is little reason to continue supporting this.
2020-05-07 19:52:33 +02:00
Christian Kellner
f2a3423caa 14
This completes the development of osbuild version 14.
2020-05-06 20:18:15 +02:00
Christian Kellner
f4470ace84 NEWS.md: prepare for osbuild release 14
Major changes are the schema validation, the `--inspect` command
line option and the way the osbuild module is being found inside
the container.
2020-05-06 20:18:15 +02:00
Christian Kellner
4b7c68fcdf spec: simplify module inclusion code
Now that as a result of commit 4d2f15f all symlinks have been
dropped from the individual module paths, the search for module
contents can be simplified again.
2020-05-06 20:18:15 +02:00
Christian Kellner
9fce523f76 main_cli: pass proper libdir to meta.Index
In case `--libdir` is not specified on the command line, and thus
`args.libdir` is `None`, pass the standard `/usr/lib/osbuild` path
to the meta.Index constructor. Otherwise no schema information can
be found.
2020-05-06 20:18:15 +02:00
Major Hayden
5516102fdb 🚽 Use Jenkins pipeline for better flow
By using a small Jenkins pipeline in the repository, we can define
almost all of our testing parameters in the repo itself and not inside
Jenkins. 🥳

This also allows us to use the GitHub Branch Source plugin and
auto-discover new repositories without `ok to test` bombs in
pull requests.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-06 12:06:12 -05:00
Christian Kellner
f3a4b2dfbf test/osbuild: add checks for Schema class
Basic checks that `Schema`, initialization with no, an invalid
and a valid schema. Check the latter can be used to do validation.
2020-05-06 15:42:23 +02:00