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..9390ffc703 --- /dev/null +++ b/.github/jobs/chroot_checks.sh @@ -0,0 +1,51 @@ +#!/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 "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..d1f578f363 --- /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, arm64, armhf, i386, 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 -