It is working although undocumented. It appears that Forgejo Actions users depend on it and breaking it would meet some non negligible push back. This test ensures that future Forgejo runner versions do not break what is working. This came to light because some fixes are necessary to the schema validation to allow for that to keep working (see https://code.forgejo.org/forgejo/act/pulls/194). Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/839 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
180 lines
5.3 KiB
Bash
Executable file
180 lines
5.3 KiB
Bash
Executable file
# Copyright 2024 The Forgejo Authors
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
ACTIONS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
function actions_export_variables() {
|
|
export HOST_PORT
|
|
export url=http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}
|
|
export token=$(cat $DOT_FORGEJO_CURL/token)
|
|
}
|
|
|
|
function actions_verify_feature() {
|
|
local feature=$1
|
|
|
|
actions_export_variables
|
|
|
|
export FEATURE_DIR=$ACTIONS_DIR/feature-$feature
|
|
|
|
echo "============================ RUN feature-$feature ==================="
|
|
bash -ex $FEATURE_DIR/run.sh || return 1
|
|
}
|
|
|
|
function actions_verify_example() {
|
|
local example=$1
|
|
|
|
actions_export_variables
|
|
actions_cleanup_example_volume
|
|
|
|
export example
|
|
export EXAMPLE_DIR=$ACTIONS_DIR/example-$example
|
|
|
|
if test -f $EXAMPLE_DIR/setup.sh; then
|
|
echo "============================ SETUP example-$example ==================="
|
|
bash -ex $EXAMPLE_DIR/setup.sh || return 1
|
|
fi
|
|
|
|
if test -f $EXAMPLE_DIR/run.sh; then
|
|
echo "============================ RUN example-$example ==================="
|
|
bash -ex $EXAMPLE_DIR/run.sh || return 1
|
|
else
|
|
forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example $example $token || return 1
|
|
fi
|
|
|
|
if test -f $EXAMPLE_DIR/teardown.sh; then
|
|
echo "============================ TEARDOWN example-$example ==================="
|
|
bash -ex $EXAMPLE_DIR/teardown.sh || return 1
|
|
fi
|
|
|
|
actions_save_contexts $example
|
|
}
|
|
|
|
function actions_save_contexts() {
|
|
local example="$1"
|
|
|
|
if test -d /srv/example/$example/contexts; then
|
|
mkdir -p /srv/contexts
|
|
rsync -av /srv/example/$example/contexts/ /srv/contexts/$example/
|
|
fi
|
|
}
|
|
|
|
function actions_cleanup_example_volume() {
|
|
if test $(id -u) != 0; then
|
|
$SUDO chown $(id -u) /srv
|
|
fi
|
|
|
|
if ! test -d /srv/example; then
|
|
mkdir -p /srv/example
|
|
return
|
|
fi
|
|
|
|
$SUDO rm -fr /srv/example/*
|
|
}
|
|
|
|
function actions_setup() {
|
|
local version=$1
|
|
actions_teardown
|
|
|
|
reset_forgejo $ACTIONS_DIR/default-app.ini
|
|
start_forgejo $version
|
|
|
|
export FORGEJO_RUNNER_LOGS=$DIR/forgejo-runner.log
|
|
|
|
actions_cleanup_example_volume
|
|
export FORGEJO_RUNNER_CONFIG=$ACTIONS_DIR/runner-config.yaml
|
|
forgejo-runner.sh setup '' '' http://${HOST_PORT}
|
|
}
|
|
|
|
function actions_teardown() {
|
|
forgejo-curl.sh logout
|
|
forgejo-runner.sh teardown
|
|
stop_forgejo
|
|
}
|
|
|
|
function actions_runner_version() {
|
|
local runner_version=$($DIR/forgejo-runner --version | sed -n -e 's/forgejo-runner version v//p')
|
|
if test -z "$runner_version"; then
|
|
$DIR/forgejo-runner --version
|
|
echo failed to parse version
|
|
false
|
|
fi
|
|
echo $runner_version
|
|
}
|
|
|
|
function prepare_dockerd() {
|
|
mkdir -p /etc/systemd/system/docker.service.d
|
|
cat >/etc/systemd/system/docker.service.d/override.conf <<'EOF'
|
|
[Service]
|
|
ExecStart=
|
|
ExecStart=/usr/sbin/dockerd -H unix:///var/run/docker.sock -H tcp://127.0.0.1:2375 --containerd=/run/containerd/containerd.sock $DOCKER_OPTS
|
|
EOF
|
|
systemctl daemon-reload
|
|
if ! systemctl restart docker.service; then
|
|
journalctl --no-pager --unit docker.service
|
|
return 1
|
|
fi
|
|
netstat -lntp | grep 127.0.0.1:2375
|
|
}
|
|
|
|
function test_actions() {
|
|
local versions="${1:-$RELEASE_NUMBERS}"
|
|
|
|
for version in $versions; do
|
|
|
|
actions_setup $version
|
|
local runner_version=$(actions_runner_version)
|
|
|
|
log_info "Testing actions with Forgejo $version & Forgejo runner $runner_version"
|
|
|
|
run actions_verify_example with-docker-tcp
|
|
if dpkg --compare-versions $runner_version gt 5.0.2; then
|
|
for example in with-docker-host with-docker-socket without-docker-socket; do
|
|
run actions_verify_example $example
|
|
done
|
|
fi
|
|
|
|
if dpkg --compare-versions $runner_version gt 6.0.1; then
|
|
run actions_verify_example force-rebuild
|
|
fi
|
|
|
|
if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0; then
|
|
for example in artifacts-v4; do
|
|
run actions_verify_example $example
|
|
done
|
|
fi
|
|
|
|
for example in echo workflow-call lxc config-options cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do
|
|
run actions_verify_example $example
|
|
done
|
|
|
|
if dpkg --compare-versions $runner_version ge 6.3.0; then
|
|
run actions_verify_example cache-proxy
|
|
fi
|
|
|
|
if dpkg --compare-versions $runner_version ge 8.0.0; then
|
|
run actions_verify_example shell
|
|
fi
|
|
|
|
if dpkg --compare-versions $version lt 7.1; then
|
|
for example in cron; do
|
|
run actions_verify_example $example
|
|
done
|
|
fi
|
|
|
|
if dpkg --compare-versions $version ge 7.1; then
|
|
for example in automerge post-7-0-schedule; do
|
|
run actions_verify_example $example
|
|
done
|
|
fi
|
|
|
|
if dpkg --compare-versions $version ge 8.0; then
|
|
for example in workflow-dispatch; do
|
|
run actions_verify_example $example
|
|
done
|
|
fi
|
|
|
|
if dpkg --compare-versions $version ge 9.0; then
|
|
run actions_verify_example schedule-noncancel
|
|
fi
|
|
done
|
|
}
|