From a2f75963bfaf08857c8d8a33e898bfa58eb47d50 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 30 Oct 2022 15:08:36 +0100 Subject: [PATCH] CI: wiki: adjust for 'pmbootstrap ci' (MR 3608) Add a wrapper .ci/wiki.sh, that pmbootstrap ci can run and use it in gitlab-ci.yml. Add a .ci/lib/gitlab_prepare_ci.sh script that makes a user available with sudo, as expected by the pmbootstrap ci compatible scripts. Set up binfmt_misc too while at it, it will be needed for running pmbootstrap. The next patches will adjust the rest of the CI scripts and move the old scripts in the .ci/lib dir, so only the scripts that should be called directly are in the .ci dir. Related: https://postmarketos.org/pmb-ci --- .ci/{ => lib}/check_devices_in_wiki.py | 4 ++-- .ci/lib/gitlab_prepare_ci.sh | 17 +++++++++++++++++ .ci/wiki.sh | 15 +++++++++++++++ .gitignore | 1 - .gitlab-ci.yml | 5 ++--- 5 files changed, 36 insertions(+), 6 deletions(-) rename .ci/{ => lib}/check_devices_in_wiki.py (98%) create mode 100755 .ci/lib/gitlab_prepare_ci.sh create mode 100755 .ci/wiki.sh diff --git a/.ci/check_devices_in_wiki.py b/.ci/lib/check_devices_in_wiki.py similarity index 98% rename from .ci/check_devices_in_wiki.py rename to .ci/lib/check_devices_in_wiki.py index fb88eabc5..3f2d5c200 100755 --- a/.ci/check_devices_in_wiki.py +++ b/.ci/lib/check_devices_in_wiki.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright 2021 Oliver Smith +# Copyright 2022 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later import argparse @@ -13,7 +13,7 @@ def get_devices(): """:returns: list of all devices""" ret = [] pmaports = (os.path.realpath(os.path.join(os.path.dirname(__file__) + - "/.."))) + "/../.."))) for path in glob.glob(pmaports + "/device/*/device-*/"): device = os.path.dirname(path).split("device-", 1)[1] diff --git a/.ci/lib/gitlab_prepare_ci.sh b/.ci/lib/gitlab_prepare_ci.sh new file mode 100755 index 000000000..fe48d8974 --- /dev/null +++ b/.ci/lib/gitlab_prepare_ci.sh @@ -0,0 +1,17 @@ +#!/bin/sh -e +# Copyright 2022 Oliver Smith +# SPDX-License-Identifier: GPL-3.0-or-later + +if ! mount | grep -q /proc/sys/fs/binfmt_misc; then + echo "Mounting binfmt_misc" + mount -t binfmt_misc none /proc/sys/fs/binfmt_misc +fi + +if id "build" > /dev/null 2>&1; then + echo "User 'build' exists already" +else + echo "Creating build user" + adduser -D build + chown -R build:build . + echo 'build ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers +fi diff --git a/.ci/wiki.sh b/.ci/wiki.sh new file mode 100755 index 000000000..b436defcb --- /dev/null +++ b/.ci/wiki.sh @@ -0,0 +1,15 @@ +#!/bin/sh -e +# Description: verify devices are documented in the wiki +# Options: native +# Run natively so we don't need to set up a chroot, python3 is the only dep. +# https://postmarktos.org/pmb-ci + +if [ "$(id -u)" = 0 ]; then + set -x + apk -q add \ + python3 + exec su "${TESTUSER:-build}" -c "sh -e $0" +fi + +set -x +.ci/lib/check_devices_in_wiki.py --booting diff --git a/.gitignore b/.gitignore index 756c204bd..9955160bd 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ dist/ downloads/ eggs/ .eggs/ -lib/ lib64/ parts/ sdist/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6aa70c72f..e9173e495 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,10 +31,9 @@ wiki: - merge_requests changes: - device/*/device-*/* - before_script: - - apk -q add python3 script: - - .ci/check_devices_in_wiki.py --booting + - .ci/lib/gitlab_prepare_ci.sh + - .ci/wiki.sh # testcases linting testcases-linting: