end-to-end/packages/alpine/test.sh
Mathieu Fenniak 1064337c89 ci: run Forgejo Actions & Packages test w/ dynamic matrix (#1367)
Incorporates these changes:
- When `forgejo/build-from-sources` is present, Actions & Packages tests are run only against the built versions.  Otherwise, they are run against the versions defined in `$RELEASE_NUMBERS`
- Updates Packages tests which are testing Alpine publishing to use currently supported Alpine releases
- Actions & Packages tests are run in a matrix, allowing parallel execution

Only the Actions & Packages tests take a significant amount of time (>10 minutes), so changes have been limited to those test suites -- every test suite that is moved into a matrix adds additional overhead in the 1 minute `prepare-end-to-end` step.

Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/1367
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2026-01-01 22:16:33 +00:00

63 lines
2.1 KiB
Bash
Executable file

#!/bin/busybox ash
set -exuo pipefail
forgejo_url=$1
forgejo_token=$2
# initialize abuild
apk update
apk add --no-cache alpine-sdk sudo util-linux curl
adduser -D user -h /home/user
addgroup user abuild
echo "root ALL=(ALL) ALL" >/etc/sudoers
echo "%abuild ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
mkdir -p /var/cache/distfiles
chgrp abuild /var/cache/distfiles
chmod 775 /var/cache/distfiles
mkdir -p "/home/user/.abuild"
echo "/home/user/.abuild/user.rsa" | abuild-keygen -i -b 4096
echo 'PACKAGER_PRIVKEY=/home/user/.abuild/user.rsa' >/home/user/.abuild/abuild.conf
chown -R "user:user" /home/user/
# make sure we own the relevant directory
cp -r package-source /srv/alpine
cd /srv
mkdir packages
echo "REPODEST=/srv/packages" >>/home/user/.abuild/abuild.conf
cat /home/user/.abuild/abuild.conf
chown -R user:user alpine packages
# build the package
sudo -u user APKBUILD=alpine/forgejo-2174/APKBUILD abuild -r
# build the package
sudo -u user APKBUILD=alpine/forgejo-2173/APKBUILD abuild -r
# upload new package
cd packages/alpine/x86_64/
for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do
# remove old package
curl \
--fail \
-H "Authorization: token $forgejo_token" \
-X DELETE \
"$forgejo_url/api/packages/root/alpine/3.21/e2e-tests/$file" ||
true
# upload new package
curl \
--fail \
-H "Authorization: token $forgejo_token" \
-T "$file" \
"$forgejo_url/api/packages/root/alpine/3.21/e2e-tests"
done
# ensure that the install-if condition works as expected
apk add openrc
(cd /etc/apk/keys && curl -JO $forgejo_url/api/packages/root/alpine/key)
echo "$forgejo_url/api/packages/root/alpine/3.21/e2e-tests" >>/etc/apk/repositories
apk add forgejo-2174 forgejo-2173
[ -e /usr/bin/forgejo_2174 ] # from the installed package
[ -e /usr/bin/forgejo_2173 ] # from the installed package
[ -e /etc/init.d/forgejo_2174 ] # from the -openrc package installed because of the install-if condition
[ -e /etc/init.d/forgejo_2173 ] # from the -openrc package installed because of the install-if condition