Merge pull request 'actions: runner [container].docker_host variations' (#370) from earl-warren/end-to-end:wip-actions-docker into main

Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/370
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
This commit is contained in:
earl-warren 2024-11-27 09:55:35 +00:00
commit acb860ef24
16 changed files with 158 additions and 0 deletions

View file

@ -77,6 +77,7 @@ jobs:
steps: steps:
- uses: https://code.forgejo.org/actions/checkout@v4 - uses: https://code.forgejo.org/actions/checkout@v4
- uses: ./.forgejo/prepare-end-to-end - uses: ./.forgejo/prepare-end-to-end
- run: ./end-to-end.sh prepare_dockerd
- run: su forgejo -c "./end-to-end.sh test_actions" - run: su forgejo -c "./end-to-end.sh test_actions"
- name: full logs - name: full logs
if: always() if: always()

View file

@ -72,6 +72,10 @@ firefox 0.0.0.0:3000 # user root / admin1234
./end-to-end.sh actions_verify_example echo ./end-to-end.sh actions_verify_example echo
./end-to-end.sh actions_teardown ./end-to-end.sh actions_teardown
``` ```
Note that `with-docker-tcp` requires the docker daemon listens to
tcp://127.0.0.1:2375. See `actions/actions.sh` for how to do that.
## Running other tests locally ## Running other tests locally
To run and debug tests, from the root of the source directory. To run and debug tests, from the root of the source directory.

View file

@ -101,6 +101,21 @@ function actions_runner_version() {
echo $runner_version 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() { function test_actions() {
local versions="${1:-$RELEASE_NUMBERS}" local versions="${1:-$RELEASE_NUMBERS}"
@ -118,6 +133,13 @@ function test_actions() {
run actions_verify_feature logs-compression run actions_verify_feature logs-compression
fi fi
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 $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0; then if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0; then
for example in artifacts-v4; do for example in artifacts-v4; do
run actions_verify_example $example run actions_verify_example $example

View file

@ -0,0 +1,9 @@
on: [push]
jobs:
build:
runs-on: docker
container:
image: code.forgejo.org/oci/node:20-bookworm
steps:
- run: "test -e /var/run/docker.sock"

View file

@ -0,0 +1,30 @@
log:
level: debug
runner:
file: .runner
capacity: 1
env_file: .env
timeout: 3h
insecure: false
fetch_timeout: 5s
fetch_interval: 2s
labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"]
cache:
enabled: true
dir: "/srv/example/cache"
host: ""
port: 0
container:
network: "bridge"
privileged: false
options:
workdir_parent:
valid_volumes: ["/srv/example"]
docker_host: "unix:///var/run/docker.sock"
host:
workdir_parent:

View file

@ -0,0 +1 @@
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload

View file

@ -0,0 +1 @@
forgejo-runner.sh reload

View file

@ -0,0 +1,9 @@
on: [push]
jobs:
build:
runs-on: docker
container:
image: code.forgejo.org/oci/node:20-bookworm
steps:
- run: "test -e /var/run/docker.sock"

View file

@ -0,0 +1,30 @@
log:
level: debug
runner:
file: .runner
capacity: 1
env_file: .env
timeout: 3h
insecure: false
fetch_timeout: 5s
fetch_interval: 2s
labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"]
cache:
enabled: true
dir: "/srv/example/cache"
host: ""
port: 0
container:
network: "bridge"
privileged: false
options:
workdir_parent:
valid_volumes: ["/srv/example"]
docker_host: "automount"
host:
workdir_parent:

View file

@ -0,0 +1 @@
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload

View file

@ -0,0 +1 @@
forgejo-runner.sh reload

View file

@ -0,0 +1,11 @@
on: [push]
jobs:
build:
runs-on: docker
container:
image: code.forgejo.org/oci/node:20-bookworm
steps:
- run: |
! test -e /var/run/docker.sock
! env | grep DOCKER_HOST

View file

@ -0,0 +1,30 @@
log:
level: debug
runner:
file: .runner
capacity: 1
env_file: .env
timeout: 3h
insecure: false
fetch_timeout: 5s
fetch_interval: 2s
labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"]
cache:
enabled: true
dir: "/srv/example/cache"
host: ""
port: 0
container:
network: "bridge"
privileged: false
options:
workdir_parent:
valid_volumes: ["/srv/example"]
docker_host: "tcp://127.0.0.1:2375"
host:
workdir_parent:

View file

@ -0,0 +1 @@
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload

View file

@ -0,0 +1 @@
forgejo-runner.sh reload

View file

@ -0,0 +1,6 @@
on: [push]
jobs:
test:
runs-on: docker
steps:
- run: "! test -e /var/run/docker.sock"