Merge pull request 'run service example in the CI' (#32) from earl-warren/setup-forgejo:wip-example-service into main

Reviewed-on: https://code.forgejo.org/actions/setup-forgejo/pulls/32
Reviewed-by: dachary <dachary@noreply.code.forgejo.org>
This commit is contained in:
earl-warren 2023-07-08 12:31:15 +00:00
commit df44f56dd9
5 changed files with 64 additions and 35 deletions

View file

@ -1,4 +1,14 @@
on: [ push, pull_request ] on: [ push, pull_request ]
env:
#
# List of tests to run as found in testdata/example-$test. The
# directory will be used to create a git repository, uploaded to a
# Forgejo instance. The test will be a success once the status of
# the commit is success, as set by the Forgejo Action run.
#
TESTS: 'echo service container expression local-action'
jobs: jobs:
integration: integration:
runs-on: self-hosted runs-on: self-hosted
@ -10,9 +20,17 @@ jobs:
./forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo 1.19 ./forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo 1.19
./forgejo-runner.sh setup ./forgejo-runner.sh setup
export FORGEJO_RUNNER_LOGS=forgejo-runner.log export FORGEJO_RUNNER_LOGS=forgejo-runner.log
for example in echo container expression local-action ; do for example in $TESTS ; do
echo "============================ example-$example ===================" config=$(pwd)/testdata/example-$example/runner-config.yaml
if test -f $config ; then
FORGEJO_RUNNER_CONFIG=$config ./forgejo-runner.sh reload
fi
echo "============================ BEGIN example-$example ==================="
./forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token) ./forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token)
echo "============================ END example-$example ==================="
if test -f $config ; then
./forgejo-runner.sh reload
fi
done done
echo "============================ demo ===================" echo "============================ demo ==================="
./forgejo-test-helper.sh run_workflow testdata/demo http://root:admin1234@$(cat forgejo-ip):3000 root demo setup-forgejo $(cat forgejo-token) > /tmp/output ./forgejo-test-helper.sh run_workflow testdata/demo http://root:admin1234@$(cat forgejo-ip):3000 root demo setup-forgejo $(cat forgejo-token) > /tmp/output

View file

@ -34,6 +34,11 @@ function run() {
cat forgejo-runner.log cat forgejo-runner.log
} }
function reload() {
teardown
run
}
function setup() { function setup() {
local runner_repository="${1:-https://code.forgejo.org/forgejo/runner}" local runner_repository="${1:-https://code.forgejo.org/forgejo/runner}"
local version="${2:-v2.1.0}" local version="${2:-v2.1.0}"

View file

@ -1,55 +1,29 @@
# Example configuration file, it's safe to copy this as the default config file without any modification.
log: log:
# The level of logging, can be trace, debug, info, warn, error, fatal
level: debug level: debug
runner: runner:
# Where to store the registration result.
file: .runner file: .runner
# Execute how many tasks concurrently at the same time.
capacity: 1 capacity: 1
# Extra environment variables to run jobs.
#envs:
# A_TEST_ENV_NAME_1: a_test_env_value_1
# A_TEST_ENV_NAME_2: a_test_env_value_2
# Extra environment variables to run jobs from a file.
# It will be ignored if it's empty or the file doesn't exist.
env_file: .env env_file: .env
# The timeout for a job to be finished.
# Please note that the Gitea instance also has a timeout (3h by default) for the job.
# So the job could be stopped by the Gitea instance if it's timeout is shorter than this.
timeout: 3h timeout: 3h
# Whether skip verifying the TLS certificate of the Gitea instance.
insecure: false insecure: false
# The timeout for fetching the job from the Gitea instance.
fetch_timeout: 5s fetch_timeout: 5s
# The interval for fetching the job from the Gitea instance.
fetch_interval: 2s fetch_interval: 2s
labels: []
cache: cache:
# Enable cache server to use actions/cache.
enabled: false enabled: false
# The directory to store the cache data.
# If it's empty, the cache data will be stored in $HOME/.cache/actcache.
dir: "" dir: ""
# The host of the cache server.
# It's not for the address to listen, but the address to connect from job containers.
# So 0.0.0.0 is a bad choice, leave it empty to detect automatically.
host: "" host: ""
# The port of the cache server.
# 0 means to use a random available port.
port: 0 port: 0
container: container:
# Specifies the network to which the container will connect.
# Could be host, bridge or the name of a custom network.
# If it's empty, act_runner will create a network automatically.
network: "bridge" network: "bridge"
# Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker).
privileged: false privileged: false
# And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway).
options: options:
# The parent directory of a job's working directory. workdir_parent:
# If it's empty, /workspace will be used. valid_volumes: []
docker_host: ""
host:
workdir_parent: workdir_parent:

View file

@ -3,6 +3,8 @@ on: [push]
jobs: jobs:
test: test:
runs-on: docker runs-on: docker
container:
image: debian:bookworm
services: services:
pgsql: pgsql:
@ -15,5 +17,5 @@ jobs:
steps: steps:
- run: | - run: |
apt-get update -qq apt-get update -qq
apt-get install -y -qq postgresql-client-11 apt-get install -y -qq postgresql-client
PGPASSWORD=postgres psql -h pgsql -U postgres -c '\dt' test PGPASSWORD=postgres psql -h pgsql -U postgres -c '\dt' test

View file

@ -0,0 +1,30 @@
log:
level: info
runner:
file: .runner
capacity: 1
env_file: .env
timeout: 3h
insecure: false
fetch_timeout: 5s
fetch_interval: 2s
labels: []
cache:
enabled: false
dir: ""
host: ""
port: 0
container:
network: ""
privileged: false
options:
workdir_parent:
valid_volumes: []
docker_host: ""
host:
workdir_parent: