fix: actions: refactor force-rebuild tests to use a remote action (#991)

The local actions are always rebuilt with a random tag and cannot be used to verify the force_rebuild setting is working.

Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/991
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>
This commit is contained in:
Earl Warren 2025-09-01 17:14:24 +00:00 committed by earl-warren
parent ecff9c4c70
commit d29439c5f7
No known key found for this signature in database
GPG key ID: F128CBE6AB3A7201
10 changed files with 50 additions and 34 deletions

View file

@ -82,6 +82,7 @@ admin permissions. But they do not need to run as root and must work
fine when run as a regular user.
```sh
export FORGEJO_RUNNER_LOGS=/tmp/forgejo-end-to-end/forgejo-runner.log
./end-to-end.sh run dependencies
./end-to-end.sh actions_setup 10.0
firefox 0.0.0.0:3000 # user root / admin1234

View file

@ -133,7 +133,7 @@ function test_actions() {
done
fi
if dpkg --compare-versions $runner_version gt 6.0.1; then
if dpkg --compare-versions $runner_version gt 10.0.0; then
run actions_verify_example force-rebuild
fi

View file

@ -1,5 +0,0 @@
FROM code.forgejo.org/oci/debian:bookworm
COPY entrypoint.sh /run/entrypoint.sh
# if we rebuild, we should notice this file change
COPY input.txt /run/input.txt
ENTRYPOINT [ "/run/entrypoint.sh" ]

View file

@ -1,6 +0,0 @@
name: local docker action
description: local docker action, build depends on "input.txt"
runs:
using: 'docker'
image: 'Dockerfile'

View file

@ -1,3 +0,0 @@
#! /usr/bin/env bash
set -x
exit "$(< /run/input.txt)"

View file

@ -1 +0,0 @@
this file will be filled by the test

View file

@ -1,10 +1,11 @@
---
on:
push:
on: [push]
jobs:
test:
ls:
runs-on: docker
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: ./.forgejo/local-docker-action
- uses: https://code.forgejo.org/forgejo/test-setup-forgejo-docker@main
with:
args: ${{ forge.workspace }}/SOMEFILE
- run: |
test -f ${{ forge.workspace }}/SOMEFILE

View file

@ -19,24 +19,51 @@ function run() {
forgejo-test-helper.sh wait_$expected $url $repo $sha
}
function get_remote_image() {
docker image ls --format='{{ .Repository }}' | grep '^runner-remote-docker-action'
}
function remove_remote_images() {
docker image ls --format='{{ .Repository }}' | grep '^runner-remote-docker-action' | while read image; do
docker rmi $image
done
}
function was_built() {
grep --quiet 'docker build -t runner-remote-docker-action' $FORGEJO_RUNNER_LOGS
}
function main() {
local dir=$TMPDIR/repository
cp -a $EXAMPLE_DIR $dir
# set up passing docker action
echo "0" >$dir/.forgejo/local-docker-action/input.txt
setup_with_rebuild
run $dir success
remove_remote_images
# change docker action to fail
echo "1" >$dir/.forgejo/local-docker-action/input.txt
# ... but without a rebuild, it should still pass
:
: Run one
:
setup_without_rebuild
run $dir success
local image="$(get_remote_image)"
test "$image"
was_built
# now the action should fail
:
: Run two: verify the image was not rebuilt
:
setup_without_rebuild # resets the logs
run $dir success
test "$image" = "$(get_remote_image)"
! was_built
:
: Run two: verify the image was rebuilt and
: the image name stayed the same
:
setup_with_rebuild
run $dir failure
run $dir success
test "$image" = "$(get_remote_image)"
was_built
}
main

View file

@ -1,5 +1,6 @@
log:
level: debug
level: trace
job_level: trace
runner:
file: .runner

View file

@ -1,5 +1,6 @@
log:
level: debug
level: trace
job_level: trace
runner:
file: .runner