From d16fcab2eafc1cdd8d41f2998ea4b9aed9795a14 Mon Sep 17 00:00:00 2001 From: Michael Vasseur Date: Wed, 20 Nov 2024 17:48:28 +0100 Subject: [PATCH] Run chroot tests in GHA We ran those in GitLab but now that the integration test works we can also move those. The crossbuilding fails but this is more related to the runners (although it also fails locally) as the container is still the same. After discussion we don't really care for this feature so I left 1 to check that the flag works but this is building the same as the hostarchitecture. The debootstrap.log is not uploaded for now. Don't crossbuild but only test 1 --- {gitlab => .github/jobs}/chroot.bats | 4 +- .github/jobs/chroot_checks.sh | 55 ++++++++++++++++++++++++++++ .github/workflows/chroot-checks.yml | 30 +++++++++++++++ .gitlab-ci.yml | 2 - gitlab/chroot_checks.sh | 45 ----------------------- gitlab/ci/misc.yml | 17 --------- 6 files changed, 87 insertions(+), 66 deletions(-) rename {gitlab => .github/jobs}/chroot.bats (94%) create mode 100755 .github/jobs/chroot_checks.sh create mode 100644 .github/workflows/chroot-checks.yml delete mode 100755 gitlab/chroot_checks.sh delete mode 100644 gitlab/ci/misc.yml diff --git a/gitlab/chroot.bats b/.github/jobs/chroot.bats similarity index 94% rename from gitlab/chroot.bats rename to .github/jobs/chroot.bats index f27013a97d..a6f0d7bdc0 100644 --- a/gitlab/chroot.bats +++ b/.github/jobs/chroot.bats @@ -3,8 +3,8 @@ load 'assert' CHROOT="/chroot/domjudge" -if [ -n "${CI_JOB_ID+x}" ]; then - CHROOT="/builds/DOMjudge/domjudge${CHROOT}" +if [ -n "${GITHUB_REPOSITORY+x}" ]; then + CHROOT="/__w/domjudge/domjudge${CHROOT}" fi # Cleanup old dir rm -rf $CHROOT diff --git a/.github/jobs/chroot_checks.sh b/.github/jobs/chroot_checks.sh new file mode 100755 index 0000000000..57989ee67c --- /dev/null +++ b/.github/jobs/chroot_checks.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +. .github/jobs/ci_settings.sh + +if [ -n "$1" ] && [ "$1" != "default" ]; then +export ARCH="$1" +fi + +function finish() { + echo -e "\\n\\n=======================================================\\n" + echo "Storing artifacts..." + trace_on + set +e + cp /proc/cmdline "$ARTIFACTS/cmdline" + cp /__w/domjudge/domjudge/chroot/domjudge/etc/apt/sources.list "$ARTIFACTS/sources.list" + cp /__w/domjudge/domjudge/chroot/domjudge/debootstrap/debootstrap.log "$ARTIFACTS/debootstrap.log" +} + +FAILED=0 + +trap finish EXIT + +DIR=$PWD +section_start "Debug info" +lsb_release -a | tee -a "$ARTIFACTS/debug-info" +mount | tee -a "$ARTIFACTS/debug-info" +whoami | tee -a "$ARTIFACTS/debug-info" +echo "Dir: $DIR" | tee -a "$ARTIFACTS/debug-info" +section_end + +section_start "Basic judgehost install" +chown -R domjudge ./ + +# configure, make and install (but skip documentation) +sudo -u domjudge make configure +sudo -u domjudge ./configure --with-baseurl='http://localhost/domjudge/' --with-domjudge-user=domjudge --with-judgehost_chrootdir=${DIR}/chroot/domjudge |& tee "$ARTIFACTS/configure.log" +sudo -u domjudge make judgehost |& tee "$ARTIFACTS/make.log" +make install-judgehost |& tee -a "$ARTIFACTS/make.log" +section_end setup + +section_start "Configure chroot" + +cd /opt/domjudge/judgehost/bin || exit 1 +section_end chroot + +section_start "Show minimal chroot" +./dj_make_chroot -a "$ARCH" | tee -a "$ARTIFACTS"/chroot.log +section_end + +section_start "Test chroot contents" +set -xe +cp ${DIR}/submit/assert.bash . +cp ${DIR}/.github/jobs/chroot.bats . +bats ./chroot.bats +section_end diff --git a/.github/workflows/chroot-checks.yml b/.github/workflows/chroot-checks.yml new file mode 100644 index 0000000000..7dc3901121 --- /dev/null +++ b/.github/workflows/chroot-checks.yml @@ -0,0 +1,30 @@ +name: Chroot checks +on: + push: + pull_request: + branches: + - main + - '[0-9]+.[0-9]+' + +jobs: + check-chroot-arch: + runs-on: ubuntu-latest + container: + image: domjudge/gitlabci:24.04 + options: --privileged --cgroupns=host --init + strategy: + matrix: + arch: [amd64, default] + steps: + - name: Checkout current code + uses: actions/checkout@v4 + - name: Install DOMjudge + run: | + .github/jobs/chroot_checks.sh ${{ matrix.arch }} + - name: Upload all logs/artifacts + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.arch }}-logs + path: | + /tmp/artifacts diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 18ef56d2a9..9f73622022 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,9 @@ include: - '/gitlab/ci/unit.yml' - '/gitlab/ci/template.yml' - - '/gitlab/ci/misc.yml' stages: - test - - chroot_checks - unit - style - ci_checks diff --git a/gitlab/chroot_checks.sh b/gitlab/chroot_checks.sh deleted file mode 100755 index d16adefaed..0000000000 --- a/gitlab/chroot_checks.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -. gitlab/ci_settings.sh - -function finish() { - echo -e "\\n\\n=======================================================\\n" - echo "Storing artifacts..." - trace_on - set +e - cp /proc/cmdline "$GITLABARTIFACTS/cmdline" - cp /chroot/domjudge/etc/apt/sources.list "$GITLABARTIFACTS/sources.list" - cp /chroot/domjudge/debootstrap/debootstrap.log "$GITLABARTIFACTS/debootstrap.log" -} -trap finish EXIT - -section_start setup "Setup and install" -lsb_release -a - -# configure, make and install (but skip documentation) -make configure -./configure --with-baseurl='http://localhost/domjudge/' --with-domjudge-user=domjudge --with-judgehost_chrootdir=${DIR}/chroot/domjudge |& tee "$GITLABARTIFACTS/configure.log" -make judgehost |& tee "$GITLABARTIFACTS/make.log" -sudo make install-judgehost |& tee -a "$GITLABARTIFACTS/make.log" -section_end setup - -section_start mount "Show runner mounts" -# Currently gitlab has some runners with noexec/nodev, -# This can be removed if we have more stable runners. -mount -o remount,exec,dev /builds -section_end mount - -section_start chroot "Configure chroot" - -if [ -e ${DIR}/chroot/domjudge ]; then - rm -rf ${DIR}/chroot/domjudge -fi - -cd ${DIR}/misc-tools || exit 1 -section_end chroot - -section_start chroottest "Test chroot contents" -cp ${DIR}/submit/assert.bash ./ -cp ${DIR}/gitlab/chroot.bats ./ -bats ./chroot.bats -section_end chroottest diff --git a/gitlab/ci/misc.yml b/gitlab/ci/misc.yml deleted file mode 100644 index f6d6448c3d..0000000000 --- a/gitlab/ci/misc.yml +++ /dev/null @@ -1,17 +0,0 @@ -run chroot script checks: - extends: [.normal_job] - stage: chroot_checks - when: manual - allow_failure: true - parallel: - matrix: - - PLACEHOLDER: - - trigger_with_default_values - - ARCH: - - amd64 - - arm64 - - armhf - - i386 - script: - - ./gitlab/chroot_checks.sh -