diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.gitignore b/.gitignore index 3c87b13..62ae47b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,32 @@ /gpg-117E8C168EFE3A7F.key /weldr-client-35.1.tar.gz +/weldr-client-35.2.tar.gz +/weldr-client-35.2.tar.gz.asc +/weldr-client-35.3.tar.gz +/weldr-client-35.3.tar.gz.asc +/weldr-client-35.4.tar.gz +/weldr-client-35.4.tar.gz.asc +/weldr-client-35.5.tar.gz +/weldr-client-35.5.tar.gz.asc +/weldr-client-35.6.tar.gz +/weldr-client-35.6.tar.gz.asc +/weldr-client-35.7.tar.gz +/weldr-client-35.7.tar.gz.asc +/weldr-client-35.8.tar.gz +/weldr-client-35.8.tar.gz.asc +/weldr-client-35.9.tar.gz +/weldr-client-35.9.tar.gz.asc +/weldr-client-35.10.tar.gz +/weldr-client-35.10.tar.gz.asc +/weldr-client-35.11.tar.gz +/weldr-client-35.11.tar.gz.asc +/weldr-client-35.12.tar.gz +/weldr-client-35.12.tar.gz.asc +/weldr-client-35.13.tar.gz +/weldr-client-35.13.tar.gz.asc +/weldr-client-35.14.tar.gz +/weldr-client-35.14.tar.gz.asc +/weldr-client-36.0.tar.gz +/weldr-client-36.0.tar.gz.asc +/weldr-client-36.1.tar.gz +/weldr-client-36.1.tar.gz.asc diff --git a/0001-tests-Skip-checking-arch-when-testing-sent-body.patch b/0001-tests-Skip-checking-arch-when-testing-sent-body.patch new file mode 100644 index 0000000..affb1aa --- /dev/null +++ b/0001-tests-Skip-checking-arch-when-testing-sent-body.patch @@ -0,0 +1,48 @@ +From 6815aa4a2a0b2bd376d0f6e072580a9c60086e3e Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Thu, 14 Aug 2025 09:26:25 -0700 +Subject: [PATCH] tests: Skip checking arch when testing sent body + +The host architecture is included in the body of the request, skip +checking for the specific arch in order to keep the tests architecture +independent. + +Related: RHEL-60137 +--- + cmd/composer-cli/projects/info_test.go | 4 +++- + cmd/composer-cli/projects/list_test.go | 4 +++- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/cmd/composer-cli/projects/info_test.go b/cmd/composer-cli/projects/info_test.go +index 3f9a85f..dd2a78c 100644 +--- a/cmd/composer-cli/projects/info_test.go ++++ b/cmd/composer-cli/projects/info_test.go +@@ -457,7 +457,9 @@ func TestCmdProjectsInfoCloud(t *testing.T) { + sentBody, err := io.ReadAll(mcc.Req.Body) + assert.Nil(t, mcc.Req.Body.Close()) + require.Nil(t, err) +- assert.Contains(t, string(sentBody), `{"distribution":"homer","architecture":"x86_64","packages":["tmux"]}`) ++ // NOTE: sentBody also contains arch specific architecture, skip checking that. ++ assert.Contains(t, string(sentBody), `"distribution":"homer"`) ++ assert.Contains(t, string(sentBody), `"packages":["tmux"]`) + assert.Equal(t, "application/json", mcc.Req.Header.Get("Content-Type")) + assert.Equal(t, "/api/image-builder-composer/v2/search/packages", mcc.Req.URL.Path) + } +diff --git a/cmd/composer-cli/projects/list_test.go b/cmd/composer-cli/projects/list_test.go +index b809224..386b793 100644 +--- a/cmd/composer-cli/projects/list_test.go ++++ b/cmd/composer-cli/projects/list_test.go +@@ -363,7 +363,9 @@ func TestCmdProjectsListCloud(t *testing.T) { + sentBody, err := io.ReadAll(mcc.Req.Body) + assert.Nil(t, mcc.Req.Body.Close()) + require.Nil(t, err) +- assert.Contains(t, string(sentBody), `{"distribution":"homer","architecture":"x86_64","packages":["*"]}`) ++ // NOTE: sentBody also contains arch specific architecture, skip checking that. ++ assert.Contains(t, string(sentBody), `"distribution":"homer"`) ++ assert.Contains(t, string(sentBody), `"packages":["*"]`) + assert.Equal(t, "application/json", mcc.Req.Header.Get("Content-Type")) + assert.Equal(t, "/api/image-builder-composer/v2/search/packages", mcc.Req.URL.Path) + } +-- +2.50.1 + diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..0c1cc35 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,7 @@ +--- !Policy +product_versions: + - fedora-* +decision_contexts: [bodhi_update_push_stable] +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} diff --git a/plans/integration-tests.fmf b/plans/integration-tests.fmf new file mode 100644 index 0000000..f1de00b --- /dev/null +++ b/plans/integration-tests.fmf @@ -0,0 +1,10 @@ +summary: Run integration tests +prepare: + how: install + package: + - osbuild-composer + - weldr-client + - weldr-client-tests + - createrepo_c +execute: + script: ./tests/scripts/run_tests.sh ./tests/ diff --git a/sources b/sources index b219810..9a05ef2 100644 --- a/sources +++ b/sources @@ -1,2 +1,3 @@ -SHA512 (gpg-117E8C168EFE3A7F.key) = 36712a4e05cbb2ca139e777d8b2abe4ee0536f970208c2c2c1a50a2294979b828a9d6abcbad1dce3cc015a0c4364ab87ab04cb459811ad3aca5cf6611093b9bd -SHA512 (weldr-client-35.1.tar.gz) = 8508b446c44eae917710083c8185054e3a89f799723b71e2d0069ce35c653ea2adabcab3b8d7d9a903f127798368933ba765c603ebed4fe3f6c6187c032a793c +SHA512 (weldr-client-36.1.tar.gz) = 52bac9879b73e3137d434a9c46a2914e0446ed63db14c9176cbd2a47aaf10a757a905a138401208958631237d354a7689035fd5a68297720431b212151eabd4d +SHA512 (weldr-client-36.1.tar.gz.asc) = 0d0fd65355356aaac2eb8052c182f619d8d7da5c6af164d7b3da97b2fc0b4435d6e4cff2b81914e99e8f094a518432dd0b769e28fba4c90b8a9453326d6b3f1a +SHA512 (gpg-117E8C168EFE3A7F.key) = cbbf218fe4427bd16f64b60cafd8c98bc3b073c25cfe2c19f03405ebfbf88ac05f0a3fa4e44afbbc514616b426008bc1e76b4e3ea49825a6ece4ad63638bb52b diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh new file mode 100755 index 0000000..6437f65 --- /dev/null +++ b/tests/scripts/run_tests.sh @@ -0,0 +1,67 @@ +#!/bin/bash +set -eux + +FAILANY=0 + +function fail { + echo -e "\n\n#### ERROR: $1\n" + FAIL=1 + FAILANY=1 +} + +function status { + if [ "$FAIL" -eq 0 ]; then + echo -e "\n\n#### PASS: $1\n" + else + echo -e "\n\n#### FAIL: $1\n" + fi +} + +function running { + FAIL=0 + echo -e "\n\n#### RUN: $1\n" +} + +backend_start() { + export BACKEND="osbuild-composer" + systemctl start osbuild-composer.socket + RET=$? + + if [ "$RET" -eq 0 ]; then + # wait for the backend to become ready + tries=0 + until curl -m 15 --unix-socket /run/weldr/api.socket http://localhost:4000/api/status | grep 'db_supported.*true'; do + echo "#### INFO: Waiting for backend to become ready. Try $tries ..." + tries=$((tries + 1)) + if [ $tries -gt 50 ]; then + fail "Backend taking too long to become ready" + # Log why starting osbuild-composer failed + journalctl -u osbuild-composer + exit 1 + fi + sleep 10 + done + else + fail "Unable to start composer backend (exit code $RET)" + # Log why starting osbuild-composer failed + journalctl -u osbuild-composer + exit $RET + fi +} + +: ${1?"Usage: $0 TOPDIR"} +TOPDIR=$1 + +# What versions of things do we have installed? +rpm -q weldr-client osbuild osbuild-composer + +composer-cli version || fail "Getting composer-cli version" + +# Start osbuild-composer +backend_start + +composer-cli status show || fail "Getting osbuild-composer status" + +/usr/libexec/tests/composer-cli/composer-cli-tests -test.v || fail "Running integration tests" + +exit $FAILANY diff --git a/weldr-client-35.1.tar.gz.asc b/weldr-client-35.1.tar.gz.asc deleted file mode 100644 index df7d102..0000000 --- a/weldr-client-35.1.tar.gz.asc +++ /dev/null @@ -1,11 +0,0 @@ ------BEGIN PGP SIGNATURE----- - -iQEzBAABCgAdFiEEtMa0UeT6i0IyyhkeEX6MFo7+On8FAmB0v1oACgkQEX6MFo7+ -On/fBQgAheXV7RRzQEKiYTc53dNKY2+jTzy++W2BpBnpMVIkcu8LjSLQ9sD2AF5o -90aeeTnMs4o2YKjInj2Rl/TfnA0JfHl+es/QcpKwM6Tl7Znn9570hRy10JuRojSe -4Lq8wxcr8m5oxAzE1UAvz4ws0xdgHwvhPJJUfMNXANj5BX7M/5A3493zDAkwvQ9H -3VdPenPgZk2nwjml0IgtTR+sRn1aJC0yXYtcP2bAlOV3sAklVkIGhL3E9bh78Bbj -oRCN50Bw3jrFmhisfT1HhKtW0B64mg12uIXAqi0S471O4eiy4cF6SFh9L5bSqaTZ -Zw1nTyzykUR0DCtQ6n/Vcqo7jl8Fsw== -=YWa+ ------END PGP SIGNATURE----- diff --git a/weldr-client.spec b/weldr-client.spec index 59ec9c9..82def08 100644 --- a/weldr-client.spec +++ b/weldr-client.spec @@ -1,23 +1,29 @@ -# Pass --with tests to rpmbuild to build composer-cli-tests -%bcond_with tests +# Pass --without tests to skip building composer-cli-tests +%bcond_without tests +# Pass --without signed to skip gpg signed tar.gz (DO NOT DO THAT IN PRODUCTION) +%bcond_without signed -%global goipath github.com/osbuild/weldr-client +%global goipath github.com/osbuild/weldr-client/v2 Name: weldr-client -Version: 35.1 -Release: 2%{?dist} +Version: 36.1 +Release: 1%{?dist} # Upstream license specification: Apache-2.0 -License: ASL 2.0 +License: Apache-2.0 Summary: Command line utility to control osbuild-composer + +%gometa Url: %{gourl} Source0: https://github.com/osbuild/weldr-client/releases/download/v%{version}/%{name}-%{version}.tar.gz +%if %{with signed} Source1: https://github.com/osbuild/weldr-client/releases/download/v%{version}/%{name}-%{version}.tar.gz.asc Source2: https://keys.openpgp.org/vks/v1/by-fingerprint/117E8C168EFE3A7F#/gpg-117E8C168EFE3A7F.key +%endif Obsoletes: composer-cli < 35.0 Provides: composer-cli = %{version}-%{release} -%gometa +Requires: diffutils BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} %if 0%{?fedora} @@ -37,7 +43,9 @@ BuildRequires: gnupg2 Command line utility to control osbuild-composer %prep +%if %{with signed} %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}' +%endif %if 0%{?rhel} %forgeautosetup -p1 %else @@ -45,6 +53,8 @@ Command line utility to control osbuild-composer %endif %build +export LDFLAGS="-X %{goipath}/cmd/composer-cli/root.Version=%{version} " + %if 0%{?rhel} GO_BUILD_PATH=$PWD/_build install -m 0755 -vd $(dirname $GO_BUILD_PATH/src/%{goipath}) @@ -58,28 +68,23 @@ export GOFLAGS=-mod=vendor export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}" export GO111MODULE=off %endif +%gobuild -o composer-cli %{goipath}/cmd/composer-cli -export LDFLAGS="-X github.com/osbuild/weldr-client/cmd/composer-cli/root.Version=%{version} " -make GOBUILDFLAGS="%{gobuildflags}" build ## TODO ##make man %if %{with tests} || 0%{?rhel} +export BUILDTAGS="integration" + # Build test binaries with `go test -c`, so that they can take advantage of -# golang's testing package. The golang rpm macros don't support building them +# golang's testing package. The RHEL golang rpm macros don't support building them # directly. Thus, do it manually, taking care to also include a build id. # -# On Fedora, also turn off go modules and set the path to the one into which +# On Fedora go modules have already been turned off, and the path set to the one into which # the golang-* packages install source code. -%if 0%{?fedora} -export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}" -export GO111MODULE=off -%endif - -export LDFLAGS="-X github.com/osbuild/weldr-client/cmd/composer-cli/root.Version=%{version} " -export BUILDTAGS="integration" -make GOBUILDFLAGS="%{gobuildflags}" integration +export LDFLAGS="${LDFLAGS:-} -linkmode=external -compressdwarf=false -B 0x$(od -N 20 -An -tx1 -w100 /dev/urandom | tr -d ' ')" +go test -c -tags=integration -buildmode pie -compiler gc -ldflags="${LDFLAGS}" -o composer-cli-tests %{goipath}/weldr %endif %install @@ -95,8 +100,10 @@ export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}" export GO111MODULE=off %endif -export LDFLAGS="-X github.com/osbuild/weldr-client/cmd/composer-cli/root.Version=%{version} " -make GOBUILDFLAGS="%{gotestflags}" test +# Run the unit tests +export LDFLAGS="-X %{goipath}/cmd/composer-cli/root.Version=%{version} " +make test + %files %license LICENSE @@ -110,6 +117,8 @@ make GOBUILDFLAGS="%{gotestflags}" test %package tests Summary: Integration tests for composer-cli +Requires: createrepo_c + %description tests Integration tests to be run on a pristine-dedicated system to test the composer-cli package. @@ -121,24 +130,12 @@ composer-cli package. %changelog -* Thu Apr 22 2021 Brian C. Lane - 35.1-2 -- Obsolete composer-cli < 35.0 instead of 34.0 - Patch until next upstream release - -* Mon Apr 12 2021 Brian C. Lane - 35.1-1 -- New release: 35.1 (bcl) -- spec: Change release back to 1 (bcl) -- spec: Move testify BuildRequires into fedora block (bcl) -- vendor: Add vendored dependencies for RHEL (bcl) -- tools: Add prepare-source.sh vendoring helper script (bcl) -- Makefile: skip vendor directory for check target (bcl) -- spec: Bump release to 2 (bcl) -- spec: Fix BuildRequires for tests (bcl) -- Makefile: Remove executable from bash completion (bcl) -- Makefile: Only use GOBUILDFLAGS (bcl) -- spec: Bump release to 2 (bcl) -- spec: Add doc files (bcl) -- spec: Add gpg signature verification (bcl) -- spec: Use git-core instead of git (bcl) -- spec: Set License to Apache 2.0 (bcl) -- spec: Update Source urls with new project location (bcl) +* Wed Oct 15 2025 Brian C. Lane - 36.1-1 +- New release: 36.1 (bcl) +- build(deps): bump actions/setup-go from 5 to 6 (49699333+dependabot[bot]) +- build(deps): bump github.com/spf13/cobra from 1.9.1 to 1.10.1 (49699333+dependabot[bot]) +- test: iot-qcow2-image does not support packages (bcl) +- test: qcow2 renamed to server-qcow2 (bcl) +- build(deps): bump github.com/stretchr/testify from 1.10.0 to 1.11.1 (49699333+dependabot[bot]) +- build(deps): bump actions/checkout from 4 to 5 (49699333+dependabot[bot]) +- tests: Use current host arch in info and list tests (bcl) \ No newline at end of file