add schedule runs-on variables test for post 7.0 releases (#151)
reimplements: forgejo/end-to-end#146 for 8.0-dev and 8.0-test Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/151 Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com> Co-committed-by: TheFox0x7 <thefox0x7@gmail.com>
This commit is contained in:
parent
1a3b74f520
commit
416db9031b
4 changed files with 68 additions and 1 deletions
|
@ -6,6 +6,7 @@ ACTIONS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
function actions_verify_example() {
|
function actions_verify_example() {
|
||||||
local example=$1
|
local example=$1
|
||||||
|
|
||||||
|
export HOST_PORT
|
||||||
export url=http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}
|
export url=http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}
|
||||||
export token=$(cat $DOT_FORGEJO_CURL/token)
|
export token=$(cat $DOT_FORGEJO_CURL/token)
|
||||||
|
|
||||||
|
@ -107,9 +108,21 @@ function test_actions() {
|
||||||
done
|
done
|
||||||
|
|
||||||
if dpkg --compare-versions $version gt 1.20 ; then
|
if dpkg --compare-versions $version gt 1.20 ; then
|
||||||
for example in push tag push-cancel artifacts pull-request context cron ; do
|
for example in push tag push-cancel artifacts pull-request context ; do
|
||||||
run actions_verify_example $example
|
run actions_verify_example $example
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if dpkg --compare-versions $version gt 1.20 && dpkg --compare-versions $version lt 7.1 ; then
|
||||||
|
for example in cron ; do
|
||||||
|
run actions_verify_example $example
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if dpkg --compare-versions $version ge 7.1 ; then
|
||||||
|
for example in post-7-0-schedule ; do
|
||||||
|
run actions_verify_example $example
|
||||||
|
done
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '* * * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ${{ vars.TEST_SCHEDULE_RUNSON }}
|
||||||
|
container:
|
||||||
|
image: code.forgejo.org/oci/debian:bookworm
|
||||||
|
options: "--volume /srv/example:/srv/example"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- run: |
|
||||||
|
echo "TEST_SCHEDULE_RUNSON=${{ vars.TEST_SCHEDULE_RUNSON }}"
|
||||||
|
touch /srv/example/post-7-0-schedule-volume/DONE
|
||||||
|
|
||||||
|
- name: save context
|
||||||
|
run: |
|
||||||
|
d=/srv/example/post-7-0-schedule/contexts/$GITHUB_EVENT_NAME
|
||||||
|
mkdir -p $d
|
||||||
|
cat > $d/github <<'EOF'
|
||||||
|
${{ toJSON(github) }}
|
||||||
|
EOF
|
30
actions/example-post-7-0-schedule/run.sh
Executable file
30
actions/example-post-7-0-schedule/run.sh
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
|
||||||
|
|
||||||
|
forgejo-curl.sh web -X POST http://${HOST_PORT}/admin/actions/variables/1/delete || true
|
||||||
|
forgejo-curl.sh web --form name=TEST_SCHEDULE_RUNSON --form data=docker http://${HOST_PORT}/admin/actions/variables/new
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verify that creating a new branch with the same SHA as the default branch
|
||||||
|
# does not change the ref associated with the schedule
|
||||||
|
#
|
||||||
|
# See https://codeberg.org/forgejo/forgejo/pulls/1941 for more information
|
||||||
|
#
|
||||||
|
function verify_ref() {
|
||||||
|
local ref=$(sqlite3 $DIR/forgejo-work-path/forgejo.db 'select ref from action_schedule')
|
||||||
|
test "${ref##*/}" = "main"
|
||||||
|
}
|
||||||
|
verify_ref
|
||||||
|
api=$url/api/v1
|
||||||
|
forgejo-curl.sh api_json --data '{"new_branch_name":"zzzz"}' $api/repos/root/example-post-7-0-schedule/branches
|
||||||
|
verify_ref
|
||||||
|
|
||||||
|
# runs once per minute, give it three minutes max before declaring failure
|
||||||
|
if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example/post-7-0-schedule-volume/DONE ; then
|
||||||
|
cat $FORGEJO_RUNNER_LOGS
|
||||||
|
false
|
||||||
|
fi
|
||||||
|
|
||||||
|
c=/srv/example/post-7-0-schedule/contexts/schedule/github
|
||||||
|
cat $c
|
||||||
|
test "schedule" = "$(jq -r .event_name < $c)"
|
||||||
|
test "schedule" = "$(jq -r .event.action < $c)"
|
1
actions/example-post-7-0-schedule/setup.sh
Executable file
1
actions/example-post-7-0-schedule/setup.sh
Executable file
|
@ -0,0 +1 @@
|
||||||
|
mkdir -p /srv/example/post-7-0-schedule-volume
|
Loading…
Add table
Reference in a new issue