.github, common/travis: run CI without root

this should allow package tests that check things like writability to
succeed and have fewer skipped tests in CI.

- switch to using the `void-LIBC-full` container
- use `uchroot` instead of `ethereal`
- simplify some scripts for this change
This commit is contained in:
classabbyamp 2025-02-22 19:19:27 -05:00 committed by classabbyamp
parent e91b5eb17b
commit 4649c32a54
14 changed files with 111 additions and 113 deletions

View file

@ -21,9 +21,8 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: 'ghcr.io/void-linux/void-buildroot-musl:20250214R1' image: 'ghcr.io/void-linux/void-musl-full:20250227R1'
env: env:
PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
LICENSE_LIST: common/travis/license.lst LICENSE_LIST: common/travis/license.lst
steps: steps:
@ -32,27 +31,28 @@ jobs:
# switch to repo-ci mirror # switch to repo-ci mirror
mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
sed -i 's|repo-default|repo-ci|g' /etc/xbps.d/*-repository-*.conf sed -i 's|repo-default|repo-ci|g' /etc/xbps.d/*-repository-*.conf
# Sync and upgrade once, assume error comes from xbps update # install dependencies
xbps-install -Syu || xbps-install -yu xbps xbps-install -Syu xbps && xbps-install -yu && xbps-install -y sudo bash grep curl git
# Upgrade again (in case there was a xbps update) # create non-root user
xbps-install -yu useradd -G xbuilder -M builder
# install tools needed for lints
xbps-install -y grep curl git
- name: Clone and checkout - name: Clone and checkout
uses: classabbyamp/treeless-checkout-action@v1 uses: classabbyamp/treeless-checkout-action@v1
- name: Create hostrepo and prepare masterdir
- name: Prepare masterdir
run: | run: |
ln -s "$(pwd)" /hostrepo && chown -R builder:builder . &&
common/travis/set_mirror.sh && sudo -Eu builder common/travis/set_mirror.sh &&
common/travis/prepare.sh &&
common/travis/fetch-xtools.sh common/travis/fetch-xtools.sh
- run: common/travis/changed_templates.sh
- name: Find changed templates
run: sudo -Eu builder common/travis/changed_templates.sh
- name: Run lints - name: Run lints
run: | run: |
rv=0 sudo -Eu builder common/travis/verify-update-check.sh || rv=1
common/travis/xlint.sh || rv=1 sudo -Eu builder common/travis/xlint.sh || rv=1
common/travis/verify-update-check.sh || rv=1 exit "${rv:-0}"
exit $rv
# Build changed packages. # Build changed packages.
build: build:
@ -61,14 +61,14 @@ jobs:
if: "!contains(github.event.pull_request.title, '[ci skip]') && !contains(github.event.pull_request.body, '[ci skip]')" if: "!contains(github.event.pull_request.title, '[ci skip]') && !contains(github.event.pull_request.body, '[ci skip]')"
container: container:
image: ghcr.io/void-linux/void-buildroot-${{ matrix.config.libc }}:20250214R1 image: ghcr.io/void-linux/void-${{ matrix.config.libc }}-full:20250227R1
options: --platform ${{ matrix.config.platform }} options: --platform ${{ matrix.config.platform }} --privileged
volumes:
- /dev:/dev
env: env:
PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
ARCH: '${{ matrix.config.arch }}' ARCH: '${{ matrix.config.arch }}'
BOOTSTRAP: '${{ matrix.config.host }}' BOOTSTRAP: '${{ matrix.config.host }}'
TEST: '${{ matrix.config.test }}' TEST: '${{ matrix.config.test }}'
HOSTREPO: /hostrepo
strategy: strategy:
fail-fast: false fail-fast: false
@ -88,64 +88,44 @@ jobs:
# switch to repo-ci mirror # switch to repo-ci mirror
mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
sed -i 's|repo-default|repo-ci|g' /etc/xbps.d/*-repository-*.conf sed -i 's|repo-default|repo-ci|g' /etc/xbps.d/*-repository-*.conf
# Sync and upgrade once, assume error comes from xbps update # install dependencies
xbps-install -Syu || xbps-install -yu xbps xbps-install -Syu xbps && xbps-install -yu && xbps-install -y sudo bash curl git
# Upgrade again (in case there was a xbps update) # create non-root user
xbps-install -yu useradd -G xbuilder -M builder
- name: Clone and checkout - name: Clone and checkout
env:
PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
uses: classabbyamp/treeless-checkout-action@v1 uses: classabbyamp/treeless-checkout-action@v1
- name: Create hostrepo and prepare masterdir
- name: Prepare masterdir
run: | run: |
ln -s "$(pwd)" /hostrepo && chown -R builder:builder . &&
common/travis/set_mirror.sh && sudo -Eu builder common/travis/set_mirror.sh &&
common/travis/prepare.sh && sudo -Eu builder common/travis/prepare.sh &&
common/travis/fetch-xtools.sh common/travis/fetch-xtools.sh
- name: Find changed templates - name: Find changed templates
env: run: sudo -Eu builder common/travis/changed_templates.sh
PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
run: common/travis/changed_templates.sh
- name: Build and check packages - name: Build and check packages
run: | run: sudo -Eu builder common/travis/build.sh "$BOOTSTRAP" "$ARCH" "$TEST"
(
here="$(pwd)"
cd /
"$here/common/travis/build.sh" "$BOOTSTRAP" "$ARCH" "$TEST"
)
- name: Show files - name: Show files
run: | run: sudo -Eu builder common/travis/show_files.sh "$BOOTSTRAP" "$ARCH"
(
here="$(pwd)"
cd /
"$here/common/travis/show_files.sh" "$BOOTSTRAP" "$ARCH"
)
- name: Compare to previous - name: Compare to previous
run: | run: sudo -Eu builder common/travis/xpkgdiff.sh "$BOOTSTRAP" "$ARCH"
(
here="$(pwd)"
cd /
"$here/common/travis/xpkgdiff.sh" "$BOOTSTRAP" "$ARCH"
)
- name: Check file conflicts - name: Check file conflicts
if: matrix.config.arch == 'x86_64' # the arch indexed in xlocate if: matrix.config.arch == 'x86_64' # the arch indexed in xlocate
env:
PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
run: | run: |
if [ -s /tmp/templates ]; then if [ -s /tmp/templates ]; then
xlocate -S && export XDG_CACHE_HOME="$PWD/.cache"
common/scripts/lint-conflicts $HOME/hostdir/binpkgs sudo -Eu builder xlocate -S &&
sudo -Eu builder common/scripts/lint-conflicts
fi fi
- name: Verify repository state - name: Verify repository state
run: | run: |
( mkdir -p /check-install &&
here="$(pwd)" chown builder:builder /check-install &&
cd / sudo -Eu builder common/travis/check-install.sh "$BOOTSTRAP" "$ARCH"
"$here/common/travis/check-install.sh" "$BOOTSTRAP" "$ARCH"
)

View file

@ -1,6 +1,7 @@
name: 'Cycle Check' name: 'Cycle Check'
on: on:
workflow_dispatch:
schedule: schedule:
- cron: '0 18 * * *' - cron: '0 18 * * *'
@ -10,33 +11,29 @@ jobs:
permissions: permissions:
issues: write issues: write
container: container:
image: 'ghcr.io/void-linux/void-buildroot-musl:20250214R1' image: 'ghcr.io/void-linux/void-musl-full:20250227R1'
env:
PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
steps: steps:
- name: Prepare container - name: Prepare container
run: | run: |
# switch to repo-ci mirror # switch to repo-ci mirror
mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
sed -i 's|repo-default|repo-ci|g' /etc/xbps.d/*-repository-*.conf sed -i 's|repo-default|repo-ci|g' /etc/xbps.d/*-repository-*.conf
# Sync and upgrade once, assume error comes from xbps update # install dependencies
xbps-install -Syu || xbps-install -yu xbps xbps-install -Syu xbps && xbps-install -yu && xbps-install -y sudo bash grep git python3-networkx github-cli
# Upgrade again (in case there was a xbps update) # create non-root user
xbps-install -yu useradd -G xbuilder -M builder
# Install script dependencies
xbps-install -y python3-networkx github-cli
- name: Clone and checkout - name: Clone and checkout
uses: classabbyamp/treeless-checkout-action@v1 uses: classabbyamp/treeless-checkout-action@v1
- name: Create hostrepo and prepare masterdir - name: Prepare masterdir
run: | run: |
ln -s "$(pwd)" /hostrepo && chown -R builder:builder . &&
common/travis/set_mirror.sh && sudo -Eu builder common/travis/set_mirror.sh
common/travis/prepare.sh
- name: Find cycles and open issues - name: Find cycles and open issues
run: | run: |
common/scripts/xbps-cycles.py | tee cycles sudo -Eu builder common/scripts/xbps-cycles.py | tee cycles
grep 'Cycle:' cycles | while read -r line; do grep 'Cycle:' cycles | while read -r line; do
if gh issue list -R "$GITHUB_REPOSITORY" -S "$line" | grep .; then if gh issue list -R "$GITHUB_REPOSITORY" -S "$line" | grep .; then
printf "Issue on '%s' already exists.\n" "$line" printf "Issue on '%s' already exists.\n" "$line"

View file

@ -7,6 +7,8 @@
# With single path as argument, read that local repository. # With single path as argument, read that local repository.
# With -a flag, find conflicts between packages indexed in xlocate. # With -a flag, find conflicts between packages indexed in xlocate.
set -e
if [ "$#" = 0 ]; then if [ "$#" = 0 ]; then
binpkgs="$PWD/hostdir/binpkgs" binpkgs="$PWD/hostdir/binpkgs"
elif [ "$1" = -a ]; then elif [ "$1" = -a ]; then

View file

@ -1,7 +1,9 @@
#!/bin/sh #!/bin/bash
# #
# build.sh # build.sh
set -e
if [ "$1" != "$2" ]; then if [ "$1" != "$2" ]; then
arch="-a $2" arch="-a $2"
fi fi
@ -10,10 +12,10 @@ if [ "$3" = 1 ]; then
test="-Q" test="-Q"
fi fi
PKGS=$(/hostrepo/xbps-src $test sort-dependencies $(cat /tmp/templates)) PKGS=$(./xbps-src $test sort-dependencies $(cat /tmp/templates))
for pkg in ${PKGS}; do for pkg in ${PKGS}; do
/hostrepo/xbps-src -j$(nproc) -s -H "$HOME"/hostdir $arch $test pkg "$pkg" ./xbps-src -j$(nproc) -s $arch $test pkg "$pkg"
[ $? -eq 1 ] && exit 1 [ $? -eq 1 ] && exit 1
done done

View file

@ -1,7 +1,9 @@
#!/bin/sh #!/bin/bash
# #
# changed_templates.sh # changed_templates.sh
set -e
tip="$(git rev-list -1 --parents HEAD)" tip="$(git rev-list -1 --parents HEAD)"
case "$tip" in case "$tip" in
# This is a merge commit, pick last parent # This is a merge commit, pick last parent

View file

@ -1,31 +1,37 @@
#!/bin/sh #!/bin/bash
# #
# check-install.sh # check-install.sh
export XBPS_TARGET_ARCH="$2" XBPS_DISTDIR=/hostrepo set -e
if [ "$1" != "$XBPS_TARGET_ARCH" ]; then HOST_ARCH="$1"
triplet="$(/hostrepo/xbps-src -a "$XBPS_TARGET_ARCH" show-var XBPS_CROSS_TRIPLET)" export XBPS_TARGET_ARCH="$2"
CONFDIR="-C /usr/$triplet/etc/xbps.d"
if [ "$HOST_ARCH" != "$XBPS_TARGET_ARCH" ]; then
triplet="$(./xbps-src -a "$XBPS_TARGET_ARCH" show-var XBPS_CROSS_TRIPLET)"
CONFDIR="-C $PWD/masterdir-$HOST_ARCH/usr/$triplet/etc/xbps.d"
else else
CONFDIR="-C /etc/xbps.d" CONFDIR="-C $PWD/masterdir-$HOST_ARCH/etc/xbps.d"
fi fi
mkdir /check-install if ! [ -d /check-install ]; then
/bin/echo -e "\x1b[31m/check-install does not exist\x1b[0m"
exit 1
fi
mkdir -p /check-install/var/db/xbps/keys mkdir -p /check-install/var/db/xbps/keys
cp /var/db/xbps/keys/* /check-install/var/db/xbps/keys/ cp /var/db/xbps/keys/* /check-install/var/db/xbps/keys/
ADDREPO="--repository=$HOME/hostdir/binpkgs/bootstrap ADDREPO="--repository=hostdir/binpkgs/bootstrap
--repository=$HOME/hostdir/binpkgs --repository=hostdir/binpkgs
--repository=$HOME/hostdir/binpkgs/nonfree" --repository=hostdir/binpkgs/nonfree"
ROOTDIR="-r /check-install" ROOTDIR="-r /check-install"
xbps-install $ROOTDIR $ADDREPO $CONFDIR -S xbps-install $ROOTDIR $ADDREPO $CONFDIR -S
while read -r pkg; do while read -r pkg; do
for subpkg in $(xsubpkg $pkg); do for subpkg in $(xsubpkg $pkg); do
/bin/echo -e "\x1b[32mTrying to install dependants of $subpkg:\x1b[0m" /bin/echo -e "\x1b[32mTrying to install dependents of $subpkg:\x1b[0m"
for dep in $(xbps-query $ADDREPO -RX "$subpkg"); do for dep in $(xbps-query $ADDREPO -RX "$subpkg"); do
xbps-install \ xbps-install \
$ROOTDIR $ADDREPO $CONFDIR \ $ROOTDIR $ADDREPO $CONFDIR \

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# fetch-xbps.sh # fetch-xbps.sh

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# fetch-xtools.sh # fetch-xtools.sh
@ -16,4 +16,4 @@ else
xbps-fetch -o "$FILE" "$URL" || exit 1 xbps-fetch -o "$FILE" "$URL" || exit 1
fi fi
$TAR xf "$FILE" -C /tmp/bin --strip-components=1 || exit 1 $TAR xf "$FILE" -C /usr/local/bin --strip-components=1 || exit 1

View file

@ -1,14 +1,16 @@
#!/bin/sh #!/bin/bash
# #
# prepare.sh # prepare.sh
set -e
/bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m' /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m'
echo XBPS_BUILD_ENVIRONMENT=void-packages-ci >> etc/conf echo XBPS_BUILD_ENVIRONMENT=void-packages-ci >> etc/conf
echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
/bin/echo -e '\x1b[32mEnabling ethereal chroot-style...\x1b[0m' /bin/echo -e '\x1b[32mEnabling uchroot chroot-style...\x1b[0m'
echo XBPS_CHROOT_CMD=ethereal >> etc/conf echo XBPS_CHROOT_CMD=uchroot >> etc/conf
echo XBPS_ALLOW_CHROOT_BREAKOUT=yes >> etc/conf
/bin/echo -e '\x1b[32mLinking / to /masterdir...\x1b[0m' /bin/echo -e '\x1b[32mBootstrapping...\x1b[0m'
ln -s / masterdir
./xbps-src binary-bootstrap

View file

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/bash
set -e
TRAVIS_MIRROR=repo-ci.voidlinux.org TRAVIS_MIRROR=repo-ci.voidlinux.org

View file

@ -1,15 +1,17 @@
#!/bin/sh #!/bin/bash
# #
# show_files.sh # show_files.sh
export XBPS_TARGET_ARCH="$2" XBPS_DISTDIR=/hostrepo set -e
export XBPS_TARGET_ARCH="$2"
while read -r pkg; do while read -r pkg; do
for subpkg in $(xsubpkg $pkg); do for subpkg in $(xsubpkg $pkg); do
/bin/echo -e "\x1b[32mFiles of $subpkg:\x1b[0m" /bin/echo -e "\x1b[32mFiles of $subpkg:\x1b[0m"
xbps-query --repository=$HOME/hostdir/binpkgs/bootstrap \ xbps-query --repository=hostdir/binpkgs/bootstrap \
--repository=$HOME/hostdir/binpkgs \ --repository=hostdir/binpkgs \
--repository=$HOME/hostdir/binpkgs/nonfree \ --repository=hostdir/binpkgs/nonfree \
-i -f "$subpkg" || -i -f "$subpkg" ||
/bin/echo -e "\x1b[33m $subpkg wasn't found\x1b[0m" /bin/echo -e "\x1b[33m $subpkg wasn't found\x1b[0m"
done done

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# runs update-check on all changed templates, then errors only if there was an # runs update-check on all changed templates, then errors only if there was an
# issue with the update-check. does not error if further updates are available, # issue with the update-check. does not error if further updates are available,
# as there may be a good reason not to update to those versions # as there may be a good reason not to update to those versions

View file

@ -1,14 +1,15 @@
#!/bin/sh #!/bin/bash
# #
# xlint.sh # xlint.sh
EXITCODE=0 EXITCODE=0
read base tip < /tmp/revisions read base tip < /tmp/revisions
/bin/echo -e "\x1b[34mLinting commits...\x1b[0m"
common/scripts/lint-commits $base $tip || EXITCODE=$? common/scripts/lint-commits $base $tip || EXITCODE=$?
for t in $(awk '{ print "srcpkgs/" $0 "/template" }' /tmp/templates); do for t in $(awk '{ print "srcpkgs/" $0 "/template" }' /tmp/templates); do
/bin/echo -e "\x1b[32mLinting $t...\x1b[0m" /bin/echo -e "\x1b[34mLinting $t...\x1b[0m"
xlint "$t" > /tmp/xlint_out || EXITCODE=$? xlint "$t" > /tmp/xlint_out || EXITCODE=$?
common/scripts/lint-version-change "$t" $base $tip > /tmp/vlint_out || EXITCODE=$? common/scripts/lint-version-change "$t" $base $tip > /tmp/vlint_out || EXITCODE=$?
awk -f common/scripts/lint2annotations.awk /tmp/xlint_out /tmp/vlint_out awk -f common/scripts/lint2annotations.awk /tmp/xlint_out /tmp/vlint_out

View file

@ -1,17 +1,19 @@
#!/bin/sh #!/bin/bash
# #
# xpkgdiff.sh # xpkgdiff.sh
export XBPS_TARGET_ARCH="$2" XBPS_DISTDIR=/hostrepo XBPS_HOSTDIR="$HOME/hostdir" set -e
export XBPS_TARGET_ARCH="$2"
export DIFF='diff --unified=0 --report-identical-files --suppress-common-lines export DIFF='diff --unified=0 --report-identical-files --suppress-common-lines
--color=always --label REPO --label BUILT' --color=always --label REPO --label BUILT'
ARGS="-a $2 -R https://repo-ci.voidlinux.org/current" ARGS="-a $2 -R https://repo-ci.voidlinux.org/current"
while read -r pkg; do while read -r pkg; do
for subpkg in $(xsubpkg $pkg); do for subpkg in $(xsubpkg $pkg); do
if xbps-query --repository=$HOME/hostdir/binpkgs/bootstrap \ if xbps-query --repository=hostdir/binpkgs/bootstrap \
--repository=$HOME/hostdir/binpkgs \ --repository=hostdir/binpkgs \
--repository=$HOME/hostdir/binpkgs/nonfree \ --repository=hostdir/binpkgs/nonfree \
-i "$subpkg" >&/dev/null; then -i "$subpkg" >&/dev/null; then
/bin/echo -e "\x1b[34mFile Diff of $subpkg:\x1b[0m" /bin/echo -e "\x1b[34mFile Diff of $subpkg:\x1b[0m"
xpkgdiff $ARGS -f $subpkg xpkgdiff $ARGS -f $subpkg