Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tasks: Install dbus-daemon and valgrind, move config and secret setup to separate script #572

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tasks/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN dnf -y update && \
byobu \
chromium-headless \
curl \
dbus-daemon \
dbus-glib \
diffstat \
expect \
Expand Down Expand Up @@ -50,6 +51,7 @@ RUN dnf -y update && \
socat \
strace \
tar \
valgrind \
vim-enhanced \
virt-install && \
curl -o /tmp/cockpit.spec -s https://raw.githubusercontent.com/cockpit-project/cockpit/main/tools/cockpit.spec && \
Expand All @@ -58,9 +60,10 @@ RUN dnf -y update && \
dnf clean all && \
pip install ruff

COPY cockpit-tasks install-service webhook github_handler.py /usr/local/bin/
COPY setup-tasks cockpit-tasks install-service webhook github_handler.py /usr/local/bin/

RUN groupadd -g 1111 -r user && useradd -r -g user -u 1111 user --home-dir /work && \
groupadd -g 1001 -r github && useradd -r --no-create-home -g github -u 1001 github && \
mkdir -p /usr/local/bin /secrets /cache/images /cache/github && \
mkdir -p /work/.config /work/.config/cockpit-dev /work/.ssh /work/.cache /work/.rhel && \
printf '[user]\n\t\nemail = cockpituous@cockpit-project.org\n\tname = Cockpituous\n[cockpit "bots"]\n\timages-data-dir = /cache/images\n' >/work/.gitconfig && \
Expand Down
39 changes: 2 additions & 37 deletions tasks/cockpit-tasks
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,15 @@

set -eux

setup-tasks

COCKPIT_BOTS_REPO=${COCKPIT_BOTS_REPO:-https://github.com/cockpit-project/bots}
COCKPIT_BOTS_BRANCH=${COCKPIT_BOTS_BRANCH:-main}

# ensure we have a passwd entry for random UIDs
# https://docs.openshift.com/container-platform/3.7/creating_images/guidelines.html
if ! whoami && [ -w /etc/passwd ]; then
echo "user:x:$(id -u):0:random uid:/work:/sbin/nologin" >> /etc/passwd
export HOME=/work
fi

# set up custom NPM registry
if [ -n "${NPM_REGISTRY:-}" ]; then
npm config set registry "$NPM_REGISTRY"
echo "Set NPM registry to $NPM_REGISTRY"
fi
if [ -r /secrets/npm-registry.crt ]; then
export NODE_EXTRA_CA_CERTS=/secrets/npm-registry.crt
fi

# prone to timeouts and errors with lots of parallel containers
npm config set fetch-retries 6
npm config set fetch-timeout 600000
npm config set fetch-retry-mintimeout 60000
npm config set maxsockets 3

# set up S3 keys for OpenShift secrets volume
if [ ! -d /secrets/s3-keys ]; then
# then our container symlink will point into the void, replace it with a directory and set up all files that we can find
rm ~/.config/cockpit-dev/s3-keys
mkdir ~/.config/cockpit-dev/s3-keys
for f in /secrets/s3-keys--*; do
[ -e "$f" ] || continue # non-matching glob
ln -s "$f" ~/.config/cockpit-dev/s3-keys/"${f#*--}"
done
fi

# let's just do our work in the current directory
WORKDIR="$PWD"
BOTS_DIR="$WORKDIR"/bots

# Set up github user and token
git config --global credential.helper store
echo "https://cockpituous:$(cat ~/.config/github-token)@github.com" > ~/.git-credentials

echo "Starting testing"

function update_bots() {
Expand Down
5 changes: 5 additions & 0 deletions tasks/install-service
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ mkdir -p $SECRETS/tasks $SECRETS/webhook $CACHE
chown -R 1111:1111 $SECRETS $CACHE
chcon -R -t container_file_t $SECRETS $CACHE

if [ -e "${SECRETS}/tasks/npm-registry.crt" ]; then
NODE_EXTRA_CA_CERTS=/secrets/npm-registry.crt
fi

if [ $INSTANCES -eq 1 ]; then
# just use the hostname without prefix
CONTAINER_HOSTNAME="%l"
Expand Down Expand Up @@ -62,6 +66,7 @@ ExecStart=/usr/bin/podman run --name=cockpit-tasks-%i --hostname=${CONTAINER_HOS
--volume=\${TEST_SECRETS}/webhook:/run/secrets/webhook:ro \
--volume=${IMAGE_STORES}:/work/.config/cockpit-dev/image-stores:ro \
--env=NPM_REGISTRY=\${NPM_REGISTRY} \
--env=NODE_EXTRA_CA_CERTS=${NODE_EXTRA_CA_CERTS:-} \
--env=TEST_JOBS=\${TEST_JOBS} \
--env=TEST_NOTIFICATION_MX=\${TEST_NOTIFICATION_MX} \
--env=TEST_NOTIFICATION_TO=\${TEST_NOTIFICATION_TO} \
Expand Down
37 changes: 37 additions & 0 deletions tasks/setup-tasks
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
# set up configuration and secrets for running tasks
set -eux

# ensure we have a passwd entry for random UIDs
# https://docs.openshift.com/container-platform/3.7/creating_images/guidelines.html
if ! whoami && [ -w /etc/passwd ]; then
echo "user:x:$(id -u):0:random uid:/work:/sbin/nologin" >> /etc/passwd
export HOME=/work
fi

# set up custom NPM registry
if [ -n "${NPM_REGISTRY:-}" ]; then
npm config set registry "$NPM_REGISTRY"
echo "Set NPM registry to $NPM_REGISTRY"
fi

# prone to timeouts and errors with lots of parallel containers
npm config set fetch-retries 6
npm config set fetch-timeout 600000
npm config set fetch-retry-mintimeout 60000
npm config set maxsockets 3

# set up S3 keys for OpenShift secrets volume
if [ ! -d /secrets/s3-keys ]; then
# then our container symlink will point into the void, replace it with a directory and set up all files that we can find
rm ~/.config/cockpit-dev/s3-keys
mkdir ~/.config/cockpit-dev/s3-keys
for f in /secrets/s3-keys--*; do
[ -e "$f" ] || continue # non-matching glob
ln -s "$f" ~/.config/cockpit-dev/s3-keys/"${f#*--}"
done
fi

# Set up github user and token
git config --global credential.helper store
echo "https://cockpituous:$(cat ~/.config/github-token)@github.com" > ~/.git-credentials
Loading