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:
parent
ecff9c4c70
commit
d29439c5f7
10 changed files with 50 additions and 34 deletions
|
|
@ -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.
|
fine when run as a regular user.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
export FORGEJO_RUNNER_LOGS=/tmp/forgejo-end-to-end/forgejo-runner.log
|
||||||
./end-to-end.sh run dependencies
|
./end-to-end.sh run dependencies
|
||||||
./end-to-end.sh actions_setup 10.0
|
./end-to-end.sh actions_setup 10.0
|
||||||
firefox 0.0.0.0:3000 # user root / admin1234
|
firefox 0.0.0.0:3000 # user root / admin1234
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ function test_actions() {
|
||||||
done
|
done
|
||||||
fi
|
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
|
run actions_verify_example force-rebuild
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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" ]
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
name: local docker action
|
|
||||||
description: local docker action, build depends on "input.txt"
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: 'docker'
|
|
||||||
image: 'Dockerfile'
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
#! /usr/bin/env bash
|
|
||||||
set -x
|
|
||||||
exit "$(< /run/input.txt)"
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
this file will be filled by the test
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
---
|
on: [push]
|
||||||
on:
|
|
||||||
push:
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
ls:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- uses: https://code.forgejo.org/forgejo/test-setup-forgejo-docker@main
|
||||||
uses: actions/checkout@v4
|
with:
|
||||||
- uses: ./.forgejo/local-docker-action
|
args: ${{ forge.workspace }}/SOMEFILE
|
||||||
|
- run: |
|
||||||
|
test -f ${{ forge.workspace }}/SOMEFILE
|
||||||
|
|
|
||||||
|
|
@ -19,24 +19,51 @@ function run() {
|
||||||
forgejo-test-helper.sh wait_$expected $url $repo $sha
|
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() {
|
function main() {
|
||||||
local dir=$TMPDIR/repository
|
local dir=$TMPDIR/repository
|
||||||
cp -a $EXAMPLE_DIR $dir
|
cp -a $EXAMPLE_DIR $dir
|
||||||
|
|
||||||
# set up passing docker action
|
remove_remote_images
|
||||||
echo "0" >$dir/.forgejo/local-docker-action/input.txt
|
|
||||||
setup_with_rebuild
|
|
||||||
run $dir success
|
|
||||||
|
|
||||||
# change docker action to fail
|
:
|
||||||
echo "1" >$dir/.forgejo/local-docker-action/input.txt
|
: Run one
|
||||||
# ... but without a rebuild, it should still pass
|
:
|
||||||
setup_without_rebuild
|
setup_without_rebuild
|
||||||
run $dir success
|
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
|
setup_with_rebuild
|
||||||
run $dir failure
|
run $dir success
|
||||||
|
test "$image" = "$(get_remote_image)"
|
||||||
|
was_built
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
log:
|
log:
|
||||||
level: debug
|
level: trace
|
||||||
|
job_level: trace
|
||||||
|
|
||||||
runner:
|
runner:
|
||||||
file: .runner
|
file: .runner
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
log:
|
log:
|
||||||
level: debug
|
level: trace
|
||||||
|
job_level: trace
|
||||||
|
|
||||||
runner:
|
runner:
|
||||||
file: .runner
|
file: .runner
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue