2021-07-03 11:18:18 +00:00
|
|
|
#!/bin/sh -e
|
CI: replace gitlab CI with sourcehut CI
Replace .gitlab-ci.yml with a minimal .build.yml that runs a script in
the .ci dir for each task. Each of these scripts runs as root first,
installs dependencies, and then drops rights to the testuser and runs
the actual test. I went with this design, so we can add a
'pmbootstrap ci' command in following patches that run these in a
pmbootstrap chroot (see pmaports#2169).
Looking at flake8, we currently ignore W504 and W604. Would be nice to
fix these instead, but let's do that in another patch.
I've added a minver package to Alpine, so we don't need to install it
form pip anymore. Use minver's new --lint argument to simplify the
script, and as recommended by minver itself, use --no-parse-comments as
speed optimization since we don't have minver specific comments.
Using doas instead of sudo in build.yml would be nice, but this doesn't
work out of the box. Can be changed in the future.
Add a note to the pytest script, that 'pmbootstrap log' can be used to
follow the log while tests are running.
2022-10-18 20:18:52 +00:00
|
|
|
# Description: run pmbootstrap python testsuite
|
|
|
|
# Options: native slow
|
2022-11-20 15:38:59 +00:00
|
|
|
# https://postmarketos.org/pmb-ci
|
CI: replace gitlab CI with sourcehut CI
Replace .gitlab-ci.yml with a minimal .build.yml that runs a script in
the .ci dir for each task. Each of these scripts runs as root first,
installs dependencies, and then drops rights to the testuser and runs
the actual test. I went with this design, so we can add a
'pmbootstrap ci' command in following patches that run these in a
pmbootstrap chroot (see pmaports#2169).
Looking at flake8, we currently ignore W504 and W604. Would be nice to
fix these instead, but let's do that in another patch.
I've added a minver package to Alpine, so we don't need to install it
form pip anymore. Use minver's new --lint argument to simplify the
script, and as recommended by minver itself, use --no-parse-comments as
speed optimization since we don't have minver specific comments.
Using doas instead of sudo in build.yml would be nice, but this doesn't
work out of the box. Can be changed in the future.
Add a note to the pytest script, that 'pmbootstrap log' can be used to
follow the log while tests are running.
2022-10-18 20:18:52 +00:00
|
|
|
|
|
|
|
if [ "$(id -u)" = 0 ]; then
|
|
|
|
set -x
|
|
|
|
apk -q add \
|
|
|
|
git \
|
|
|
|
openssl \
|
|
|
|
py3-pytest \
|
|
|
|
py3-pytest-cov \
|
|
|
|
sudo
|
|
|
|
exec su "${TESTUSER:-build}" -c "sh -e $0"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Require pytest to be installed on the host system
|
|
|
|
if [ -z "$(command -v pytest)" ]; then
|
|
|
|
echo "ERROR: pytest command not found, make sure it is in your PATH."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Use pytest-cov if it is installed to display code coverage
|
|
|
|
cov_arg=""
|
|
|
|
if python -c "import pytest_cov" >/dev/null 2>&1; then
|
|
|
|
cov_arg="--cov=pmb"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Initializing pmbootstrap..."
|
|
|
|
if ! yes '' | ./pmbootstrap.py \
|
|
|
|
--details-to-stdout \
|
|
|
|
init \
|
|
|
|
>/tmp/pmb_init 2>&1; then
|
|
|
|
cat /tmp/pmb_init
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-07-03 11:18:18 +00:00
|
|
|
|
|
|
|
# Make sure that the work folder format is up to date, and that there are no
|
|
|
|
# mounts from aborted test cases (#1595)
|
|
|
|
./pmbootstrap.py work_migrate
|
|
|
|
./pmbootstrap.py -q shutdown
|
|
|
|
|
|
|
|
# Make sure we have a valid device (#1128)
|
|
|
|
device="$(./pmbootstrap.py config device)"
|
|
|
|
pmaports="$(./pmbootstrap.py config aports)"
|
|
|
|
deviceinfo="$(ls -1 "$pmaports"/device/*/device-"$device"/deviceinfo)"
|
|
|
|
if ! [ -e "$deviceinfo" ]; then
|
|
|
|
echo "ERROR: Could not find deviceinfo file for selected device:" \
|
|
|
|
"$device"
|
|
|
|
echo "Expected path: $deviceinfo"
|
|
|
|
echo "Maybe you have switched to a branch where your device does not"
|
|
|
|
echo "exist? Use 'pmbootstrap config device qemu-amd64' to switch to"
|
|
|
|
echo "a valid device."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-02-26 18:47:31 +00:00
|
|
|
# Make sure pmaports is clean, some of the tests will fail otherwise
|
|
|
|
if [ -n "$(git -C "$pmaports" status --porcelain)" ]; then
|
|
|
|
echo "ERROR: pmaports dir is not clean"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
CI: replace gitlab CI with sourcehut CI
Replace .gitlab-ci.yml with a minimal .build.yml that runs a script in
the .ci dir for each task. Each of these scripts runs as root first,
installs dependencies, and then drops rights to the testuser and runs
the actual test. I went with this design, so we can add a
'pmbootstrap ci' command in following patches that run these in a
pmbootstrap chroot (see pmaports#2169).
Looking at flake8, we currently ignore W504 and W604. Would be nice to
fix these instead, but let's do that in another patch.
I've added a minver package to Alpine, so we don't need to install it
form pip anymore. Use minver's new --lint argument to simplify the
script, and as recommended by minver itself, use --no-parse-comments as
speed optimization since we don't have minver specific comments.
Using doas instead of sudo in build.yml would be nice, but this doesn't
work out of the box. Can be changed in the future.
Add a note to the pytest script, that 'pmbootstrap log' can be used to
follow the log while tests are running.
2022-10-18 20:18:52 +00:00
|
|
|
echo "Running pytest..."
|
|
|
|
echo "NOTE: use 'pmbootstrap log' to see the detailed log if running locally."
|
|
|
|
pytest \
|
|
|
|
--color=yes \
|
|
|
|
-vv \
|
|
|
|
-x \
|
|
|
|
$cov_arg \
|
|
|
|
test \
|
|
|
|
-m "not skip_ci" \
|
|
|
|
"$@"
|