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
This commit is contained in:
Oliver Smith 2022-10-30 15:08:36 +01:00
parent 23790a3577
commit a2f75963bf
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
5 changed files with 36 additions and 6 deletions

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright 2021 Oliver Smith # Copyright 2022 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
import argparse import argparse
@ -13,7 +13,7 @@ def get_devices():
""":returns: list of all devices""" """:returns: list of all devices"""
ret = [] ret = []
pmaports = (os.path.realpath(os.path.join(os.path.dirname(__file__) + pmaports = (os.path.realpath(os.path.join(os.path.dirname(__file__) +
"/.."))) "/../..")))
for path in glob.glob(pmaports + "/device/*/device-*/"): for path in glob.glob(pmaports + "/device/*/device-*/"):
device = os.path.dirname(path).split("device-", 1)[1] device = os.path.dirname(path).split("device-", 1)[1]

17
.ci/lib/gitlab_prepare_ci.sh Executable file
View file

@ -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

15
.ci/wiki.sh Executable file
View file

@ -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

1
.gitignore vendored
View file

@ -20,7 +20,6 @@ dist/
downloads/ downloads/
eggs/ eggs/
.eggs/ .eggs/
lib/
lib64/ lib64/
parts/ parts/
sdist/ sdist/

View file

@ -31,10 +31,9 @@ wiki:
- merge_requests - merge_requests
changes: changes:
- device/*/device-*/* - device/*/device-*/*
before_script:
- apk -q add python3
script: script:
- .ci/check_devices_in_wiki.py --booting - .ci/lib/gitlab_prepare_ci.sh
- .ci/wiki.sh
# testcases linting # testcases linting
testcases-linting: testcases-linting: