actions: force-rebuild must use a copy of the repository

it may not have permission to write on the repository itself, nor
should it.
This commit is contained in:
Earl Warren 2025-01-12 08:05:37 +01:00
parent 3d53d7f99e
commit 65e3fafd02
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -1,3 +1,7 @@
TMPDIR=$(mktemp -d)
trap "rm -fr $TMPDIR" EXIT
function setup_with_rebuild() { function setup_with_rebuild() {
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config-with-rebuild.yml forgejo-runner.sh reload FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config-with-rebuild.yml forgejo-runner.sh reload
} }
@ -7,28 +11,32 @@ function setup_without_rebuild() {
} }
function run() { function run() {
local expected="$1" local dir="$1"
local expected="$2"
local repo=root/example-$example local repo=root/example-$example
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token forgejo-test-helper.sh push_workflow $dir $url root example-$example setup-forgejo $token
sha=$(forgejo-test-helper.sh branch_tip $url $repo main) sha=$(forgejo-test-helper.sh branch_tip $url $repo main)
forgejo-test-helper.sh wait_$expected $url $repo $sha forgejo-test-helper.sh wait_$expected $url $repo $sha
} }
function main() { function main() {
local dir=$TMPDIR/repository
cp -a $EXAMPLE_DIR $dir
# set up passing docker action # set up passing docker action
echo "0" > $EXAMPLE_DIR/.forgejo/local-docker-action/input.txt echo "0" >$dir/.forgejo/local-docker-action/input.txt
setup_with_rebuild setup_with_rebuild
run success run $dir success
# change docker action to fail # change docker action to fail
echo "1" > $EXAMPLE_DIR/.forgejo/local-docker-action/input.txt echo "1" >$dir/.forgejo/local-docker-action/input.txt
# ... but without a rebuild, it should still pass # ... but without a rebuild, it should still pass
setup_without_rebuild setup_without_rebuild
run success run $dir success
# now the action should fail # now the action should fail
setup_with_rebuild setup_with_rebuild
run failure run $dir failure
} }
main main