diff --git a/actions/actions.sh b/actions/actions.sh index 50cbe8f..49a6eb5 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -6,6 +6,7 @@ ACTIONS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" function actions_verify_example() { local example=$1 + export HOST_PORT export url=http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT} export token=$(cat $DOT_FORGEJO_CURL/token) @@ -87,7 +88,7 @@ function actions_runner_version() { } function test_actions() { - local versions="${1:-1.20 1.21 $RELEASE_NUMBERS_AND_DEV}" + local versions=8.0-dev for version in $versions ; do @@ -96,5 +97,11 @@ function test_actions() { log_info "Testing actions with Forgejo $version & Forgejo runner $runner_version" + if dpkg --compare-versions $version ge 7.0 ; then + for example in 7-0-schedule ; do + run actions_verify_example $example + done + fi + done } diff --git a/actions/example-7-0-schedule/.forgejo/workflows/test.yml b/actions/example-7-0-schedule/.forgejo/workflows/test.yml new file mode 100644 index 0000000..e546741 --- /dev/null +++ b/actions/example-7-0-schedule/.forgejo/workflows/test.yml @@ -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/7-0-schedule-volume/DONE + + - name: save context + run: | + d=/srv/example/7-0-schedule/contexts/$GITHUB_EVENT_NAME + mkdir -p $d + cat > $d/github <<'EOF' + ${{ toJSON(github) }} + EOF diff --git a/actions/example-7-0-schedule/run.sh b/actions/example-7-0-schedule/run.sh new file mode 100755 index 0000000..6da29fe --- /dev/null +++ b/actions/example-7-0-schedule/run.sh @@ -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-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/7-0-schedule-volume/DONE ; then + cat $FORGEJO_RUNNER_LOGS + false +fi + +c=/srv/example/7-0-schedule/contexts/schedule/github +cat $c +test "schedule" = "$(jq -r .event_name < $c)" +test "schedule" = "$(jq -r .event.action < $c)" diff --git a/actions/example-7-0-schedule/setup.sh b/actions/example-7-0-schedule/setup.sh new file mode 100755 index 0000000..384b70e --- /dev/null +++ b/actions/example-7-0-schedule/setup.sh @@ -0,0 +1 @@ +mkdir -p /srv/example/7-0-schedule-volume