From 0e7f5d9e7baecf016ee3b28a34fa614d27d67062 Mon Sep 17 00:00:00 2001 From: Sanne Raymaekers Date: Thu, 14 Aug 2025 13:17:31 +0200 Subject: [PATCH] plans: add gating tests This tmt[0] test runs the playwright tests as gating tests. Having the gating tests upstream avoids duplication across fedora and centos dist-git repositories, and running them upstream should keep them in working order. Only add x86_64 for now, the aarch runners seem to be a bit too slow. [0]: https://tmt.readthedocs.io/en/stable/index.html --- .fmf/version | 1 + packit.yaml | 10 +++++++++- plans/all.fmf | 14 ++++++++++++++ schutzbot/playwright.fmf | 8 ++++++++ schutzbot/playwright_tests.sh | 35 +++++++++++++++++++---------------- 5 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 .fmf/version create mode 100644 plans/all.fmf create mode 100644 schutzbot/playwright.fmf diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/packit.yaml b/packit.yaml index bd019940..2cbf432b 100644 --- a/packit.yaml +++ b/packit.yaml @@ -16,6 +16,15 @@ srpm_build_deps: - npm jobs: + - job: tests + identifier: self + trigger: pull_request + tmt_plan: /plans/all/main + targets: + - centos-stream-10 + - fedora-41 + - fedora-42 + - job: copr_build trigger: pull_request targets: &build_targets @@ -24,7 +33,6 @@ jobs: - centos-stream-10 - centos-stream-10-aarch64 - fedora-all - - fedora-all-aarch64 - job: copr_build trigger: commit diff --git a/plans/all.fmf b/plans/all.fmf new file mode 100644 index 00000000..66deae89 --- /dev/null +++ b/plans/all.fmf @@ -0,0 +1,14 @@ +summary: cockpit-image-builder playwright tests +prepare: + how: install + package: + - cockpit-image-builder +discover: + how: fmf +execute: + how: tmt + +/main: + summary: playwright tests + discover+: + test: /schutzbot/playwright diff --git a/schutzbot/playwright.fmf b/schutzbot/playwright.fmf new file mode 100644 index 00000000..bbc5721a --- /dev/null +++ b/schutzbot/playwright.fmf @@ -0,0 +1,8 @@ +summary: run playwright tests +test: ./playwright_tests.sh +require: + - cockpit-image-builder + - podman + - nodejs + - nodejs-npm +duration: 30m diff --git a/schutzbot/playwright_tests.sh b/schutzbot/playwright_tests.sh index d6a5a87f..2ad039e4 100755 --- a/schutzbot/playwright_tests.sh +++ b/schutzbot/playwright_tests.sh @@ -1,16 +1,16 @@ #!/bin/bash set -euo pipefail -# As playwright isn't supported on fedora/el, install dependencies -# beforehand. -sudo dnf install -y \ - alsa-lib \ - libXrandr-devel \ - libXdamage-devel \ - libXcomposite-devel \ - at-spi2-atk-devel \ - cups \ - atk +TMT_SOURCE_DIR=${TMT_SOURCE_DIR:-} +if [ -n "$TMT_SOURCE_DIR" ]; then + # Move to the directory with sources + cd "${TMT_SOURCE_DIR}/cockpit-image-builder" + npm ci +elif [ "${CI:-}" != "true" ]; then + # packit drops us into the schutzbot directory + cd ../ + npm ci +fi sudo systemctl enable --now cockpit.socket @@ -19,10 +19,13 @@ sudo usermod -aG wheel admin echo "admin ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee "/etc/sudoers.d/admin-nopasswd" function upload_artifacts { - mkdir -p /tmp/artifacts/extra-screenshots - USER="$(whoami)" - sudo chown -R "$USER:$USER" playwright-report - mv playwright-report /tmp/artifacts/ + if [ -n "${TMT_TEST_DATA:-}" ]; then + mv playwright-report "$TMT_TEST_DATA"/playwright-report + else + USER="$(whoami)" + sudo chown -R "$USER:$USER" playwright-report + mv playwright-report /tmp/artifacts/ + fi } trap upload_artifacts EXIT @@ -73,8 +76,8 @@ sudo podman run \ -e "CI=true" \ -e "PLAYWRIGHT_USER=admin" \ -e "PLAYWRIGHT_PASSWORD=foobar" \ - -e "CURRENTS_PROJECT_ID=$CURRENTS_PROJECT_ID" \ - -e "CURRENTS_RECORD_KEY=$CURRENTS_RECORD_KEY" \ + -e "CURRENTS_PROJECT_ID=${CURRENTS_PROJECT_ID:-}" \ + -e "CURRENTS_RECORD_KEY=${CURRENTS_RECORD_KEY:-}" \ --net=host \ -v "$PWD:/tests" \ -v '/etc:/etc' \