2024-10-06 16:53:11 +02:00
|
|
|
repo=root/example-$example
|
2024-10-12 15:11:14 +02:00
|
|
|
#
|
|
|
|
# delete the repository
|
|
|
|
#
|
|
|
|
api=$url/api/v1
|
2024-10-13 12:45:19 +02:00
|
|
|
if forgejo-curl.sh api_json -X GET $api/repos/root/example-$example; then
|
|
|
|
forgejo-curl.sh api_json -X DELETE $api/repos/root/example-$example
|
|
|
|
fi
|
2024-10-12 15:11:14 +02:00
|
|
|
|
2024-10-06 16:53:11 +02:00
|
|
|
#
|
|
|
|
# push the repository
|
|
|
|
#
|
|
|
|
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
|
2024-10-12 15:11:14 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# get the run id of the workflow that just started
|
|
|
|
#
|
|
|
|
getScheduleRun() {
|
2024-10-17 11:48:22 +02:00
|
|
|
rm -f $DIR/forgejo-work-path/forgejo.copy.db
|
|
|
|
cp $DIR/forgejo-work-path/forgejo.db $DIR/forgejo-work-path/forgejo.copy.db
|
|
|
|
sqlite3 $DIR/forgejo-work-path/forgejo.copy.db \
|
|
|
|
"pragma busy_timeout = 5000; \
|
|
|
|
select action_run.id \
|
2024-10-12 15:11:14 +02:00
|
|
|
from action_run \
|
|
|
|
inner join action_schedule on action_run.schedule_id = action_schedule.id \
|
|
|
|
inner join repository on action_schedule.repo_id = repository.id \
|
|
|
|
where repository.name = 'example-schedule-noncancel' \
|
2024-10-17 11:48:22 +02:00
|
|
|
order by action_run.created desc limit 1" | sed '2q;d'
|
2024-10-12 15:11:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
run_id=$(getScheduleRun)
|
|
|
|
while [ -z $run_id ]; do
|
|
|
|
echo waiting 5...
|
|
|
|
sleep 5
|
|
|
|
run_id=$(getScheduleRun)
|
|
|
|
done
|
|
|
|
|
|
|
|
echo Schedule run id: $run_id
|
|
|
|
|
2024-10-06 16:53:11 +02:00
|
|
|
#
|
2024-10-12 15:11:14 +02:00
|
|
|
# Wait for it to be started
|
2024-10-06 16:53:11 +02:00
|
|
|
#
|
2024-10-12 15:11:14 +02:00
|
|
|
checkStarted() {
|
2024-10-17 11:48:22 +02:00
|
|
|
rm -f $DIR/forgejo-work-path/forgejo.copy.db
|
|
|
|
cp $DIR/forgejo-work-path/forgejo.db $DIR/forgejo-work-path/forgejo.copy.db
|
|
|
|
sqlite3 $DIR/forgejo-work-path/forgejo.copy.db \
|
|
|
|
"pragma busy_timeout = 5000; \
|
|
|
|
select id \
|
2024-10-12 15:11:14 +02:00
|
|
|
from action_run \
|
|
|
|
where id = $run_id \
|
2024-10-17 11:48:22 +02:00
|
|
|
and started is not null" | sed '2q;d'
|
2024-10-12 15:11:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
started_check=$(checkStarted)
|
|
|
|
while [ -z $started_check ]; do
|
|
|
|
echo waiting 2...
|
|
|
|
sleep 2
|
|
|
|
started_check=$(checkStarted)
|
|
|
|
done
|
|
|
|
|
|
|
|
echo Run has started
|
|
|
|
echo Push to repo again
|
|
|
|
|
2024-10-06 16:53:11 +02:00
|
|
|
#
|
2024-10-12 15:11:14 +02:00
|
|
|
# Push to the repo again
|
2024-10-06 16:53:11 +02:00
|
|
|
#
|
|
|
|
forgejo-test-helper.sh push_workflow actions/example-echo $url root example-$example setup-forgejo $token
|
2024-10-12 15:11:14 +02:00
|
|
|
|
2024-10-13 12:45:19 +02:00
|
|
|
echo Signal to the workflow that the push has happened
|
|
|
|
mkdir -p /srv/example/schedule-noncancel
|
|
|
|
touch /srv/example/schedule-noncancel/PUSHED
|
|
|
|
|
2024-10-06 16:53:11 +02:00
|
|
|
#
|
2024-10-12 15:11:14 +02:00
|
|
|
# Wait for the workflow to finish anyway
|
2024-10-06 16:53:11 +02:00
|
|
|
#
|
2024-10-12 15:11:14 +02:00
|
|
|
echo Wait for workflow to finish
|
|
|
|
|
|
|
|
checkFinished() {
|
2024-10-17 11:48:22 +02:00
|
|
|
rm -f $DIR/forgejo-work-path/forgejo.copy.db
|
|
|
|
cp $DIR/forgejo-work-path/forgejo.db $DIR/forgejo-work-path/forgejo.copy.db
|
|
|
|
sqlite3 $DIR/forgejo-work-path/forgejo.copy.db \
|
|
|
|
"pragma busy_timeout = 5000; \
|
|
|
|
select status \
|
2024-10-12 15:11:14 +02:00
|
|
|
from action_run \
|
|
|
|
where id = $run_id \
|
2024-10-17 11:48:22 +02:00
|
|
|
and (status != 6 and status != 5)" | sed '2q;d'
|
2024-10-12 15:11:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
finished_status=$(checkFinished)
|
|
|
|
while [ -z $finished_status ]; do
|
|
|
|
echo waiting 5...
|
|
|
|
sleep 5
|
|
|
|
finished_status=$(checkFinished)
|
|
|
|
done
|
|
|
|
|
|
|
|
echo Workflow finished.
|
2024-10-17 11:48:22 +02:00
|
|
|
rm -f $DIR/forgejo-work-path/forgejo.copy.db
|
2024-10-12 15:11:14 +02:00
|
|
|
|
|
|
|
test $finished_status = 1
|