From b63144cb0d031c0c7ea5c1214100dbb1c0487995 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 5 Jan 2024 18:11:19 +0100 Subject: [PATCH 001/203] always allow workflows to mount /srv/example because it is generally useful to store informations about how the workflow ran --- .../example-cron/.forgejo/workflows/test.yml | 4 +-- actions/example-cron/run.sh | 2 +- actions/example-cron/runner-config.yaml | 30 ------------------- actions/example-cron/setup.sh | 4 +-- actions/example-cron/teardown.sh | 1 - .../.forgejo/workflows/test.yml | 4 +-- actions/example-pull-request/run.sh | 4 ++- actions/example-pull-request/setup.sh | 8 +---- actions/example-pull-request/teardown.sh | 1 - actions/run.sh | 20 ++++++++++++- .../runner-config.yaml | 2 +- 11 files changed, 30 insertions(+), 50 deletions(-) delete mode 100644 actions/example-cron/runner-config.yaml delete mode 100755 actions/example-cron/teardown.sh delete mode 100755 actions/example-pull-request/teardown.sh rename actions/{example-pull-request => }/runner-config.yaml (89%) diff --git a/actions/example-cron/.forgejo/workflows/test.yml b/actions/example-cron/.forgejo/workflows/test.yml index c81b017..5f9a843 100644 --- a/actions/example-cron/.forgejo/workflows/test.yml +++ b/actions/example-cron/.forgejo/workflows/test.yml @@ -7,8 +7,8 @@ jobs: runs-on: docker container: image: code.forgejo.org/oci/debian:bookworm - options: "--volume /srv/example-cron-volume:/srv/example-cron-volume" + options: "--volume /srv/example:/srv/example" steps: - run: | - touch /srv/example-cron-volume/DONE + touch /srv/example/cron-volume/DONE diff --git a/actions/example-cron/run.sh b/actions/example-cron/run.sh index 3ced64c..c0dc193 100755 --- a/actions/example-cron/run.sh +++ b/actions/example-cron/run.sh @@ -16,7 +16,7 @@ forgejo-curl.sh api_json --data '{"new_branch_name":"zzzz"}' $api/repos/root/exa verify_ref # cron 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-cron-volume/DONE ; then +if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example/cron-volume/DONE ; then cat $FORGEJO_RUNNER_LOGS false fi diff --git a/actions/example-cron/runner-config.yaml b/actions/example-cron/runner-config.yaml deleted file mode 100644 index 119cde4..0000000 --- a/actions/example-cron/runner-config.yaml +++ /dev/null @@ -1,30 +0,0 @@ - -log: - level: info - -runner: - file: .runner - capacity: 1 - env_file: .env - timeout: 3h - insecure: false - fetch_timeout: 5s - fetch_interval: 2s - labels: ["docker:docker://code.forgejo.org/oci/node:16-bullseye"] - -cache: - enabled: false - dir: "" - host: "" - port: 0 - -container: - network: "" - privileged: false - options: - workdir_parent: - valid_volumes: ["/srv/example-cron-volume"] - docker_host: "" - -host: - workdir_parent: diff --git a/actions/example-cron/setup.sh b/actions/example-cron/setup.sh index ee70b92..ed70dec 100755 --- a/actions/example-cron/setup.sh +++ b/actions/example-cron/setup.sh @@ -1,3 +1 @@ -rm -fr /srv/example-cron-volume -mkdir -p /srv/example-cron-volume -FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload +mkdir -p /srv/example/cron-volume diff --git a/actions/example-cron/teardown.sh b/actions/example-cron/teardown.sh deleted file mode 100755 index b410c51..0000000 --- a/actions/example-cron/teardown.sh +++ /dev/null @@ -1 +0,0 @@ -forgejo-runner.sh reload diff --git a/actions/example-pull-request/.forgejo/workflows/test.yml b/actions/example-pull-request/.forgejo/workflows/test.yml index 90e9fb4..52be20f 100644 --- a/actions/example-pull-request/.forgejo/workflows/test.yml +++ b/actions/example-pull-request/.forgejo/workflows/test.yml @@ -10,7 +10,7 @@ jobs: runs-on: docker container: image: code.forgejo.org/oci/node:20-bookworm - options: "--volume /srv/example-pull-request:/srv/example-pull-request" + options: "--volume /srv/example:/srv/example" steps: - name: setup @@ -115,7 +115,7 @@ jobs: - name: save event run: | - d=/srv/example-pull-request/${{ github.event.pull_request.head.repo.owner.username }}/$GITHUB_EVENT_NAME/${{ github.event.action }} + d=/srv/example/pull-request/${{ github.event.pull_request.head.repo.owner.username }}/$GITHUB_EVENT_NAME/${{ github.event.action }} mkdir -p $d cat > $d/event <<'EOF' ${{ toJSON(github.event) }} diff --git a/actions/example-pull-request/run.sh b/actions/example-pull-request/run.sh index 2a88afd..b6897a2 100755 --- a/actions/example-pull-request/run.sh +++ b/actions/example-pull-request/run.sh @@ -1,9 +1,11 @@ api=$url/api/v1 -export d=/srv/example-pull-request +export d=/srv/example/pull-request PROOF='some proof' function setup() { + mkdir -p $d + forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token forgejo-curl.sh api_json --data-raw '{"username":"fork-org"}' $api/orgs diff --git a/actions/example-pull-request/setup.sh b/actions/example-pull-request/setup.sh index e93087e..72c13c0 100755 --- a/actions/example-pull-request/setup.sh +++ b/actions/example-pull-request/setup.sh @@ -1,8 +1,2 @@ -if test $(id -u) != 0 ; then - SUDO=sudo -fi +mkdir -p /srv/example/pull-request -$SUDO rm -fr /srv/example-pull-request/{root,fork-org} -rm -fr /srv/example-pull-request -mkdir -p /srv/example-pull-request -FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload diff --git a/actions/example-pull-request/teardown.sh b/actions/example-pull-request/teardown.sh deleted file mode 100755 index b410c51..0000000 --- a/actions/example-pull-request/teardown.sh +++ /dev/null @@ -1 +0,0 @@ -forgejo-runner.sh reload diff --git a/actions/run.sh b/actions/run.sh index 717682d..a776982 100755 --- a/actions/run.sh +++ b/actions/run.sh @@ -2,11 +2,13 @@ set -e +SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + function run() { local example=$1 export example - export EXAMPLE_DIR=$(pwd)/actions/example-$example + export EXAMPLE_DIR=$SELF_DIR/example-$example if test -f $EXAMPLE_DIR/setup.sh ; then echo "============================ SETUP example-$example ===================" @@ -39,9 +41,24 @@ function examples_v1_22() { examples_v1_21 } +function cleanup_example_volume() { + if ! test -d /srv/example ; then + mkdir -p /srv/example + return + fi + + if test $(id -u) != 0 ; then + SUDO=sudo + fi + + $SUDO rm -fr /srv/example/* +} + function setup() { local binary=$1 forgejo-binary.sh setup root admin1234 $binary + cleanup_example_volume + export FORGEJO_RUNNER_CONFIG=$SELF_DIR/runner-config.yaml forgejo-runner.sh setup } @@ -90,6 +107,7 @@ function main() { false fi echo "======================== END example-$example ===================" + cleanup_example_volume done } diff --git a/actions/example-pull-request/runner-config.yaml b/actions/runner-config.yaml similarity index 89% rename from actions/example-pull-request/runner-config.yaml rename to actions/runner-config.yaml index 5c3a6b3..12019d7 100644 --- a/actions/example-pull-request/runner-config.yaml +++ b/actions/runner-config.yaml @@ -23,7 +23,7 @@ container: privileged: false options: workdir_parent: - valid_volumes: ["/srv/example-pull-request"] + valid_volumes: ["/srv/example"] docker_host: "" host: From 66b125cffacc6cffeb2faaf4d8d928d5ea1252ea Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 5 Jan 2024 19:34:30 +0100 Subject: [PATCH 002/203] actions: container: upgrade alpine 3.19 --- actions/example-container/.forgejo/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/example-container/.forgejo/workflows/test.yml b/actions/example-container/.forgejo/workflows/test.yml index 6385e42..583df87 100644 --- a/actions/example-container/.forgejo/workflows/test.yml +++ b/actions/example-container/.forgejo/workflows/test.yml @@ -3,6 +3,6 @@ jobs: test: runs-on: docker container: - image: alpine:3.18 + image: alpine:3.19 steps: - run: grep Alpine /etc/os-release From c5cccca38dd2a97a270e51936d64d4762f29b245 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 5 Jan 2024 19:35:33 +0100 Subject: [PATCH 003/203] actions: service: upgrade node:20-bookworm --- actions/example-service/runner-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/example-service/runner-config.yaml b/actions/example-service/runner-config.yaml index 4606852..27981ab 100644 --- a/actions/example-service/runner-config.yaml +++ b/actions/example-service/runner-config.yaml @@ -10,7 +10,7 @@ runner: insecure: false fetch_timeout: 5s fetch_interval: 2s - labels: ["docker:docker://code.forgejo.org/oci/node:16-bullseye"] + labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"] cache: enabled: false From 476890848917c1e4c6d1ed5610e9b068431a4bea Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 5 Jan 2024 19:37:15 +0100 Subject: [PATCH 004/203] actions: add context example --- actions/example-context/.forgejo/fileone.txt | 1 - .../.forgejo/workflows/test.yml | 188 ++++++++++++++++++ .../action-for-context/action.yml | 21 ++ actions/example-context/run.sh | 1 + actions/example-context/setup.sh | 3 + .../.forgejo/local-action/action.yml | 6 + .../.forgejo/workflows/test.yml | 18 ++ actions/run.sh | 6 +- 8 files changed, 240 insertions(+), 4 deletions(-) delete mode 100644 actions/example-context/.forgejo/fileone.txt create mode 100644 actions/example-context/.forgejo/workflows/test.yml create mode 100644 actions/example-context/action-for-context/action.yml create mode 100644 actions/example-context/run.sh create mode 100644 actions/example-context/setup.sh diff --git a/actions/example-context/.forgejo/fileone.txt b/actions/example-context/.forgejo/fileone.txt deleted file mode 100644 index a2628c1..0000000 --- a/actions/example-context/.forgejo/fileone.txt +++ /dev/null @@ -1 +0,0 @@ -ONE diff --git a/actions/example-context/.forgejo/workflows/test.yml b/actions/example-context/.forgejo/workflows/test.yml new file mode 100644 index 0000000..4da32ec --- /dev/null +++ b/actions/example-context/.forgejo/workflows/test.yml @@ -0,0 +1,188 @@ +on: [push] + +jobs: + test: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + options: "--volume /srv/example:/srv/example" + steps: + + - name: env.CI + run: | + set -x + test "$CI" = true + test "$CI" = "${{ env.CI }}" + + - name: env.GITHUB_ACTION + run: | + set -x + echo "$GITHUB_ACTION" | grep -E '^[0-9]+$' + test "$GITHUB_ACTION" = "${{ env.GITHUB_ACTION }}" + + # See also actions/example-local-action/.forgejo/local-action/action.yml + - name: env.GITHUB_ACTION_PATH + run: | + set -x + test -z "$GITHUB_ACTION_PATH" + test "$GITHUB_ACTION_PATH" = "${{ env.GITHUB_ACTION_PATH }}" + + - name: when running an action + if: ${{ env.GITHUB_ACTIONS }} + uses: SELF@main + with: + input-one: "otherone" + + - name: env.GITHUB_ACTION_REPOSITORY + run: test -f /srv/example/example-context/GITHUB_ACTION_REPOSITORY + + - name: env.GITHUB_ACTION_PATH + run: test -f /srv/example/example-context/GITHUB_ACTION_PATH + + - name: env.GITHUB_ACTIONS + run: | + set -x + test "$GITHUB_ACTIONS" = true + test "$GITHUB_ACTIONS" = "${{ env.GITHUB_ACTIONS }}" + + - name: env.GITHUB_ACTOR + run: | + set -x + test "$GITHUB_ACTOR" + test "$GITHUB_ACTOR" = "${{ env.GITHUB_ACTOR }}" + + - name: env.GITHUB_API_URL + shell: bash + run: | + set -x + [[ "$GITHUB_API_URL" =~ /api/v1$ ]] + test "$GITHUB_API_URL" = "${{ env.GITHUB_API_URL }}" + + # See also actions/example-pull-request/.forgejo/workflows/test.yml + - name: env.GITHUB_BASE_REF + run: | + set -x + test -z "$GITHUB_BASE_REF" + test "$GITHUB_BASE_REF" = "${{ env.GITHUB_BASE_REF }}" + + # See also actions/example-pull-request/.forgejo/workflows/test.yml + - name: env.GITHUB_HEAD_REF + run: | + set -x + test -z "$GITHUB_HEAD_REF" + test "$GITHUB_HEAD_REF" = "${{ env.GITHUB_HEAD_REF }}" + + - name: env.GITHUB_ENV + run: | + set -x + test -f "$GITHUB_ENV" + test "$GITHUB_ENV" = "${{ env.GITHUB_ENV }}" + + - name: env.GITHUB_EVENT_NAME + run: | + set -x + test "$GITHUB_EVENT_NAME" = push + test "$GITHUB_EVENT_NAME" = "${{ env.GITHUB_EVENT_NAME }}" + + - name: env.GITHUB_JOB + run: | + set -x + test "$GITHUB_JOB" = test + test "$GITHUB_JOB" = "${{ env.GITHUB_JOB }}" + + - name: env.GITHUB_OUTPUT + run: | + set -x + test -f "$GITHUB_OUTPUT" + test "$GITHUB_OUTPUT" = "${{ env.GITHUB_OUTPUT }}" + + - name: env.GITHUB_PATH + run: | + set -x + test -f "$GITHUB_PATH" + test "$GITHUB_PATH" = "${{ env.GITHUB_PATH }}" + + - name: env.GITHUB_REF + shell: bash + run: | + set -x + [[ "$GITHUB_REF" =~ ^refs/ ]] + test "$GITHUB_REF" = "${{ env.GITHUB_REF }}" + + - name: env.GITHUB_REF_NAME + shell: bash + run: | + set -x + ! [[ "$GITHUB_REF_NAME" =~ ^refs/ ]] + test "$GITHUB_REF_NAME" = "${{ env.GITHUB_REF_NAME }}" + + - name: env.GITHUB_REPOSITORY + run: | + set -x + test "$GITHUB_REPOSITORY" = root/example-context + test "$GITHUB_REPOSITORY" = "${{ env.GITHUB_REPOSITORY }}" + + - name: env.GITHUB_REPOSITORY_OWNER + run: | + set -x + test "$GITHUB_REPOSITORY_OWNER" = root + test "$GITHUB_REPOSITORY_OWNER" = "${{ env.GITHUB_REPOSITORY_OWNER }}" + + - name: env.GITHUB_RUN_NUMBER + run: | + set -x + echo "$GITHUB_RUN_NUMBER" | grep -E '^[0-9]+$' + test "$GITHUB_RUN_NUMBER" = "${{ env.GITHUB_RUN_NUMBER }}" + + - name: env.GITHUB_SERVER_URL + shell: bash + run: | + set -x + [[ "$GITHUB_SERVER_URL" =~ ^http ]] + test "$GITHUB_SERVER_URL" = "${{ env.GITHUB_SERVER_URL }}" + + - name: env.GITHUB_SHA + run: | + set -x + test "$GITHUB_SHA" + test "$GITHUB_SHA" = "${{ env.GITHUB_SHA }}" + + - name: env.GITHUB_STEP_SUMMARY + run: | + set -x + test -f "$GITHUB_STEP_SUMMARY" + test "$GITHUB_STEP_SUMMARY" = "${{ env.GITHUB_STEP_SUMMARY }}" + + # See also actions/example-pull-request/.forgejo/workflows/test.yml + - name: env.GITHUB_TOKEN + run: | + set -x + test "$GITHUB_TOKEN" + test "$GITHUB_TOKEN" = "${{ env.GITHUB_TOKEN }}" + + - name: env.GITHUB_WORKSPACE + run: | + set -x + test -d "$GITHUB_WORKSPACE" + test "$GITHUB_WORKSPACE" = "${{ env.GITHUB_WORKSPACE }}" + + - name: RUNNER_ARCH + run: | + set -x + test "$RUNNER_ARCH" = X64 + + - name: RUNNER_OS + run: | + set -x + test "$RUNNER_OS" = Linux + + # runner 3.3.0 $RUNNER_TOOL_CACHE is not an existing directory + # - name: RUNNER_TOOL_CACHE + # run: | + # set -x + # test -d "$RUNNER_TOOL_CACHE" + + - name: RUNNER_TEMP + run: | + set -x + test -d "$RUNNER_TEMP" diff --git a/actions/example-context/action-for-context/action.yml b/actions/example-context/action-for-context/action.yml new file mode 100644 index 0000000..5a79adc --- /dev/null +++ b/actions/example-context/action-for-context/action.yml @@ -0,0 +1,21 @@ +inputs: + input-one: + default: 'one' + description: 'description one' + +runs: + using: "composite" + steps: + - name: GITHUB_ACTION_REPOSITORY + run: | + set -x + test "$GITHUB_ACTION_REPOSITORY" = root/action-for-context + test "$GITHUB_ACTION_REPOSITORY" = "${{ env.GITHUB_ACTION_REPOSITORY }}" + touch /srv/example/example-context/GITHUB_ACTION_REPOSITORY + + - name: GITHUB_ACTION_PATH + shell: bash + run: | + set -x + [[ "$GITHUB_ACTION_PATH" =~ action-for-context@main$ ]] + touch /srv/example/example-context/GITHUB_ACTION_PATH diff --git a/actions/example-context/run.sh b/actions/example-context/run.sh new file mode 100644 index 0000000..d9d08b8 --- /dev/null +++ b/actions/example-context/run.sh @@ -0,0 +1 @@ +forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example action-for-context $token diff --git a/actions/example-context/setup.sh b/actions/example-context/setup.sh new file mode 100644 index 0000000..c7759f4 --- /dev/null +++ b/actions/example-context/setup.sh @@ -0,0 +1,3 @@ +mkdir -p /srv/example/example-context + +forgejo-test-helper.sh push actions/example-$example/action-for-context $url root action-for-context diff --git a/actions/example-local-action/.forgejo/local-action/action.yml b/actions/example-local-action/.forgejo/local-action/action.yml index d83d33c..7963757 100644 --- a/actions/example-local-action/.forgejo/local-action/action.yml +++ b/actions/example-local-action/.forgejo/local-action/action.yml @@ -13,4 +13,10 @@ outputs: runs: using: "composite" steps: + - name: GITHUB_ACTION_PATH + run: | + set -x + test "$(basename $GITHUB_ACTION_PATH)" = local-action + test "$GITHUB_ACTION_PATH" = "${{ env.GITHUB_ACTION_PATH }}" + - run: echo key=${{ inputs.input-two-required }} >> $GITHUB_OUTPUT diff --git a/actions/example-pull-request/.forgejo/workflows/test.yml b/actions/example-pull-request/.forgejo/workflows/test.yml index 52be20f..c9a4cdf 100644 --- a/actions/example-pull-request/.forgejo/workflows/test.yml +++ b/actions/example-pull-request/.forgejo/workflows/test.yml @@ -33,6 +33,24 @@ jobs: echo value=true >> $GITHUB_OUTPUT fi + # See also actions/example-context/.forgejo/workflows/test.yml + - name: env.GITHUB_BASE_REF + run: | + set -x + test "$GITHUB_BASE_REF" = main + test "$GITHUB_BASE_REF" = "${{ env.GITHUB_BASE_REF }}" + + # See also actions/example-context/.forgejo/workflows/test.yml + - name: env.GITHUB_HEAD_REF + run: | + set -x + if ${{ steps.forked.outputs.value }} ; then + test "$GITHUB_HEAD_REF" = main + else + test "$GITHUB_HEAD_REF" = other + fi + test "$GITHUB_HEAD_REF" = "${{ env.GITHUB_HEAD_REF }}" + - name: secrets shell: bash run: | diff --git a/actions/run.sh b/actions/run.sh index a776982..eee678a 100755 --- a/actions/run.sh +++ b/actions/run.sh @@ -19,7 +19,7 @@ function run() { echo "============================ RUN example-$example ===================" bash -ex $EXAMPLE_DIR/run.sh || return 1 else - forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example setup-forgejo $token || return 1 + forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example $example $token || return 1 fi if test -f $EXAMPLE_DIR/teardown.sh ; then @@ -34,7 +34,7 @@ function examples_v1_20() { function examples_v1_21() { # keep "cron" last otherwise it will linger and pollute the following runs - echo 'echo push-cancel artifacts service checkout pull-request container expression local-action docker-action if if-fail cron' + echo 'echo push-cancel artifacts service checkout pull-request container expression local-action context docker-action if if-fail cron' } function examples_v1_22() { @@ -101,7 +101,7 @@ function main() { for example in $examples ; do echo "======================== BEGIN example-$example ===================" if ! time run $example >& /tmp/run.out ; then - cat /tmp/run.out + sed -e 's/^/[RUN] /' < /tmp/run.out echo "======================== FAIL example-$example ===================" sleep 5 # hack for Forgejo v1.21 to workaround a bug by which the last lines of the output are moved to the next step false From f0570182b8f7591894ca2629953c28a8b9731764 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Jan 2024 18:08:41 +0100 Subject: [PATCH 005/203] do not hardcode the full version --- .forgejo/workflows/actions.yml | 21 ++++++++++++--------- actions/run.sh | 4 +++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.forgejo/workflows/actions.yml b/.forgejo/workflows/actions.yml index 383eed3..70625a3 100644 --- a/.forgejo/workflows/actions.yml +++ b/.forgejo/workflows/actions.yml @@ -10,14 +10,17 @@ jobs: strategy: matrix: info: - - binary: https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 - version: v1_22 + - version: v1.22 + forgejo: https://codeberg.org + repo: forgejo-experimental/forgejo tests: ${{ vars.V1_22_TESTS }} - - binary: https://codeberg.org/forgejo/forgejo/releases/download/v1.21.3-0/forgejo-1.21.3-0-linux-amd64 - version: v1_21 + - version: v1.21 + forgejo: https://codeberg.org + repo: forgejo/forgejo tests: ${{ vars.V1_21_TESTS }} - - binary: https://codeberg.org/forgejo/forgejo/releases/download/v1.20.6-1/forgejo-1.20.6-1-linux-amd64 - version: v1_20 + - version: v1.20 + forgejo: https://codeberg.org + repo: forgejo/forgejo tests: ${{ vars.V1_20_TESTS }} steps: - uses: actions/checkout@v4 @@ -31,10 +34,10 @@ jobs: run: | set -x forgejo-binary.sh ensure_user forgejo - test "${{ matrix.info.binary }}" - test "${{ matrix.info.version }}" + full_version=$(curl -sS ${{ matrix.info.forgejo }}/api/v1/repos/${{ matrix.info.repo }}/releases | jq -r '.[] | .tag_name | select(startswith("${{ matrix.info.version }}"))' | sort -r | head -1) + binary=${{ matrix.info.forgejo }}/${{ matrix.info.repo }}/releases/download/${full_version}/forgejo-${full_version#v}-linux-amd64 export DIR=$(mktemp -d) chown forgejo $DIR /srv - su -c "actions/run.sh ${{ matrix.info.binary }} ${{ matrix.info.version }} ${{ matrix.info.tests }}" forgejo + su -c "actions/run.sh $binary $full_version ${{ matrix.info.version }} ${{ matrix.info.tests }}" forgejo diff --git a/actions/run.sh b/actions/run.sh index eee678a..4a1b8df 100755 --- a/actions/run.sh +++ b/actions/run.sh @@ -71,6 +71,8 @@ function teardown() { function main() { local binary="$1" shift + export full_version="$1" + shift export version="$1" shift @@ -79,7 +81,7 @@ function main() { teardown if test "$#" = 0 ; then - examples=$(examples_$version) + examples=$(examples_${version/./_}) else examples="$@" fi From 79cc059d987d7e4032425c0829e508566807f05b Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Jan 2024 23:48:36 +0100 Subject: [PATCH 006/203] actions: update the documentation with context examples (script) --- .forgejo/cascading-docs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 .forgejo/cascading-docs diff --git a/.forgejo/cascading-docs b/.forgejo/cascading-docs new file mode 100755 index 0000000..97e1d8a --- /dev/null +++ b/.forgejo/cascading-docs @@ -0,0 +1,18 @@ +#!/bin/bash + +set -ex + +docs=$1 +docs_pr=$2 +end_to_end=$3 +end_to_end_ref=$4 + +cd $docs/docs/user + +if ! test -f actions-contexts/version.txt || test "$VERSION" != $(cat actions-contexts/version.txt) ; then + rm -fr actions-contexts + mkdir actions-contexts + echo "$VERSION" > actions-contexts/version.txt + # populated by actions/run.sh + rsync -av /srv/contexts/ actions-contexts/ +fi From 921ed6f48186348771c28802efcf2caba4034e9c Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Jan 2024 23:49:28 +0100 Subject: [PATCH 007/203] actions: update the documentation with context examples --- .forgejo/workflows/actions.yml | 36 ++++++++++++++++++- .../.forgejo/workflows/test.yml | 6 ++-- actions/example-pull-request/assert-token.sh | 11 +++--- actions/example-pull-request/run.sh | 2 +- actions/run.sh | 11 ++++++ 5 files changed, 57 insertions(+), 9 deletions(-) diff --git a/.forgejo/workflows/actions.yml b/.forgejo/workflows/actions.yml index 70625a3..c02a967 100644 --- a/.forgejo/workflows/actions.yml +++ b/.forgejo/workflows/actions.yml @@ -1,3 +1,15 @@ +# +# +# https://code.forgejo.org/forgejo/end-to-end/settings/actions +# +# secrets.CASCADE_DOCS_ORIGIN_TOKEN +# https://code.forgejo.org/forgejo-ci scope write:issue, read:repository, read:user +# vars.CASCADE_DOCS_DESTINATION_DOER +# forgejo-cascading-pr (https://codeberg.org/forgejo-cascading-pr) +# secrets.CASCADE_DOCS_DESTINATION_TOKEN +# https://codeberg.org/forgejo-cascading-pr scope write:issue, write:repository, read:user +# + on: pull_request: push: @@ -11,6 +23,7 @@ jobs: matrix: info: - version: v1.22 + branch: next forgejo: https://codeberg.org repo: forgejo-experimental/forgejo tests: ${{ vars.V1_22_TESTS }} @@ -29,7 +42,9 @@ jobs: with: install-only: true - - if: matrix.info.tests != 'none' + - name: run + id: run + if: matrix.info.tests != 'none' shell: bash run: | set -x @@ -41,3 +56,22 @@ jobs: chown forgejo $DIR /srv su -c "actions/run.sh $binary $full_version ${{ matrix.info.version }} ${{ matrix.info.tests }}" forgejo + + echo full_version="$full_version" >> $GITHUB_OUTPUT + + - name: update documentation + if: matrix.info.version == 'v1.21' && matrix.info.tests != 'none' && github.ref == 'refs/heads/main' + uses: https://code.forgejo.org/actions/cascading-pr@v1 + with: + origin-url: ${{ env.GITHUB_SERVER_URL }} + origin-repo: ${{ github.repository }} + origin-token: ${{ secrets.CASCADE_DOCS_ORIGIN_TOKEN }} + origin-ref: refs/heads/main + destination-url: https://codeberg.org + destination-fork-repo: ${{ vars.CASCADE_DOCS_DESTINATION_DOER }}/docs + destination-repo: forgejo/docs + destination-branch: ${{ matrix.info.branch || matrix.info.version }} + destination-token: ${{ secrets.CASCADE_DOCS_DESTINATION_TOKEN }} + update: .forgejo/cascading-docs + env: + VERSION: "${{ steps.run.outputs.full_version }}" diff --git a/actions/example-pull-request/.forgejo/workflows/test.yml b/actions/example-pull-request/.forgejo/workflows/test.yml index c9a4cdf..772a38f 100644 --- a/actions/example-pull-request/.forgejo/workflows/test.yml +++ b/actions/example-pull-request/.forgejo/workflows/test.yml @@ -133,10 +133,10 @@ jobs: - name: save event run: | - d=/srv/example/pull-request/${{ github.event.pull_request.head.repo.owner.username }}/$GITHUB_EVENT_NAME/${{ github.event.action }} + d=/srv/example/pull-request/contexts/${{ github.event.pull_request.head.repo.owner.username }}/$GITHUB_EVENT_NAME mkdir -p $d - cat > $d/event <<'EOF' - ${{ toJSON(github.event) }} + cat > $d/github <<'EOF' + ${{ toJSON(github) }} EOF - uses: https://code.forgejo.org/actions/checkout@v4 diff --git a/actions/example-pull-request/assert-token.sh b/actions/example-pull-request/assert-token.sh index daa47d3..57f0257 100755 --- a/actions/example-pull-request/assert-token.sh +++ b/actions/example-pull-request/assert-token.sh @@ -2,7 +2,10 @@ set -ex -test -d $d/fork-org/pull_request/opened -test -d $d/fork-org/pull_request_target/opened -test -d $d/root/pull_request/opened -test -d $d/root/pull_request_target/opened +c=$d/contexts + +test opened = "$(jq -r .event.action < $c/fork-org/pull_request/github)" +test opened = "$(jq -r .event.action < $c/fork-org/pull_request_target/github)" + +test opened = "$(jq -r .event.action < $c/root/pull_request/github)" +test opened = "$(jq -r .event.action < $c/root/pull_request_target/github)" diff --git a/actions/example-pull-request/run.sh b/actions/example-pull-request/run.sh index b6897a2..5ae0baa 100755 --- a/actions/example-pull-request/run.sh +++ b/actions/example-pull-request/run.sh @@ -48,7 +48,7 @@ function setup() { for assert in $EXAMPLE_DIR/assert-*.sh ; do if ! forgejo.sh retry $assert ; then find $d - cat $FORGEJO_RUNNER_LOGS + sed -e 's/^/[RUNNER LOGS]/' < $FORGEJO_RUNNER_LOGS false fi done diff --git a/actions/run.sh b/actions/run.sh index 4a1b8df..60c6eed 100755 --- a/actions/run.sh +++ b/actions/run.sh @@ -1,6 +1,7 @@ #!/bin/bash set -e +set -o pipefail SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -41,6 +42,15 @@ function examples_v1_22() { examples_v1_21 } +function save_contexts() { + local example="$1" + + if test -d /srv/example/$example/contexts; then + mkdir -p /srv/contexts + rsync -av /srv/example/$example/contexts/ /srv/contexts/$example/ + fi +} + function cleanup_example_volume() { if ! test -d /srv/example ; then mkdir -p /srv/example @@ -109,6 +119,7 @@ function main() { false fi echo "======================== END example-$example ===================" + save_contexts $example cleanup_example_volume done } From cb4932192a823068a7c27be230012701d388df46 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 8 Jan 2024 00:43:26 +0100 Subject: [PATCH 008/203] documentation updates is half done, disable it for now --- .forgejo/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/actions.yml b/.forgejo/workflows/actions.yml index c02a967..3fee2aa 100644 --- a/.forgejo/workflows/actions.yml +++ b/.forgejo/workflows/actions.yml @@ -60,7 +60,7 @@ jobs: echo full_version="$full_version" >> $GITHUB_OUTPUT - name: update documentation - if: matrix.info.version == 'v1.21' && matrix.info.tests != 'none' && github.ref == 'refs/heads/main' + if: false && matrix.info.tests != 'none' && github.ref == 'refs/heads/main' uses: https://code.forgejo.org/actions/cascading-pr@v1 with: origin-url: ${{ env.GITHUB_SERVER_URL }} From 793c91b2545762417f2c2a986155453ffe86eaf4 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 9 Jan 2024 21:44:00 +0100 Subject: [PATCH 009/203] event cascading-prs need branches built out of the version each version for which events are collected need a different branch in the destination repository because they will open pull requests for each of the versions. --- .forgejo/workflows/actions.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.forgejo/workflows/actions.yml b/.forgejo/workflows/actions.yml index 3fee2aa..9ca830b 100644 --- a/.forgejo/workflows/actions.yml +++ b/.forgejo/workflows/actions.yml @@ -72,6 +72,7 @@ jobs: destination-repo: forgejo/docs destination-branch: ${{ matrix.info.branch || matrix.info.version }} destination-token: ${{ secrets.CASCADE_DOCS_DESTINATION_TOKEN }} + prefix: ${{ env.GITHUB_REPOSITORY }}-${{ matrix.info.version }} update: .forgejo/cascading-docs env: VERSION: "${{ steps.run.outputs.full_version }}" From 8aa95dc301193a1018c5eec25343d658ee90a2f6 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 10 Jan 2024 15:57:22 +0100 Subject: [PATCH 010/203] docs: do nothing if /srv/contexts does not exist --- .forgejo/cascading-docs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.forgejo/cascading-docs b/.forgejo/cascading-docs index 97e1d8a..7bc4103 100755 --- a/.forgejo/cascading-docs +++ b/.forgejo/cascading-docs @@ -7,6 +7,11 @@ docs_pr=$2 end_to_end=$3 end_to_end_ref=$4 +if ! test -d /srv/contexts ; then + echo no contexts in /srv/contexts, do nothing + exit 0 +fi + cd $docs/docs/user if ! test -f actions-contexts/version.txt || test "$VERSION" != $(cat actions-contexts/version.txt) ; then From 9d4becce0673cfbe8f4023a1918767310db584af Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 10 Jan 2024 16:05:41 +0100 Subject: [PATCH 011/203] docs: enable updates --- .forgejo/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/actions.yml b/.forgejo/workflows/actions.yml index 9ca830b..e2d70b2 100644 --- a/.forgejo/workflows/actions.yml +++ b/.forgejo/workflows/actions.yml @@ -60,7 +60,7 @@ jobs: echo full_version="$full_version" >> $GITHUB_OUTPUT - name: update documentation - if: false && matrix.info.tests != 'none' && github.ref == 'refs/heads/main' + if: matrix.info.tests != 'none' && github.ref == 'refs/heads/main' uses: https://code.forgejo.org/actions/cascading-pr@v1 with: origin-url: ${{ env.GITHUB_SERVER_URL }} From 3a47977c686e31d52378e84ea48b35706fd79973 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 9 Jan 2024 23:02:33 +0100 Subject: [PATCH 012/203] actions: context: add github. --- .../.forgejo/workflows/test.yml | 65 ++++++++++++------- .../action-for-context/action.yml | 2 + 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/actions/example-context/.forgejo/workflows/test.yml b/actions/example-context/.forgejo/workflows/test.yml index 4da32ec..dd5a38e 100644 --- a/actions/example-context/.forgejo/workflows/test.yml +++ b/actions/example-context/.forgejo/workflows/test.yml @@ -14,18 +14,20 @@ jobs: test "$CI" = true test "$CI" = "${{ env.CI }}" - - name: env.GITHUB_ACTION + - name: GITHUB_ACTION run: | set -x echo "$GITHUB_ACTION" | grep -E '^[0-9]+$' test "$GITHUB_ACTION" = "${{ env.GITHUB_ACTION }}" + test "$GITHUB_ACTION" = "${{ github.ACTION }}" # See also actions/example-local-action/.forgejo/local-action/action.yml - - name: env.GITHUB_ACTION_PATH + - name: GITHUB_ACTION_PATH run: | set -x test -z "$GITHUB_ACTION_PATH" test "$GITHUB_ACTION_PATH" = "${{ env.GITHUB_ACTION_PATH }}" + test "$GITHUB_ACTION_PATH" = "${{ github.ACTION_PATH }}" - name: when running an action if: ${{ env.GITHUB_ACTIONS }} @@ -33,138 +35,153 @@ jobs: with: input-one: "otherone" - - name: env.GITHUB_ACTION_REPOSITORY + - name: GITHUB_ACTION_REPOSITORY run: test -f /srv/example/example-context/GITHUB_ACTION_REPOSITORY - - name: env.GITHUB_ACTION_PATH + - name: GITHUB_ACTION_PATH run: test -f /srv/example/example-context/GITHUB_ACTION_PATH - - name: env.GITHUB_ACTIONS + - name: GITHUB_ACTIONS run: | set -x test "$GITHUB_ACTIONS" = true test "$GITHUB_ACTIONS" = "${{ env.GITHUB_ACTIONS }}" - - name: env.GITHUB_ACTOR + - name: GITHUB_ACTOR run: | set -x test "$GITHUB_ACTOR" test "$GITHUB_ACTOR" = "${{ env.GITHUB_ACTOR }}" + test "$GITHUB_ACTOR" = "${{ github.ACTOR }}" - - name: env.GITHUB_API_URL + - name: GITHUB_API_URL shell: bash run: | set -x [[ "$GITHUB_API_URL" =~ /api/v1$ ]] test "$GITHUB_API_URL" = "${{ env.GITHUB_API_URL }}" + test "$GITHUB_API_URL" = "${{ github.API_URL }}" # See also actions/example-pull-request/.forgejo/workflows/test.yml - - name: env.GITHUB_BASE_REF + - name: GITHUB_BASE_REF run: | set -x test -z "$GITHUB_BASE_REF" test "$GITHUB_BASE_REF" = "${{ env.GITHUB_BASE_REF }}" + test "$GITHUB_BASE_REF" = "${{ github.BASE_REF }}" # See also actions/example-pull-request/.forgejo/workflows/test.yml - - name: env.GITHUB_HEAD_REF + - name: GITHUB_HEAD_REF run: | set -x test -z "$GITHUB_HEAD_REF" test "$GITHUB_HEAD_REF" = "${{ env.GITHUB_HEAD_REF }}" + test "$GITHUB_HEAD_REF" = "${{ github.HEAD_REF }}" - - name: env.GITHUB_ENV + - name: GITHUB_ENV run: | set -x test -f "$GITHUB_ENV" test "$GITHUB_ENV" = "${{ env.GITHUB_ENV }}" - - name: env.GITHUB_EVENT_NAME + - name: GITHUB_EVENT_NAME run: | set -x test "$GITHUB_EVENT_NAME" = push test "$GITHUB_EVENT_NAME" = "${{ env.GITHUB_EVENT_NAME }}" + test "$GITHUB_EVENT_NAME" = "${{ github.EVENT_NAME }}" - - name: env.GITHUB_JOB + - name: GITHUB_JOB run: | set -x test "$GITHUB_JOB" = test test "$GITHUB_JOB" = "${{ env.GITHUB_JOB }}" + test "$GITHUB_JOB" = "${{ github.JOB }}" - - name: env.GITHUB_OUTPUT + - name: GITHUB_OUTPUT run: | set -x test -f "$GITHUB_OUTPUT" test "$GITHUB_OUTPUT" = "${{ env.GITHUB_OUTPUT }}" - - name: env.GITHUB_PATH + - name: GITHUB_PATH run: | set -x test -f "$GITHUB_PATH" test "$GITHUB_PATH" = "${{ env.GITHUB_PATH }}" - - name: env.GITHUB_REF + - name: GITHUB_REF shell: bash run: | set -x [[ "$GITHUB_REF" =~ ^refs/ ]] test "$GITHUB_REF" = "${{ env.GITHUB_REF }}" + test "$GITHUB_REF" = "${{ github.REF }}" - - name: env.GITHUB_REF_NAME + - name: GITHUB_REF_NAME shell: bash run: | set -x ! [[ "$GITHUB_REF_NAME" =~ ^refs/ ]] test "$GITHUB_REF_NAME" = "${{ env.GITHUB_REF_NAME }}" + test "$GITHUB_REF_NAME" = "${{ github.REF_NAME }}" - - name: env.GITHUB_REPOSITORY + - name: GITHUB_REPOSITORY run: | set -x test "$GITHUB_REPOSITORY" = root/example-context test "$GITHUB_REPOSITORY" = "${{ env.GITHUB_REPOSITORY }}" + test "$GITHUB_REPOSITORY" = "${{ github.REPOSITORY }}" - - name: env.GITHUB_REPOSITORY_OWNER + - name: GITHUB_REPOSITORY_OWNER run: | set -x test "$GITHUB_REPOSITORY_OWNER" = root test "$GITHUB_REPOSITORY_OWNER" = "${{ env.GITHUB_REPOSITORY_OWNER }}" + test "$GITHUB_REPOSITORY_OWNER" = "${{ github.REPOSITORY_OWNER }}" - - name: env.GITHUB_RUN_NUMBER + - name: GITHUB_RUN_NUMBER run: | set -x echo "$GITHUB_RUN_NUMBER" | grep -E '^[0-9]+$' test "$GITHUB_RUN_NUMBER" = "${{ env.GITHUB_RUN_NUMBER }}" + test "$GITHUB_RUN_NUMBER" = "${{ github.RUN_NUMBER }}" - - name: env.GITHUB_SERVER_URL + - name: GITHUB_SERVER_URL shell: bash run: | set -x [[ "$GITHUB_SERVER_URL" =~ ^http ]] test "$GITHUB_SERVER_URL" = "${{ env.GITHUB_SERVER_URL }}" + test "$GITHUB_SERVER_URL" = "${{ github.SERVER_URL }}" - - name: env.GITHUB_SHA + - name: GITHUB_SHA run: | set -x test "$GITHUB_SHA" test "$GITHUB_SHA" = "${{ env.GITHUB_SHA }}" + test "$GITHUB_SHA" = "${{ github.SHA }}" - - name: env.GITHUB_STEP_SUMMARY + - name: GITHUB_STEP_SUMMARY run: | set -x test -f "$GITHUB_STEP_SUMMARY" test "$GITHUB_STEP_SUMMARY" = "${{ env.GITHUB_STEP_SUMMARY }}" # See also actions/example-pull-request/.forgejo/workflows/test.yml - - name: env.GITHUB_TOKEN + - name: GITHUB_TOKEN run: | set -x test "$GITHUB_TOKEN" test "$GITHUB_TOKEN" = "${{ env.GITHUB_TOKEN }}" + test "$GITHUB_TOKEN" = "${{ github.TOKEN }}" - - name: env.GITHUB_WORKSPACE + - name: GITHUB_WORKSPACE run: | set -x test -d "$GITHUB_WORKSPACE" test "$GITHUB_WORKSPACE" = "${{ env.GITHUB_WORKSPACE }}" + test "$GITHUB_WORKSPACE" = "${{ github.WORKSPACE }}" - name: RUNNER_ARCH run: | diff --git a/actions/example-context/action-for-context/action.yml b/actions/example-context/action-for-context/action.yml index 5a79adc..dcb8f2b 100644 --- a/actions/example-context/action-for-context/action.yml +++ b/actions/example-context/action-for-context/action.yml @@ -11,6 +11,7 @@ runs: set -x test "$GITHUB_ACTION_REPOSITORY" = root/action-for-context test "$GITHUB_ACTION_REPOSITORY" = "${{ env.GITHUB_ACTION_REPOSITORY }}" + test "$GITHUB_ACTION_REPOSITORY" = "${{ github.ACTION_REPOSITORY }}" touch /srv/example/example-context/GITHUB_ACTION_REPOSITORY - name: GITHUB_ACTION_PATH @@ -18,4 +19,5 @@ runs: run: | set -x [[ "$GITHUB_ACTION_PATH" =~ action-for-context@main$ ]] + test "$GITHUB_ACTION_PATH" = "${{ github.ACTION_PATH }}" touch /srv/example/example-context/GITHUB_ACTION_PATH From b648c1cd50866856b024f0f1f60be02f4f412019 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 10 Jan 2024 21:37:05 +0100 Subject: [PATCH 013/203] actions: use volumes: instead of options: for test coverage purposes --- actions/example-context/.forgejo/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actions/example-context/.forgejo/workflows/test.yml b/actions/example-context/.forgejo/workflows/test.yml index dd5a38e..a894bfd 100644 --- a/actions/example-context/.forgejo/workflows/test.yml +++ b/actions/example-context/.forgejo/workflows/test.yml @@ -5,7 +5,8 @@ jobs: runs-on: docker container: image: code.forgejo.org/oci/node:20-bookworm - options: "--volume /srv/example:/srv/example" + volumes: + - /srv/example:/srv/example steps: - name: env.CI From 465538429ece4d9ec0260455e5a7c51a0b52171d Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 12 Jan 2024 17:15:47 +0100 Subject: [PATCH 014/203] actions: add example-push --- .../example-push/.forgejo/workflows/test.yml | 21 +++++++++++++++++++ actions/run.sh | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 actions/example-push/.forgejo/workflows/test.yml diff --git a/actions/example-push/.forgejo/workflows/test.yml b/actions/example-push/.forgejo/workflows/test.yml new file mode 100644 index 0000000..323f2f8 --- /dev/null +++ b/actions/example-push/.forgejo/workflows/test.yml @@ -0,0 +1,21 @@ +on: + push: + branches: + - 'mai*' + +jobs: + test: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + volumes: + - /srv/example:/srv/example + steps: + + - name: save event + run: | + d=/srv/example/pull-request/contexts/$GITHUB_EVENT_NAME + mkdir -p $d + cat > $d/github <<'EOF' + ${{ toJSON(github) }} + EOF diff --git a/actions/run.sh b/actions/run.sh index 60c6eed..84d7707 100755 --- a/actions/run.sh +++ b/actions/run.sh @@ -35,7 +35,7 @@ function examples_v1_20() { function examples_v1_21() { # keep "cron" last otherwise it will linger and pollute the following runs - echo 'echo push-cancel artifacts service checkout pull-request container expression local-action context docker-action if if-fail cron' + echo 'echo push push-cancel artifacts service checkout pull-request container expression local-action context docker-action if if-fail cron' } function examples_v1_22() { From 9222919990f5d51079bfdc25dfade36d699d8ab1 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 13 Jan 2024 17:20:15 +0100 Subject: [PATCH 015/203] actions: push: paths --- actions/example-push/.forgejo/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/actions/example-push/.forgejo/workflows/test.yml b/actions/example-push/.forgejo/workflows/test.yml index 323f2f8..89763f2 100644 --- a/actions/example-push/.forgejo/workflows/test.yml +++ b/actions/example-push/.forgejo/workflows/test.yml @@ -2,6 +2,8 @@ on: push: branches: - 'mai*' + paths: + - '**/test.yml' jobs: test: @@ -14,7 +16,7 @@ jobs: - name: save event run: | - d=/srv/example/pull-request/contexts/$GITHUB_EVENT_NAME + d=/srv/example/push/contexts/$GITHUB_EVENT_NAME mkdir -p $d cat > $d/github <<'EOF' ${{ toJSON(github) }} From f9e93647fb3f275c003e73cda2e02f9f0d6bd7a2 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 13 Jan 2024 17:57:29 +0100 Subject: [PATCH 016/203] update hacking instructions --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f85ed11..77f5eb7 100644 --- a/README.md +++ b/README.md @@ -28,24 +28,25 @@ export PATH=$(pwd)/setup-forgejo:$PATH git clone https://code.forgejo.org/forgejo/end-to-end cd end-to-end export DIR=/tmp/end-to-end +sudo rm -fr /srv/example ; sudo mkdir /srv/example ; sudo chown -R $USER /srv/example ``` Run one example ```sh -actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1_22 cron # runs actions/example-cron +actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 cron # runs actions/example-cron ``` Cleanup ```sh -actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1_22 none +actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 none ``` Run all examples for v1_22 ```sh -actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1_22 +actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 ``` ### Remote testing From dcc61603a2cef8832df6e873443900c3c4453d1c Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 13 Jan 2024 18:03:40 +0100 Subject: [PATCH 017/203] actions: add example-tag --- .../example-tag/.forgejo/workflows/test.yml | 21 +++++++++++++++++++ actions/example-tag/run.sh | 19 +++++++++++++++++ actions/run.sh | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 actions/example-tag/.forgejo/workflows/test.yml create mode 100755 actions/example-tag/run.sh diff --git a/actions/example-tag/.forgejo/workflows/test.yml b/actions/example-tag/.forgejo/workflows/test.yml new file mode 100644 index 0000000..c7e1357 --- /dev/null +++ b/actions/example-tag/.forgejo/workflows/test.yml @@ -0,0 +1,21 @@ +on: + push: + tags: + - 'v*' + +jobs: + test: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + volumes: + - /srv/example:/srv/example + steps: + + - name: save event + run: | + d=/srv/example/tag/contexts/$GITHUB_EVENT_NAME + mkdir -p $d + cat > $d/github <<'EOF' + ${{ toJSON(github) }} + EOF diff --git a/actions/example-tag/run.sh b/actions/example-tag/run.sh new file mode 100755 index 0000000..001c303 --- /dev/null +++ b/actions/example-tag/run.sh @@ -0,0 +1,19 @@ +export d=/srv/example/tag + +function main() { + mkdir -p $d + + local repo=root/example-$example + + forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token + local sha=$(forgejo-test-helper.sh branch_tip $url $repo main) + + local api=$url/api/v1 + forgejo-curl.sh api_json --data-raw '{"tag_name":"v1.1","target":"'$sha'"}' $api/repos/$repo/tags + + forgejo-test-helper.sh wait_success $url $repo $sha + + test -f /srv/example/tag/contexts/push/github +} + +main diff --git a/actions/run.sh b/actions/run.sh index 84d7707..b40cc68 100755 --- a/actions/run.sh +++ b/actions/run.sh @@ -35,7 +35,7 @@ function examples_v1_20() { function examples_v1_21() { # keep "cron" last otherwise it will linger and pollute the following runs - echo 'echo push push-cancel artifacts service checkout pull-request container expression local-action context docker-action if if-fail cron' + echo 'echo push tag push-cancel artifacts service checkout pull-request container expression local-action context docker-action if if-fail cron' } function examples_v1_22() { From 6236202f0946709efaabf3c329b3eeca31a9f50b Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 13 Jan 2024 18:19:56 +0100 Subject: [PATCH 018/203] actions: CASCADE_DOCS_FORCE_VERSION can force generating a version --- .forgejo/cascading-docs | 2 +- .forgejo/workflows/actions.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.forgejo/cascading-docs b/.forgejo/cascading-docs index 7bc4103..63a5bd9 100755 --- a/.forgejo/cascading-docs +++ b/.forgejo/cascading-docs @@ -14,7 +14,7 @@ fi cd $docs/docs/user -if ! test -f actions-contexts/version.txt || test "$VERSION" != $(cat actions-contexts/version.txt) ; then +if test "$FORCE_VERSION" = "$VERSION" || ! test -f actions-contexts/version.txt || test "$VERSION" != $(cat actions-contexts/version.txt) ; then rm -fr actions-contexts mkdir actions-contexts echo "$VERSION" > actions-contexts/version.txt diff --git a/.forgejo/workflows/actions.yml b/.forgejo/workflows/actions.yml index e2d70b2..a4f27a9 100644 --- a/.forgejo/workflows/actions.yml +++ b/.forgejo/workflows/actions.yml @@ -8,6 +8,9 @@ # forgejo-cascading-pr (https://codeberg.org/forgejo-cascading-pr) # secrets.CASCADE_DOCS_DESTINATION_TOKEN # https://codeberg.org/forgejo-cascading-pr scope write:issue, write:repository, read:user +# vars.CASCADE_DOCS_FORCE_VERSION +# replace the generated documentation for a given version even if it has already +# been generated (e.g. v1.22.0-test) # on: @@ -75,4 +78,5 @@ jobs: prefix: ${{ env.GITHUB_REPOSITORY }}-${{ matrix.info.version }} update: .forgejo/cascading-docs env: + FORCE_VERSION: "${{ vars.CASCADE_DOCS_FORCE_VERSION }}" VERSION: "${{ steps.run.outputs.full_version }}" From 4879daf24a0c86b0b4a9f6d59ddd7a98c434d74e Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 18 Jan 2024 17:44:12 +0000 Subject: [PATCH 019/203] update hacking instructions --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 77f5eb7..7d1aaa7 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ export PATH=$(pwd)/setup-forgejo:$PATH git clone https://code.forgejo.org/forgejo/end-to-end cd end-to-end export DIR=/tmp/end-to-end -sudo rm -fr /srv/example ; sudo mkdir /srv/example ; sudo chown -R $USER /srv/example +rm -fr /tmp/end-to-end ; sudo rm -fr /srv/example ; sudo mkdir /srv/example ; sudo chown -R $USER /srv/example ``` Run one example @@ -37,7 +37,7 @@ Run one example actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 cron # runs actions/example-cron ``` -Cleanup +Cleanup. It will teardown Forgejo & the runner and not run them because there is nothing to test. ```sh actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 none @@ -49,6 +49,13 @@ Run all examples for v1_22 actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 ``` +Run from sources + +```sh +make TAGS='bindata sqlite sqlite_unlock_notify' generate forgejo +cp -a forgejo $DIR/forgejo +``` + ### Remote testing To reduce the runtime the following variables can be set to control From 5cdebe65db3e228b8d097740c4f13793f814d8df Mon Sep 17 00:00:00 2001 From: username Date: Wed, 20 Dec 2023 16:46:33 +0100 Subject: [PATCH 020/203] actions/example-cron: verify the type of the event --- actions/example-cron/.forgejo/workflows/test.yml | 8 ++++++++ actions/example-cron/run.sh | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/actions/example-cron/.forgejo/workflows/test.yml b/actions/example-cron/.forgejo/workflows/test.yml index 5f9a843..2eedd14 100644 --- a/actions/example-cron/.forgejo/workflows/test.yml +++ b/actions/example-cron/.forgejo/workflows/test.yml @@ -12,3 +12,11 @@ jobs: steps: - run: | touch /srv/example/cron-volume/DONE + + - name: save context + run: | + d=/srv/example/cron/contexts/$GITHUB_EVENT_NAME + mkdir -p $d + cat > $d/github <<'EOF' + ${{ toJSON(github) }} + EOF diff --git a/actions/example-cron/run.sh b/actions/example-cron/run.sh index c0dc193..f95045f 100755 --- a/actions/example-cron/run.sh +++ b/actions/example-cron/run.sh @@ -20,3 +20,8 @@ if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example/cron cat $FORGEJO_RUNNER_LOGS false fi + +c=/srv/example/cron/contexts/schedule/github +cat $c +test "schedule" = "$(jq -r .event_name < $c)" +test "schedule" = "$(jq -r .event.action < $c)" From 74d11b5eaf7064ee382784e9885e0e53f4fae676 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 24 Jan 2024 00:03:34 +0100 Subject: [PATCH 021/203] packages: add alpine test cases --- .forgejo/workflows/packages.yml | 41 ++++++++++ README.md | 71 ++++++++++++++--- forgejo/build.sh | 2 + lib/lib.sh | 14 ++++ packages/alpine.sh | 17 +++++ packages/alpine/package-source/APKBUILD | 26 +++++++ packages/alpine/package-source/forgejo_2174 | 3 + .../alpine/package-source/forgejo_2174.init | 7 ++ packages/alpine/test.sh | 58 ++++++++++++++ packages/run.sh | 76 +++++++++++++++++++ 10 files changed, 305 insertions(+), 10 deletions(-) create mode 100644 .forgejo/workflows/packages.yml create mode 100644 lib/lib.sh create mode 100644 packages/alpine.sh create mode 100644 packages/alpine/package-source/APKBUILD create mode 100755 packages/alpine/package-source/forgejo_2174 create mode 100755 packages/alpine/package-source/forgejo_2174.init create mode 100755 packages/alpine/test.sh create mode 100755 packages/run.sh diff --git a/.forgejo/workflows/packages.yml b/.forgejo/workflows/packages.yml new file mode 100644 index 0000000..75fd222 --- /dev/null +++ b/.forgejo/workflows/packages.yml @@ -0,0 +1,41 @@ +on: + pull_request: + push: + branches: + - 'main' + +jobs: + actions: + runs-on: self-hosted + strategy: + matrix: + info: + - version: v1.22 + branch: next + forgejo: https://codeberg.org + repo: forgejo-experimental/forgejo + tests: ${{ vars.V1_22_TESTS }} + - version: v1.21 + forgejo: https://codeberg.org + repo: forgejo/forgejo + tests: ${{ vars.V1_21_TESTS }} + steps: + - uses: actions/checkout@v4 + + - uses: https://code.forgejo.org/actions/setup-forgejo@v2 + with: + install-only: true + + - name: run + if: matrix.info.tests != 'none' + shell: bash + run: | + set -x + forgejo-binary.sh ensure_user forgejo + full_version=$(curl -sS ${{ matrix.info.forgejo }}/api/v1/repos/${{ matrix.info.repo }}/releases | jq -r '.[] | .tag_name | select(startswith("${{ matrix.info.version }}"))' | sort -r | head -1) + binary=${{ matrix.info.forgejo }}/${{ matrix.info.repo }}/releases/download/${full_version}/forgejo-${full_version#v}-linux-amd64 + + export DIR=$(mktemp -d) + chown forgejo $DIR /srv + + su -c "packages/run.sh $binary $full_version ${{ matrix.info.version }} ${{ matrix.info.tests }}" forgejo diff --git a/README.md b/README.md index 7d1aaa7..2125eda 100644 --- a/README.md +++ b/README.md @@ -10,17 +10,19 @@ specifically for testing such as They are designed to run using Forgejo releases and development versions compiled from designated repositories. -## Hacking +# Hacking -To run and debug workflows from `actions/example-*`, from the root of -the source directory, with docker and forgejo-curl.sh installed, mimic -what `.forgejo/workflows/actions.yml` does. There may be some manual -tweaking (such as creating temporary directories) because the tests -run as root in the context of Forgejo Actions and assume they have -admin permissions. But they do not need to run as root and must work -fine when run as a regular user. +docker and sudo must be installed with insecure registries allowed in +/etc/docker/daemon.json for the IP that will be used for forgejo such +as: -### Prepare the Forgejo instance and the runner +```json +{ + "insecure-registries": [ "10.80.4.76:3000" ] +} +``` + +Use setup-forgejo from source. ```sh git clone https://code.forgejo.org/actions/setup-forgejo @@ -31,6 +33,23 @@ export DIR=/tmp/end-to-end rm -fr /tmp/end-to-end ; sudo rm -fr /srv/example ; sudo mkdir /srv/example ; sudo chown -R $USER /srv/example ``` +Run using Forgejo built from source. + +```sh +make TAGS='bindata sqlite sqlite_unlock_notify' generate forgejo +cp -a forgejo $DIR/forgejo +``` + +## Running actions locally + +To run and debug workflows from `actions/example-*`, from the root of +the source directory, with docker and forgejo-curl.sh installed, mimic +what `.forgejo/workflows/actions.yml` does. There may be some manual +tweaking (such as creating temporary directories) because the tests +run as root in the context of Forgejo Actions and assume they have +admin permissions. But they do not need to run as root and must work +fine when run as a regular user. + Run one example ```sh @@ -56,7 +75,7 @@ make TAGS='bindata sqlite sqlite_unlock_notify' generate forgejo cp -a forgejo $DIR/forgejo ``` -### Remote testing +Remote testing To reduce the runtime the following variables can be set to control the number of cases run by the @@ -67,3 +86,35 @@ it does not exist, all tests are run. * `V1_22_TESTS` * `V1_21_TESTS` * `V1_20_TESTS` + +## Running packages locally + +To run and debug package tests, from the root of the source directory. + +Run one test + +```sh +packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 alpine # runs packages/alpine.sh +``` + +Cleanup. It will teardown Forgejo and not run them because there is nothing to test. + +```sh +packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 none +``` +Run all examples for v1_22 + +```sh +packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 +``` + +Remote testing + +To reduce the runtime the following variables can be set to control +the number of cases run by the +[packages test](.forgejo/workflows/packages.yml) tests. If set to +**none** they are not run at all for that version of Forgejo. If +it does not exist, all tests are run. + +* `V1_22_PACKAGES_TESTS` +* `V1_21_PACKAGES_TESTS` diff --git a/forgejo/build.sh b/forgejo/build.sh index c78bbdd..5ee106d 100755 --- a/forgejo/build.sh +++ b/forgejo/build.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright 2024 The Forgejo Authors +# SPDX-License-Identifier: MIT set -ex diff --git a/lib/lib.sh b/lib/lib.sh new file mode 100644 index 0000000..f5155c0 --- /dev/null +++ b/lib/lib.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Copyright 2024 The Forgejo Authors +# SPDX-License-Identifier: MIT + +set -e +set -o pipefail + +export DEBIAN_FRONTEND=noninteractive + +if test $(id -u) != 0 ; then + SUDO=sudo +fi + +PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: ' diff --git a/packages/alpine.sh b/packages/alpine.sh new file mode 100644 index 0000000..96c619b --- /dev/null +++ b/packages/alpine.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Copyright 2024 The Forgejo Authors +# SPDX-License-Identifier: MIT + +SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source $SELF_DIR/../lib/lib.sh + +function main() { + local d=$SELF_DIR/alpine + local token=$(cat $DIR/forgejo-token) + local url=$(cat $DIR/forgejo-url) + + docker run --rm --volume $d:$d:ro --workdir $d docker.io/alpine:3.19 ash -c "./test.sh $url $token" +} + +"${@:-main}" diff --git a/packages/alpine/package-source/APKBUILD b/packages/alpine/package-source/APKBUILD new file mode 100644 index 0000000..ce75e29 --- /dev/null +++ b/packages/alpine/package-source/APKBUILD @@ -0,0 +1,26 @@ +# -*- mode: Shell-script; eval: (setq indent-tabs-mode 't); eval: (setq tab-width 4) -*- +# Maintainer: Dominic Meiser +pkgname=forgejo-2174 +pkgver=1.0 +pkgrel=0 +pkgdesc="Forgejo #2174 Reproduction" +url="https://msrd0.dev/msrd0/$pkgname" +arch="x86_64" +license="custom" + +# using x86_64 instead of noarch as a workaround of +# https://codeberg.org/forgejo/forgejo/issues/2173 +subpackages="$pkgname-openrc::x86_64" + +source="forgejo_2174 forgejo_2174.init" +builddir="$srcdir" + +package() { + install -D -m755 "$srcdir/forgejo_2174" "$pkgdir"/usr/bin/forgejo_2174 + install -D -m755 "$srcdir/forgejo_2174.init" "$pkgdir"/etc/init.d/forgejo_2174 +} + +sha512sums=" +651c2a816510a18981bcd45077eb5acd6e58511d641949ddc690e326b81018d851eb7f1c88e2336eada2f216606ce2aa0569eb2d02d7c423c80705cc00acf838 forgejo_2174 +b1cba77139cdaf9e0cdd78de93becbb3891ec59646e8d2cb40620b230bd798d51e6d9c58e65b584812a6bb8eb2b9c9f89262a8700a39c62af8ec8ea09aee4e29 forgejo_2174.init +" diff --git a/packages/alpine/package-source/forgejo_2174 b/packages/alpine/package-source/forgejo_2174 new file mode 100755 index 0000000..b12f87b --- /dev/null +++ b/packages/alpine/package-source/forgejo_2174 @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Hello World" diff --git a/packages/alpine/package-source/forgejo_2174.init b/packages/alpine/package-source/forgejo_2174.init new file mode 100755 index 0000000..06b7f20 --- /dev/null +++ b/packages/alpine/package-source/forgejo_2174.init @@ -0,0 +1,7 @@ +#!/sbin/openrc-run + +command="/usr/bin/forgejo_2174" + +depend() { + need net +} diff --git a/packages/alpine/test.sh b/packages/alpine/test.sh new file mode 100755 index 0000000..e210879 --- /dev/null +++ b/packages/alpine/test.sh @@ -0,0 +1,58 @@ +#!/bin/busybox ash +set -exuo pipefail + +forgejo_url=$1 +forgejo_token=$2 + +# initialize abuild +apk update +apk add --no-cache alpine-sdk sudo util-linux +adduser -D user -h /home/user +addgroup user abuild +echo "root ALL=(ALL) ALL" >/etc/sudoers +echo "%abuild ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers +mkdir -p /var/cache/distfiles +chgrp abuild /var/cache/distfiles +chmod 775 /var/cache/distfiles +mkdir -p "/home/user/.abuild" +echo "/home/user/.abuild/user.rsa" | abuild-keygen -i -b 4096 +echo 'PACKAGER_PRIVKEY=/home/user/.abuild/user.rsa' >/home/user/.abuild/abuild.conf +chown -R "user:user" /home/user/ + +# make sure we own the relevant directory +cp -r package-source /srv/alpine +cd /srv +mkdir packages +echo "REPODEST=/srv/packages" >>/home/user/.abuild/abuild.conf +cat /home/user/.abuild/abuild.conf +chown -R user:user alpine packages + +# build the package +sudo -u user APKBUILD=alpine/APKBUILD abuild -r + +# upload new package +cd packages/srv/x86_64/ +for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do + # remove old package + curl \ + --fail \ + -H "Authorization: token $forgejo_token" \ + -X DELETE \ + "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174/$file" \ + || true + + # upload new package + curl \ + --fail \ + -H "Authorization: token $forgejo_token" \ + -T "$file" \ + "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174" +done + +# ensure that the install-if condition works as expected +apk add openrc +(cd /etc/apk/keys && curl -JO $forgejo_url/api/packages/root/alpine/key) +echo "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174" >>/etc/apk/repositories +apk add forgejo-2174 +[ -e /usr/bin/forgejo_2174 ] # from the installed package +[ -e /etc/init.d/forgejo_2174 ] # from the -openrc package installed because of the install-if condition diff --git a/packages/run.sh b/packages/run.sh new file mode 100755 index 0000000..2a8f991 --- /dev/null +++ b/packages/run.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# Copyright 2024 The Forgejo Authors +# SPDX-License-Identifier: MIT + +SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source $SELF_DIR/../lib/lib.sh + +function run() { + local package=$1 + + bash -ex $SELF_DIR/$package.sh +} + +function packages_v1_21() { + echo 'alpine' +} + +function packages_v1_22() { + packages_v1_21 +} + +function setup() { + local binary=$1 + forgejo-binary.sh setup root admin1234 $binary +} + +function teardown() { + forgejo-curl.sh logout + forgejo-binary.sh teardown +} + +function main() { + local binary="$1" + shift + export full_version="$1" + shift + export version="$1" + shift + + export DOT=$DIR/forgejo-curl + + teardown + + if test "$#" = 0 ; then + packages=$(packages_${version/./_}) + else + packages="$@" + fi + + if test "$packages" = "none" ; then + exit 0 + fi + + setup $binary + + if ! test -f "$DIR/forgejo-auth-url" ; then + echo "DIR=$DIR must be a directory with a forgejo-auth-url file" + fi + + export url=$(cat $DIR/forgejo-auth-url) + export token=$(cat $DIR/forgejo-token) + + for package in $packages ; do + echo "======================== BEGIN package-$package ===================" + if ! time run $package >& /tmp/run.out ; then + sed -e 's/^/[RUN] /' < /tmp/run.out + echo "======================== FAIL package-$package ===================" + sleep 5 # hack for Forgejo v1.21 to workaround a bug by which the last lines of the output are moved to the next step + false + fi + echo "======================== END package-$package ===================" + done +} + +main "$@" From 985388b5b6a7b3fcd1edb7ddc4ae3278a45a6dee Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 3 Feb 2024 19:40:42 +0100 Subject: [PATCH 022/203] README: explain why setup-forgejo is needed for local debug --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 2125eda..a458be0 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,14 @@ as: Use setup-forgejo from source. +The [setup-forgejo](https://code.forgejo.org/actions/setup-forgejo) +repository is a [Forgejo +Action](https://forgejo.org/docs/v1.21/user/actions/) which is meant +to be used in workflows. However, it is implemented as shell scripts that +can also be used to create Forgejo instances and runners locally. This +is convenient for testing and the reason why it needs to be added to the PATH. +For instance, it is a dependency of the `actions/run.sh` script. + ```sh git clone https://code.forgejo.org/actions/setup-forgejo export PATH=$(pwd)/setup-forgejo:$PATH From 9daf94745309bea516b836f1113794a43294ce4a Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 27 Feb 2024 17:15:05 +0100 Subject: [PATCH 023/203] tests: set the name of the packages jobs actions is a copy/paste from the action workflow and packages is better. It also solves a name clash problem as the commit status is based on the job name. --- .forgejo/workflows/packages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/packages.yml b/.forgejo/workflows/packages.yml index 75fd222..99e8072 100644 --- a/.forgejo/workflows/packages.yml +++ b/.forgejo/workflows/packages.yml @@ -5,7 +5,7 @@ on: - 'main' jobs: - actions: + packages: runs-on: self-hosted strategy: matrix: From 0f6708163fa2abbf074ced4239a06053368c77a8 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 28 Feb 2024 17:09:44 +0100 Subject: [PATCH 024/203] packages: support vars.VERBOSE to see what's happening and debug false positives --- .forgejo/workflows/packages.yml | 2 ++ packages/run.sh | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.forgejo/workflows/packages.yml b/.forgejo/workflows/packages.yml index 75fd222..edc8fd2 100644 --- a/.forgejo/workflows/packages.yml +++ b/.forgejo/workflows/packages.yml @@ -38,4 +38,6 @@ jobs: export DIR=$(mktemp -d) chown forgejo $DIR /srv + export VERBOSE="${{ vars.VERBOSE || false }}" + su -c "packages/run.sh $binary $full_version ${{ matrix.info.version }} ${{ matrix.info.tests }}" forgejo diff --git a/packages/run.sh b/packages/run.sh index 2a8f991..5c691c2 100755 --- a/packages/run.sh +++ b/packages/run.sh @@ -68,6 +68,10 @@ function main() { echo "======================== FAIL package-$package ===================" sleep 5 # hack for Forgejo v1.21 to workaround a bug by which the last lines of the output are moved to the next step false + else + if test "$VERBOSE" = true ; then + sed -e 's/^/[RUN] /' < /tmp/run.out + fi fi echo "======================== END package-$package ===================" done From 78027e672db2b5b7d246dafbac721dd33d8c8a20 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 28 Feb 2024 17:38:31 +0100 Subject: [PATCH 025/203] Forgejo v1.22 will actually be Forgejo v7.0 --- .forgejo/workflows/actions.yml | 6 +++--- .forgejo/workflows/packages.yml | 4 ++-- README.md | 20 ++++++++++---------- actions/run.sh | 2 +- forgejo/sources/1.22 | 1 - forgejo/sources/7.0 | 1 + forgejo/upgrades/test-upgrade.sh | 4 ++-- packages/run.sh | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 forgejo/sources/1.22 create mode 100644 forgejo/sources/7.0 diff --git a/.forgejo/workflows/actions.yml b/.forgejo/workflows/actions.yml index a4f27a9..2c17002 100644 --- a/.forgejo/workflows/actions.yml +++ b/.forgejo/workflows/actions.yml @@ -10,7 +10,7 @@ # https://codeberg.org/forgejo-cascading-pr scope write:issue, write:repository, read:user # vars.CASCADE_DOCS_FORCE_VERSION # replace the generated documentation for a given version even if it has already -# been generated (e.g. v1.22.0-test) +# been generated (e.g. v7.0.0-test) # on: @@ -25,11 +25,11 @@ jobs: strategy: matrix: info: - - version: v1.22 + - version: v7.0 branch: next forgejo: https://codeberg.org repo: forgejo-experimental/forgejo - tests: ${{ vars.V1_22_TESTS }} + tests: ${{ vars.V7_0_TESTS }} - version: v1.21 forgejo: https://codeberg.org repo: forgejo/forgejo diff --git a/.forgejo/workflows/packages.yml b/.forgejo/workflows/packages.yml index edc8fd2..7321706 100644 --- a/.forgejo/workflows/packages.yml +++ b/.forgejo/workflows/packages.yml @@ -10,11 +10,11 @@ jobs: strategy: matrix: info: - - version: v1.22 + - version: v7.0 branch: next forgejo: https://codeberg.org repo: forgejo-experimental/forgejo - tests: ${{ vars.V1_22_TESTS }} + tests: ${{ vars.V7_0_TESTS }} - version: v1.21 forgejo: https://codeberg.org repo: forgejo/forgejo diff --git a/README.md b/README.md index a458be0..9fefef9 100644 --- a/README.md +++ b/README.md @@ -61,19 +61,19 @@ fine when run as a regular user. Run one example ```sh -actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 cron # runs actions/example-cron +actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 cron # runs actions/example-cron ``` Cleanup. It will teardown Forgejo & the runner and not run them because there is nothing to test. ```sh -actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 none +actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 none ``` -Run all examples for v1_22 +Run all examples for v7_0 ```sh -actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 +actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 ``` Run from sources @@ -91,7 +91,7 @@ the number of cases run by the **none** they are not run at all for that version of Forgejo. If it does not exist, all tests are run. -* `V1_22_TESTS` +* `v7_0_TESTS` * `V1_21_TESTS` * `V1_20_TESTS` @@ -102,18 +102,18 @@ To run and debug package tests, from the root of the source directory. Run one test ```sh -packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 alpine # runs packages/alpine.sh +packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 alpine # runs packages/alpine.sh ``` Cleanup. It will teardown Forgejo and not run them because there is nothing to test. ```sh -packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 none +packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 none ``` -Run all examples for v1_22 +Run all examples for v7_0 ```sh -packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1.22.0-test v1_22 +packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 ``` Remote testing @@ -124,5 +124,5 @@ the number of cases run by the **none** they are not run at all for that version of Forgejo. If it does not exist, all tests are run. -* `V1_22_PACKAGES_TESTS` +* `v7_0_PACKAGES_TESTS` * `V1_21_PACKAGES_TESTS` diff --git a/actions/run.sh b/actions/run.sh index b40cc68..ab8b86b 100755 --- a/actions/run.sh +++ b/actions/run.sh @@ -38,7 +38,7 @@ function examples_v1_21() { echo 'echo push tag push-cancel artifacts service checkout pull-request container expression local-action context docker-action if if-fail cron' } -function examples_v1_22() { +function examples_v7_0() { examples_v1_21 } diff --git a/forgejo/sources/1.22 b/forgejo/sources/1.22 deleted file mode 100644 index 985576e..0000000 --- a/forgejo/sources/1.22 +++ /dev/null @@ -1 +0,0 @@ -https://codeberg.org/forgejo/forgejo forgejo 7.0.0+0-gitea-1.22.0 diff --git a/forgejo/sources/7.0 b/forgejo/sources/7.0 new file mode 100644 index 0000000..32da8fd --- /dev/null +++ b/forgejo/sources/7.0 @@ -0,0 +1 @@ +https://codeberg.org/forgejo/forgejo forgejo 7.0.0+gitea-1.22.0 diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index cfbb946..a848163 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -65,8 +65,8 @@ function dependencies() { } function build_all() { - log_info 1.22.0-dev - $SELF_DIR/../build.sh 1.22.0-dev $DIR + log_info 7.0.0-dev + $SELF_DIR/../build.sh 7.0.0-dev $DIR } function retry() { diff --git a/packages/run.sh b/packages/run.sh index 5c691c2..7a0a62e 100755 --- a/packages/run.sh +++ b/packages/run.sh @@ -16,7 +16,7 @@ function packages_v1_21() { echo 'alpine' } -function packages_v1_22() { +function packages_v7_0() { packages_v1_21 } From f1fa7c581f03c11f468301824ba461d42cf611aa Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 28 Feb 2024 17:12:29 +0100 Subject: [PATCH 026/203] add editorconfig to help with Forgejo space display --- .editorconfig | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c17e595 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,3 @@ +root = true +[*] +tab_width: 8 From 67dcb074ea8c01b951f8e44e0e51acd6b7b81196 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Thu, 14 Mar 2024 10:36:19 +0700 Subject: [PATCH 027/203] use CIDR in insecure-registries example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fefef9..10e50e6 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ as: ```json { - "insecure-registries": [ "10.80.4.76:3000" ] + "insecure-registries": [ "10.0.0.0/8" ] } ``` From 77b08e6e3329c310465678ac3413d45366fc1157 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Thu, 14 Mar 2024 11:14:22 +0700 Subject: [PATCH 028/203] upgrades: fix path to test-upgrade.sh --- forgejo/upgrades/test-upgrade.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index a848163..2959855 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -4,9 +4,9 @@ # # Debug loop from the source tree: # -# ./.forgejo/upgrades/test-upgrade.sh dependencies -# ./.forgejo/upgrades/test-upgrade.sh build_all -# VERBOSE=true ./.forgejo/upgrades/test-upgrade.sh test_downgrade_1.20.2_fails +# ./forgejo/upgrades/test-upgrade.sh dependencies +# ./forgejo/upgrades/test-upgrade.sh build_all +# VERBOSE=true ./forgejo/upgrades/test-upgrade.sh test_downgrade_1.20.2_fails # # Everything happens in /tmp/forgejo-upgrades # From 4dc1068027f3b9d6ae0efb5d1d3ab0ceff321104 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Thu, 14 Mar 2024 11:14:51 +0700 Subject: [PATCH 029/203] upgrade: fix the version number FORGEJO_VERSION=$semver must be set for make backend --- forgejo/build.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/forgejo/build.sh b/forgejo/build.sh index 5ee106d..857b0c4 100755 --- a/forgejo/build.sh +++ b/forgejo/build.sh @@ -22,11 +22,8 @@ else git clone --depth 1 -b $ref $url $DIR/src cd $DIR/src fi -export TAGS="bindata sqlite sqlite_unlock_notify" + +export TAGS="bindata sqlite sqlite_unlock_notify" FORGEJO_VERSION=$semver make deps-backend backend -# -# use the gitea target here so that branches that do not contain the commit that adds -# the `forgejo` target to the Makefile can build successfully -# -make VERSION=v$version GITEA_VERSION=v$version FORGEJO_VERSION=$semver generate gitea -mv gitea $DIR/forgejo-$version +make generate forgejo +mv forgejo $DIR/forgejo-$version From bc55c01cc64aa08af7a6779c1b7af219a336004f Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Thu, 14 Mar 2024 12:09:29 +0700 Subject: [PATCH 030/203] upgrades: the X.Y version is equivalent to the latest patch release --- forgejo/build.sh | 2 +- forgejo/upgrades/test-upgrade.sh | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/forgejo/build.sh b/forgejo/build.sh index 857b0c4..6d66576 100755 --- a/forgejo/build.sh +++ b/forgejo/build.sh @@ -9,7 +9,7 @@ SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" version=$1 DIR=$2 -v=$(echo $version | sed -E -e 's/([0-9]+\.[0-9]+).*/\1/') +v=$(echo $version | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/') read url ref semver < $SELF_DIR/sources/$v rm -fr $DIR/src diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index 2959855..c9fee3b 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -87,16 +87,40 @@ function retry() { fi } +function full_version() { + local version=$1 + local owner=$2 + + if [[ $version =~ ^[0-9]+\.[0-9]+$ ]] ; then + full_version=$(curl -sS https://codeberg.org/api/v1/repos/$owner/forgejo/releases | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort -r | head -1) + echo ${full_version#v} + else + echo $version + fi +} + function download() { local version=$1 if ! test -f $DIR/forgejo-$version ; then mkdir -p $DIR for owner in forgejo forgejo-experimental forgejo-integration ; do - if wget -O $DIR/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$version/forgejo-$version-linux-amd64 ; then + full_version=$(full_version $version $owner) + if test "$full_version" = "" ; then + continue + fi + if wget -O $DIR/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64 ; then break fi done + if test -s $DIR/forgejo-$version ; then + if test "$version" != "$full_version" ; then + log_info "downloaded $full_version for $version" + fi + else + echo unable to download Forgejo $version + return 1 + fi chmod +x $DIR/forgejo-$version fi } @@ -208,7 +232,7 @@ function create_user() { local cli="$DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path" $cli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email "$FORGEJO_USER@example.com" local scopes="--scopes all" - if echo $version | grep --quiet 1.18. ; then + if echo $version | grep --quiet 1.18 ; then scopes="" fi From 1546793d0a369f810c8c6be1ee84bfd6d8cd0f3b Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Thu, 14 Mar 2024 12:12:43 +0700 Subject: [PATCH 031/203] upgrades: verify storage settings on the latest v1.21 & v7.0 --- forgejo/upgrades/test-upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index c9fee3b..ef7ffb7 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -564,7 +564,7 @@ function test_successful_upgrades() { log_info "using $config app.ini" reset $config - for version in 1.18.5-0 1.19.4-0 1.20.2-0 1.20.3-0 1.21.0-5-rc2 ; do + for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 7.0 ; do log_info "run $version" cleanup_storage start $version From 8bc234e82f9c347f354da606acaa2ee3a2983244 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Thu, 14 Mar 2024 13:06:20 +0700 Subject: [PATCH 032/203] upgrades: verify S3 storage works on v1.21 & v7.0 --- forgejo/upgrades/test-upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index ef7ffb7..5548794 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -500,7 +500,7 @@ function test_storage_stable_s3() { log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338" - for version in 1.18.5-0 1.19.4-0 1.20.2-0 1.20.3-0 ; do + for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 7.0 ; do log_info "Forgejo $version & $s3_backend" stop reset stable-s3 From dcab318b4ab95337a635fa571bd367d5e40457c3 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Thu, 14 Mar 2024 13:33:28 +0700 Subject: [PATCH 033/203] upgrades: prefix the logs with the filename for debugging --- forgejo/upgrades/test-upgrade.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index 5548794..067e7e9 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -143,8 +143,8 @@ function start_forgejo() { local work_path=$DIR/forgejo-work-path daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path if ! retry grep 'Starting server on' $work_path/log/forgejo.log ; then - cat $DIR/*.log - cat $work_path/log/*.log + grep '' $DIR/*.log + grep '' $work_path/log/*.log 2> /dev/null return 1 fi create_user $version From aa83694fd76f80ae06d4c3401a07ae2c512544fd Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Thu, 14 Mar 2024 15:05:49 +0700 Subject: [PATCH 034/203] upgrades: leftovers in the avatars storage is not important, ignore --- forgejo/upgrades/fixtures.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/forgejo/upgrades/fixtures.sh b/forgejo/upgrades/fixtures.sh index 1b8cb44..335b53c 100644 --- a/forgejo/upgrades/fixtures.sh +++ b/forgejo/upgrades/fixtures.sh @@ -12,11 +12,29 @@ function fixture_get_paths_s3() { local path=$1 ( - echo -n $path/ - mc ls --quiet --recursive testS3/$path | sed -e 's/.* //' + mc ls --quiet --recursive testS3/$path | sed -e "s|.* |$path/|" ) > $DIR/path } +function fixture_content_search_s3() { + local path="$1" + local expected="$2" + + fixture_get_paths_s3 $path + if test $(wc -l < $DIR/path) -lt 1 ; then + echo expected at least one but got "'$(cat $DIR/path)'" + return 1 + fi + for filename in $(cat $DIR/path) ; do + local content=$(mc cat testS3/$filename | base64 -w0) + if test "$content" = "$expected" ; then + return 0 + fi + done + echo nothing in $path found with the expected content "$expected" + return 1 +} + function fixture_get_paths_local() { local path=$1 local work_path=$DIR/forgejo-work-path @@ -101,9 +119,7 @@ function fixture_avatars_create() { } function fixture_avatars_assert_s3() { - local filename=$(fixture_get_one_path s3 forgejo/avatars) - local content=$(mc cat testS3/$filename | base64 -w0) - test "$content" = "$ONEPIXEL" + fixture_content_search_s3 forgejo/avatars "$ONEPIXEL" } function fixture_avatars_assert_local() { From be86fe2e445261f781098cf76880e31b0c05a5bf Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Thu, 14 Mar 2024 16:07:40 +0700 Subject: [PATCH 035/203] upgrade: RELEASE_NUMBERS is a variable with all known releases the development branch is not build for v1.21 & v1.20 because they pre-date the hard fork and near EOL --- forgejo/build.sh | 18 +++++++++++------- forgejo/sources/1.20 | 1 - forgejo/sources/1.21 | 1 - forgejo/upgrades/test-upgrade.sh | 16 ++++++++++++---- 4 files changed, 23 insertions(+), 13 deletions(-) delete mode 100644 forgejo/sources/1.20 delete mode 100644 forgejo/sources/1.21 diff --git a/forgejo/build.sh b/forgejo/build.sh index 6d66576..e0330e8 100755 --- a/forgejo/build.sh +++ b/forgejo/build.sh @@ -12,18 +12,22 @@ DIR=$2 v=$(echo $version | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/') read url ref semver < $SELF_DIR/sources/$v -rm -fr $DIR/src -if [[ "$ref" =~ ^refs/ ]] ; then - git clone --depth 1 $url $DIR/src +if ! test -d $DIR/src ; then + mkdir -p $DIR/src cd $DIR/src - git fetch origin +$ref:$ref - git checkout -b $v $ref + git init + git remote add origin $url else - git clone --depth 1 -b $ref $url $DIR/src cd $DIR/src fi +if ! [[ "$ref" =~ ^refs/ ]] ; then + ref=refs/heads/$ref +fi +git fetch --update-head-ok origin +$ref:$ref +git switch --force-create $v $ref + export TAGS="bindata sqlite sqlite_unlock_notify" FORGEJO_VERSION=$semver make deps-backend backend make generate forgejo -mv forgejo $DIR/forgejo-$version +cp -a forgejo $DIR/forgejo-$v-dev diff --git a/forgejo/sources/1.20 b/forgejo/sources/1.20 deleted file mode 100644 index 3539e49..0000000 --- a/forgejo/sources/1.20 +++ /dev/null @@ -1 +0,0 @@ -https://codeberg.org/forgejo/forgejo v1.20/forgejo 5.0.0+0-gitea-1.20.0 diff --git a/forgejo/sources/1.21 b/forgejo/sources/1.21 deleted file mode 100644 index fc1869a..0000000 --- a/forgejo/sources/1.21 +++ /dev/null @@ -1 +0,0 @@ -https://codeberg.org/forgejo/forgejo v1.21/forgejo 6.0.0+0-gitea-1.21.0 diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index 067e7e9..77458d1 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -11,6 +11,11 @@ # Everything happens in /tmp/forgejo-upgrades # +# +# Forgejo releases for which a branch exists (7.0/forgejo etc.) +# +RELEASE_NUMBERS="7.0" + PREFIX=============== HOST_PORT=0.0.0.0:3000 STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars" @@ -26,6 +31,7 @@ SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" : ${FORGEJO_USER:=root} : ${FORGEJO_REPO:=fixture} : ${FORGEJO_PASSWORD:=admin1234} +RELEASE_NUMBERS_AND_DEV="$(for r in $RELEASE_NUMBERS ; do echo -n $r $r-dev ; done)" source $SELF_DIR/fixtures.sh @@ -65,8 +71,10 @@ function dependencies() { } function build_all() { - log_info 7.0.0-dev - $SELF_DIR/../build.sh 7.0.0-dev $DIR + for dev in $RELEASE_NUMBERS ; do + log_info $dev-dev + $SELF_DIR/../build.sh $dev $DIR + done } function retry() { @@ -500,7 +508,7 @@ function test_storage_stable_s3() { log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338" - for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 7.0 ; do + for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do log_info "Forgejo $version & $s3_backend" stop reset stable-s3 @@ -564,7 +572,7 @@ function test_successful_upgrades() { log_info "using $config app.ini" reset $config - for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 7.0 ; do + for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do log_info "run $version" cleanup_storage start $version From b011f038aabc78fffc670a1de381f4e64e1b08a3 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Thu, 14 Mar 2024 16:22:55 +0700 Subject: [PATCH 036/203] upgrades: split v1.20 & database v3 tests in separate files --- forgejo/upgrades/test-upgrade-1.20-storage.sh | 223 ++++++++++++++++ .../test-upgrade-forgejo-database-v3.sh | 28 ++ forgejo/upgrades/test-upgrade.sh | 250 +----------------- 3 files changed, 257 insertions(+), 244 deletions(-) create mode 100644 forgejo/upgrades/test-upgrade-1.20-storage.sh create mode 100644 forgejo/upgrades/test-upgrade-forgejo-database-v3.sh diff --git a/forgejo/upgrades/test-upgrade-1.20-storage.sh b/forgejo/upgrades/test-upgrade-1.20-storage.sh new file mode 100644 index 0000000..6be1fbb --- /dev/null +++ b/forgejo/upgrades/test-upgrade-1.20-storage.sh @@ -0,0 +1,223 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT + +function test_downgrade_1.20.2_fails() { + local work_path=$DIR/forgejo-work-path + + log_info "See also https://codeberg.org/forgejo/forgejo/pulls/1225" + + log_info "downgrading from 1.20.3-0 to 1.20.2-0 fails" + stop + reset default + start 1.20.3-0 + stop + download 1.20.2-0 + timeout 60 $DIR/forgejo-1.20.2-0 --config $work_path/app.ini --work-path $work_path || true + if ! grep --fixed-strings --quiet 'use the newer database' $work_path/log/forgejo.log ; then + cat $work_path/log/forgejo.log + return 1 + fi +} + +function test_bug_storage_merged() { + local work_path=$DIR/forgejo-work-path + + log_info "See also https://codeberg.org/forgejo/forgejo/pulls/1225" + + log_info "using < 1.20.3-0 and [storage].PATH merge all storage" + for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do + stop + reset merged + start $version + for path in ${STORAGE_PATHS} ; do + ! test -d $work_path/data/$path + done + for path in ${STORAGE_PATHS} ; do + ! test -d $work_path/merged/$path + done + test -d $work_path/merged + done + stop + + log_info "upgrading from 1.20.2-0 with [storage].PATH fails" + download 1.20.3-0 + timeout 60 $DIR/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true + if ! grep --fixed-strings --quiet '[storage].PATH is set and may create storage issues' $work_path/log/forgejo.log ; then + cat $work_path/log/forgejo.log + return 1 + fi +} + +function test_bug_storage_relative_path() { + local work_path=$DIR/forgejo-work-path + + log_info "using < 1.20.3-0 legacy [server].XXXX and [picture].XXXX are relative to WORK_PATH" + for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do + stop + reset legagy-relative + start $version + test -d $work_path/relative-lfs + test -d $work_path/relative-avatars + test -d $work_path/relative-repo-avatars + done + + log_info "using >= 1.20.3-0 legacy [server].XXXX and [picture].XXXX are relative to APP_DATA_PATH" + for version in 1.20.3-0 1.21.0-5-rc2 ; do + stop + reset legagy-relative + start $version + test -d $work_path/data/relative-lfs + test -d $work_path/data/relative-avatars + test -d $work_path/data/relative-repo-avatars + done + + log_info "using >= 1.20.3-0 relative [storage.XXXX].PATHS are relative to APP_DATA_PATH" + for version in 1.20.3-0 1.21.0-5-rc2 ; do + stop + reset storage-relative + start $version + for path in ${STORAGE_PATHS} ; do + test -d $work_path/data/relative-$path + done + done + + log_info "using 1.20.[12]-0 relative [storage.XXXX].PATHS are inconsistent" + for version in 1.20.2-0 ; do + stop + reset storage-relative + start $version + test -d $work_path/data/packages + test -d $work_path/relative-repo-archive + test -d $work_path/relative-attachments + test -d $work_path/relative-lfs + test -d $work_path/data/avatars + test -d $work_path/data/repo-avatars + done + + log_info "using < 1.20 relative [storage.XXXX].PATHS are inconsistent" + for version in 1.18.5-0 1.19.4-0 ; do + stop + reset storage-relative + start $version + test -d $work_path/relative-packages + test -d $work_path/relative-repo-archive + test -d $work_path/relative-attachments + test -d $work_path/data/lfs + test -d $work_path/data/avatars + test -d $work_path/data/repo-avatars + done + + log_info "using < 1.20.3-0 relative [XXXX].PATHS are relative to WORK_PATH" + for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do + stop + reset relative + start $version + for path in ${STORAGE_PATHS} ; do + test -d $work_path/relative-$path + done + done + + log_info "using >= 1.20.3-0 relative [XXXX].PATHS are relative to APP_DATA_PATH" + for version in 1.20.3-0 1.21.0-5-rc2 ; do + stop + reset relative + start $version + for path in ${STORAGE_PATHS} ; do + test -d $work_path/data/relative-$path + done + done + + stop +} + +function test_bug_storage_s3_misplace() { + local work_path=$DIR/forgejo-work-path + local s3_backend=${2:-minio} + + log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338" + + for version in 1.20.2-0 1.20.3-0 ; do + log_info "Forgejo $version & $s3_backend" + stop + reset misplace-s3 + start $version $s3_backend + fixture_create + for fun in ${STORAGE_FUN} ; do + fixture_${fun}_assert_s3 + done + done + + for version in 1.18.5-0 1.19.4-0 ; do + log_info "Forgejo $version & $s3_backend" + stop + reset misplace-s3 + start $version $s3_backend + fixture_create + # + # some storage are in S3 + # + fixture_attachments_assert_s3 + fixture_lfs_assert_s3 + # + # others are in local + # + fixture_repo_archive_assert_local elsewhere/repo-archive + fixture_avatars_assert_local elsewhere/avatars + fixture_packages_assert_local elsewhere/packages + fixture_repo_avatars_assert_local elsewhere/repo-avatars + done +} + +function test_bug_storage_misplace() { + local work_path=$DIR/forgejo-work-path + + log_info "See also https://codeberg.org/forgejo/forgejo/pulls/1225" + + log_info "using < 1.20 and conflicting sections misplace storage" + for version in 1.18.5-0 1.19.4-0 ; do + stop + reset misplace + start $version + # + # some storage are where they should be + # + test -d $work_path/data/packages + test -d $work_path/data/repo-archive + test -d $work_path/data/attachments + # + # others are under APP_DATA_PATH + # + test -d $work_path/elsewhere/lfs + test -d $work_path/elsewhere/avatars + test -d $work_path/elsewhere/repo-avatars + done + + log_info "using < 1.20.[12]-0 and conflicting sections ignores [storage.*]" + for version in 1.20.2-0 ; do + stop + reset misplace + start $version + for path in ${STORAGE_PATHS} ; do + test -d $work_path/elsewhere/$path + done + done + + stop + + log_info "upgrading from 1.20.2-0 with conflicting sections fails" + download 1.20.3-0 + timeout 60 $DIR/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true + for path in ${STORAGE_PATHS} ; do + if ! grep --fixed-strings --quiet "[storage.$path] may conflict" $work_path/log/forgejo.log ; then + cat $work_path/log/forgejo.log + return 1 + fi + done +} + +function test_upgrade_1_20_storage() { + run test_bug_storage_misplace + run test_bug_storage_merged + run test_downgrade_1.20.2_fails + run test_bug_storage_s3_misplace +} diff --git a/forgejo/upgrades/test-upgrade-forgejo-database-v3.sh b/forgejo/upgrades/test-upgrade-forgejo-database-v3.sh new file mode 100644 index 0000000..db1e9d4 --- /dev/null +++ b/forgejo/upgrades/test-upgrade-forgejo-database-v3.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT + +function test_forgejo_database_v3_upgrades_list_table() { + local table=$1 + local work_path=$DIR/forgejo-work-path + + sqlite3 $work_path/forgejo.db ".tables $table" .exit | grep --quiet $table +} + +function test_forgejo_database_v3_upgrades() { + local table=forgejo_auth_token + + stop + + reset default + log_info "run 1.20.4-1" + start 1.20.4-1 + stop + ! test_forgejo_database_v3_upgrades_list_table $table + test_forgejo_database_version 2 + + log_info "run 1.20.5-0" + start 1.20.5-0 + stop + test_forgejo_database_v3_upgrades_list_table $table + test_forgejo_database_version 3 +} diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index 77458d1..14313c4 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -335,173 +335,6 @@ function cleanup_storage() { done } -function test_downgrade_1.20.2_fails() { - local work_path=$DIR/forgejo-work-path - - log_info "See also https://codeberg.org/forgejo/forgejo/pulls/1225" - - log_info "downgrading from 1.20.3-0 to 1.20.2-0 fails" - stop - reset default - start 1.20.3-0 - stop - download 1.20.2-0 - timeout 60 $DIR/forgejo-1.20.2-0 --config $work_path/app.ini --work-path $work_path || true - if ! grep --fixed-strings --quiet 'use the newer database' $work_path/log/forgejo.log ; then - cat $work_path/log/forgejo.log - return 1 - fi -} - -function test_bug_storage_merged() { - local work_path=$DIR/forgejo-work-path - - log_info "See also https://codeberg.org/forgejo/forgejo/pulls/1225" - - log_info "using < 1.20.3-0 and [storage].PATH merge all storage" - for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do - stop - reset merged - start $version - for path in ${STORAGE_PATHS} ; do - ! test -d $work_path/data/$path - done - for path in ${STORAGE_PATHS} ; do - ! test -d $work_path/merged/$path - done - test -d $work_path/merged - done - stop - - log_info "upgrading from 1.20.2-0 with [storage].PATH fails" - download 1.20.3-0 - timeout 60 $DIR/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true - if ! grep --fixed-strings --quiet '[storage].PATH is set and may create storage issues' $work_path/log/forgejo.log ; then - cat $work_path/log/forgejo.log - return 1 - fi -} - -function test_bug_storage_relative_path() { - local work_path=$DIR/forgejo-work-path - - log_info "using < 1.20.3-0 legacy [server].XXXX and [picture].XXXX are relative to WORK_PATH" - for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do - stop - reset legagy-relative - start $version - test -d $work_path/relative-lfs - test -d $work_path/relative-avatars - test -d $work_path/relative-repo-avatars - done - - log_info "using >= 1.20.3-0 legacy [server].XXXX and [picture].XXXX are relative to APP_DATA_PATH" - for version in 1.20.3-0 1.21.0-5-rc2 ; do - stop - reset legagy-relative - start $version - test -d $work_path/data/relative-lfs - test -d $work_path/data/relative-avatars - test -d $work_path/data/relative-repo-avatars - done - - log_info "using >= 1.20.3-0 relative [storage.XXXX].PATHS are relative to APP_DATA_PATH" - for version in 1.20.3-0 1.21.0-5-rc2 ; do - stop - reset storage-relative - start $version - for path in ${STORAGE_PATHS} ; do - test -d $work_path/data/relative-$path - done - done - - log_info "using 1.20.[12]-0 relative [storage.XXXX].PATHS are inconsistent" - for version in 1.20.2-0 ; do - stop - reset storage-relative - start $version - test -d $work_path/data/packages - test -d $work_path/relative-repo-archive - test -d $work_path/relative-attachments - test -d $work_path/relative-lfs - test -d $work_path/data/avatars - test -d $work_path/data/repo-avatars - done - - log_info "using < 1.20 relative [storage.XXXX].PATHS are inconsistent" - for version in 1.18.5-0 1.19.4-0 ; do - stop - reset storage-relative - start $version - test -d $work_path/relative-packages - test -d $work_path/relative-repo-archive - test -d $work_path/relative-attachments - test -d $work_path/data/lfs - test -d $work_path/data/avatars - test -d $work_path/data/repo-avatars - done - - log_info "using < 1.20.3-0 relative [XXXX].PATHS are relative to WORK_PATH" - for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do - stop - reset relative - start $version - for path in ${STORAGE_PATHS} ; do - test -d $work_path/relative-$path - done - done - - log_info "using >= 1.20.3-0 relative [XXXX].PATHS are relative to APP_DATA_PATH" - for version in 1.20.3-0 1.21.0-5-rc2 ; do - stop - reset relative - start $version - for path in ${STORAGE_PATHS} ; do - test -d $work_path/data/relative-$path - done - done - - stop -} - -function test_bug_storage_s3_misplace() { - local work_path=$DIR/forgejo-work-path - local s3_backend=${2:-minio} - - log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338" - - for version in 1.20.2-0 1.20.3-0 ; do - log_info "Forgejo $version & $s3_backend" - stop - reset misplace-s3 - start $version $s3_backend - fixture_create - for fun in ${STORAGE_FUN} ; do - fixture_${fun}_assert_s3 - done - done - - for version in 1.18.5-0 1.19.4-0 ; do - log_info "Forgejo $version & $s3_backend" - stop - reset misplace-s3 - start $version $s3_backend - fixture_create - # - # some storage are in S3 - # - fixture_attachments_assert_s3 - fixture_lfs_assert_s3 - # - # others are in local - # - fixture_repo_archive_assert_local elsewhere/repo-archive - fixture_avatars_assert_local elsewhere/avatars - fixture_packages_assert_local elsewhere/packages - fixture_repo_avatars_assert_local elsewhere/repo-avatars - done -} - function test_storage_stable_s3() { local work_path=$DIR/forgejo-work-path local s3_backend=${1:-minio} @@ -520,53 +353,6 @@ function test_storage_stable_s3() { done } -function test_bug_storage_misplace() { - local work_path=$DIR/forgejo-work-path - - log_info "See also https://codeberg.org/forgejo/forgejo/pulls/1225" - - log_info "using < 1.20 and conflicting sections misplace storage" - for version in 1.18.5-0 1.19.4-0 ; do - stop - reset misplace - start $version - # - # some storage are where they should be - # - test -d $work_path/data/packages - test -d $work_path/data/repo-archive - test -d $work_path/data/attachments - # - # others are under APP_DATA_PATH - # - test -d $work_path/elsewhere/lfs - test -d $work_path/elsewhere/avatars - test -d $work_path/elsewhere/repo-avatars - done - - log_info "using < 1.20.[12]-0 and conflicting sections ignores [storage.*]" - for version in 1.20.2-0 ; do - stop - reset misplace - start $version - for path in ${STORAGE_PATHS} ; do - test -d $work_path/elsewhere/$path - done - done - - stop - - log_info "upgrading from 1.20.2-0 with conflicting sections fails" - download 1.20.3-0 - timeout 60 $DIR/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true - for path in ${STORAGE_PATHS} ; do - if ! grep --fixed-strings --quiet "[storage.$path] may conflict" $work_path/log/forgejo.log ; then - cat $work_path/log/forgejo.log - return 1 - fi - done -} - function test_successful_upgrades() { for config in default specific ; do log_info "using $config app.ini" @@ -590,32 +376,6 @@ function test_forgejo_database_version() { test "$expected_version" = "$actual_version" } -function test_forgejo_database_v3_upgrades_list_table() { - local table=$1 - local work_path=$DIR/forgejo-work-path - - sqlite3 $work_path/forgejo.db ".tables $table" .exit | grep --quiet $table -} - -function test_forgejo_database_v3_upgrades() { - local table=forgejo_auth_token - - stop - - reset default - log_info "run 1.20.4-1" - start 1.20.4-1 - stop - ! test_forgejo_database_v3_upgrades_list_table $table - test_forgejo_database_version 2 - - log_info "run 1.20.5-0" - start 1.20.5-0 - stop - test_forgejo_database_v3_upgrades_list_table $table - test_forgejo_database_version 3 -} - function run() { local fun=$1 shift @@ -635,17 +395,19 @@ function run() { echo Success running $fun } +source $SELF_DIR/test-upgrade-1.20-storage.sh +source $SELF_DIR/test-upgrade-forgejo-database-v3.sh + function test_upgrades() { run stop run dependencies run build_all + run test_successful_upgrades - run test_bug_storage_misplace - run test_bug_storage_merged - run test_downgrade_1.20.2_fails - run test_bug_storage_s3_misplace run test_storage_stable_s3 minio run test_storage_stable_s3 garage + + test_upgrade_1_20_storage run test_forgejo_database_v3_upgrades } From f4d0c03302d9b86c247faa7ab4a1c6b5cf1afe9d Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Fri, 15 Mar 2024 09:57:35 +0700 Subject: [PATCH 037/203] upgrades: remove ad-hoc code and use forgejo-curl.sh instead --- .gitignore | 3 -- forgejo/upgrades/fixtures.sh | 18 +++++------ forgejo/upgrades/test-upgrade.sh | 55 +++++++++++--------------------- 3 files changed, 28 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index 5c2e2ef..ff9fe83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,9 @@ *~ -forgejo-api -forgejo-header forgejo-ip forgejo-runner-home forgejo-runner-pid forgejo-runner-token forgejo-runner.clientpid forgejo-runner.log -forgejo-token .runner #* diff --git a/forgejo/upgrades/fixtures.sh b/forgejo/upgrades/fixtures.sh index 335b53c..abad7e3 100644 --- a/forgejo/upgrades/fixtures.sh +++ b/forgejo/upgrades/fixtures.sh @@ -97,8 +97,8 @@ function fixture_lfs_assert_local() { function fixture_packages_create() { echo PACKAGE_CONTENT > $DIR/fixture/package - $work_path/forgejo-api -X DELETE http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt || true - $work_path/forgejo-api --upload-file $DIR/fixture/package http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt + forgejo-curl.sh api_json -X DELETE http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt || true + forgejo-curl.sh api_json --upload-file $DIR/fixture/package http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt } function fixture_packages_assert_s3() { @@ -115,7 +115,7 @@ function fixture_packages_assert_local() { function fixture_avatars_create() { echo -n $ONEPIXEL | base64 --decode > $DIR/avatar.png - $work_path/forgejo-client --form avatar=@$DIR/avatar.png http://${HOST_PORT}/user/settings/avatar + forgejo-curl.sh web --form avatar=@$DIR/avatar.png http://${HOST_PORT}/user/settings/avatar } function fixture_avatars_assert_s3() { @@ -132,9 +132,9 @@ function fixture_avatars_assert_local() { function fixture_repo_avatars_create() { echo -n $ONEPIXEL | base64 --decode > $DIR/repo-avatar.png - $work_path/forgejo-client --form avatar=@$DIR/repo-avatar.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/settings/avatar + forgejo-curl.sh web --form avatar=@$DIR/repo-avatar.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/settings/avatar # v1.21 only - #$work_path/forgejo-api -X POST --data-raw '{"body":"'$avatar'"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/avatar + #forgejo-curl.sh api_json -X POST --data-raw '{"body":"'$avatar'"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/avatar } function fixture_repo_avatars_assert_s3() { @@ -153,17 +153,17 @@ function fixture_repo_avatars_assert_local() { function fixture_attachments_create_1_18() { echo -n $ONEPIXEL | base64 --decode > $DIR/attachment.png - $work_path/forgejo-client --trace-ascii - --form file=@$DIR/attachment.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/issues/attachments + forgejo-curl.sh web --trace-ascii - --form file=@$DIR/attachment.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/issues/attachments } function fixture_attachments_create() { - if $work_path/forgejo-api http://${HOST_PORT}/api/v1/version | grep --quiet --fixed-strings 1.18. ; then + if forgejo-curl.sh api_json http://${HOST_PORT}/api/v1/version | grep --quiet --fixed-strings 1.18. ; then fixture_attachments_create_1_18 return fi - id=$($work_path/forgejo-api --data-raw '{"title":"TITLE"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues | jq .id) + id=$(forgejo-curl.sh api_json --data-raw '{"title":"TITLE"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues | jq .id) echo -n $ONEPIXEL | base64 --decode > $DIR/attachment.png - $work_path/forgejo-client -H @$DIR/forgejo-work-path/forgejo-header --form name=attachment.png --form attachment=@$DIR/attachment.png http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues/$id/assets + forgejo-curl.sh api --form name=attachment.png --form attachment=@$DIR/attachment.png http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues/$id/assets } function fixture_attachments_assert_s3() { diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index 14313c4..8d825f1 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -21,6 +21,8 @@ HOST_PORT=0.0.0.0:3000 STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars" STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars" DIR=/tmp/forgejo-upgrades +export DOT_FORGEJO_CURL=$DIR/forgejo-curl +export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 if ${VERBOSE:-false} ; then set -ex PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: ' @@ -47,17 +49,23 @@ function log_info() { function dependencies() { maybe_sudo + + if ! test -f /usr/local/bin/forgejo-curl.sh ; then + $SUDO curl --fail -sS https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh -o /usr/local/bin/forgejo-curl.sh + $SUDO chmod +x /usr/local/bin/forgejo-curl.sh + fi + if ! which curl daemon jq git-lfs > /dev/null ; then export DEBIAN_FRONTEND=noninteractive $SUDO apt-get update -qq $SUDO apt-get install -y -qq curl daemon git-lfs jq sqlite3 gettext-base fi - if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio > /dev/null ; then + if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio ; then $SUDO curl --fail -sS https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc $SUDO curl --fail -sS https://dl.min.io/server/minio/release/linux-amd64/minio -o /usr/local/bin/minio fi - if ! test -x /usr/local/bin/mc || ! test -x /usr/local/bin/minio > /dev/null ; then + if ! test -x /usr/local/bin/mc || ! test -x /usr/local/bin/minio ; then $SUDO chmod +x /usr/local/bin/mc $SUDO chmod +x /usr/local/bin/minio fi @@ -155,7 +163,7 @@ function start_forgejo() { grep '' $work_path/log/*.log 2> /dev/null return 1 fi - create_user $version + create_user_and_login $version } function start_minio() { @@ -228,47 +236,22 @@ function start() { start_forgejo $version } -function create_user() { +function create_user_and_login() { local version=$1 local work_path=$DIR/forgejo-work-path - - if test -f $work_path/forgejo-token; then - return + local email="$FORGEJO_USER@example.com" + local cli="$DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path" + if ! $cli admin user list | grep --quiet "$email" ; then + $cli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email fi - local cli="$DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path" - $cli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email "$FORGEJO_USER@example.com" - local scopes="--scopes all" + forgejo-curl.sh logout + local scopes='--scopes ["all"]' if echo $version | grep --quiet 1.18 ; then scopes="" fi - - # - # forgejo-cli is to use with api/v1 enpoints - # - # tail -1 is because there are logs creating noise in the output in v1.19.4-0 - # - $cli admin user generate-access-token -u $FORGEJO_USER --raw $scopes | tail -1 > $work_path/forgejo-token - ( echo -n 'Authorization: token ' ; cat $work_path/forgejo-token ) > $work_path/forgejo-header - ( echo "#!/bin/sh" ; echo 'curl -f -sS -H "Content-Type: application/json" -H @'$work_path/forgejo-header' "$@"' ) > $work_path/forgejo-api && chmod +x $work_path/forgejo-api - $work_path/forgejo-api http://${HOST_PORT}/api/v1/version - - # - # forgejo-client is to use with web endpoints - # - # - # login and obtain a CSRF, all stored in the cookie file - # - ( echo "#!/bin/sh" ; echo 'curl --cookie-jar '$DIR/cookies' --cookie '$DIR/cookies' -f -sS "$@"' ) > $work_path/forgejo-client-update-cookies && chmod +x $work_path/forgejo-client-update-cookies - $work_path/forgejo-client-update-cookies http://${HOST_PORT}/user/login -o /dev/null - $work_path/forgejo-client-update-cookies --verbose -X POST --data user_name=${FORGEJO_USER} --data password=${FORGEJO_PASSWORD} http://${HOST_PORT}/user/login >& $DIR/login.html - $work_path/forgejo-client-update-cookies http://${HOST_PORT}/user/login -o /dev/null - local csrf=$(sed -n -e '/csrf/s/.*csrf\t//p' $DIR/cookies) - # - # use the cookie file but do not modify it - # - ( echo "#!/bin/sh" ; echo 'curl --cookie '$DIR/cookies' -H "X-Csrf-Token: '$csrf'" -f -sS "$@"' ) > $work_path/forgejo-client && chmod +x $work_path/forgejo-client + forgejo-curl.sh --user "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" $scopes login http://${HOST_PORT} } function stop_daemon() { From 3ead37ed3769ee0d8b2f4723ac7d82b06159b7eb Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Fri, 15 Mar 2024 12:30:06 +0700 Subject: [PATCH 038/203] upgrades: use the host IP instead of 0.0.0.0 otherwise it cannot be used when running from a LXC/docker container --- forgejo/upgrades/test-upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index 8d825f1..b0a104e 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -17,7 +17,7 @@ RELEASE_NUMBERS="7.0" PREFIX=============== -HOST_PORT=0.0.0.0:3000 +HOST_PORT=$(hostname -I | cut -f1 -d' '):3000 STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars" STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars" DIR=/tmp/forgejo-upgrades From bf6ece0f5271b383a6d6f5c0da7641239f507789 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Fri, 15 Mar 2024 13:15:54 +0700 Subject: [PATCH 039/203] README: v7.0.0-test is known as v7.0-test --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 10e50e6..3cdb044 100644 --- a/README.md +++ b/README.md @@ -102,18 +102,18 @@ To run and debug package tests, from the root of the source directory. Run one test ```sh -packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 alpine # runs packages/alpine.sh +packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0-test/forgejo-7.0-test-linux-amd64 v7.0.0-test v7_0 alpine # runs packages/alpine.sh ``` Cleanup. It will teardown Forgejo and not run them because there is nothing to test. ```sh -packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 none +packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0-test/forgejo-7.0-test-linux-amd64 v7.0.0-test v7_0 none ``` Run all examples for v7_0 ```sh -packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 +packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0-test/forgejo-7.0-test-linux-amd64 v7.0.0-test v7_0 ``` Remote testing From 8347d9e0401beb811cffa11680b5bd7196bd5027 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Fri, 15 Mar 2024 13:17:01 +0700 Subject: [PATCH 040/203] upgrades; move SUDO and verbosity control to lib --- forgejo/upgrades/test-upgrade.sh | 22 +++++----------------- lib/lib.sh | 10 ++++++++-- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index b0a104e..7967454 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -11,25 +11,21 @@ # Everything happens in /tmp/forgejo-upgrades # +SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $SELF_DIR/../../lib/lib.sh + # # Forgejo releases for which a branch exists (7.0/forgejo etc.) # RELEASE_NUMBERS="7.0" PREFIX=============== -HOST_PORT=$(hostname -I | cut -f1 -d' '):3000 +HOST_PORT=$IP:3000 STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars" STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars" DIR=/tmp/forgejo-upgrades export DOT_FORGEJO_CURL=$DIR/forgejo-curl export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 -if ${VERBOSE:-false} ; then - set -ex - PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: ' -else - set -e -fi -SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" : ${FORGEJO_USER:=root} : ${FORGEJO_REPO:=fixture} : ${FORGEJO_PASSWORD:=admin1234} @@ -37,18 +33,11 @@ RELEASE_NUMBERS_AND_DEV="$(for r in $RELEASE_NUMBERS ; do echo -n $r $r-dev ; do source $SELF_DIR/fixtures.sh -function maybe_sudo() { - if test $(id -u) != 0 ; then - SUDO=sudo - fi -} - function log_info() { echo "$PREFIX $@" } function dependencies() { - maybe_sudo if ! test -f /usr/local/bin/forgejo-curl.sh ; then $SUDO curl --fail -sS https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh -o /usr/local/bin/forgejo-curl.sh @@ -56,7 +45,6 @@ function dependencies() { fi if ! which curl daemon jq git-lfs > /dev/null ; then - export DEBIAN_FRONTEND=noninteractive $SUDO apt-get update -qq $SUDO apt-get install -y -qq curl daemon git-lfs jq sqlite3 gettext-base fi @@ -367,7 +355,7 @@ function run() { mkdir -p $DIR > $DIR/$fun.out tail --follow $DIR/$fun.out | sed --unbuffered -n -e "/^$PREFIX/s/^$PREFIX //p" & - pid=$! + local pid=$! if ! VERBOSE=true ${BASH_SOURCE[0]} $fun "$@" >& $DIR/$fun.out ; then kill $pid cat $DIR/$fun.out diff --git a/lib/lib.sh b/lib/lib.sh index f5155c0..4bacc59 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -2,7 +2,13 @@ # Copyright 2024 The Forgejo Authors # SPDX-License-Identifier: MIT -set -e +if ${VERBOSE:-false} ; then + set -ex + PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: ' +else + set -e +fi + set -o pipefail export DEBIAN_FRONTEND=noninteractive @@ -11,4 +17,4 @@ if test $(id -u) != 0 ; then SUDO=sudo fi -PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: ' +IP=$(hostname -I | cut -f1 -d' ') From dd35a9f1a8eaa04373a83591a255e2cbe5bfbf4c Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Fri, 15 Mar 2024 13:29:20 +0700 Subject: [PATCH 041/203] lib: import generic helpers from upgrades --- forgejo/upgrades/test-upgrade.sh | 285 +------------------------------ {forgejo => lib}/build.sh | 2 +- lib/lib.sh | 285 +++++++++++++++++++++++++++++++ 3 files changed, 288 insertions(+), 284 deletions(-) rename {forgejo => lib}/build.sh (92%) diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index 7967454..25eea18 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -12,280 +12,18 @@ # SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +SELF="${BASH_SOURCE[0]}" source $SELF_DIR/../../lib/lib.sh -# -# Forgejo releases for which a branch exists (7.0/forgejo etc.) -# -RELEASE_NUMBERS="7.0" - -PREFIX=============== -HOST_PORT=$IP:3000 STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars" STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars" -DIR=/tmp/forgejo-upgrades -export DOT_FORGEJO_CURL=$DIR/forgejo-curl -export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 -: ${FORGEJO_USER:=root} : ${FORGEJO_REPO:=fixture} -: ${FORGEJO_PASSWORD:=admin1234} -RELEASE_NUMBERS_AND_DEV="$(for r in $RELEASE_NUMBERS ; do echo -n $r $r-dev ; done)" source $SELF_DIR/fixtures.sh -function log_info() { - echo "$PREFIX $@" -} - -function dependencies() { - - if ! test -f /usr/local/bin/forgejo-curl.sh ; then - $SUDO curl --fail -sS https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh -o /usr/local/bin/forgejo-curl.sh - $SUDO chmod +x /usr/local/bin/forgejo-curl.sh - fi - - if ! which curl daemon jq git-lfs > /dev/null ; then - $SUDO apt-get update -qq - $SUDO apt-get install -y -qq curl daemon git-lfs jq sqlite3 gettext-base - fi - - if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio ; then - $SUDO curl --fail -sS https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc - $SUDO curl --fail -sS https://dl.min.io/server/minio/release/linux-amd64/minio -o /usr/local/bin/minio - fi - if ! test -x /usr/local/bin/mc || ! test -x /usr/local/bin/minio ; then - $SUDO chmod +x /usr/local/bin/mc - $SUDO chmod +x /usr/local/bin/minio - fi - - if ! test -f /usr/local/bin/garage > /dev/null ; then - $SUDO curl --fail -sS https://garagehq.deuxfleurs.fr/_releases/v0.8.2/x86_64-unknown-linux-musl/garage -o /usr/local/bin/garage - fi - if ! test -x /usr/local/bin/garage > /dev/null ; then - $SUDO chmod +x /usr/local/bin/garage - fi -} - -function build_all() { - for dev in $RELEASE_NUMBERS ; do - log_info $dev-dev - $SELF_DIR/../build.sh $dev $DIR - done -} - -function retry() { - rm -f $DIR/wait-for.out - success=false - for delay in 1 1 5 5 15 ; do - if "$@" >> $DIR/wait-for.out 2>&1 ; then - success=true - break - fi - cat $DIR/wait-for.out - echo waiting $delay - sleep $delay - done - if test $success = false ; then - cat $DIR/wait-for.out - return 1 - fi -} - -function full_version() { - local version=$1 - local owner=$2 - - if [[ $version =~ ^[0-9]+\.[0-9]+$ ]] ; then - full_version=$(curl -sS https://codeberg.org/api/v1/repos/$owner/forgejo/releases | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort -r | head -1) - echo ${full_version#v} - else - echo $version - fi -} - -function download() { - local version=$1 - - if ! test -f $DIR/forgejo-$version ; then - mkdir -p $DIR - for owner in forgejo forgejo-experimental forgejo-integration ; do - full_version=$(full_version $version $owner) - if test "$full_version" = "" ; then - continue - fi - if wget -O $DIR/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64 ; then - break - fi - done - if test -s $DIR/forgejo-$version ; then - if test "$version" != "$full_version" ; then - log_info "downloaded $full_version for $version" - fi - else - echo unable to download Forgejo $version - return 1 - fi - chmod +x $DIR/forgejo-$version - fi -} - -function cleanup_logs() { - local work_path=$DIR/forgejo-work-path - - rm -f $DIR/*.log - rm -f $work_path/log/*.log -} - -function clobber() { - rm -fr /tmp/forgejo-upgrades -} - -function start_forgejo() { - local version=$1 - - download $version - local work_path=$DIR/forgejo-work-path - daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path - if ! retry grep 'Starting server on' $work_path/log/forgejo.log ; then - grep '' $DIR/*.log - grep '' $work_path/log/*.log 2> /dev/null - return 1 - fi - create_user_and_login $version -} - -function start_minio() { - mkdir -p $DIR/minio - daemon --chdir=$DIR --unsafe \ - --env="PATH=$PATH" \ - --env=MINIO_ROOT_USER=123456 \ - --env=MINIO_ROOT_PASSWORD=12345678 \ - --env=MINIO_VOLUMES=$DIR/minio \ - --pidfile=$DIR/minio-pid --errlog=$DIR/minio-err.log --output=$DIR/minio-out.log -- /usr/local/bin/minio server - retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678 -} - -function start_garage() { - mkdir -p $DIR/garage/{data,meta} - cat > $DIR/garage/garage.toml < $work_path/app.ini -} - -function reset_minio() { - rm -fr $DIR/minio -} - -function reset_garage() { - rm -fr $DIR/garage -} - function reset() { local config=$1 - reset_forgejo $config + reset_forgejo $SELF_DIR/$config-app.ini reset_minio reset_garage } @@ -347,25 +85,6 @@ function test_forgejo_database_version() { test "$expected_version" = "$actual_version" } -function run() { - local fun=$1 - shift - - echo Start running $fun - mkdir -p $DIR - > $DIR/$fun.out - tail --follow $DIR/$fun.out | sed --unbuffered -n -e "/^$PREFIX/s/^$PREFIX //p" & - local pid=$! - if ! VERBOSE=true ${BASH_SOURCE[0]} $fun "$@" >& $DIR/$fun.out ; then - kill $pid - cat $DIR/$fun.out - echo Failure running $fun - return 1 - fi - kill $pid - echo Success running $fun -} - source $SELF_DIR/test-upgrade-1.20-storage.sh source $SELF_DIR/test-upgrade-forgejo-database-v3.sh diff --git a/forgejo/build.sh b/lib/build.sh similarity index 92% rename from forgejo/build.sh rename to lib/build.sh index e0330e8..61f87c3 100755 --- a/forgejo/build.sh +++ b/lib/build.sh @@ -10,7 +10,7 @@ version=$1 DIR=$2 v=$(echo $version | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/') -read url ref semver < $SELF_DIR/sources/$v +read url ref semver < $SELF_DIR/../forgejo/sources/$v if ! test -d $DIR/src ; then mkdir -p $DIR/src diff --git a/lib/lib.sh b/lib/lib.sh index 4bacc59..78a9876 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -2,6 +2,8 @@ # Copyright 2024 The Forgejo Authors # SPDX-License-Identifier: MIT +LIB_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + if ${VERBOSE:-false} ; then set -ex PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: ' @@ -18,3 +20,286 @@ if test $(id -u) != 0 ; then fi IP=$(hostname -I | cut -f1 -d' ') + +# +# Forgejo releases for which a branch exists (7.0/forgejo etc.) +# +RELEASE_NUMBERS="7.0" + +PREFIX=============== +HOST_PORT=$IP:3000 +DIR=/tmp/forgejo-end-to-end +export DOT_FORGEJO_CURL=$DIR/forgejo-curl +export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 +: ${FORGEJO_USER:=root} +: ${FORGEJO_PASSWORD:=admin1234} +RELEASE_NUMBERS_AND_DEV="$(for r in $RELEASE_NUMBERS ; do echo -n $r $r-dev ; done)" + +function log_info() { + echo "$PREFIX $@" +} + +function dependencies() { + + if ! test -f /usr/local/bin/forgejo-curl.sh ; then + $SUDO curl --fail -sS https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh -o /usr/local/bin/forgejo-curl.sh + $SUDO chmod +x /usr/local/bin/forgejo-curl.sh + fi + + if ! which curl daemon jq git-lfs > /dev/null ; then + $SUDO apt-get update -qq + $SUDO apt-get install -y -qq curl daemon git-lfs jq sqlite3 gettext-base + fi + + if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio ; then + $SUDO curl --fail -sS https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc + $SUDO curl --fail -sS https://dl.min.io/server/minio/release/linux-amd64/minio -o /usr/local/bin/minio + fi + if ! test -x /usr/local/bin/mc || ! test -x /usr/local/bin/minio ; then + $SUDO chmod +x /usr/local/bin/mc + $SUDO chmod +x /usr/local/bin/minio + fi + + if ! test -f /usr/local/bin/garage > /dev/null ; then + $SUDO curl --fail -sS https://garagehq.deuxfleurs.fr/_releases/v0.8.2/x86_64-unknown-linux-musl/garage -o /usr/local/bin/garage + fi + if ! test -x /usr/local/bin/garage > /dev/null ; then + $SUDO chmod +x /usr/local/bin/garage + fi +} + +function build_all() { + for dev in $RELEASE_NUMBERS ; do + log_info $dev-dev + $LIB_DIR/build.sh $dev $DIR + done +} + +function retry() { + rm -f $DIR/wait-for.out + success=false + for delay in 1 1 5 5 15 ; do + if "$@" >> $DIR/wait-for.out 2>&1 ; then + success=true + break + fi + cat $DIR/wait-for.out + echo waiting $delay + sleep $delay + done + if test $success = false ; then + cat $DIR/wait-for.out + return 1 + fi +} + +function full_version() { + local version=$1 + local owner=$2 + + if [[ $version =~ ^[0-9]+\.[0-9]+$ ]] ; then + full_version=$(curl -sS https://codeberg.org/api/v1/repos/$owner/forgejo/releases | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort -r | head -1) + echo ${full_version#v} + else + echo $version + fi +} + +function download() { + local version=$1 + + if ! test -f $DIR/forgejo-$version ; then + mkdir -p $DIR + for owner in forgejo forgejo-experimental forgejo-integration ; do + full_version=$(full_version $version $owner) + if test "$full_version" = "" ; then + continue + fi + if wget -O $DIR/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64 ; then + break + fi + done + if test -s $DIR/forgejo-$version ; then + if test "$version" != "$full_version" ; then + log_info "downloaded $full_version for $version" + fi + else + echo unable to download Forgejo $version + return 1 + fi + chmod +x $DIR/forgejo-$version + fi +} + +function cleanup_logs() { + local work_path=$DIR/forgejo-work-path + + rm -f $DIR/*.log + rm -f $work_path/log/*.log +} + +function clobber() { + rm -fr /tmp/forgejo-end-to-end +} + +function start_forgejo() { + local version=$1 + + download $version + local work_path=$DIR/forgejo-work-path + daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path + if ! retry grep 'Starting server on' $work_path/log/forgejo.log ; then + grep '' $DIR/*.log + grep '' $work_path/log/*.log 2> /dev/null + return 1 + fi + create_user_and_login $version +} + +function start_minio() { + mkdir -p $DIR/minio + daemon --chdir=$DIR --unsafe \ + --env="PATH=$PATH" \ + --env=MINIO_ROOT_USER=123456 \ + --env=MINIO_ROOT_PASSWORD=12345678 \ + --env=MINIO_VOLUMES=$DIR/minio \ + --pidfile=$DIR/minio-pid --errlog=$DIR/minio-err.log --output=$DIR/minio-out.log -- /usr/local/bin/minio server + retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678 +} + +function start_garage() { + mkdir -p $DIR/garage/{data,meta} + cat > $DIR/garage/garage.toml < $work_path/app.ini +} + +function reset_minio() { + rm -fr $DIR/minio +} + +function reset_garage() { + rm -fr $DIR/garage +} + +function create_user_and_login() { + local version=$1 + + local work_path=$DIR/forgejo-work-path + local email="$FORGEJO_USER@example.com" + local cli="$DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path" + if ! $cli admin user list | grep --quiet "$email" ; then + $cli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email + fi + + forgejo-curl.sh logout + local scopes='--scopes ["all"]' + if echo $version | grep --quiet 1.18 ; then + scopes="" + fi + forgejo-curl.sh --user "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" $scopes login http://${HOST_PORT} +} + +function stop_daemon() { + local daemon=$1 + + if test -f $DIR/$daemon-pid ; then + local pid=$(cat $DIR/$daemon-pid) + kill -TERM $pid + pidwait $pid || true + for delay in 1 1 2 2 5 5 ; do + if ! test -f $DIR/$daemon-pid ; then + break + fi + sleep $delay + done + ! test -f $DIR/$daemon-pid + fi +} + +function stop() { + stop_daemon forgejo + stop_daemon minio + stop_daemon garage + + cleanup_logs +} + +function run() { + local fun=$1 + shift + + echo Start running $fun + mkdir -p $DIR + > $DIR/$fun.out + tail --follow $DIR/$fun.out | sed --unbuffered -n -e "/^$PREFIX/s/^$PREFIX //p" & + local pid=$! + if ! VERBOSE=true $SELF $fun "$@" >& $DIR/$fun.out ; then + kill $pid + cat $DIR/$fun.out + echo Failure running $fun + return 1 + fi + kill $pid + echo Success running $fun +} From 9ff495254af1cd2ad6c0f938f781cb349dd82676 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Fri, 15 Mar 2024 14:34:55 +0700 Subject: [PATCH 042/203] packages: simplify the setup to use the same as upgrades the packages tests control which Forgejo version they run against so they can test a feature on version X+1 and not on version X --- .forgejo/workflows/packages.yml | 43 ----------------- .forgejo/workflows/upgrade.yml | 3 ++ README.md | 29 +++--------- forgejo/upgrades/test-upgrade.sh | 3 ++ packages/alpine-app.ini | 30 ++++++++++++ packages/alpine.sh | 18 +++---- packages/packages.sh | 11 +++++ packages/run.sh | 80 -------------------------------- 8 files changed, 64 insertions(+), 153 deletions(-) delete mode 100644 .forgejo/workflows/packages.yml create mode 100644 packages/alpine-app.ini create mode 100644 packages/packages.sh delete mode 100755 packages/run.sh diff --git a/.forgejo/workflows/packages.yml b/.forgejo/workflows/packages.yml deleted file mode 100644 index fc59c92..0000000 --- a/.forgejo/workflows/packages.yml +++ /dev/null @@ -1,43 +0,0 @@ -on: - pull_request: - push: - branches: - - 'main' - -jobs: - packages: - runs-on: self-hosted - strategy: - matrix: - info: - - version: v7.0 - branch: next - forgejo: https://codeberg.org - repo: forgejo-experimental/forgejo - tests: ${{ vars.V7_0_TESTS }} - - version: v1.21 - forgejo: https://codeberg.org - repo: forgejo/forgejo - tests: ${{ vars.V1_21_TESTS }} - steps: - - uses: actions/checkout@v4 - - - uses: https://code.forgejo.org/actions/setup-forgejo@v2 - with: - install-only: true - - - name: run - if: matrix.info.tests != 'none' - shell: bash - run: | - set -x - forgejo-binary.sh ensure_user forgejo - full_version=$(curl -sS ${{ matrix.info.forgejo }}/api/v1/repos/${{ matrix.info.repo }}/releases | jq -r '.[] | .tag_name | select(startswith("${{ matrix.info.version }}"))' | sort -r | head -1) - binary=${{ matrix.info.forgejo }}/${{ matrix.info.repo }}/releases/download/${full_version}/forgejo-${full_version#v}-linux-amd64 - - export DIR=$(mktemp -d) - chown forgejo $DIR /srv - - export VERBOSE="${{ vars.VERBOSE || false }}" - - su -c "packages/run.sh $binary $full_version ${{ matrix.info.version }} ${{ matrix.info.tests }}" forgejo diff --git a/.forgejo/workflows/upgrade.yml b/.forgejo/workflows/upgrade.yml index 06a8843..eb285f7 100644 --- a/.forgejo/workflows/upgrade.yml +++ b/.forgejo/workflows/upgrade.yml @@ -31,8 +31,11 @@ jobs: with: go-version: "1.21" - run: | + apt-get update -qq + apt-get -q install -qq -y docker.io git config --add safe.directory '*' adduser --quiet --comment forgejo --disabled-password forgejo + adduser forgejo docker chown -R forgejo:forgejo . - run: | script=$(pwd)/forgejo/upgrades/test-upgrade.sh diff --git a/README.md b/README.md index 3cdb044..6ca1311 100644 --- a/README.md +++ b/README.md @@ -95,34 +95,19 @@ it does not exist, all tests are run. * `V1_21_TESTS` * `V1_20_TESTS` -## Running packages locally +## Running other tests locally -To run and debug package tests, from the root of the source directory. +To run and debug tests, from the root of the source directory. -Run one test +Run one test. When the test fails the instance can be inspected at http://0.0.0.0:3000 ```sh -packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0-test/forgejo-7.0-test-linux-amd64 v7.0.0-test v7_0 alpine # runs packages/alpine.sh +VERBOSE=true ./forgejo/upgrades/test-upgrade.sh test_packages_alpine +VERBOSE=true ./forgejo/upgrades/test-upgrade.sh test_storage_stable_s3 minio ``` -Cleanup. It will teardown Forgejo and not run them because there is nothing to test. +Cleanup. It will teardown the Forgejo instance. ```sh -packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0-test/forgejo-7.0-test-linux-amd64 v7.0.0-test v7_0 none +./forgejo/upgrades/test-upgrade.sh stop ``` -Run all examples for v7_0 - -```sh -packages/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0-test/forgejo-7.0-test-linux-amd64 v7.0.0-test v7_0 -``` - -Remote testing - -To reduce the runtime the following variables can be set to control -the number of cases run by the -[packages test](.forgejo/workflows/packages.yml) tests. If set to -**none** they are not run at all for that version of Forgejo. If -it does not exist, all tests are run. - -* `v7_0_PACKAGES_TESTS` -* `V1_21_PACKAGES_TESTS` diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index 25eea18..b2a0c10 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -87,12 +87,15 @@ function test_forgejo_database_version() { source $SELF_DIR/test-upgrade-1.20-storage.sh source $SELF_DIR/test-upgrade-forgejo-database-v3.sh +source $SELF_DIR/../../packages/packages.sh function test_upgrades() { run stop run dependencies run build_all + test_packages + run test_successful_upgrades run test_storage_stable_s3 minio run test_storage_stable_s3 garage diff --git a/packages/alpine-app.ini b/packages/alpine-app.ini new file mode 100644 index 0000000..a51290a --- /dev/null +++ b/packages/alpine-app.ini @@ -0,0 +1,30 @@ +RUN_MODE = prod +WORK_PATH = ${WORK_PATH} + +[server] +APP_DATA_PATH = ${WORK_PATH}/data +HTTP_PORT = 3000 +SSH_LISTEN_PORT = 2222 +LFS_START_SERVER = true + +[database] +DB_TYPE = sqlite3 +PATH = ${WORK_PATH}/forgejo.db + +[log] +MODE = file +LEVEL = trace +ROUTER = file + +[log.file] +FILE_NAME = forgejo.log + +[security] +INSTALL_LOCK = true + +[repository] +ENABLE_PUSH_CREATE_USER = true +DEFAULT_PUSH_CREATE_PRIVATE = false + +[actions] +ENABLED = true diff --git a/packages/alpine.sh b/packages/alpine.sh index 96c619b..11cb56a 100644 --- a/packages/alpine.sh +++ b/packages/alpine.sh @@ -2,16 +2,18 @@ # Copyright 2024 The Forgejo Authors # SPDX-License-Identifier: MIT -SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +function test_packages_alpine_v1.21() { + stop_daemon forgejo + reset_forgejo $PACKAGES_DIR/alpine-app.ini + start_forgejo 1.21 -source $SELF_DIR/../lib/lib.sh - -function main() { - local d=$SELF_DIR/alpine - local token=$(cat $DIR/forgejo-token) - local url=$(cat $DIR/forgejo-url) + local d=$PACKAGES_DIR/alpine + local token=$(cat $DIR/forgejo-curl/token) + local url=http://${HOST_PORT} docker run --rm --volume $d:$d:ro --workdir $d docker.io/alpine:3.19 ash -c "./test.sh $url $token" } -"${@:-main}" +function test_packages_alpine() { + test_packages_alpine_v1.21 +} diff --git a/packages/packages.sh b/packages/packages.sh new file mode 100644 index 0000000..002ed79 --- /dev/null +++ b/packages/packages.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Copyright 2024 The Forgejo Authors +# SPDX-License-Identifier: MIT + +PACKAGES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source $PACKAGES_DIR/alpine.sh + +function test_packages() { + run test_packages_alpine +} diff --git a/packages/run.sh b/packages/run.sh deleted file mode 100755 index 7a0a62e..0000000 --- a/packages/run.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# Copyright 2024 The Forgejo Authors -# SPDX-License-Identifier: MIT - -SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -source $SELF_DIR/../lib/lib.sh - -function run() { - local package=$1 - - bash -ex $SELF_DIR/$package.sh -} - -function packages_v1_21() { - echo 'alpine' -} - -function packages_v7_0() { - packages_v1_21 -} - -function setup() { - local binary=$1 - forgejo-binary.sh setup root admin1234 $binary -} - -function teardown() { - forgejo-curl.sh logout - forgejo-binary.sh teardown -} - -function main() { - local binary="$1" - shift - export full_version="$1" - shift - export version="$1" - shift - - export DOT=$DIR/forgejo-curl - - teardown - - if test "$#" = 0 ; then - packages=$(packages_${version/./_}) - else - packages="$@" - fi - - if test "$packages" = "none" ; then - exit 0 - fi - - setup $binary - - if ! test -f "$DIR/forgejo-auth-url" ; then - echo "DIR=$DIR must be a directory with a forgejo-auth-url file" - fi - - export url=$(cat $DIR/forgejo-auth-url) - export token=$(cat $DIR/forgejo-token) - - for package in $packages ; do - echo "======================== BEGIN package-$package ===================" - if ! time run $package >& /tmp/run.out ; then - sed -e 's/^/[RUN] /' < /tmp/run.out - echo "======================== FAIL package-$package ===================" - sleep 5 # hack for Forgejo v1.21 to workaround a bug by which the last lines of the output are moved to the next step - false - else - if test "$VERBOSE" = true ; then - sed -e 's/^/[RUN] /' < /tmp/run.out - fi - fi - echo "======================== END package-$package ===================" - done -} - -main "$@" From 8f0f6537c6fc9c6033fef52e45db71261ae23660 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Fri, 15 Mar 2024 17:01:07 +0700 Subject: [PATCH 043/203] upgrades: use setup-forgejo as a helper to setup docker & user --- .forgejo/workflows/upgrade.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.forgejo/workflows/upgrade.yml b/.forgejo/workflows/upgrade.yml index eb285f7..9c4ce87 100644 --- a/.forgejo/workflows/upgrade.yml +++ b/.forgejo/workflows/upgrade.yml @@ -27,16 +27,15 @@ jobs: run: echo no hit - uses: https://code.forgejo.org/actions/checkout@v4 + - uses: https://code.forgejo.org/actions/setup-forgejo@v2 + with: + install-only: true - uses: https://code.forgejo.org/actions/setup-go@v4 with: go-version: "1.21" - run: | - apt-get update -qq - apt-get -q install -qq -y docker.io - git config --add safe.directory '*' - adduser --quiet --comment forgejo --disabled-password forgejo - adduser forgejo docker - chown -R forgejo:forgejo . + set -x + forgejo-binary.sh ensure_user forgejo - run: | script=$(pwd)/forgejo/upgrades/test-upgrade.sh $script run dependencies From f321bf5d5e529cbf24e825b615b2c06550a19629 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Fri, 15 Mar 2024 18:04:02 +0700 Subject: [PATCH 044/203] upgrades: test_successful_upgrades must stop lingering Forgejo --- forgejo/upgrades/test-upgrade.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index b2a0c10..721f219 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -63,6 +63,7 @@ function test_storage_stable_s3() { } function test_successful_upgrades() { + stop for config in default specific ; do log_info "using $config app.ini" reset $config From 2bb546d366669443f37826551a10833a080a1dce Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Fri, 15 Mar 2024 17:23:35 +0700 Subject: [PATCH 045/203] upgrades: run on LXC to allow for running docker --- .forgejo/workflows/upgrade.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/upgrade.yml b/.forgejo/workflows/upgrade.yml index 9c4ce87..5e8f7c5 100644 --- a/.forgejo/workflows/upgrade.yml +++ b/.forgejo/workflows/upgrade.yml @@ -8,9 +8,7 @@ on: jobs: upgrade: - runs-on: docker - container: - image: 'docker.io/node:20-bookworm' + runs-on: lxc-bookworm steps: - name: cache S3 binaries id: S3 @@ -36,6 +34,7 @@ jobs: - run: | set -x forgejo-binary.sh ensure_user forgejo + apt-get -q install -y -qq build-essential - run: | script=$(pwd)/forgejo/upgrades/test-upgrade.sh $script run dependencies From bf689a247842c8683d7302afdfd460b0e3600c0f Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sun, 17 Mar 2024 11:58:02 +0100 Subject: [PATCH 046/203] refactor end-to-end.yml workflow to use a top-level end-to-end.sh --- .forgejo/prepare-end-to-end/action.yml | 19 +++++ .forgejo/workflows/end-to-end.yml | 70 +++++++++++++++++++ .forgejo/workflows/upgrade.yml | 42 ----------- README.md | 4 +- end-to-end.sh | 21 ++++++ forgejo/upgrades/test-upgrade-1.20-storage.sh | 6 +- forgejo/upgrades/test-upgrade.sh | 17 ++--- lib/build.sh | 13 ++-- lib/lib.sh | 24 ++++--- 9 files changed, 142 insertions(+), 74 deletions(-) create mode 100644 .forgejo/prepare-end-to-end/action.yml create mode 100644 .forgejo/workflows/end-to-end.yml delete mode 100644 .forgejo/workflows/upgrade.yml create mode 100755 end-to-end.sh diff --git a/.forgejo/prepare-end-to-end/action.yml b/.forgejo/prepare-end-to-end/action.yml new file mode 100644 index 0000000..d94a09a --- /dev/null +++ b/.forgejo/prepare-end-to-end/action.yml @@ -0,0 +1,19 @@ +runs: + using: "composite" + steps: + - uses: https://code.forgejo.org/actions/setup-forgejo@v2 + with: + install-only: true + - run: forgejo-binary.sh ensure_user forgejo + - uses: actions/download-artifact@v3 + with: + name: forgejo-dev + path: /srv/forgejo-binaries + - name: chown/chmod /srv/forgejo-binaries + run: | + chmod +x /srv/forgejo-binaries/* + chown -R forgejo /srv/forgejo-binaries + - run: | + script=$(pwd)/end-to-end.sh + $script run dependencies + $script clobber diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml new file mode 100644 index 0000000..4ad4303 --- /dev/null +++ b/.forgejo/workflows/end-to-end.yml @@ -0,0 +1,70 @@ +on: + pull_request: + push: + branches: + - 'main' + +jobs: + build: + runs-on: docker + container: + image: 'docker.io/node:20-bookworm' + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + - uses: https://code.forgejo.org/actions/setup-go@v4 + with: + go-version: "1.21" + - name: lib/build.sh + run: | + set -x + + # + # SQLite needs gcc to be compiled + # + export DEBIAN_FRONTEND=noninteractive + apt-get update -qq + apt-get -q install -y -qq build-essential + + d=/tmp/forgejo-binaries + mkdir $d /tmp/forgejo-upload + + for version in $(ls forgejo/sources) ; do + forgejo=$d/forgejo-$version-dev + lib/build.sh $version $d + $forgejo --version + mv $forgejo /tmp/forgejo-upload + done + - uses: actions/upload-artifact@v3 + with: + name: forgejo-dev + path: /tmp/forgejo-upload + + packages: + needs: [build] + runs-on: lxc-bookworm + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + - uses: ./.forgejo/prepare-end-to-end + - run: su forgejo -c "./end-to-end.sh test_packages" + + upgrade: + needs: [build] + runs-on: lxc-bookworm + steps: + - name: cache S3 binaries + id: S3 + uses: https://code.forgejo.org/actions/cache@v3 + with: + path: | + /usr/local/bin/minio + /usr/local/bin/mc + /usr/local/bin/garage + key: S3 + + - name: skip if S3 cache hit + if: steps.S3.outputs.cache-hit != 'true' + run: echo no hit + + - uses: https://code.forgejo.org/actions/checkout@v4 + - uses: ./.forgejo/prepare-end-to-end + - run: su forgejo -c "./end-to-end.sh test_upgrades" diff --git a/.forgejo/workflows/upgrade.yml b/.forgejo/workflows/upgrade.yml deleted file mode 100644 index 5e8f7c5..0000000 --- a/.forgejo/workflows/upgrade.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: upgrade - -on: - pull_request: - push: - branches: - - 'main' - -jobs: - upgrade: - runs-on: lxc-bookworm - steps: - - name: cache S3 binaries - id: S3 - uses: https://code.forgejo.org/actions/cache@v3 - with: - path: | - /usr/local/bin/minio - /usr/local/bin/mc - /usr/local/bin/garage - key: S3 - - - name: skip if S3 cache hit - if: steps.S3.outputs.cache-hit != 'true' - run: echo no hit - - - uses: https://code.forgejo.org/actions/checkout@v4 - - uses: https://code.forgejo.org/actions/setup-forgejo@v2 - with: - install-only: true - - uses: https://code.forgejo.org/actions/setup-go@v4 - with: - go-version: "1.21" - - run: | - set -x - forgejo-binary.sh ensure_user forgejo - apt-get -q install -y -qq build-essential - - run: | - script=$(pwd)/forgejo/upgrades/test-upgrade.sh - $script run dependencies - $script clobber - su forgejo -c "$script test_upgrades" diff --git a/README.md b/README.md index 6ca1311..7d3a95e 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ git clone https://code.forgejo.org/actions/setup-forgejo export PATH=$(pwd)/setup-forgejo:$PATH git clone https://code.forgejo.org/forgejo/end-to-end cd end-to-end -export DIR=/tmp/end-to-end -rm -fr /tmp/end-to-end ; sudo rm -fr /srv/example ; sudo mkdir /srv/example ; sudo chown -R $USER /srv/example +export DIR=/tmp/forgejo-end-to-end +rm -fr /tmp/forgejo-end-to-end ; sudo rm -fr /srv/example ; sudo mkdir /srv/example ; sudo chown -R $USER /srv/example ``` Run using Forgejo built from source. diff --git a/end-to-end.sh b/end-to-end.sh new file mode 100755 index 0000000..3202c23 --- /dev/null +++ b/end-to-end.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT + +# +# Debug loop from the source tree: +# +# ./end-to-end.sh dependencies +# ./end-to-end.sh build_all +# VERBOSE=true ./end-to-end.sh test_downgrade_1.20.2_fails +# +# Everything happens in /tmp/forgejo-end-to-end +# + +SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +SELF="${BASH_SOURCE[0]}" +source $SELF_DIR/lib/lib.sh + +source $SELF_DIR/forgejo/upgrades/test-upgrade.sh +source $SELF_DIR/packages/packages.sh + +"$@" diff --git a/forgejo/upgrades/test-upgrade-1.20-storage.sh b/forgejo/upgrades/test-upgrade-1.20-storage.sh index 6be1fbb..74bd0c9 100644 --- a/forgejo/upgrades/test-upgrade-1.20-storage.sh +++ b/forgejo/upgrades/test-upgrade-1.20-storage.sh @@ -12,7 +12,7 @@ function test_downgrade_1.20.2_fails() { start 1.20.3-0 stop download 1.20.2-0 - timeout 60 $DIR/forgejo-1.20.2-0 --config $work_path/app.ini --work-path $work_path || true + timeout 60 $DIR_BINARIES/forgejo-1.20.2-0 --config $work_path/app.ini --work-path $work_path || true if ! grep --fixed-strings --quiet 'use the newer database' $work_path/log/forgejo.log ; then cat $work_path/log/forgejo.log return 1 @@ -41,7 +41,7 @@ function test_bug_storage_merged() { log_info "upgrading from 1.20.2-0 with [storage].PATH fails" download 1.20.3-0 - timeout 60 $DIR/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true + timeout 60 $DIR_BINARIES/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true if ! grep --fixed-strings --quiet '[storage].PATH is set and may create storage issues' $work_path/log/forgejo.log ; then cat $work_path/log/forgejo.log return 1 @@ -206,7 +206,7 @@ function test_bug_storage_misplace() { log_info "upgrading from 1.20.2-0 with conflicting sections fails" download 1.20.3-0 - timeout 60 $DIR/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true + timeout 60 $DIR_BINARIES/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true for path in ${STORAGE_PATHS} ; do if ! grep --fixed-strings --quiet "[storage.$path] may conflict" $work_path/log/forgejo.log ; then cat $work_path/log/forgejo.log diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh index 721f219..c62e2a2 100755 --- a/forgejo/upgrades/test-upgrade.sh +++ b/forgejo/upgrades/test-upgrade.sh @@ -11,19 +11,17 @@ # Everything happens in /tmp/forgejo-upgrades # -SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -SELF="${BASH_SOURCE[0]}" -source $SELF_DIR/../../lib/lib.sh +UPGRADE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars" STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars" : ${FORGEJO_REPO:=fixture} -source $SELF_DIR/fixtures.sh +source $UPGRADE_DIR/fixtures.sh function reset() { local config=$1 - reset_forgejo $SELF_DIR/$config-app.ini + reset_forgejo $UPGRADE_DIR/$config-app.ini reset_minio reset_garage } @@ -86,17 +84,14 @@ function test_forgejo_database_version() { test "$expected_version" = "$actual_version" } -source $SELF_DIR/test-upgrade-1.20-storage.sh -source $SELF_DIR/test-upgrade-forgejo-database-v3.sh -source $SELF_DIR/../../packages/packages.sh +source $UPGRADE_DIR/test-upgrade-1.20-storage.sh +source $UPGRADE_DIR/test-upgrade-forgejo-database-v3.sh function test_upgrades() { run stop run dependencies run build_all - test_packages - run test_successful_upgrades run test_storage_stable_s3 minio run test_storage_stable_s3 garage @@ -104,5 +99,3 @@ function test_upgrades() { test_upgrade_1_20_storage run test_forgejo_database_v3_upgrades } - -"$@" diff --git a/lib/build.sh b/lib/build.sh index 61f87c3..9ad74ec 100755 --- a/lib/build.sh +++ b/lib/build.sh @@ -7,18 +7,19 @@ set -ex SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" version=$1 -DIR=$2 +dir_binaries=$2 v=$(echo $version | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/') +src=$dir_binaries/src-$v read url ref semver < $SELF_DIR/../forgejo/sources/$v -if ! test -d $DIR/src ; then - mkdir -p $DIR/src - cd $DIR/src +if ! test -d $src ; then + mkdir -p $src + cd $src git init git remote add origin $url else - cd $DIR/src + cd $src fi if ! [[ "$ref" =~ ^refs/ ]] ; then @@ -30,4 +31,4 @@ git switch --force-create $v $ref export TAGS="bindata sqlite sqlite_unlock_notify" FORGEJO_VERSION=$semver make deps-backend backend make generate forgejo -cp -a forgejo $DIR/forgejo-$v-dev +cp -a forgejo $dir_binaries/forgejo-$v-dev diff --git a/lib/lib.sh b/lib/lib.sh index 78a9876..846e295 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -29,6 +29,7 @@ RELEASE_NUMBERS="7.0" PREFIX=============== HOST_PORT=$IP:3000 DIR=/tmp/forgejo-end-to-end +DIR_BINARIES=/srv/forgejo-binaries export DOT_FORGEJO_CURL=$DIR/forgejo-curl export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 : ${FORGEJO_USER:=root} @@ -70,8 +71,13 @@ function dependencies() { function build_all() { for dev in $RELEASE_NUMBERS ; do - log_info $dev-dev - $LIB_DIR/build.sh $dev $DIR + local forgejo=$DIR_BINARIES/forgejo-$dev-dev + if test -f $forgejo ; then + log_info $dev already exists + else + $LIB_DIR/build.sh $dev $DIR_BINARIES + log_info $dev built from sources + fi done } @@ -108,18 +114,18 @@ function full_version() { function download() { local version=$1 - if ! test -f $DIR/forgejo-$version ; then - mkdir -p $DIR + if ! test -f $DIR_BINARIES/forgejo-$version ; then + mkdir -p $DIR_BINARIES for owner in forgejo forgejo-experimental forgejo-integration ; do full_version=$(full_version $version $owner) if test "$full_version" = "" ; then continue fi - if wget -O $DIR/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64 ; then + if wget -O $DIR_BINARIES/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64 ; then break fi done - if test -s $DIR/forgejo-$version ; then + if test -s $DIR_BINARIES/forgejo-$version ; then if test "$version" != "$full_version" ; then log_info "downloaded $full_version for $version" fi @@ -127,7 +133,7 @@ function download() { echo unable to download Forgejo $version return 1 fi - chmod +x $DIR/forgejo-$version + chmod +x $DIR_BINARIES/forgejo-$version fi } @@ -147,7 +153,7 @@ function start_forgejo() { download $version local work_path=$DIR/forgejo-work-path - daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path + daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $DIR_BINARIES/forgejo-$version --config $work_path/app.ini --work-path $work_path if ! retry grep 'Starting server on' $work_path/log/forgejo.log ; then grep '' $DIR/*.log grep '' $work_path/log/*.log 2> /dev/null @@ -247,7 +253,7 @@ function create_user_and_login() { local work_path=$DIR/forgejo-work-path local email="$FORGEJO_USER@example.com" - local cli="$DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path" + local cli="$DIR_BINARIES/forgejo-$version --config $work_path/app.ini --work-path $work_path" if ! $cli admin user list | grep --quiet "$email" ; then $cli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email fi From 554d2b48c0c4083c1389f585ae1dc86805e666e4 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sun, 17 Mar 2024 16:26:17 +0100 Subject: [PATCH 047/203] split storage & ugprade and separate fixtures --- .forgejo/workflows/end-to-end.yml | 2 + end-to-end.sh | 4 +- forgejo/fixtures.sh | 5 + .../fixtures.sh => fixtures/storage.sh} | 1 - forgejo/upgrades/test-upgrade.sh | 101 ------------------ {forgejo/upgrades => storage}/default-app.ini | 0 .../legagy-relative-app.ini | 0 {forgejo/upgrades => storage}/merged-app.ini | 0 .../upgrades => storage}/misplace-app.ini | 0 .../upgrades => storage}/misplace-s3-app.ini | 0 .../misplace-s3-two-app.ini | 0 .../upgrades => storage}/relative-app.ini | 0 .../upgrades => storage}/specific-app.ini | 0 .../upgrades => storage}/stable-s3-app.ini | 0 .../storage-relative-app.ini | 0 storage/storage.sh | 58 ++++++++++ .../test-upgrade-1.20-storage.sh | 26 ++--- upgrade/default-app.ini | 30 ++++++ .../test-upgrade-forgejo-database-v3.sh | 11 +- upgrade/upgrade.sh | 50 +++++++++ 20 files changed, 170 insertions(+), 118 deletions(-) create mode 100644 forgejo/fixtures.sh rename forgejo/{upgrades/fixtures.sh => fixtures/storage.sh} (99%) delete mode 100755 forgejo/upgrades/test-upgrade.sh rename {forgejo/upgrades => storage}/default-app.ini (100%) rename {forgejo/upgrades => storage}/legagy-relative-app.ini (100%) rename {forgejo/upgrades => storage}/merged-app.ini (100%) rename {forgejo/upgrades => storage}/misplace-app.ini (100%) rename {forgejo/upgrades => storage}/misplace-s3-app.ini (100%) rename {forgejo/upgrades => storage}/misplace-s3-two-app.ini (100%) rename {forgejo/upgrades => storage}/relative-app.ini (100%) rename {forgejo/upgrades => storage}/specific-app.ini (100%) rename {forgejo/upgrades => storage}/stable-s3-app.ini (100%) rename {forgejo/upgrades => storage}/storage-relative-app.ini (100%) create mode 100755 storage/storage.sh rename {forgejo/upgrades => storage}/test-upgrade-1.20-storage.sh (93%) create mode 100644 upgrade/default-app.ini rename {forgejo/upgrades => upgrade}/test-upgrade-forgejo-database-v3.sh (68%) create mode 100755 upgrade/upgrade.sh diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index 4ad4303..04072cd 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -48,6 +48,7 @@ jobs: - run: su forgejo -c "./end-to-end.sh test_packages" upgrade: + name: upgrade and storage needs: [build] runs-on: lxc-bookworm steps: @@ -68,3 +69,4 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: ./.forgejo/prepare-end-to-end - run: su forgejo -c "./end-to-end.sh test_upgrades" + - run: su forgejo -c "./end-to-end.sh test_storage" diff --git a/end-to-end.sh b/end-to-end.sh index 3202c23..6157d3f 100755 --- a/end-to-end.sh +++ b/end-to-end.sh @@ -15,7 +15,9 @@ SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SELF="${BASH_SOURCE[0]}" source $SELF_DIR/lib/lib.sh -source $SELF_DIR/forgejo/upgrades/test-upgrade.sh +source $SELF_DIR/forgejo/fixtures.sh +source $SELF_DIR/storage/storage.sh +source $SELF_DIR/upgrade/upgrade.sh source $SELF_DIR/packages/packages.sh "$@" diff --git a/forgejo/fixtures.sh b/forgejo/fixtures.sh new file mode 100644 index 0000000..9c609f5 --- /dev/null +++ b/forgejo/fixtures.sh @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: MIT + +FIXTURES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source $FIXTURES_DIR/fixtures/storage.sh diff --git a/forgejo/upgrades/fixtures.sh b/forgejo/fixtures/storage.sh similarity index 99% rename from forgejo/upgrades/fixtures.sh rename to forgejo/fixtures/storage.sh index abad7e3..1efffe1 100644 --- a/forgejo/upgrades/fixtures.sh +++ b/forgejo/fixtures/storage.sh @@ -1,4 +1,3 @@ -#!/bin/bash # SPDX-License-Identifier: MIT #ONEPIXEL="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==" diff --git a/forgejo/upgrades/test-upgrade.sh b/forgejo/upgrades/test-upgrade.sh deleted file mode 100755 index c62e2a2..0000000 --- a/forgejo/upgrades/test-upgrade.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: MIT - -# -# Debug loop from the source tree: -# -# ./forgejo/upgrades/test-upgrade.sh dependencies -# ./forgejo/upgrades/test-upgrade.sh build_all -# VERBOSE=true ./forgejo/upgrades/test-upgrade.sh test_downgrade_1.20.2_fails -# -# Everything happens in /tmp/forgejo-upgrades -# - -UPGRADE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars" -STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars" -: ${FORGEJO_REPO:=fixture} - -source $UPGRADE_DIR/fixtures.sh - -function reset() { - local config=$1 - reset_forgejo $UPGRADE_DIR/$config-app.ini - reset_minio - reset_garage -} - -function verify_storage() { - local work_path=$DIR/forgejo-work-path - - for path in ${STORAGE_PATHS} ; do - test -d $work_path/data/$path - done -} - -function cleanup_storage() { - local work_path=$DIR/forgejo-work-path - - for path in ${STORAGE_PATHS} ; do - rm -fr $work_path/data/$path - done -} - -function test_storage_stable_s3() { - local work_path=$DIR/forgejo-work-path - local s3_backend=${1:-minio} - - log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338" - - for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do - log_info "Forgejo $version & $s3_backend" - stop - reset stable-s3 - start $version $s3_backend - fixture_create - for fun in ${STORAGE_FUN} ; do - fixture_${fun}_assert_s3 - done - done -} - -function test_successful_upgrades() { - stop - for config in default specific ; do - log_info "using $config app.ini" - reset $config - - for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do - log_info "run $version" - cleanup_storage - start $version - verify_storage - stop - done - done -} - -function test_forgejo_database_version() { - local expected_version=$1 - local work_path=$DIR/forgejo-work-path - - actual_version=$(sqlite3 $work_path/forgejo.db "select version from forgejo_version") - test "$expected_version" = "$actual_version" -} - -source $UPGRADE_DIR/test-upgrade-1.20-storage.sh -source $UPGRADE_DIR/test-upgrade-forgejo-database-v3.sh - -function test_upgrades() { - run stop - run dependencies - run build_all - - run test_successful_upgrades - run test_storage_stable_s3 minio - run test_storage_stable_s3 garage - - test_upgrade_1_20_storage - run test_forgejo_database_v3_upgrades -} diff --git a/forgejo/upgrades/default-app.ini b/storage/default-app.ini similarity index 100% rename from forgejo/upgrades/default-app.ini rename to storage/default-app.ini diff --git a/forgejo/upgrades/legagy-relative-app.ini b/storage/legagy-relative-app.ini similarity index 100% rename from forgejo/upgrades/legagy-relative-app.ini rename to storage/legagy-relative-app.ini diff --git a/forgejo/upgrades/merged-app.ini b/storage/merged-app.ini similarity index 100% rename from forgejo/upgrades/merged-app.ini rename to storage/merged-app.ini diff --git a/forgejo/upgrades/misplace-app.ini b/storage/misplace-app.ini similarity index 100% rename from forgejo/upgrades/misplace-app.ini rename to storage/misplace-app.ini diff --git a/forgejo/upgrades/misplace-s3-app.ini b/storage/misplace-s3-app.ini similarity index 100% rename from forgejo/upgrades/misplace-s3-app.ini rename to storage/misplace-s3-app.ini diff --git a/forgejo/upgrades/misplace-s3-two-app.ini b/storage/misplace-s3-two-app.ini similarity index 100% rename from forgejo/upgrades/misplace-s3-two-app.ini rename to storage/misplace-s3-two-app.ini diff --git a/forgejo/upgrades/relative-app.ini b/storage/relative-app.ini similarity index 100% rename from forgejo/upgrades/relative-app.ini rename to storage/relative-app.ini diff --git a/forgejo/upgrades/specific-app.ini b/storage/specific-app.ini similarity index 100% rename from forgejo/upgrades/specific-app.ini rename to storage/specific-app.ini diff --git a/forgejo/upgrades/stable-s3-app.ini b/storage/stable-s3-app.ini similarity index 100% rename from forgejo/upgrades/stable-s3-app.ini rename to storage/stable-s3-app.ini diff --git a/forgejo/upgrades/storage-relative-app.ini b/storage/storage-relative-app.ini similarity index 100% rename from forgejo/upgrades/storage-relative-app.ini rename to storage/storage-relative-app.ini diff --git a/storage/storage.sh b/storage/storage.sh new file mode 100755 index 0000000..dda1307 --- /dev/null +++ b/storage/storage.sh @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: MIT + +STORAGE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars" +STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars" +: ${FORGEJO_REPO:=fixture} + +function storage_reset() { + local config=$1 + reset_forgejo $STORAGE_DIR/$config-app.ini + reset_minio + reset_garage +} + +function verify_storage() { + local work_path=$DIR/forgejo-work-path + + for path in ${STORAGE_PATHS} ; do + test -d $work_path/data/$path + done +} + +function cleanup_storage() { + local work_path=$DIR/forgejo-work-path + + for path in ${STORAGE_PATHS} ; do + rm -fr $work_path/data/$path + done +} + +function test_storage_stable_s3() { + local work_path=$DIR/forgejo-work-path + local s3_backend=${1:-minio} + + log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338" + + for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do + log_info "Forgejo $version & $s3_backend" + stop + storage_reset stable-s3 + start $version $s3_backend + fixture_create + for fun in ${STORAGE_FUN} ; do + fixture_${fun}_assert_s3 + done + done +} + +source $STORAGE_DIR/test-upgrade-1.20-storage.sh + +function test_storage() { + run test_storage_stable_s3 minio + run test_storage_stable_s3 garage + + test_upgrade_1_20_storage + run test_forgejo_database_v3_upgrades +} diff --git a/forgejo/upgrades/test-upgrade-1.20-storage.sh b/storage/test-upgrade-1.20-storage.sh similarity index 93% rename from forgejo/upgrades/test-upgrade-1.20-storage.sh rename to storage/test-upgrade-1.20-storage.sh index 74bd0c9..063b56a 100644 --- a/forgejo/upgrades/test-upgrade-1.20-storage.sh +++ b/storage/test-upgrade-1.20-storage.sh @@ -8,7 +8,7 @@ function test_downgrade_1.20.2_fails() { log_info "downgrading from 1.20.3-0 to 1.20.2-0 fails" stop - reset default + storage_reset default start 1.20.3-0 stop download 1.20.2-0 @@ -27,7 +27,7 @@ function test_bug_storage_merged() { log_info "using < 1.20.3-0 and [storage].PATH merge all storage" for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do stop - reset merged + storage_reset merged start $version for path in ${STORAGE_PATHS} ; do ! test -d $work_path/data/$path @@ -54,7 +54,7 @@ function test_bug_storage_relative_path() { log_info "using < 1.20.3-0 legacy [server].XXXX and [picture].XXXX are relative to WORK_PATH" for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do stop - reset legagy-relative + storage_reset legagy-relative start $version test -d $work_path/relative-lfs test -d $work_path/relative-avatars @@ -64,7 +64,7 @@ function test_bug_storage_relative_path() { log_info "using >= 1.20.3-0 legacy [server].XXXX and [picture].XXXX are relative to APP_DATA_PATH" for version in 1.20.3-0 1.21.0-5-rc2 ; do stop - reset legagy-relative + storage_reset legagy-relative start $version test -d $work_path/data/relative-lfs test -d $work_path/data/relative-avatars @@ -74,7 +74,7 @@ function test_bug_storage_relative_path() { log_info "using >= 1.20.3-0 relative [storage.XXXX].PATHS are relative to APP_DATA_PATH" for version in 1.20.3-0 1.21.0-5-rc2 ; do stop - reset storage-relative + storage_reset storage-relative start $version for path in ${STORAGE_PATHS} ; do test -d $work_path/data/relative-$path @@ -84,7 +84,7 @@ function test_bug_storage_relative_path() { log_info "using 1.20.[12]-0 relative [storage.XXXX].PATHS are inconsistent" for version in 1.20.2-0 ; do stop - reset storage-relative + storage_reset storage-relative start $version test -d $work_path/data/packages test -d $work_path/relative-repo-archive @@ -97,7 +97,7 @@ function test_bug_storage_relative_path() { log_info "using < 1.20 relative [storage.XXXX].PATHS are inconsistent" for version in 1.18.5-0 1.19.4-0 ; do stop - reset storage-relative + storage_reset storage-relative start $version test -d $work_path/relative-packages test -d $work_path/relative-repo-archive @@ -110,7 +110,7 @@ function test_bug_storage_relative_path() { log_info "using < 1.20.3-0 relative [XXXX].PATHS are relative to WORK_PATH" for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do stop - reset relative + storage_reset relative start $version for path in ${STORAGE_PATHS} ; do test -d $work_path/relative-$path @@ -120,7 +120,7 @@ function test_bug_storage_relative_path() { log_info "using >= 1.20.3-0 relative [XXXX].PATHS are relative to APP_DATA_PATH" for version in 1.20.3-0 1.21.0-5-rc2 ; do stop - reset relative + storage_reset relative start $version for path in ${STORAGE_PATHS} ; do test -d $work_path/data/relative-$path @@ -139,7 +139,7 @@ function test_bug_storage_s3_misplace() { for version in 1.20.2-0 1.20.3-0 ; do log_info "Forgejo $version & $s3_backend" stop - reset misplace-s3 + storage_reset misplace-s3 start $version $s3_backend fixture_create for fun in ${STORAGE_FUN} ; do @@ -150,7 +150,7 @@ function test_bug_storage_s3_misplace() { for version in 1.18.5-0 1.19.4-0 ; do log_info "Forgejo $version & $s3_backend" stop - reset misplace-s3 + storage_reset misplace-s3 start $version $s3_backend fixture_create # @@ -176,7 +176,7 @@ function test_bug_storage_misplace() { log_info "using < 1.20 and conflicting sections misplace storage" for version in 1.18.5-0 1.19.4-0 ; do stop - reset misplace + storage_reset misplace start $version # # some storage are where they should be @@ -195,7 +195,7 @@ function test_bug_storage_misplace() { log_info "using < 1.20.[12]-0 and conflicting sections ignores [storage.*]" for version in 1.20.2-0 ; do stop - reset misplace + storage_reset misplace start $version for path in ${STORAGE_PATHS} ; do test -d $work_path/elsewhere/$path diff --git a/upgrade/default-app.ini b/upgrade/default-app.ini new file mode 100644 index 0000000..a51290a --- /dev/null +++ b/upgrade/default-app.ini @@ -0,0 +1,30 @@ +RUN_MODE = prod +WORK_PATH = ${WORK_PATH} + +[server] +APP_DATA_PATH = ${WORK_PATH}/data +HTTP_PORT = 3000 +SSH_LISTEN_PORT = 2222 +LFS_START_SERVER = true + +[database] +DB_TYPE = sqlite3 +PATH = ${WORK_PATH}/forgejo.db + +[log] +MODE = file +LEVEL = trace +ROUTER = file + +[log.file] +FILE_NAME = forgejo.log + +[security] +INSTALL_LOCK = true + +[repository] +ENABLE_PUSH_CREATE_USER = true +DEFAULT_PUSH_CREATE_PRIVATE = false + +[actions] +ENABLED = true diff --git a/forgejo/upgrades/test-upgrade-forgejo-database-v3.sh b/upgrade/test-upgrade-forgejo-database-v3.sh similarity index 68% rename from forgejo/upgrades/test-upgrade-forgejo-database-v3.sh rename to upgrade/test-upgrade-forgejo-database-v3.sh index db1e9d4..f15a4f3 100644 --- a/forgejo/upgrades/test-upgrade-forgejo-database-v3.sh +++ b/upgrade/test-upgrade-forgejo-database-v3.sh @@ -1,6 +1,13 @@ -#!/bin/bash # SPDX-License-Identifier: MIT +function test_forgejo_database_version() { + local expected_version=$1 + local work_path=$DIR/forgejo-work-path + + actual_version=$(sqlite3 $work_path/forgejo.db "select version from forgejo_version") + test "$expected_version" = "$actual_version" +} + function test_forgejo_database_v3_upgrades_list_table() { local table=$1 local work_path=$DIR/forgejo-work-path @@ -13,7 +20,7 @@ function test_forgejo_database_v3_upgrades() { stop - reset default + upgrade_reset default log_info "run 1.20.4-1" start 1.20.4-1 stop diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh new file mode 100755 index 0000000..fa40d76 --- /dev/null +++ b/upgrade/upgrade.sh @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: MIT + +UPGRADE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +function upgrade_reset() { + local config=$1 + reset_forgejo $UPGRADE_DIR/$config-app.ini + reset_minio +} + +function verify_storage() { + local work_path=$DIR/forgejo-work-path + + for path in ${STORAGE_PATHS} ; do + test -d $work_path/data/$path + done +} + +function cleanup_storage() { + local work_path=$DIR/forgejo-work-path + + for path in ${STORAGE_PATHS} ; do + rm -fr $work_path/data/$path + done +} + +function test_successful_upgrades() { + for config in default ; do + log_info "using $config app.ini" + upgrade_reset $config + + for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do + log_info "run $version" + cleanup_storage + start $version + verify_storage + stop + done + done +} + +source $UPGRADE_DIR/test-upgrade-forgejo-database-v3.sh + +function test_upgrades() { + run dependencies + run build_all + + run test_successful_upgrades + run test_forgejo_database_v3_upgrades +} From 51f7263dee25235921dc39471f5f81400dd9a3e5 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sun, 17 Mar 2024 17:36:05 +0100 Subject: [PATCH 048/203] hide expected errors so they are not confused with actual errors --- lib/lib.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/lib.sh b/lib/lib.sh index 846e295..5b07c86 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -154,7 +154,7 @@ function start_forgejo() { download $version local work_path=$DIR/forgejo-work-path daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $DIR_BINARIES/forgejo-$version --config $work_path/app.ini --work-path $work_path - if ! retry grep 'Starting server on' $work_path/log/forgejo.log ; then + if ! retry grep --no-messages --quiet 'Starting server on' $work_path/log/forgejo.log ; then grep '' $DIR/*.log grep '' $work_path/log/*.log 2> /dev/null return 1 @@ -170,7 +170,8 @@ function start_minio() { --env=MINIO_ROOT_PASSWORD=12345678 \ --env=MINIO_VOLUMES=$DIR/minio \ --pidfile=$DIR/minio-pid --errlog=$DIR/minio-err.log --output=$DIR/minio-out.log -- /usr/local/bin/minio server - retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678 + retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678 >& /dev/null + mc alias set testS3 http://127.0.0.1:9000 123456 12345678 } function start_garage() { From 21920b10d97d5404cda48fb3911ce392bcd41063 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sun, 17 Mar 2024 17:22:44 +0100 Subject: [PATCH 049/203] upgrades: add LFS assert --- forgejo/fixtures/storage.sh | 21 +++++++++++++++++++++ lib/lib.sh | 14 ++++++++++---- storage/storage.sh | 2 -- upgrade/upgrade.sh | 14 +++++++++++--- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/forgejo/fixtures/storage.sh b/forgejo/fixtures/storage.sh index 1efffe1..0de79b5 100644 --- a/forgejo/fixtures/storage.sh +++ b/forgejo/fixtures/storage.sh @@ -7,6 +7,9 @@ # ONEPIXEL="iVBORw0KGgoAAAANSUhEUgAAASIAAAEiCAYAAABdvt+2AAADrElEQVR4nOzUMRHAMADEsL9eeQd6AsOLhMCT/7udAYS+OgDAiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDuBQAA//+4jAPFe1H1tgAAAABJRU5ErkJggg==" +STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars" +: ${FORGEJO_REPO:=fixture} + function fixture_get_paths_s3() { local path=$1 @@ -81,6 +84,18 @@ function fixture_lfs_create() { ) } +function fixture_lfs_assert() { + local d=$(mktemp -d) + ( + git clone http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO} $d/${FORGEJO_REPO} + cd $d/${FORGEJO_REPO} + rm file.txt + git-lfs checkout file.txt + test -f file.txt + ) + rm -fr $d +} + function fixture_lfs_assert_s3() { local content=$(mc cat testS3/forgejo/lfs/d6/1e/5fa787e50330288923bd0c9866b44643925965144262288447cf52f9f9b7) test "$content" = CONTENT @@ -200,3 +215,9 @@ function fixture_create() { fixture_${fun}_create done } + +function fixture_assert() { + for fun in lfs ; do + fixture_${fun}_assert + done +} diff --git a/lib/lib.sh b/lib/lib.sh index 5b07c86..fa6375f 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -249,14 +249,20 @@ function reset_garage() { rm -fr $DIR/garage } +function forgejo_cli() { + local version="$1" + shift + local work_path=$DIR/forgejo-work-path + + $DIR_BINARIES/forgejo-$version --config $work_path/app.ini --work-path $work_path "$@" +} + function create_user_and_login() { local version=$1 - local work_path=$DIR/forgejo-work-path local email="$FORGEJO_USER@example.com" - local cli="$DIR_BINARIES/forgejo-$version --config $work_path/app.ini --work-path $work_path" - if ! $cli admin user list | grep --quiet "$email" ; then - $cli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email + if ! forgejo_cli $version admin user list | grep --quiet "$email" ; then + forgejo_cli $version admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email fi forgejo-curl.sh logout diff --git a/storage/storage.sh b/storage/storage.sh index dda1307..b08e6bc 100755 --- a/storage/storage.sh +++ b/storage/storage.sh @@ -3,8 +3,6 @@ STORAGE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars" -STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars" -: ${FORGEJO_REPO:=fixture} function storage_reset() { local config=$1 diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index fa40d76..5ad4415 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -25,16 +25,24 @@ function cleanup_storage() { } function test_successful_upgrades() { + stop for config in default ; do log_info "using $config app.ini" upgrade_reset $config - for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do + version=1.18 + log_info "run $version" + cleanup_storage + start $version + fixture_create + fixture_assert + + for version in 1.19 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do + stop log_info "run $version" - cleanup_storage start $version verify_storage - stop + fixture_assert done done } From 6bb5e947fb0d2ef90465f4563692f8fe44172ba3 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sun, 17 Mar 2024 18:12:41 +0100 Subject: [PATCH 050/203] upgrades: run doctor check --all after each upgrade --- forgejo/fixtures.sh | 1 + forgejo/fixtures/doctor.sh | 7 +++++++ upgrade/default-app.ini | 3 +++ upgrade/upgrade.sh | 2 ++ 4 files changed, 13 insertions(+) create mode 100644 forgejo/fixtures/doctor.sh diff --git a/forgejo/fixtures.sh b/forgejo/fixtures.sh index 9c609f5..9e7f5ca 100644 --- a/forgejo/fixtures.sh +++ b/forgejo/fixtures.sh @@ -3,3 +3,4 @@ FIXTURES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $FIXTURES_DIR/fixtures/storage.sh +source $FIXTURES_DIR/fixtures/doctor.sh diff --git a/forgejo/fixtures/doctor.sh b/forgejo/fixtures/doctor.sh new file mode 100644 index 0000000..9064699 --- /dev/null +++ b/forgejo/fixtures/doctor.sh @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: MIT + +function doctor_run() { + local version=$1 + + forgejo_cli $version doctor check --all # --log-file - +} diff --git a/upgrade/default-app.ini b/upgrade/default-app.ini index a51290a..af8f6e3 100644 --- a/upgrade/default-app.ini +++ b/upgrade/default-app.ini @@ -7,6 +7,9 @@ HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true +[queue] +TYPE = immediate + [database] DB_TYPE = sqlite3 PATH = ${WORK_PATH}/forgejo.db diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 5ad4415..5f69abc 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -36,6 +36,7 @@ function test_successful_upgrades() { start $version fixture_create fixture_assert + doctor_run $version for version in 1.19 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do stop @@ -43,6 +44,7 @@ function test_successful_upgrades() { start $version verify_storage fixture_assert + doctor_run $version done done } From b563e5cd191217e5004dfdf01c7f4d2ef9f16f07 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sun, 17 Mar 2024 19:55:01 +0100 Subject: [PATCH 051/203] packages: Add E2E test for Alpine package with noarch Refs: https://code.forgejo.org/forgejo/end-to-end/pulls/75 --- .../package-source/APKBUILD | 0 .../package-source/forgejo_2174 | 0 .../package-source/forgejo_2174.init | 0 packages/{alpine => alpine-1.21}/test.sh | 0 packages/alpine-7.0-dev | 1 + .../package-source/forgejo-2173/APKBUILD | 24 +++++++ .../package-source/forgejo-2173/forgejo_2173 | 3 + .../forgejo-2173/forgejo_2173.init | 7 +++ .../package-source/forgejo-2174/APKBUILD | 26 ++++++++ .../package-source/forgejo-2174/forgejo_2174 | 3 + .../forgejo-2174/forgejo_2174.init | 7 +++ packages/alpine-7.0-test/test.sh | 63 +++++++++++++++++++ packages/alpine.sh | 17 +++-- 13 files changed, 145 insertions(+), 6 deletions(-) rename packages/{alpine => alpine-1.21}/package-source/APKBUILD (100%) rename packages/{alpine => alpine-1.21}/package-source/forgejo_2174 (100%) rename packages/{alpine => alpine-1.21}/package-source/forgejo_2174.init (100%) rename packages/{alpine => alpine-1.21}/test.sh (100%) create mode 120000 packages/alpine-7.0-dev create mode 100644 packages/alpine-7.0-test/package-source/forgejo-2173/APKBUILD create mode 100755 packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173 create mode 100755 packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173.init create mode 100644 packages/alpine-7.0-test/package-source/forgejo-2174/APKBUILD create mode 100755 packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174 create mode 100755 packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174.init create mode 100755 packages/alpine-7.0-test/test.sh diff --git a/packages/alpine/package-source/APKBUILD b/packages/alpine-1.21/package-source/APKBUILD similarity index 100% rename from packages/alpine/package-source/APKBUILD rename to packages/alpine-1.21/package-source/APKBUILD diff --git a/packages/alpine/package-source/forgejo_2174 b/packages/alpine-1.21/package-source/forgejo_2174 similarity index 100% rename from packages/alpine/package-source/forgejo_2174 rename to packages/alpine-1.21/package-source/forgejo_2174 diff --git a/packages/alpine/package-source/forgejo_2174.init b/packages/alpine-1.21/package-source/forgejo_2174.init similarity index 100% rename from packages/alpine/package-source/forgejo_2174.init rename to packages/alpine-1.21/package-source/forgejo_2174.init diff --git a/packages/alpine/test.sh b/packages/alpine-1.21/test.sh similarity index 100% rename from packages/alpine/test.sh rename to packages/alpine-1.21/test.sh diff --git a/packages/alpine-7.0-dev b/packages/alpine-7.0-dev new file mode 120000 index 0000000..a2389c0 --- /dev/null +++ b/packages/alpine-7.0-dev @@ -0,0 +1 @@ +alpine-7.0-test \ No newline at end of file diff --git a/packages/alpine-7.0-test/package-source/forgejo-2173/APKBUILD b/packages/alpine-7.0-test/package-source/forgejo-2173/APKBUILD new file mode 100644 index 0000000..75c9dd1 --- /dev/null +++ b/packages/alpine-7.0-test/package-source/forgejo-2173/APKBUILD @@ -0,0 +1,24 @@ +# -*- mode: Shell-script; eval: (setq indent-tabs-mode 't); eval: (setq tab-width 4) -*- +# Maintainer: Dominic Meiser +pkgname=forgejo-2173 +pkgver=1.0 +pkgrel=0 +pkgdesc="Forgejo #2173 Reproduction" +url="https://msrd0.dev/msrd0/$pkgname" +arch="noarch" +license="custom" + +subpackages="$pkgname-openrc" + +source="forgejo_2173 forgejo_2173.init" +builddir="$srcdir" + +package() { + install -D -m755 "$srcdir/forgejo_2173" "$pkgdir"/usr/bin/forgejo_2173 + install -D -m755 "$srcdir/forgejo_2173.init" "$pkgdir"/etc/init.d/forgejo_2173 +} + +sha512sums=" +651c2a816510a18981bcd45077eb5acd6e58511d641949ddc690e326b81018d851eb7f1c88e2336eada2f216606ce2aa0569eb2d02d7c423c80705cc00acf838 forgejo_2173 +abc3b1c91bd69478e8e0d46a31148bcd5b4e7838dc35e7b601673866d7e925d70ab70d63c32df98aad060134eaaa6f957691c2c4397d85af5a77f9773de21b5b forgejo_2173.init +" diff --git a/packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173 b/packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173 new file mode 100755 index 0000000..b12f87b --- /dev/null +++ b/packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173 @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Hello World" diff --git a/packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173.init b/packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173.init new file mode 100755 index 0000000..b5d66cc --- /dev/null +++ b/packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173.init @@ -0,0 +1,7 @@ +#!/sbin/openrc-run + +command="/usr/bin/forgejo_2173" + +depend() { + need net +} diff --git a/packages/alpine-7.0-test/package-source/forgejo-2174/APKBUILD b/packages/alpine-7.0-test/package-source/forgejo-2174/APKBUILD new file mode 100644 index 0000000..ce75e29 --- /dev/null +++ b/packages/alpine-7.0-test/package-source/forgejo-2174/APKBUILD @@ -0,0 +1,26 @@ +# -*- mode: Shell-script; eval: (setq indent-tabs-mode 't); eval: (setq tab-width 4) -*- +# Maintainer: Dominic Meiser +pkgname=forgejo-2174 +pkgver=1.0 +pkgrel=0 +pkgdesc="Forgejo #2174 Reproduction" +url="https://msrd0.dev/msrd0/$pkgname" +arch="x86_64" +license="custom" + +# using x86_64 instead of noarch as a workaround of +# https://codeberg.org/forgejo/forgejo/issues/2173 +subpackages="$pkgname-openrc::x86_64" + +source="forgejo_2174 forgejo_2174.init" +builddir="$srcdir" + +package() { + install -D -m755 "$srcdir/forgejo_2174" "$pkgdir"/usr/bin/forgejo_2174 + install -D -m755 "$srcdir/forgejo_2174.init" "$pkgdir"/etc/init.d/forgejo_2174 +} + +sha512sums=" +651c2a816510a18981bcd45077eb5acd6e58511d641949ddc690e326b81018d851eb7f1c88e2336eada2f216606ce2aa0569eb2d02d7c423c80705cc00acf838 forgejo_2174 +b1cba77139cdaf9e0cdd78de93becbb3891ec59646e8d2cb40620b230bd798d51e6d9c58e65b584812a6bb8eb2b9c9f89262a8700a39c62af8ec8ea09aee4e29 forgejo_2174.init +" diff --git a/packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174 b/packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174 new file mode 100755 index 0000000..b12f87b --- /dev/null +++ b/packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174 @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Hello World" diff --git a/packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174.init b/packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174.init new file mode 100755 index 0000000..06b7f20 --- /dev/null +++ b/packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174.init @@ -0,0 +1,7 @@ +#!/sbin/openrc-run + +command="/usr/bin/forgejo_2174" + +depend() { + need net +} diff --git a/packages/alpine-7.0-test/test.sh b/packages/alpine-7.0-test/test.sh new file mode 100755 index 0000000..45bb60e --- /dev/null +++ b/packages/alpine-7.0-test/test.sh @@ -0,0 +1,63 @@ +#!/bin/busybox ash +set -exuo pipefail + +forgejo_url=$1 +forgejo_token=$2 + +# initialize abuild +apk update +apk add --no-cache alpine-sdk sudo util-linux +adduser -D user -h /home/user +addgroup user abuild +echo "root ALL=(ALL) ALL" >/etc/sudoers +echo "%abuild ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers +mkdir -p /var/cache/distfiles +chgrp abuild /var/cache/distfiles +chmod 775 /var/cache/distfiles +mkdir -p "/home/user/.abuild" +echo "/home/user/.abuild/user.rsa" | abuild-keygen -i -b 4096 +echo 'PACKAGER_PRIVKEY=/home/user/.abuild/user.rsa' >/home/user/.abuild/abuild.conf +chown -R "user:user" /home/user/ + +# make sure we own the relevant directory +cp -r package-source /srv/alpine +cd /srv +mkdir packages +echo "REPODEST=/srv/packages" >>/home/user/.abuild/abuild.conf +cat /home/user/.abuild/abuild.conf +chown -R user:user alpine packages + +# build the package +sudo -u user APKBUILD=alpine/forgejo-2174/APKBUILD abuild -r + +# build the package +sudo -u user APKBUILD=alpine/forgejo-2173/APKBUILD abuild -r + +# upload new package +cd packages/alpine/x86_64/ +for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do + # remove old package + curl \ + --fail \ + -H "Authorization: token $forgejo_token" \ + -X DELETE \ + "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests/$file" \ + || true + + # upload new package + curl \ + --fail \ + -H "Authorization: token $forgejo_token" \ + -T "$file" \ + "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests" +done + +# ensure that the install-if condition works as expected +apk add openrc +(cd /etc/apk/keys && curl -JO $forgejo_url/api/packages/root/alpine/key) +echo "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests" >>/etc/apk/repositories +apk add forgejo-2174 forgejo-2173 +[ -e /usr/bin/forgejo_2174 ] # from the installed package +[ -e /usr/bin/forgejo_2173 ] # from the installed package +[ -e /etc/init.d/forgejo_2174 ] # from the -openrc package installed because of the install-if condition +[ -e /etc/init.d/forgejo_2173 ] # from the -openrc package installed because of the install-if condition diff --git a/packages/alpine.sh b/packages/alpine.sh index 11cb56a..b3e5b5d 100644 --- a/packages/alpine.sh +++ b/packages/alpine.sh @@ -1,19 +1,24 @@ -#!/bin/sh # Copyright 2024 The Forgejo Authors # SPDX-License-Identifier: MIT -function test_packages_alpine_v1.21() { +function test_packages_alpine_version() { + local alpine_version=$1 forgejo_version=$2 stop_daemon forgejo reset_forgejo $PACKAGES_DIR/alpine-app.ini - start_forgejo 1.21 + start_forgejo $forgejo_version - local d=$PACKAGES_DIR/alpine + local d=$PACKAGES_DIR/alpine-$forgejo_version local token=$(cat $DIR/forgejo-curl/token) local url=http://${HOST_PORT} - docker run --rm --volume $d:$d:ro --workdir $d docker.io/alpine:3.19 ash -c "./test.sh $url $token" + log_info "alpine:$alpine_version & Forgejo $forgejo_version" + docker run --rm --volume $d:$d:ro --workdir $d docker.io/alpine:$alpine_version ash -c "./test.sh $url $token" } function test_packages_alpine() { - test_packages_alpine_v1.21 + for alpine_version in 3.18 3.19 ; do + for forgejo_version in 1.21 7.0-test 7.0-dev ; do + test_packages_alpine_version $alpine_version $forgejo_version + done + done } From 81eebc10d84d093b12b616143398bca955b68769 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sun, 17 Mar 2024 21:19:13 +0100 Subject: [PATCH 052/203] show the full logs in a separate step for forensic analysis --- .forgejo/workflows/end-to-end.yml | 6 ++++++ lib/lib.sh | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index 04072cd..e136f40 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -46,6 +46,9 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: ./.forgejo/prepare-end-to-end - run: su forgejo -c "./end-to-end.sh test_packages" + - name: full logs + if: always() + run: su forgejo -c "./end-to-end.sh show_logs" upgrade: name: upgrade and storage @@ -70,3 +73,6 @@ jobs: - uses: ./.forgejo/prepare-end-to-end - run: su forgejo -c "./end-to-end.sh test_upgrades" - run: su forgejo -c "./end-to-end.sh test_storage" + - name: full logs + if: always() + run: su forgejo -c "./end-to-end.sh show_logs" diff --git a/lib/lib.sh b/lib/lib.sh index fa6375f..349d1a4 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -298,6 +298,13 @@ function stop() { cleanup_logs } +function show_logs() { + ( + cd $DIR + grep '' *.out + ) +} + function run() { local fun=$1 shift From 96f91063c929c48e72b0f91973811545bcbb497c Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Wed, 20 Mar 2024 11:51:46 +0100 Subject: [PATCH 053/203] merge actions test into end-to-end.sh * replace the high level test running actions tests with end-to-end.sh * set DOMAIN to the IP instead of 127.0.0.1 for runner <-> forgejo communications * move forgejo_cli from a function to a file so that it can be used by forgejo-runner.sh * keep the documentation updates workflows separate because they need to open one PR per version --- .forgejo/workflows/actions.yml | 82 ------------------- .forgejo/workflows/end-to-end.yml | 66 ++++++++++++++++ README.md | 55 +++---------- actions/actions.sh | 98 +++++++++++++++++++++++ actions/default-app.ini | 35 ++++++++ actions/run.sh | 127 ------------------------------ end-to-end.sh | 1 + forgejo/fixtures/doctor.sh | 2 +- lib/lib.sh | 26 +++--- packages/alpine-app.ini | 1 + storage/default-app.ini | 1 + storage/legagy-relative-app.ini | 1 + storage/merged-app.ini | 1 + storage/misplace-app.ini | 1 + storage/misplace-s3-app.ini | 1 + storage/misplace-s3-two-app.ini | 1 + storage/relative-app.ini | 1 + storage/specific-app.ini | 1 + storage/stable-s3-app.ini | 1 + storage/storage-relative-app.ini | 1 + upgrade/default-app.ini | 1 + 21 files changed, 235 insertions(+), 269 deletions(-) delete mode 100644 .forgejo/workflows/actions.yml create mode 100755 actions/actions.sh create mode 100644 actions/default-app.ini delete mode 100755 actions/run.sh diff --git a/.forgejo/workflows/actions.yml b/.forgejo/workflows/actions.yml deleted file mode 100644 index 2c17002..0000000 --- a/.forgejo/workflows/actions.yml +++ /dev/null @@ -1,82 +0,0 @@ -# -# -# https://code.forgejo.org/forgejo/end-to-end/settings/actions -# -# secrets.CASCADE_DOCS_ORIGIN_TOKEN -# https://code.forgejo.org/forgejo-ci scope write:issue, read:repository, read:user -# vars.CASCADE_DOCS_DESTINATION_DOER -# forgejo-cascading-pr (https://codeberg.org/forgejo-cascading-pr) -# secrets.CASCADE_DOCS_DESTINATION_TOKEN -# https://codeberg.org/forgejo-cascading-pr scope write:issue, write:repository, read:user -# vars.CASCADE_DOCS_FORCE_VERSION -# replace the generated documentation for a given version even if it has already -# been generated (e.g. v7.0.0-test) -# - -on: - pull_request: - push: - branches: - - 'main' - -jobs: - actions: - runs-on: self-hosted - strategy: - matrix: - info: - - version: v7.0 - branch: next - forgejo: https://codeberg.org - repo: forgejo-experimental/forgejo - tests: ${{ vars.V7_0_TESTS }} - - version: v1.21 - forgejo: https://codeberg.org - repo: forgejo/forgejo - tests: ${{ vars.V1_21_TESTS }} - - version: v1.20 - forgejo: https://codeberg.org - repo: forgejo/forgejo - tests: ${{ vars.V1_20_TESTS }} - steps: - - uses: actions/checkout@v4 - - - uses: https://code.forgejo.org/actions/setup-forgejo@v2 - with: - install-only: true - - - name: run - id: run - if: matrix.info.tests != 'none' - shell: bash - run: | - set -x - forgejo-binary.sh ensure_user forgejo - full_version=$(curl -sS ${{ matrix.info.forgejo }}/api/v1/repos/${{ matrix.info.repo }}/releases | jq -r '.[] | .tag_name | select(startswith("${{ matrix.info.version }}"))' | sort -r | head -1) - binary=${{ matrix.info.forgejo }}/${{ matrix.info.repo }}/releases/download/${full_version}/forgejo-${full_version#v}-linux-amd64 - - export DIR=$(mktemp -d) - chown forgejo $DIR /srv - - su -c "actions/run.sh $binary $full_version ${{ matrix.info.version }} ${{ matrix.info.tests }}" forgejo - - echo full_version="$full_version" >> $GITHUB_OUTPUT - - - name: update documentation - if: matrix.info.tests != 'none' && github.ref == 'refs/heads/main' - uses: https://code.forgejo.org/actions/cascading-pr@v1 - with: - origin-url: ${{ env.GITHUB_SERVER_URL }} - origin-repo: ${{ github.repository }} - origin-token: ${{ secrets.CASCADE_DOCS_ORIGIN_TOKEN }} - origin-ref: refs/heads/main - destination-url: https://codeberg.org - destination-fork-repo: ${{ vars.CASCADE_DOCS_DESTINATION_DOER }}/docs - destination-repo: forgejo/docs - destination-branch: ${{ matrix.info.branch || matrix.info.version }} - destination-token: ${{ secrets.CASCADE_DOCS_DESTINATION_TOKEN }} - prefix: ${{ env.GITHUB_REPOSITORY }}-${{ matrix.info.version }} - update: .forgejo/cascading-docs - env: - FORCE_VERSION: "${{ vars.CASCADE_DOCS_FORCE_VERSION }}" - VERSION: "${{ steps.run.outputs.full_version }}" diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index 04072cd..c0e1f3e 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -1,3 +1,18 @@ +# +# +# https://code.forgejo.org/forgejo/end-to-end/settings/actions +# +# secrets.CASCADE_DOCS_ORIGIN_TOKEN +# https://code.forgejo.org/forgejo-ci scope write:issue, read:repository, read:user +# vars.CASCADE_DOCS_DESTINATION_DOER +# forgejo-cascading-pr (https://codeberg.org/forgejo-cascading-pr) +# secrets.CASCADE_DOCS_DESTINATION_TOKEN +# https://codeberg.org/forgejo-cascading-pr scope write:issue, write:repository, read:user +# vars.CASCADE_DOCS_FORCE_VERSION +# replace the generated documentation for a given version even if it has already +# been generated (e.g. v7.0.0-test) +# + on: pull_request: push: @@ -47,6 +62,57 @@ jobs: - uses: ./.forgejo/prepare-end-to-end - run: su forgejo -c "./end-to-end.sh test_packages" + actions: + needs: [build] + runs-on: lxc-bookworm + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + - uses: ./.forgejo/prepare-end-to-end + - run: su forgejo -c "./end-to-end.sh test_actions" + + actions-docs: + needs: [build] + runs-on: lxc-bookworm + if: github.ref == 'refs/heads/main' + strategy: + matrix: + info: + - version: 7.0 + branch: next + forgejo: https://codeberg.org + repo: forgejo-experimental/forgejo + - version: 1.21 + forgejo: https://codeberg.org + repo: forgejo/forgejo + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + - uses: ./.forgejo/prepare-end-to-end + - name: set full-version + id: full-version + shell: bash + run: | + set -x + full_version=$(./end-to-end.sh full_version ${{ matrix.info.version }}) + echo value="$full_version" >> $GITHUB_OUTPUT + - run: su forgejo -c "./end-to-end.sh test_actions ${{ matrix.info.version }}" + - name: update documentation + uses: https://code.forgejo.org/actions/cascading-pr@v1 + with: + origin-url: ${{ env.GITHUB_SERVER_URL }} + origin-repo: ${{ github.repository }} + origin-token: ${{ secrets.CASCADE_DOCS_ORIGIN_TOKEN }} + origin-ref: refs/heads/main + destination-url: https://codeberg.org + destination-fork-repo: ${{ vars.CASCADE_DOCS_DESTINATION_DOER }}/docs + destination-repo: forgejo/docs + destination-branch: ${{ matrix.info.branch || format('v{0}', matrix.info.version) }} + destination-token: ${{ secrets.CASCADE_DOCS_DESTINATION_TOKEN }} + prefix: ${{ env.GITHUB_REPOSITORY }}-${{ matrix.info.version }} + update: .forgejo/cascading-docs + env: + FORCE_VERSION: "${{ vars.CASCADE_DOCS_FORCE_VERSION }}" + VERSION: "${{ steps.full-version.outputs.value }}" + upgrade: name: upgrade and storage needs: [build] diff --git a/README.md b/README.md index 7d3a95e..2b409da 100644 --- a/README.md +++ b/README.md @@ -30,24 +30,24 @@ Action](https://forgejo.org/docs/v1.21/user/actions/) which is meant to be used in workflows. However, it is implemented as shell scripts that can also be used to create Forgejo instances and runners locally. This is convenient for testing and the reason why it needs to be added to the PATH. -For instance, it is a dependency of the `actions/run.sh` script. +For instance, it is a dependency of the `end-to-end.sh` script. ```sh git clone https://code.forgejo.org/actions/setup-forgejo export PATH=$(pwd)/setup-forgejo:$PATH git clone https://code.forgejo.org/forgejo/end-to-end cd end-to-end -export DIR=/tmp/forgejo-end-to-end -rm -fr /tmp/forgejo-end-to-end ; sudo rm -fr /srv/example ; sudo mkdir /srv/example ; sudo chown -R $USER /srv/example ``` -Run using Forgejo built from source. +## Running from locally built binary ```sh make TAGS='bindata sqlite sqlite_unlock_notify' generate forgejo -cp -a forgejo $DIR/forgejo +cp -a forgejo /srv/forgejo-binaries/forgejo-7.0-dev ``` +It will be used whenver the version `7.0-dev` is specified in a test. + ## Running actions locally To run and debug workflows from `actions/example-*`, from the root of @@ -58,43 +58,12 @@ run as root in the context of Forgejo Actions and assume they have admin permissions. But they do not need to run as root and must work fine when run as a regular user. -Run one example - ```sh -actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 cron # runs actions/example-cron +./end-to-end.sh actions_setup 1.21 +firefox 0.0.0.0:3000 # user root / admin1234 +./end-to-end.sh actions_verify_example artifacts +./end-to-end.sh actions_teardown ``` - -Cleanup. It will teardown Forgejo & the runner and not run them because there is nothing to test. - -```sh -actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 none -``` - -Run all examples for v7_0 - -```sh -actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v7.0.0-test/forgejo-7.0.0-test-linux-amd64 v7.0.0-test v7_0 -``` - -Run from sources - -```sh -make TAGS='bindata sqlite sqlite_unlock_notify' generate forgejo -cp -a forgejo $DIR/forgejo -``` - -Remote testing - -To reduce the runtime the following variables can be set to control -the number of cases run by the -[actions](.forgejo/workflows/actions.yml) tests. If set to -**none** they are not run at all for that version of Forgejo. If -it does not exist, all tests are run. - -* `v7_0_TESTS` -* `V1_21_TESTS` -* `V1_20_TESTS` - ## Running other tests locally To run and debug tests, from the root of the source directory. @@ -102,12 +71,12 @@ To run and debug tests, from the root of the source directory. Run one test. When the test fails the instance can be inspected at http://0.0.0.0:3000 ```sh -VERBOSE=true ./forgejo/upgrades/test-upgrade.sh test_packages_alpine -VERBOSE=true ./forgejo/upgrades/test-upgrade.sh test_storage_stable_s3 minio +./end-to-end.sh test_packages_alpine +./end-to-end.sh test_storage_stable_s3 minio ``` Cleanup. It will teardown the Forgejo instance. ```sh -./forgejo/upgrades/test-upgrade.sh stop +./end-to-end.sh stop ``` diff --git a/actions/actions.sh b/actions/actions.sh new file mode 100755 index 0000000..fb3c18e --- /dev/null +++ b/actions/actions.sh @@ -0,0 +1,98 @@ +# Copyright 2024 The Forgejo Authors +# SPDX-License-Identifier: MIT + +ACTIONS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +function actions_verify_example() { + local example=$1 + + export url=http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT} + export token=$(cat $DOT_FORGEJO_CURL/token) + + actions_cleanup_example_volume + + export example + export EXAMPLE_DIR=$ACTIONS_DIR/example-$example + + if test -f $EXAMPLE_DIR/setup.sh ; then + echo "============================ SETUP example-$example ===================" + bash -ex $EXAMPLE_DIR/setup.sh || return 1 + fi + + if test -f $EXAMPLE_DIR/run.sh ; then + echo "============================ RUN example-$example ===================" + bash -ex $EXAMPLE_DIR/run.sh || return 1 + else + forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example $example $token || return 1 + fi + + if test -f $EXAMPLE_DIR/teardown.sh ; then + echo "============================ TEARDOWN example-$example ===================" + bash -ex $EXAMPLE_DIR/teardown.sh || return 1 + fi + + actions_save_contexts $example +} + +function actions_save_contexts() { + local example="$1" + + if test -d /srv/example/$example/contexts; then + mkdir -p /srv/contexts + rsync -av /srv/example/$example/contexts/ /srv/contexts/$example/ + fi +} + +function actions_cleanup_example_volume() { + if test $(id -u) != 0 ; then + $SUDO chown $(id -u) /srv + fi + + if ! test -d /srv/example ; then + mkdir -p /srv/example + return + fi + + $SUDO rm -fr /srv/example/* +} + +function actions_setup() { + local version=$1 + actions_teardown + + reset_forgejo $ACTIONS_DIR/default-app.ini + start_forgejo $version + + export FORGEJO_RUNNER_LOGS=$DIR/forgejo-runner.log + + actions_cleanup_example_volume + export FORGEJO_RUNNER_CONFIG=$ACTIONS_DIR/runner-config.yaml + forgejo-runner.sh setup '' '' http://${HOST_PORT} +} + +function actions_teardown() { + forgejo-curl.sh logout + forgejo-runner.sh teardown + stop_daemon forgejo +} + +function test_actions() { + local versions="${1:-1.20 1.21 $RELEASE_NUMBERS_AND_DEV}" + + for version in $versions ; do + + log_info "Testing actions for $version" + + actions_setup $version + + for example in echo checkout service container expression local-action docker-action if if-fail ; do + run actions_verify_example $example + done + + if dpkg --compare-versions $version gt 1.20 ; then + for example in push tag push-cancel artifacts pull-request context cron ; do + run actions_verify_example $example + done + fi + done +} diff --git a/actions/default-app.ini b/actions/default-app.ini new file mode 100644 index 0000000..7ef8df1 --- /dev/null +++ b/actions/default-app.ini @@ -0,0 +1,35 @@ +RUN_MODE = prod +WORK_PATH = ${WORK_PATH} + +[server] +APP_DATA_PATH = ${WORK_PATH}/data +DOMAIN = ${IP} +HTTP_PORT = 3000 +SSH_LISTEN_PORT = 2222 +LFS_START_SERVER = true + +[queue] +TYPE = immediate + +[database] +DB_TYPE = sqlite3 +PATH = ${WORK_PATH}/forgejo.db + +[log] +MODE = file +LEVEL = trace +ROUTER = file + +[log.file] +FILE_NAME = forgejo.log + +[security] +INSTALL_LOCK = true + +[repository] +ENABLE_PUSH_CREATE_USER = true +DEFAULT_PUSH_CREATE_PRIVATE = false +DEFAULT_REPO_UNITS = repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects,repo.packages,repo.actions + +[actions] +ENABLED = true diff --git a/actions/run.sh b/actions/run.sh deleted file mode 100755 index ab8b86b..0000000 --- a/actions/run.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/bash - -set -e -set -o pipefail - -SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -function run() { - local example=$1 - - export example - export EXAMPLE_DIR=$SELF_DIR/example-$example - - if test -f $EXAMPLE_DIR/setup.sh ; then - echo "============================ SETUP example-$example ===================" - bash -ex $EXAMPLE_DIR/setup.sh || return 1 - fi - - if test -f $EXAMPLE_DIR/run.sh ; then - echo "============================ RUN example-$example ===================" - bash -ex $EXAMPLE_DIR/run.sh || return 1 - else - forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example $example $token || return 1 - fi - - if test -f $EXAMPLE_DIR/teardown.sh ; then - echo "============================ TEARDOWN example-$example ===================" - bash -ex $EXAMPLE_DIR/teardown.sh || return 1 - fi -} - -function examples_v1_20() { - echo 'echo checkout service container expression local-action docker-action if if-fail' -} - -function examples_v1_21() { - # keep "cron" last otherwise it will linger and pollute the following runs - echo 'echo push tag push-cancel artifacts service checkout pull-request container expression local-action context docker-action if if-fail cron' -} - -function examples_v7_0() { - examples_v1_21 -} - -function save_contexts() { - local example="$1" - - if test -d /srv/example/$example/contexts; then - mkdir -p /srv/contexts - rsync -av /srv/example/$example/contexts/ /srv/contexts/$example/ - fi -} - -function cleanup_example_volume() { - if ! test -d /srv/example ; then - mkdir -p /srv/example - return - fi - - if test $(id -u) != 0 ; then - SUDO=sudo - fi - - $SUDO rm -fr /srv/example/* -} - -function setup() { - local binary=$1 - forgejo-binary.sh setup root admin1234 $binary - cleanup_example_volume - export FORGEJO_RUNNER_CONFIG=$SELF_DIR/runner-config.yaml - forgejo-runner.sh setup -} - -function teardown() { - forgejo-curl.sh logout - forgejo-runner.sh teardown - forgejo-binary.sh teardown -} - -function main() { - local binary="$1" - shift - export full_version="$1" - shift - export version="$1" - shift - - export DOT=$DIR/forgejo-curl - - teardown - - if test "$#" = 0 ; then - examples=$(examples_${version/./_}) - else - examples="$@" - fi - - if test "$examples" = "none" ; then - exit 0 - fi - - setup $binary - - if ! test -f "$DIR/forgejo-auth-url" ; then - echo "DIR=$DIR must be a directory with a forgejo-auth-url file" - fi - - export FORGEJO_RUNNER_LOGS=$DIR/forgejo-runner.log - export url=$(cat $DIR/forgejo-auth-url) - export token=$(cat $DIR/forgejo-token) - - for example in $examples ; do - echo "======================== BEGIN example-$example ===================" - if ! time run $example >& /tmp/run.out ; then - sed -e 's/^/[RUN] /' < /tmp/run.out - echo "======================== FAIL example-$example ===================" - sleep 5 # hack for Forgejo v1.21 to workaround a bug by which the last lines of the output are moved to the next step - false - fi - echo "======================== END example-$example ===================" - save_contexts $example - cleanup_example_volume - done -} - -main "$@" diff --git a/end-to-end.sh b/end-to-end.sh index 6157d3f..04478c3 100755 --- a/end-to-end.sh +++ b/end-to-end.sh @@ -15,6 +15,7 @@ SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SELF="${BASH_SOURCE[0]}" source $SELF_DIR/lib/lib.sh +source $SELF_DIR/actions/actions.sh source $SELF_DIR/forgejo/fixtures.sh source $SELF_DIR/storage/storage.sh source $SELF_DIR/upgrade/upgrade.sh diff --git a/forgejo/fixtures/doctor.sh b/forgejo/fixtures/doctor.sh index 9064699..04e5b99 100644 --- a/forgejo/fixtures/doctor.sh +++ b/forgejo/fixtures/doctor.sh @@ -3,5 +3,5 @@ function doctor_run() { local version=$1 - forgejo_cli $version doctor check --all # --log-file - + $DIR/forgejocli doctor check --all # --log-file - } diff --git a/lib/lib.sh b/lib/lib.sh index fa6375f..08c7e8e 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -28,7 +28,7 @@ RELEASE_NUMBERS="7.0" PREFIX=============== HOST_PORT=$IP:3000 -DIR=/tmp/forgejo-end-to-end +export DIR=/tmp/forgejo-end-to-end DIR_BINARIES=/srv/forgejo-binaries export DOT_FORGEJO_CURL=$DIR/forgejo-curl export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 @@ -47,9 +47,9 @@ function dependencies() { $SUDO chmod +x /usr/local/bin/forgejo-curl.sh fi - if ! which curl daemon jq git-lfs > /dev/null ; then + if ! which make curl daemon git-lfs jq sqlite3 > /dev/null ; then $SUDO apt-get update -qq - $SUDO apt-get install -y -qq curl daemon git-lfs jq sqlite3 gettext-base + $SUDO apt-get install -y -qq make curl daemon git-lfs jq sqlite3 gettext-base fi if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio ; then @@ -159,6 +159,8 @@ function start_forgejo() { grep '' $work_path/log/*.log 2> /dev/null return 1 fi + echo "$DIR_BINARIES/forgejo-$version --config $work_path/app.ini --work-path $work_path" '"$@"' > $DIR/forgejocli + chmod +x $DIR/forgejocli create_user_and_login $version } @@ -238,7 +240,7 @@ function reset_forgejo() { local work_path=$DIR/forgejo-work-path rm -fr $work_path mkdir -p $work_path - WORK_PATH=$work_path envsubst < $config > $work_path/app.ini + IP=$IP WORK_PATH=$work_path envsubst < $config > $work_path/app.ini } function reset_minio() { @@ -249,20 +251,12 @@ function reset_garage() { rm -fr $DIR/garage } -function forgejo_cli() { - local version="$1" - shift - local work_path=$DIR/forgejo-work-path - - $DIR_BINARIES/forgejo-$version --config $work_path/app.ini --work-path $work_path "$@" -} - function create_user_and_login() { local version=$1 local email="$FORGEJO_USER@example.com" - if ! forgejo_cli $version admin user list | grep --quiet "$email" ; then - forgejo_cli $version admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email + if ! $DIR/forgejocli admin user list | grep --quiet "$email" ; then + $DIR/forgejocli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email fi forgejo-curl.sh logout @@ -302,10 +296,10 @@ function run() { local fun=$1 shift - echo Start running $fun + echo Start running $fun "$@" mkdir -p $DIR > $DIR/$fun.out - tail --follow $DIR/$fun.out | sed --unbuffered -n -e "/^$PREFIX/s/^$PREFIX //p" & + tail --follow $DIR/$fun.out |& sed --unbuffered -n -e "/^$PREFIX/s/^$PREFIX //p" & local pid=$! if ! VERBOSE=true $SELF $fun "$@" >& $DIR/$fun.out ; then kill $pid diff --git a/packages/alpine-app.ini b/packages/alpine-app.ini index a51290a..113f242 100644 --- a/packages/alpine-app.ini +++ b/packages/alpine-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/data +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true diff --git a/storage/default-app.ini b/storage/default-app.ini index a51290a..113f242 100644 --- a/storage/default-app.ini +++ b/storage/default-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/data +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true diff --git a/storage/legagy-relative-app.ini b/storage/legagy-relative-app.ini index 130294a..f5ea40f 100644 --- a/storage/legagy-relative-app.ini +++ b/storage/legagy-relative-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/data +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true diff --git a/storage/merged-app.ini b/storage/merged-app.ini index 0b7150c..0a30227 100644 --- a/storage/merged-app.ini +++ b/storage/merged-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/data +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true diff --git a/storage/misplace-app.ini b/storage/misplace-app.ini index 0aeff45..9ffe725 100644 --- a/storage/misplace-app.ini +++ b/storage/misplace-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/elsewhere +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true diff --git a/storage/misplace-s3-app.ini b/storage/misplace-s3-app.ini index d9243dd..490abbe 100644 --- a/storage/misplace-s3-app.ini +++ b/storage/misplace-s3-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/elsewhere +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true diff --git a/storage/misplace-s3-two-app.ini b/storage/misplace-s3-two-app.ini index 00445ea..bcf65c8 100644 --- a/storage/misplace-s3-two-app.ini +++ b/storage/misplace-s3-two-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/elsewhere +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true diff --git a/storage/relative-app.ini b/storage/relative-app.ini index d53c291..5bce502 100644 --- a/storage/relative-app.ini +++ b/storage/relative-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/data +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true diff --git a/storage/specific-app.ini b/storage/specific-app.ini index d7a0bad..980a3b0 100644 --- a/storage/specific-app.ini +++ b/storage/specific-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/elsewhere +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true diff --git a/storage/stable-s3-app.ini b/storage/stable-s3-app.ini index e8c48ae..667bfba 100644 --- a/storage/stable-s3-app.ini +++ b/storage/stable-s3-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/elsewhere +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true diff --git a/storage/storage-relative-app.ini b/storage/storage-relative-app.ini index eba5232..d0b7023 100644 --- a/storage/storage-relative-app.ini +++ b/storage/storage-relative-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/data +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true diff --git a/upgrade/default-app.ini b/upgrade/default-app.ini index af8f6e3..518504c 100644 --- a/upgrade/default-app.ini +++ b/upgrade/default-app.ini @@ -3,6 +3,7 @@ WORK_PATH = ${WORK_PATH} [server] APP_DATA_PATH = ${WORK_PATH}/data +DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true From 8d8994f7ea4870f6c4064fb3eceda4becb6b6f48 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Wed, 20 Mar 2024 14:29:54 +0100 Subject: [PATCH 054/203] always cache minio & garage binaries they are sometime very slow to download and it does not help to do it five times for each workflow --- .forgejo/prepare-end-to-end/action.yml | 10 ++++++++++ .forgejo/workflows/end-to-end.yml | 15 ++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.forgejo/prepare-end-to-end/action.yml b/.forgejo/prepare-end-to-end/action.yml index d94a09a..0fa2794 100644 --- a/.forgejo/prepare-end-to-end/action.yml +++ b/.forgejo/prepare-end-to-end/action.yml @@ -1,6 +1,16 @@ runs: using: "composite" steps: + - name: cache S3 binaries + id: S3 + uses: https://code.forgejo.org/actions/cache@v3 + with: + path: | + /usr/local/bin/minio + /usr/local/bin/mc + /usr/local/bin/garage + key: S3 + - uses: https://code.forgejo.org/actions/setup-forgejo@v2 with: install-only: true diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index e90c791..e90609f 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -121,22 +121,11 @@ jobs: needs: [build] runs-on: lxc-bookworm steps: - - name: cache S3 binaries - id: S3 - uses: https://code.forgejo.org/actions/cache@v3 - with: - path: | - /usr/local/bin/minio - /usr/local/bin/mc - /usr/local/bin/garage - key: S3 - + - uses: https://code.forgejo.org/actions/checkout@v4 + - uses: ./.forgejo/prepare-end-to-end - name: skip if S3 cache hit if: steps.S3.outputs.cache-hit != 'true' run: echo no hit - - - uses: https://code.forgejo.org/actions/checkout@v4 - - uses: ./.forgejo/prepare-end-to-end - run: su forgejo -c "./end-to-end.sh test_upgrades" - run: su forgejo -c "./end-to-end.sh test_storage" - name: full logs From 473c9820c9ff3f8201d61d89ba68381eb9c16c72 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Wed, 20 Mar 2024 14:34:34 +0100 Subject: [PATCH 055/203] versions must be strings --- .forgejo/workflows/end-to-end.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index e90609f..a95cde4 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -80,13 +80,13 @@ jobs: strategy: matrix: info: - - version: 7.0 + - version: "7.0" branch: next forgejo: https://codeberg.org - repo: forgejo-experimental/forgejo - - version: 1.21 + owner: forgejo-experimental + - version: "1.21" forgejo: https://codeberg.org - repo: forgejo/forgejo + owner: forgejo steps: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: ./.forgejo/prepare-end-to-end @@ -95,7 +95,7 @@ jobs: shell: bash run: | set -x - full_version=$(./end-to-end.sh full_version ${{ matrix.info.version }}) + full_version=$(./end-to-end.sh full_version ${{ matrix.info.version }} ${{ matrix.info.owner }}) echo value="$full_version" >> $GITHUB_OUTPUT - run: su forgejo -c "./end-to-end.sh test_actions ${{ matrix.info.version }}" - name: update documentation From dd5d55f032b51bc6d3f066023805c988f206075e Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 20 Mar 2024 16:53:29 +0100 Subject: [PATCH 056/203] upgrade to cascading-pr@v2.1 Closes: https://code.forgejo.org/forgejo/end-to-end/issues/114 --- .forgejo/workflows/end-to-end.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index a95cde4..58e2197 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -99,7 +99,7 @@ jobs: echo value="$full_version" >> $GITHUB_OUTPUT - run: su forgejo -c "./end-to-end.sh test_actions ${{ matrix.info.version }}" - name: update documentation - uses: https://code.forgejo.org/actions/cascading-pr@v1 + uses: https://code.forgejo.org/actions/cascading-pr@v2.1 with: origin-url: ${{ env.GITHUB_SERVER_URL }} origin-repo: ${{ github.repository }} From f4c266f6b2ca4ac91b46ec435f52965ec29dddc9 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Wed, 20 Mar 2024 19:44:00 +0100 Subject: [PATCH 057/203] actions: add step to show logs --- .forgejo/workflows/end-to-end.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index a95cde4..32ec58b 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -72,6 +72,9 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: ./.forgejo/prepare-end-to-end - run: su forgejo -c "./end-to-end.sh test_actions" + - name: full logs + if: always() + run: su forgejo -c "./end-to-end.sh show_logs" actions-docs: needs: [build] From 4e517fb4df12c32bb9b0c9ab69ea4e24ab153a07 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Wed, 20 Mar 2024 19:44:15 +0100 Subject: [PATCH 058/203] outputs do not cross local actions --- .forgejo/workflows/end-to-end.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index 32ec58b..5663d0d 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -126,9 +126,6 @@ jobs: steps: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: ./.forgejo/prepare-end-to-end - - name: skip if S3 cache hit - if: steps.S3.outputs.cache-hit != 'true' - run: echo no hit - run: su forgejo -c "./end-to-end.sh test_upgrades" - run: su forgejo -c "./end-to-end.sh test_storage" - name: full logs From 02d263e21245fa88e8bc10186e3b8bc1e44104eb Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Wed, 20 Mar 2024 19:49:21 +0100 Subject: [PATCH 059/203] lib: ORGANIZATIONS ordered list they determine the order in which Forgejo binaries will be looked up. It is moved to a file so it can be overriden to change the order. --- lib/ORGANIZATIONS | 1 + lib/lib.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 lib/ORGANIZATIONS diff --git a/lib/ORGANIZATIONS b/lib/ORGANIZATIONS new file mode 100644 index 0000000..8c8989a --- /dev/null +++ b/lib/ORGANIZATIONS @@ -0,0 +1 @@ +forgejo forgejo-experimental forgejo-integration diff --git a/lib/lib.sh b/lib/lib.sh index 853a4f2..2d1be2e 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -35,6 +35,7 @@ export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1 : ${FORGEJO_USER:=root} : ${FORGEJO_PASSWORD:=admin1234} RELEASE_NUMBERS_AND_DEV="$(for r in $RELEASE_NUMBERS ; do echo -n $r $r-dev ; done)" +ORGANIZATIONS=$(cat $LIB_DIR/ORGANIZATIONS) function log_info() { echo "$PREFIX $@" @@ -116,7 +117,7 @@ function download() { if ! test -f $DIR_BINARIES/forgejo-$version ; then mkdir -p $DIR_BINARIES - for owner in forgejo forgejo-experimental forgejo-integration ; do + for owner in $ORGANIZATIONS ; do full_version=$(full_version $version $owner) if test "$full_version" = "" ; then continue From e1fd4cbc0f9fdc503e974810a46b96ac06b05854 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 21 Mar 2024 14:25:28 +0100 Subject: [PATCH 060/203] actions: test {upload,download}-artifacts@v4 support If Forgejo version is >= 7.0 and Forgejo runner > 3.3.0 artifacts@v4 are tested to work with a forked modified version that claims to be compatible. --- actions/actions.sh | 17 +++++++ .../.forgejo/workflows/test.yml | 47 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 actions/example-artifacts-v4/.forgejo/workflows/test.yml diff --git a/actions/actions.sh b/actions/actions.sh index fb3c18e..3596139 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -76,6 +76,16 @@ function actions_teardown() { stop_daemon forgejo } +function actions_runner_version() { + local runner_version=$($DIR/forgejo-runner --version | sed -n -e 's/forgejo-runner version v//p') + if test -z "$runner_version" ; then + $DIR/forgejo-runner --version + echo failed to parse version + false + fi + echo $runner_version +} + function test_actions() { local versions="${1:-1.20 1.21 $RELEASE_NUMBERS_AND_DEV}" @@ -84,6 +94,13 @@ function test_actions() { log_info "Testing actions for $version" actions_setup $version + local runner_version=$(actions_runner_version) + + if dpkg --compare-versions $version gt 7.0 && dpkg --compare-versions $runner_version gt 3.3.0 ; then + for example in artifacts-v4 ; do + run actions_verify_example $example + done + fi for example in echo checkout service container expression local-action docker-action if if-fail ; do run actions_verify_example $example diff --git a/actions/example-artifacts-v4/.forgejo/workflows/test.yml b/actions/example-artifacts-v4/.forgejo/workflows/test.yml new file mode 100644 index 0000000..d215354 --- /dev/null +++ b/actions/example-artifacts-v4/.forgejo/workflows/test.yml @@ -0,0 +1,47 @@ +on: [push] +jobs: + upload-many: + runs-on: docker + steps: + - run: mkdir -p artifacts + + - run: touch artifacts/ONE artifacts/TWO + + - uses: https://code.forgejo.org/forgejo/upload-artifact@v4 + with: + name: many-artifacts + path: artifacts/ + + download-many: + needs: [upload-many] + runs-on: docker + steps: + - uses: https://code.forgejo.org/forgejo/download-artifact@v4 + + - run: | + test -f many-artifacts/ONE + test -f many-artifacts/TWO + + upload-one: + runs-on: docker + steps: + - run: mkdir -p path/to/artifact + + - run: echo hello > path/to/artifact/world.txt + + - uses: https://code.forgejo.org/forgejo/upload-artifact@v4 + with: + name: my-artifact + path: path/to/artifact/world.txt + + download-one: + needs: [upload-one] + runs-on: docker + steps: + - run: "! test -f world.txt" + + - uses: https://code.forgejo.org/forgejo/download-artifact@v4 + with: + name: my-artifact + + - run: "test -f world.txt" From a9a46b7b7de19677779ebc435cf6d41652dd6673 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 21 Mar 2024 15:34:38 +0100 Subject: [PATCH 061/203] actions: display the runner version --- actions/actions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/actions.sh b/actions/actions.sh index 3596139..475b8ae 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -91,11 +91,11 @@ function test_actions() { for version in $versions ; do - log_info "Testing actions for $version" - actions_setup $version local runner_version=$(actions_runner_version) + log_info "Testing actions with Forgejo $version & Forgejo runner $runner_version" + if dpkg --compare-versions $version gt 7.0 && dpkg --compare-versions $runner_version gt 3.3.0 ; then for example in artifacts-v4 ; do run actions_verify_example $example From 13f18f9f47bfd79c9001e504d3af1b17bc6353fa Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 21 Mar 2024 17:16:05 +0100 Subject: [PATCH 062/203] actions: Forgejo 7.0 is equivalent to 7.0-test and run artifacts v4 --- actions/actions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/actions.sh b/actions/actions.sh index 475b8ae..ee3e128 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -96,7 +96,7 @@ function test_actions() { log_info "Testing actions with Forgejo $version & Forgejo runner $runner_version" - if dpkg --compare-versions $version gt 7.0 && dpkg --compare-versions $runner_version gt 3.3.0 ; then + if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0 ; then for example in artifacts-v4 ; do run actions_verify_example $example done From be033071a468e5d1ef90106ef9b846784c16b6a6 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 24 Mar 2024 10:51:02 +0100 Subject: [PATCH 063/203] actions: services: cover the case when no container is specified When the container for running the steps is specificied, it is setup differently than when it is implicit. This test adds coverage for both instead of running all examples with an explicitly specified container image. --- .../.forgejo/workflows/test.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/actions/example-service/.forgejo/workflows/test.yml b/actions/example-service/.forgejo/workflows/test.yml index 438203c..014653a 100644 --- a/actions/example-service/.forgejo/workflows/test.yml +++ b/actions/example-service/.forgejo/workflows/test.yml @@ -2,7 +2,23 @@ on: [push] jobs: # - # No volume involved + # No volume involved & the container is implicit + # + simple-no-container: + runs-on: docker + services: + pgsql: + image: code.forgejo.org/oci/postgres:15 + env: + POSTGRES_DB: test + POSTGRES_PASSWORD: postgres + steps: + - run: | + apt-get update -qq + apt-get install -y -qq postgresql-client + PGPASSWORD=postgres psql -h pgsql -U postgres -c '\dt' test + # + # No volume involved & the container is explicit # simple: runs-on: docker From f3ec6704bae06b240797324477e1f5ebe2e4df96 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 25 Mar 2024 18:26:07 +0100 Subject: [PATCH 064/203] tests: the development branch requires go 1.22 to build --- .forgejo/workflows/end-to-end.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index 12e13d6..cb8fa30 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -28,7 +28,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" - name: lib/build.sh run: | set -x From 36456ee74f90a9941afe76cb6dd69eb4097d2926 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 26 Mar 2024 08:31:26 +0100 Subject: [PATCH 065/203] actions: pull-request: assert the existence of contexts and not the existence of tokens --- .../example-pull-request/{assert-token.sh => assert-contexts.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename actions/example-pull-request/{assert-token.sh => assert-contexts.sh} (100%) diff --git a/actions/example-pull-request/assert-token.sh b/actions/example-pull-request/assert-contexts.sh similarity index 100% rename from actions/example-pull-request/assert-token.sh rename to actions/example-pull-request/assert-contexts.sh From d8673b8c0bb39a7ef253c6b92aa00aee09fbacdd Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 26 Mar 2024 08:35:16 +0100 Subject: [PATCH 066/203] actions: pull-request: squash main/setup functions --- actions/example-pull-request/run.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/actions/example-pull-request/run.sh b/actions/example-pull-request/run.sh index 5ae0baa..a262e6f 100755 --- a/actions/example-pull-request/run.sh +++ b/actions/example-pull-request/run.sh @@ -3,7 +3,7 @@ export d=/srv/example/pull-request PROOF='some proof' -function setup() { +function main() { mkdir -p $d forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token @@ -54,8 +54,4 @@ function setup() { done } -function main() { - setup -} - main From cd377ddbade31688a734f58dc72a96c6475ddf24 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 26 Mar 2024 09:21:32 +0100 Subject: [PATCH 067/203] actions: push-cancel: fix typo --- actions/example-push-cancel/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/example-push-cancel/run.sh b/actions/example-push-cancel/run.sh index 37ed9d3..dbdebb4 100755 --- a/actions/example-push-cancel/run.sh +++ b/actions/example-push-cancel/run.sh @@ -13,6 +13,6 @@ forgejo-test-helper.sh wait_running $url $repo $sha # forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token # -# wait for the workflow to be canceld as a result of the previous push +# wait for the workflow to be canceled as a result of the previous push # forgejo-test-helper.sh wait_failure $url $repo $sha 'Has been cancelled' From 6be26d2a69f4e471be9be4b242819555bb1920b5 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 30 Mar 2024 12:24:32 +0100 Subject: [PATCH 068/203] the forgejo development branch is now 8.0 --- forgejo/sources/7.0 | 2 +- forgejo/sources/8.0 | 1 + lib/lib.sh | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 forgejo/sources/8.0 diff --git a/forgejo/sources/7.0 b/forgejo/sources/7.0 index 32da8fd..b033f01 100644 --- a/forgejo/sources/7.0 +++ b/forgejo/sources/7.0 @@ -1 +1 @@ -https://codeberg.org/forgejo/forgejo forgejo 7.0.0+gitea-1.22.0 +https://codeberg.org/forgejo/forgejo v7.0/forgejo 7.0.0+gitea-1.22.0 diff --git a/forgejo/sources/8.0 b/forgejo/sources/8.0 new file mode 100644 index 0000000..1412273 --- /dev/null +++ b/forgejo/sources/8.0 @@ -0,0 +1 @@ +https://codeberg.org/forgejo/forgejo forgejo 8.0.0+gitea-1.22.0 diff --git a/lib/lib.sh b/lib/lib.sh index 2d1be2e..86251fc 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -24,7 +24,7 @@ IP=$(hostname -I | cut -f1 -d' ') # # Forgejo releases for which a branch exists (7.0/forgejo etc.) # -RELEASE_NUMBERS="7.0" +RELEASE_NUMBERS="7.0 8.0" PREFIX=============== HOST_PORT=$IP:3000 @@ -34,7 +34,7 @@ export DOT_FORGEJO_CURL=$DIR/forgejo-curl export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 : ${FORGEJO_USER:=root} : ${FORGEJO_PASSWORD:=admin1234} -RELEASE_NUMBERS_AND_DEV="$(for r in $RELEASE_NUMBERS ; do echo -n $r $r-dev ; done)" +RELEASE_NUMBERS_AND_DEV="$(for r in $RELEASE_NUMBERS ; do echo -n "$r $r-dev " ; done)" ORGANIZATIONS=$(cat $LIB_DIR/ORGANIZATIONS) function log_info() { From fbe3c3c59cbf04e119c64e1d31f2e99135c3a7b7 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sun, 31 Mar 2024 22:49:52 +0200 Subject: [PATCH 069/203] add pprof test --- upgrade/default-app.ini | 1 + upgrade/test_pprof_upload.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 upgrade/test_pprof_upload.sh diff --git a/upgrade/default-app.ini b/upgrade/default-app.ini index 518504c..6eadb37 100644 --- a/upgrade/default-app.ini +++ b/upgrade/default-app.ini @@ -7,6 +7,7 @@ DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true +ENABLE_PPROF = true [queue] TYPE = immediate diff --git a/upgrade/test_pprof_upload.sh b/upgrade/test_pprof_upload.sh new file mode 100644 index 0000000..ad360a6 --- /dev/null +++ b/upgrade/test_pprof_upload.sh @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: MIT + +function test_upload_profiles() { + FORGEJO_URL="http://0.0.0.0:6060" + PROFILECLI_URL="http://0.0.0.0:4040" + + endpoints=("/debug/pprof/allocs" "/debug/pprof/block" "/debug/pprof/goroutine" "/debug/pprof/mutex" "/debug/pprof/profile?seconds=5") + + for endpoint in "${endpoints[@]}"; do + output=$(basename "$endpoint") + if [[ $endpoint == *"/profile"* ]]; then + output="profile" + fi + output="${output}.pprof" + # Download the content and save it to a file + curl -s "${FORGEJO_URL}${endpoint}" -o "${output}" + ./profilecli upload ${output} --url=${PROFILECLI_URL} + + rm ${output} + done +} + +function test_forgejo_pprof() { + stop + docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope + + log_info "run 7.0.0" + + start 7.0.0 + test_upload_profiles + stop + + docker stop test_pyroscope + +} From 5a5b461453b1eddcc74e43fcf687634c1e875606 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Mon, 1 Apr 2024 01:21:59 +0200 Subject: [PATCH 070/203] correct version to run against --- upgrade/test_pprof_upload.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/upgrade/test_pprof_upload.sh b/upgrade/test_pprof_upload.sh index ad360a6..9a82598 100644 --- a/upgrade/test_pprof_upload.sh +++ b/upgrade/test_pprof_upload.sh @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT function test_upload_profiles() { - FORGEJO_URL="http://0.0.0.0:6060" + FORGEJO_URL="http://${IP}:6060" PROFILECLI_URL="http://0.0.0.0:4040" endpoints=("/debug/pprof/allocs" "/debug/pprof/block" "/debug/pprof/goroutine" "/debug/pprof/mutex" "/debug/pprof/profile?seconds=5") @@ -24,9 +24,9 @@ function test_forgejo_pprof() { stop docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope - log_info "run 7.0.0" + log_info "run 8.0-dev" - start 7.0.0 + start 8.0-dev test_upload_profiles stop From 0b216e98515ebf0c6eaa5d990938c87c4baf22ff Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Mon, 1 Apr 2024 01:47:56 +0200 Subject: [PATCH 071/203] actually add test to suite --- upgrade/{test_pprof_upload.sh => test-pprof-upload.sh} | 0 upgrade/upgrade.sh | 2 ++ 2 files changed, 2 insertions(+) rename upgrade/{test_pprof_upload.sh => test-pprof-upload.sh} (100%) diff --git a/upgrade/test_pprof_upload.sh b/upgrade/test-pprof-upload.sh similarity index 100% rename from upgrade/test_pprof_upload.sh rename to upgrade/test-pprof-upload.sh diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 5f69abc..50dc94d 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -50,6 +50,7 @@ function test_successful_upgrades() { } source $UPGRADE_DIR/test-upgrade-forgejo-database-v3.sh +source $UPGRADE_DIR/test-pprof-upload.sh function test_upgrades() { run dependencies @@ -57,4 +58,5 @@ function test_upgrades() { run test_successful_upgrades run test_forgejo_database_v3_upgrades + run test_forgejo_pprof } From c00a5bfc9cf7b3fa72fa573decef88a8e45dc100 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Mon, 1 Apr 2024 18:29:54 +0200 Subject: [PATCH 072/203] download profilecli --- upgrade/test-pprof-upload.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upgrade/test-pprof-upload.sh b/upgrade/test-pprof-upload.sh index 9a82598..62a2f4d 100644 --- a/upgrade/test-pprof-upload.sh +++ b/upgrade/test-pprof-upload.sh @@ -1,10 +1,12 @@ # SPDX-License-Identifier: MIT function test_upload_profiles() { - FORGEJO_URL="http://${IP}:6060" + FORGEJO_URL="http://localhost:6060" PROFILECLI_URL="http://0.0.0.0:4040" endpoints=("/debug/pprof/allocs" "/debug/pprof/block" "/debug/pprof/goroutine" "/debug/pprof/mutex" "/debug/pprof/profile?seconds=5") + curl -fL https://github.com/grafana/pyroscope/releases/download/v1.1.5/profilecli_1.1.5_linux_amd64.tar.gz -o profilecli.tar.gz + tar xzf profilecli.tar.gz for endpoint in "${endpoints[@]}"; do output=$(basename "$endpoint") @@ -27,6 +29,7 @@ function test_forgejo_pprof() { log_info "run 8.0-dev" start 8.0-dev + test_upload_profiles stop From 191976a836fa267558ca353feb287a8fc52f29b6 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 2 Apr 2024 07:40:08 +0200 Subject: [PATCH 073/203] actions: workaround for possible 404 transient bug on artifacts Refs: https://codeberg.org/forgejo/forgejo/issues/2949 --- actions/example-artifacts-v4/.forgejo/workflows/test.yml | 8 ++++++++ actions/example-artifacts/.forgejo/workflows/test.yml | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/actions/example-artifacts-v4/.forgejo/workflows/test.yml b/actions/example-artifacts-v4/.forgejo/workflows/test.yml index d215354..7d97365 100644 --- a/actions/example-artifacts-v4/.forgejo/workflows/test.yml +++ b/actions/example-artifacts-v4/.forgejo/workflows/test.yml @@ -12,6 +12,10 @@ jobs: name: many-artifacts path: artifacts/ + - run: | + # Workaround for https://codeberg.org/forgejo/forgejo/issues/2949 + sleep 10 + download-many: needs: [upload-many] runs-on: docker @@ -34,6 +38,10 @@ jobs: name: my-artifact path: path/to/artifact/world.txt + - run: | + # Workaround for https://codeberg.org/forgejo/forgejo/issues/2949 + sleep 10 + download-one: needs: [upload-one] runs-on: docker diff --git a/actions/example-artifacts/.forgejo/workflows/test.yml b/actions/example-artifacts/.forgejo/workflows/test.yml index 0a8e3b8..9d1403f 100644 --- a/actions/example-artifacts/.forgejo/workflows/test.yml +++ b/actions/example-artifacts/.forgejo/workflows/test.yml @@ -12,6 +12,10 @@ jobs: name: many-artifacts path: artifacts/ + - run: | + # Workaround for https://codeberg.org/forgejo/forgejo/issues/2949 + sleep 10 + download-many: needs: [upload-many] runs-on: docker @@ -34,6 +38,10 @@ jobs: name: my-artifact path: path/to/artifact/world.txt + - run: | + # Workaround for https://codeberg.org/forgejo/forgejo/issues/2949 + sleep 10 + download-one: needs: [upload-one] runs-on: docker From 4a82c559b909f1f831b37fd07392e78fa7f38ea8 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Tue, 2 Apr 2024 20:15:57 +0200 Subject: [PATCH 074/203] run pprof test on test build --- upgrade/test-pprof-upload.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upgrade/test-pprof-upload.sh b/upgrade/test-pprof-upload.sh index 62a2f4d..0fce257 100644 --- a/upgrade/test-pprof-upload.sh +++ b/upgrade/test-pprof-upload.sh @@ -26,9 +26,9 @@ function test_forgejo_pprof() { stop docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope - log_info "run 8.0-dev" + log_info "run 8.0-test" - start 8.0-dev + start 8.0-test test_upload_profiles stop From e3a6e1fd8a51e5c1b58b8391dba9553e2f4a46e1 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 5 Apr 2024 05:24:04 +0200 Subject: [PATCH 075/203] Revert "actions: workaround for possible 404 transient bug on artifacts" Refs: https://code.forgejo.org/forgejo/end-to-end/issues/144 This reverts commit 191976a836fa267558ca353feb287a8fc52f29b6. --- actions/example-artifacts-v4/.forgejo/workflows/test.yml | 8 -------- actions/example-artifacts/.forgejo/workflows/test.yml | 8 -------- 2 files changed, 16 deletions(-) diff --git a/actions/example-artifacts-v4/.forgejo/workflows/test.yml b/actions/example-artifacts-v4/.forgejo/workflows/test.yml index 7d97365..d215354 100644 --- a/actions/example-artifacts-v4/.forgejo/workflows/test.yml +++ b/actions/example-artifacts-v4/.forgejo/workflows/test.yml @@ -12,10 +12,6 @@ jobs: name: many-artifacts path: artifacts/ - - run: | - # Workaround for https://codeberg.org/forgejo/forgejo/issues/2949 - sleep 10 - download-many: needs: [upload-many] runs-on: docker @@ -38,10 +34,6 @@ jobs: name: my-artifact path: path/to/artifact/world.txt - - run: | - # Workaround for https://codeberg.org/forgejo/forgejo/issues/2949 - sleep 10 - download-one: needs: [upload-one] runs-on: docker diff --git a/actions/example-artifacts/.forgejo/workflows/test.yml b/actions/example-artifacts/.forgejo/workflows/test.yml index 9d1403f..0a8e3b8 100644 --- a/actions/example-artifacts/.forgejo/workflows/test.yml +++ b/actions/example-artifacts/.forgejo/workflows/test.yml @@ -12,10 +12,6 @@ jobs: name: many-artifacts path: artifacts/ - - run: | - # Workaround for https://codeberg.org/forgejo/forgejo/issues/2949 - sleep 10 - download-many: needs: [upload-many] runs-on: docker @@ -38,10 +34,6 @@ jobs: name: my-artifact path: path/to/artifact/world.txt - - run: | - # Workaround for https://codeberg.org/forgejo/forgejo/issues/2949 - sleep 10 - download-one: needs: [upload-one] runs-on: docker From 4a6ed59cb6b55718f60084225927c422aaf639bd Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 6 Apr 2024 09:33:34 +0200 Subject: [PATCH 076/203] logs: show logs, not just the .out files --- lib/lib.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/lib.sh b/lib/lib.sh index 86251fc..0eaf5ed 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -296,7 +296,10 @@ function stop() { function show_logs() { ( cd $DIR - grep '' *.out + set +e + grep --text '' *.log + grep --text '' forgejo-work-path/log/*.log + grep --text '' *.out ) } From 174cb37ac9e29bcf365efd279819fad20865e016 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 6 Apr 2024 16:15:12 +0200 Subject: [PATCH 077/203] temporarily skip 8.0-test because 7.0-dev contains a migration that is ahead of 8.0 which should not happen but does today because a PR was backported. The last one. --- lib/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lib.sh b/lib/lib.sh index 0eaf5ed..3cfb9a9 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -34,7 +34,7 @@ export DOT_FORGEJO_CURL=$DIR/forgejo-curl export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 : ${FORGEJO_USER:=root} : ${FORGEJO_PASSWORD:=admin1234} -RELEASE_NUMBERS_AND_DEV="$(for r in $RELEASE_NUMBERS ; do echo -n "$r $r-dev " ; done)" +RELEASE_NUMBERS_AND_DEV="7.0 7.0-dev 8.0-dev" ORGANIZATIONS=$(cat $LIB_DIR/ORGANIZATIONS) function log_info() { From 05341f1ae0768fd6883bd9c5aa2baf1c8187f842 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Apr 2024 07:45:05 +0200 Subject: [PATCH 078/203] Revert "temporarily skip 8.0-test" This reverts commit 174cb37ac9e29bcf365efd279819fad20865e016. --- lib/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lib.sh b/lib/lib.sh index 3cfb9a9..0eaf5ed 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -34,7 +34,7 @@ export DOT_FORGEJO_CURL=$DIR/forgejo-curl export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 : ${FORGEJO_USER:=root} : ${FORGEJO_PASSWORD:=admin1234} -RELEASE_NUMBERS_AND_DEV="7.0 7.0-dev 8.0-dev" +RELEASE_NUMBERS_AND_DEV="$(for r in $RELEASE_NUMBERS ; do echo -n "$r $r-dev " ; done)" ORGANIZATIONS=$(cat $LIB_DIR/ORGANIZATIONS) function log_info() { From 416db9031ba6ac466e3f027a388702ee349efc6b Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sun, 7 Apr 2024 20:25:02 +0000 Subject: [PATCH 079/203] 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 Co-authored-by: TheFox0x7 Co-committed-by: TheFox0x7 --- actions/actions.sh | 15 +++++++++- .../.forgejo/workflows/test.yml | 23 ++++++++++++++ actions/example-post-7-0-schedule/run.sh | 30 +++++++++++++++++++ actions/example-post-7-0-schedule/setup.sh | 1 + 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 actions/example-post-7-0-schedule/.forgejo/workflows/test.yml create mode 100755 actions/example-post-7-0-schedule/run.sh create mode 100755 actions/example-post-7-0-schedule/setup.sh diff --git a/actions/actions.sh b/actions/actions.sh index ee3e128..def5fef 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) @@ -107,9 +108,21 @@ function test_actions() { done 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 done 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 } diff --git a/actions/example-post-7-0-schedule/.forgejo/workflows/test.yml b/actions/example-post-7-0-schedule/.forgejo/workflows/test.yml new file mode 100644 index 0000000..ee7c233 --- /dev/null +++ b/actions/example-post-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/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 \ No newline at end of file diff --git a/actions/example-post-7-0-schedule/run.sh b/actions/example-post-7-0-schedule/run.sh new file mode 100755 index 0000000..e6e1309 --- /dev/null +++ b/actions/example-post-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-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)" \ No newline at end of file diff --git a/actions/example-post-7-0-schedule/setup.sh b/actions/example-post-7-0-schedule/setup.sh new file mode 100755 index 0000000..9e17073 --- /dev/null +++ b/actions/example-post-7-0-schedule/setup.sh @@ -0,0 +1 @@ +mkdir -p /srv/example/post-7-0-schedule-volume \ No newline at end of file From 74294d14f0d00df18e6d501f9e6e7516b7ee5be4 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 6 Apr 2024 15:38:23 +0200 Subject: [PATCH 080/203] logs: always prefix with the file name otherwise it is difficult to figure out where the runner logs end and where the forgejo logs start. --- lib/lib.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/lib.sh b/lib/lib.sh index 0eaf5ed..12a5d90 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -297,9 +297,9 @@ function show_logs() { ( cd $DIR set +e - grep --text '' *.log - grep --text '' forgejo-work-path/log/*.log - grep --text '' *.out + grep --with-filename --text '' *.log + grep --with-filename --text '' forgejo-work-path/log/*.log + grep --with-filename --text '' *.out ) } From 9ca95cd19a350e066dbbbfa1f7f3e1516c42de2b Mon Sep 17 00:00:00 2001 From: thefox Date: Sat, 13 Apr 2024 10:42:40 +0000 Subject: [PATCH 081/203] add 7.0-test to pprof (#148) Test backport of pprof to 7.0 Closes #143 Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/148 Co-authored-by: thefox Co-committed-by: thefox --- upgrade/test-pprof-upload.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/upgrade/test-pprof-upload.sh b/upgrade/test-pprof-upload.sh index 0fce257..80425a9 100644 --- a/upgrade/test-pprof-upload.sh +++ b/upgrade/test-pprof-upload.sh @@ -26,13 +26,17 @@ function test_forgejo_pprof() { stop docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope - log_info "run 8.0-test" - - start 8.0-test - + + log_info "run 7.0-test" + start 7.0-test test_upload_profiles stop + log_info "run 8.0-test" + start 8.0-test + test_upload_profiles + stop + docker stop test_pyroscope } From 3bd723d6b8a7b7c8da9cdb4b9ad980939ee314b4 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 13 Apr 2024 15:50:08 +0200 Subject: [PATCH 082/203] upgrades: gitea 1.21.10 -> forgejo 7.0.0 --- lib/lib.sh | 11 +++++++++-- upgrade/default-app.ini | 3 +++ upgrade/upgrade.sh | 44 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/lib/lib.sh b/lib/lib.sh index 0eaf5ed..1663ba6 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -153,14 +153,21 @@ function start_forgejo() { local version=$1 download $version + start_forgejo_daemon $version $DIR_BINARIES/forgejo-$version +} + +function start_forgejo_daemon() { + local version=$1 + local binary=$2 + local work_path=$DIR/forgejo-work-path - daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $DIR_BINARIES/forgejo-$version --config $work_path/app.ini --work-path $work_path + daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $binary --config $work_path/app.ini --work-path $work_path if ! retry grep --no-messages --quiet 'Starting server on' $work_path/log/forgejo.log ; then grep '' $DIR/*.log grep '' $work_path/log/*.log 2> /dev/null return 1 fi - echo "$DIR_BINARIES/forgejo-$version --config $work_path/app.ini --work-path $work_path" '"$@"' > $DIR/forgejocli + echo "$binary --config $work_path/app.ini --work-path $work_path" '"$@"' > $DIR/forgejocli chmod +x $DIR/forgejocli create_user_and_login $version } diff --git a/upgrade/default-app.ini b/upgrade/default-app.ini index 6eadb37..e8134aa 100644 --- a/upgrade/default-app.ini +++ b/upgrade/default-app.ini @@ -9,6 +9,9 @@ SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true ENABLE_PPROF = true +[repository] +ROOT = ${WORK_PATH}/data/forgejo-repositories + [queue] TYPE = immediate diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 50dc94d..8de9903 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -49,6 +49,49 @@ function test_successful_upgrades() { done } +function download_gitea() { + local version=$1 + + if ! test -f $DIR_BINARIES/gitea-$version ; then + mkdir -p $DIR_BINARIES + wget -O $DIR_BINARIES/gitea-$version --quiet https://dl.gitea.com/gitea/$version/gitea-$version-linux-amd64 + chmod +x $DIR_BINARIES/gitea-$version + fi +} + +function start_gitea() { + local version=$1 + + download_gitea $version + start_forgejo_daemon $version $DIR_BINARIES/gitea-$version +} + +function test_gitea_upgrades() { + stop + for config in default ; do + log_info "using $config app.ini" + upgrade_reset $config + + version=1.21.10 + log_info "run gitea $version" + cleanup_storage + start_s3 minio + start_gitea $version + fixture_create + fixture_assert + doctor_run $version + + for version in 7.0-test ; do + stop + log_info "run forgejo $version" + start $version + verify_storage + fixture_assert + doctor_run $version + done + done +} + source $UPGRADE_DIR/test-upgrade-forgejo-database-v3.sh source $UPGRADE_DIR/test-pprof-upload.sh @@ -59,4 +102,5 @@ function test_upgrades() { run test_successful_upgrades run test_forgejo_database_v3_upgrades run test_forgejo_pprof + run test_gitea_upgrades } From 4bff22bc373d30dee8be2a53d0a2845737a9f973 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 19 Apr 2024 16:36:38 +0200 Subject: [PATCH 083/203] lib: sort releases in version order If sorted in alphabetical order v1.21.11 will be lower than v1.21.8 --- lib/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lib.sh b/lib/lib.sh index 1663ba6..aea34c2 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -105,7 +105,7 @@ function full_version() { local owner=$2 if [[ $version =~ ^[0-9]+\.[0-9]+$ ]] ; then - full_version=$(curl -sS https://codeberg.org/api/v1/repos/$owner/forgejo/releases | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort -r | head -1) + full_version=$(curl -sS https://codeberg.org/api/v1/repos/$owner/forgejo/releases | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort --reverse --version-sort | head -1) echo ${full_version#v} else echo $version From 456dab50024af4a47217776f84e0ea015b489583 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 25 Apr 2024 12:38:58 +0200 Subject: [PATCH 084/203] docs: managing legacy tests and cutting branches --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b409da..39644c6 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,23 @@ A series of tests scenarios and assertions covering [Forgejo](https://codeberg.org/forgejo/forgejo) and the [Forgejo runner](https://code.forgejo.org/forgejo/runner). They partially rely -on [Forgejo actions](https://code.forgejo.org/actions) developped +on [Forgejo actions](https://code.forgejo.org/actions) developed specifically for testing such as [setup-forgejo](https://code.forgejo.org/actions/setup-forgejo). They are designed to run using Forgejo releases and development versions compiled from designated repositories. +# Removing legacy tests + +End to end tests cover the supported range of releases and when one of +them is EOL, it must be removed as well as the tests that target it +specifically. Otherwise the test suite would grow indefinitely. + +When a release is EOL, a branch is cut with a name following the +pattern `legacy/vX.Y-vA.B`. For instance when `v8.0` is published and +`v1.21` is EOL, the branch `legacy/v8.0-v1.21` is cut. + # Hacking docker and sudo must be installed with insecure registries allowed in @@ -46,7 +56,7 @@ make TAGS='bindata sqlite sqlite_unlock_notify' generate forgejo cp -a forgejo /srv/forgejo-binaries/forgejo-7.0-dev ``` -It will be used whenver the version `7.0-dev` is specified in a test. +It will be used whenever the version `7.0-dev` is specified in a test. ## Running actions locally From e80f12ace917124cc5a3d69d7d1ae31ca7aaf8a1 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 25 Apr 2024 12:39:48 +0200 Subject: [PATCH 085/203] chore(cleanup): v1.20 is EOL, trim it --- actions/actions.sh | 12 +- storage/legagy-relative-app.ini | 33 --- storage/merged-app.ini | 33 --- storage/misplace-app.ini | 60 ------ storage/misplace-s3-app.ini | 90 -------- storage/misplace-s3-two-app.ini | 114 ---------- storage/relative-app.ini | 45 ---- storage/storage-relative-app.ini | 45 ---- storage/storage.sh | 7 +- storage/test-upgrade-1.20-storage.sh | 223 -------------------- upgrade/test-upgrade-forgejo-database-v3.sh | 35 --- upgrade/upgrade.sh | 6 +- 12 files changed, 6 insertions(+), 697 deletions(-) delete mode 100644 storage/legagy-relative-app.ini delete mode 100644 storage/merged-app.ini delete mode 100644 storage/misplace-app.ini delete mode 100644 storage/misplace-s3-app.ini delete mode 100644 storage/misplace-s3-two-app.ini delete mode 100644 storage/relative-app.ini delete mode 100644 storage/storage-relative-app.ini delete mode 100644 storage/test-upgrade-1.20-storage.sh delete mode 100644 upgrade/test-upgrade-forgejo-database-v3.sh diff --git a/actions/actions.sh b/actions/actions.sh index def5fef..32b110b 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -88,7 +88,7 @@ function actions_runner_version() { } function test_actions() { - local versions="${1:-1.20 1.21 $RELEASE_NUMBERS_AND_DEV}" + local versions="${1:-1.21 $RELEASE_NUMBERS_AND_DEV}" for version in $versions ; do @@ -103,17 +103,11 @@ function test_actions() { done fi - for example in echo checkout service container expression local-action docker-action if if-fail ; do + for example in echo checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context ; do run actions_verify_example $example done - if dpkg --compare-versions $version gt 1.20 ; then - for example in push tag push-cancel artifacts pull-request context ; do - run actions_verify_example $example - done - fi - - if dpkg --compare-versions $version gt 1.20 && dpkg --compare-versions $version lt 7.1 ; then + if dpkg --compare-versions $version lt 7.1 ; then for example in cron ; do run actions_verify_example $example done diff --git a/storage/legagy-relative-app.ini b/storage/legagy-relative-app.ini deleted file mode 100644 index f5ea40f..0000000 --- a/storage/legagy-relative-app.ini +++ /dev/null @@ -1,33 +0,0 @@ -RUN_MODE = prod -WORK_PATH = ${WORK_PATH} - -[server] -APP_DATA_PATH = ${WORK_PATH}/data -DOMAIN = ${IP} -HTTP_PORT = 3000 -SSH_LISTEN_PORT = 2222 -LFS_START_SERVER = true -LFS_CONTENT_PATH = relative-lfs - -[database] -DB_TYPE = sqlite3 -PATH = ${WORK_PATH}/forgejo.db - -[log] -MODE = file -LEVEL = debug -ROUTER = file - -[log.file] -FILE_NAME = forgejo.log - -[security] -INSTALL_LOCK = true - -[repository] -ENABLE_PUSH_CREATE_USER = true -DEFAULT_PUSH_CREATE_PRIVATE = false - -[picture] -AVATAR_UPLOAD_PATH = relative-avatars -REPOSITORY_AVATAR_UPLOAD_PATH = relative-repo-avatars diff --git a/storage/merged-app.ini b/storage/merged-app.ini deleted file mode 100644 index 0a30227..0000000 --- a/storage/merged-app.ini +++ /dev/null @@ -1,33 +0,0 @@ -RUN_MODE = prod -WORK_PATH = ${WORK_PATH} - -[server] -APP_DATA_PATH = ${WORK_PATH}/data -DOMAIN = ${IP} -HTTP_PORT = 3000 -SSH_LISTEN_PORT = 2222 -LFS_START_SERVER = true - -[database] -DB_TYPE = sqlite3 - -[log] -MODE = file -LEVEL = debug -ROUTER = file - -[log.file] -FILE_NAME = forgejo.log - -[security] -INSTALL_LOCK = true - -[repository] -ENABLE_PUSH_CREATE_USER = true -DEFAULT_PUSH_CREATE_PRIVATE = false - -[actions] -ENABLED = true - -[storage] -PATH = ${WORK_PATH}/merged diff --git a/storage/misplace-app.ini b/storage/misplace-app.ini deleted file mode 100644 index 9ffe725..0000000 --- a/storage/misplace-app.ini +++ /dev/null @@ -1,60 +0,0 @@ -RUN_MODE = prod -WORK_PATH = ${WORK_PATH} - -[server] -APP_DATA_PATH = ${WORK_PATH}/elsewhere -DOMAIN = ${IP} -HTTP_PORT = 3000 -SSH_LISTEN_PORT = 2222 -LFS_START_SERVER = true - -[database] -DB_TYPE = sqlite3 - -[log] -MODE = file -LEVEL = debug -ROUTER = file - -[log.file] -FILE_NAME = forgejo.log - -[security] -INSTALL_LOCK = true - -[repository] -ENABLE_PUSH_CREATE_USER = true -DEFAULT_PUSH_CREATE_PRIVATE = false - -[actions] -ENABLED = true - -[attachment] - -[storage.attachments] -PATH = ${WORK_PATH}/data/attachments - -[lfs] - -[storage.lfs] -PATH = ${WORK_PATH}/data/lfs - -[avatar] - -[storage.avatars] -PATH = ${WORK_PATH}/data/avatars - -[repo-avatar] - -[storage.repo-avatars] -PATH = ${WORK_PATH}/data/repo-avatars - -[repo-archive] - -[storage.repo-archive] -PATH = ${WORK_PATH}/data/repo-archive - -[packages] - -[storage.packages] -PATH = ${WORK_PATH}/data/packages diff --git a/storage/misplace-s3-app.ini b/storage/misplace-s3-app.ini deleted file mode 100644 index 490abbe..0000000 --- a/storage/misplace-s3-app.ini +++ /dev/null @@ -1,90 +0,0 @@ -RUN_MODE = prod -WORK_PATH = ${WORK_PATH} - -[server] -APP_DATA_PATH = ${WORK_PATH}/elsewhere -DOMAIN = ${IP} -HTTP_PORT = 3000 -SSH_LISTEN_PORT = 2222 -LFS_START_SERVER = true - -[database] -DB_TYPE = sqlite3 - -[log] -MODE = file -LEVEL = debug -ROUTER = file - -[log.file] -FILE_NAME = forgejo.log - -[security] -INSTALL_LOCK = true - -[repository] -ENABLE_PUSH_CREATE_USER = true -DEFAULT_PUSH_CREATE_PRIVATE = false - -[actions] -ENABLED = true - -[attachment] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[lfs] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[repo-avatar] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[avatar] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[repo-archive] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[packages] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false diff --git a/storage/misplace-s3-two-app.ini b/storage/misplace-s3-two-app.ini deleted file mode 100644 index bcf65c8..0000000 --- a/storage/misplace-s3-two-app.ini +++ /dev/null @@ -1,114 +0,0 @@ -RUN_MODE = prod -WORK_PATH = ${WORK_PATH} - -[server] -APP_DATA_PATH = ${WORK_PATH}/elsewhere -DOMAIN = ${IP} -HTTP_PORT = 3000 -SSH_LISTEN_PORT = 2222 -LFS_START_SERVER = true - -[database] -DB_TYPE = sqlite3 - -[log] -MODE = file -LEVEL = debug -ROUTER = file - -[log.file] -FILE_NAME = forgejo.log - -[security] -INSTALL_LOCK = true - -[repository] -ENABLE_PUSH_CREATE_USER = true -DEFAULT_PUSH_CREATE_PRIVATE = false - -[actions] -ENABLED = true - -[storage.attachments] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[storage.lfs] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[picture] -AVATAR_STORAGE_TYPE = minio -REPOSITORY_AVATAR_STORAGE_TYPE = minio - -[storage.repo-avatars] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[storage.minio] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[storage] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[storage.avatars] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[storage.repo-archive] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false - -[storage.packages] -STORAGE_TYPE = minio -SERVE_DIRECT = false -MINIO_ENDPOINT = 127.0.0.1:9000 -MINIO_ACCESS_KEY_ID = 123456 -MINIO_SECRET_ACCESS_KEY = 12345678 -MINIO_BUCKET = forgejo -MINIO_LOCATION = us-east-1 -MINIO_USE_SSL = false diff --git a/storage/relative-app.ini b/storage/relative-app.ini deleted file mode 100644 index 5bce502..0000000 --- a/storage/relative-app.ini +++ /dev/null @@ -1,45 +0,0 @@ -RUN_MODE = prod -WORK_PATH = ${WORK_PATH} - -[server] -APP_DATA_PATH = ${WORK_PATH}/data -DOMAIN = ${IP} -HTTP_PORT = 3000 -SSH_LISTEN_PORT = 2222 -LFS_START_SERVER = true - -[database] -DB_TYPE = sqlite3 - -[log] -MODE = file -LEVEL = debug -ROUTER = file - -[log.file] -FILE_NAME = forgejo.log - -[security] -INSTALL_LOCK = true - -[repository] -ENABLE_PUSH_CREATE_USER = true -DEFAULT_PUSH_CREATE_PRIVATE = false - -[attachment] -PATH = relative-attachments - -[lfs] -PATH = relative-lfs - -[avatar] -PATH = relative-avatars - -[repo-avatar] -PATH = relative-repo-avatars - -[repo-archive] -PATH = relative-repo-archive - -[packages] -PATH = relative-packages diff --git a/storage/storage-relative-app.ini b/storage/storage-relative-app.ini deleted file mode 100644 index d0b7023..0000000 --- a/storage/storage-relative-app.ini +++ /dev/null @@ -1,45 +0,0 @@ -RUN_MODE = prod -WORK_PATH = ${WORK_PATH} - -[server] -APP_DATA_PATH = ${WORK_PATH}/data -DOMAIN = ${IP} -HTTP_PORT = 3000 -SSH_LISTEN_PORT = 2222 -LFS_START_SERVER = true - -[database] -DB_TYPE = sqlite3 - -[log] -MODE = file -LEVEL = debug -ROUTER = file - -[log.file] -FILE_NAME = forgejo.log - -[security] -INSTALL_LOCK = true - -[repository] -ENABLE_PUSH_CREATE_USER = true -DEFAULT_PUSH_CREATE_PRIVATE = false - -[storage.attachments] -PATH = relative-attachments - -[storage.lfs] -PATH = relative-lfs - -[storage.avatars] -PATH = relative-avatars - -[storage.repo-avatars] -PATH = relative-repo-avatars - -[storage.repo-archive] -PATH = relative-repo-archive - -[storage.packages] -PATH = relative-packages diff --git a/storage/storage.sh b/storage/storage.sh index b08e6bc..a531e50 100755 --- a/storage/storage.sh +++ b/storage/storage.sh @@ -33,7 +33,7 @@ function test_storage_stable_s3() { log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338" - for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do + for version in 1.21 $RELEASE_NUMBERS_AND_DEV ; do log_info "Forgejo $version & $s3_backend" stop storage_reset stable-s3 @@ -45,12 +45,7 @@ function test_storage_stable_s3() { done } -source $STORAGE_DIR/test-upgrade-1.20-storage.sh - function test_storage() { run test_storage_stable_s3 minio run test_storage_stable_s3 garage - - test_upgrade_1_20_storage - run test_forgejo_database_v3_upgrades } diff --git a/storage/test-upgrade-1.20-storage.sh b/storage/test-upgrade-1.20-storage.sh deleted file mode 100644 index 063b56a..0000000 --- a/storage/test-upgrade-1.20-storage.sh +++ /dev/null @@ -1,223 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: MIT - -function test_downgrade_1.20.2_fails() { - local work_path=$DIR/forgejo-work-path - - log_info "See also https://codeberg.org/forgejo/forgejo/pulls/1225" - - log_info "downgrading from 1.20.3-0 to 1.20.2-0 fails" - stop - storage_reset default - start 1.20.3-0 - stop - download 1.20.2-0 - timeout 60 $DIR_BINARIES/forgejo-1.20.2-0 --config $work_path/app.ini --work-path $work_path || true - if ! grep --fixed-strings --quiet 'use the newer database' $work_path/log/forgejo.log ; then - cat $work_path/log/forgejo.log - return 1 - fi -} - -function test_bug_storage_merged() { - local work_path=$DIR/forgejo-work-path - - log_info "See also https://codeberg.org/forgejo/forgejo/pulls/1225" - - log_info "using < 1.20.3-0 and [storage].PATH merge all storage" - for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do - stop - storage_reset merged - start $version - for path in ${STORAGE_PATHS} ; do - ! test -d $work_path/data/$path - done - for path in ${STORAGE_PATHS} ; do - ! test -d $work_path/merged/$path - done - test -d $work_path/merged - done - stop - - log_info "upgrading from 1.20.2-0 with [storage].PATH fails" - download 1.20.3-0 - timeout 60 $DIR_BINARIES/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true - if ! grep --fixed-strings --quiet '[storage].PATH is set and may create storage issues' $work_path/log/forgejo.log ; then - cat $work_path/log/forgejo.log - return 1 - fi -} - -function test_bug_storage_relative_path() { - local work_path=$DIR/forgejo-work-path - - log_info "using < 1.20.3-0 legacy [server].XXXX and [picture].XXXX are relative to WORK_PATH" - for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do - stop - storage_reset legagy-relative - start $version - test -d $work_path/relative-lfs - test -d $work_path/relative-avatars - test -d $work_path/relative-repo-avatars - done - - log_info "using >= 1.20.3-0 legacy [server].XXXX and [picture].XXXX are relative to APP_DATA_PATH" - for version in 1.20.3-0 1.21.0-5-rc2 ; do - stop - storage_reset legagy-relative - start $version - test -d $work_path/data/relative-lfs - test -d $work_path/data/relative-avatars - test -d $work_path/data/relative-repo-avatars - done - - log_info "using >= 1.20.3-0 relative [storage.XXXX].PATHS are relative to APP_DATA_PATH" - for version in 1.20.3-0 1.21.0-5-rc2 ; do - stop - storage_reset storage-relative - start $version - for path in ${STORAGE_PATHS} ; do - test -d $work_path/data/relative-$path - done - done - - log_info "using 1.20.[12]-0 relative [storage.XXXX].PATHS are inconsistent" - for version in 1.20.2-0 ; do - stop - storage_reset storage-relative - start $version - test -d $work_path/data/packages - test -d $work_path/relative-repo-archive - test -d $work_path/relative-attachments - test -d $work_path/relative-lfs - test -d $work_path/data/avatars - test -d $work_path/data/repo-avatars - done - - log_info "using < 1.20 relative [storage.XXXX].PATHS are inconsistent" - for version in 1.18.5-0 1.19.4-0 ; do - stop - storage_reset storage-relative - start $version - test -d $work_path/relative-packages - test -d $work_path/relative-repo-archive - test -d $work_path/relative-attachments - test -d $work_path/data/lfs - test -d $work_path/data/avatars - test -d $work_path/data/repo-avatars - done - - log_info "using < 1.20.3-0 relative [XXXX].PATHS are relative to WORK_PATH" - for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do - stop - storage_reset relative - start $version - for path in ${STORAGE_PATHS} ; do - test -d $work_path/relative-$path - done - done - - log_info "using >= 1.20.3-0 relative [XXXX].PATHS are relative to APP_DATA_PATH" - for version in 1.20.3-0 1.21.0-5-rc2 ; do - stop - storage_reset relative - start $version - for path in ${STORAGE_PATHS} ; do - test -d $work_path/data/relative-$path - done - done - - stop -} - -function test_bug_storage_s3_misplace() { - local work_path=$DIR/forgejo-work-path - local s3_backend=${2:-minio} - - log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338" - - for version in 1.20.2-0 1.20.3-0 ; do - log_info "Forgejo $version & $s3_backend" - stop - storage_reset misplace-s3 - start $version $s3_backend - fixture_create - for fun in ${STORAGE_FUN} ; do - fixture_${fun}_assert_s3 - done - done - - for version in 1.18.5-0 1.19.4-0 ; do - log_info "Forgejo $version & $s3_backend" - stop - storage_reset misplace-s3 - start $version $s3_backend - fixture_create - # - # some storage are in S3 - # - fixture_attachments_assert_s3 - fixture_lfs_assert_s3 - # - # others are in local - # - fixture_repo_archive_assert_local elsewhere/repo-archive - fixture_avatars_assert_local elsewhere/avatars - fixture_packages_assert_local elsewhere/packages - fixture_repo_avatars_assert_local elsewhere/repo-avatars - done -} - -function test_bug_storage_misplace() { - local work_path=$DIR/forgejo-work-path - - log_info "See also https://codeberg.org/forgejo/forgejo/pulls/1225" - - log_info "using < 1.20 and conflicting sections misplace storage" - for version in 1.18.5-0 1.19.4-0 ; do - stop - storage_reset misplace - start $version - # - # some storage are where they should be - # - test -d $work_path/data/packages - test -d $work_path/data/repo-archive - test -d $work_path/data/attachments - # - # others are under APP_DATA_PATH - # - test -d $work_path/elsewhere/lfs - test -d $work_path/elsewhere/avatars - test -d $work_path/elsewhere/repo-avatars - done - - log_info "using < 1.20.[12]-0 and conflicting sections ignores [storage.*]" - for version in 1.20.2-0 ; do - stop - storage_reset misplace - start $version - for path in ${STORAGE_PATHS} ; do - test -d $work_path/elsewhere/$path - done - done - - stop - - log_info "upgrading from 1.20.2-0 with conflicting sections fails" - download 1.20.3-0 - timeout 60 $DIR_BINARIES/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true - for path in ${STORAGE_PATHS} ; do - if ! grep --fixed-strings --quiet "[storage.$path] may conflict" $work_path/log/forgejo.log ; then - cat $work_path/log/forgejo.log - return 1 - fi - done -} - -function test_upgrade_1_20_storage() { - run test_bug_storage_misplace - run test_bug_storage_merged - run test_downgrade_1.20.2_fails - run test_bug_storage_s3_misplace -} diff --git a/upgrade/test-upgrade-forgejo-database-v3.sh b/upgrade/test-upgrade-forgejo-database-v3.sh deleted file mode 100644 index f15a4f3..0000000 --- a/upgrade/test-upgrade-forgejo-database-v3.sh +++ /dev/null @@ -1,35 +0,0 @@ -# SPDX-License-Identifier: MIT - -function test_forgejo_database_version() { - local expected_version=$1 - local work_path=$DIR/forgejo-work-path - - actual_version=$(sqlite3 $work_path/forgejo.db "select version from forgejo_version") - test "$expected_version" = "$actual_version" -} - -function test_forgejo_database_v3_upgrades_list_table() { - local table=$1 - local work_path=$DIR/forgejo-work-path - - sqlite3 $work_path/forgejo.db ".tables $table" .exit | grep --quiet $table -} - -function test_forgejo_database_v3_upgrades() { - local table=forgejo_auth_token - - stop - - upgrade_reset default - log_info "run 1.20.4-1" - start 1.20.4-1 - stop - ! test_forgejo_database_v3_upgrades_list_table $table - test_forgejo_database_version 2 - - log_info "run 1.20.5-0" - start 1.20.5-0 - stop - test_forgejo_database_v3_upgrades_list_table $table - test_forgejo_database_version 3 -} diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 8de9903..3b89393 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -30,7 +30,7 @@ function test_successful_upgrades() { log_info "using $config app.ini" upgrade_reset $config - version=1.18 + version=1.21 log_info "run $version" cleanup_storage start $version @@ -38,7 +38,7 @@ function test_successful_upgrades() { fixture_assert doctor_run $version - for version in 1.19 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do + for version in $RELEASE_NUMBERS_AND_DEV ; do stop log_info "run $version" start $version @@ -92,7 +92,6 @@ function test_gitea_upgrades() { done } -source $UPGRADE_DIR/test-upgrade-forgejo-database-v3.sh source $UPGRADE_DIR/test-pprof-upload.sh function test_upgrades() { @@ -100,7 +99,6 @@ function test_upgrades() { run build_all run test_successful_upgrades - run test_forgejo_database_v3_upgrades run test_forgejo_pprof run test_gitea_upgrades } From c5a35b1ad5c7c5f8808b6bd55c15b2fe69863847 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 25 Apr 2024 13:54:12 +0200 Subject: [PATCH 086/203] fix(pprof): reset_forgejo before running it it was working before because the previous tests did it. Now that it is gone, it no longer worked because there was no app.ini. --- upgrade/test-pprof-upload.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/upgrade/test-pprof-upload.sh b/upgrade/test-pprof-upload.sh index 80425a9..e5ab46d 100644 --- a/upgrade/test-pprof-upload.sh +++ b/upgrade/test-pprof-upload.sh @@ -24,9 +24,10 @@ function test_upload_profiles() { function test_forgejo_pprof() { stop + docker rm -f test_pyroscope docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope - + reset_forgejo $UPGRADE_DIR/default-app.ini log_info "run 7.0-test" start 7.0-test test_upload_profiles From d9fc5cee11a40dbda3e8c0ac088bb6efcba1d16e Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 3 May 2024 07:22:55 +0100 Subject: [PATCH 087/203] fix(lib): explicitly set the page limit for releases otherwise it is subject to limitations imposed by the server and as the number of releases grow, the older ones will no longer be found. --- lib/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lib.sh b/lib/lib.sh index aea34c2..79e929d 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -105,7 +105,7 @@ function full_version() { local owner=$2 if [[ $version =~ ^[0-9]+\.[0-9]+$ ]] ; then - full_version=$(curl -sS https://codeberg.org/api/v1/repos/$owner/forgejo/releases | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort --reverse --version-sort | head -1) + full_version=$(curl -sS "https://codeberg.org/api/v1/repos/$owner/forgejo/releases?limit=50" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort --reverse --version-sort | head -1) echo ${full_version#v} else echo $version From 9f55d67bd2c2092cdefde94d079f719e66e67a56 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 13 May 2024 19:18:33 +0200 Subject: [PATCH 088/203] actions: push-cancel intermitent failure A) When both push happen within the same second, the SHA will be identical and there will not be any cancelation. B) When `sleep infinity` happens after the reload of the runner, it will block the following tests forever because it has a capacity of one. Fixes: https://code.forgejo.org/forgejo/end-to-end/issues/144 2024-05-13T00:58:49.1453499Z actions_verify_example.out:[main (root-commit) cbf3afb] initial commit 2024-05-13T00:58:49.1453528Z actions_verify_example.out: 3 files changed, 28 insertions(+) 2024-05-13T00:58:49.1453556Z actions_verify_example.out: create mode 100644 .forgejo/workflows/test.yml 2024-05-13T00:58:49.1453585Z actions_verify_example.out: create mode 100755 run.sh 2024-05-13T00:58:49.1453611Z actions_verify_example.out: create mode 100644 teardown.sh 2024-05-13T00:58:49.1453638Z actions_verify_example.out:+ git remote add origin http://root:admin1234@10.201.14.172:3000/root/example-push-cancel 2024-05-13T00:58:49.1453669Z actions_verify_example.out:+ git push --force -u origin main 2024-05-13T00:58:49.1453699Z actions_verify_example.out:remote: . Processing 1 references 2024-05-13T00:58:49.1453728Z actions_verify_example.out:remote: Processed 1 references in total 2024-05-13T00:58:49.1453758Z actions_verify_example.out:To http://10.201.14.172:3000/root/example-push-cancel 2024-05-13T00:58:49.1453786Z actions_verify_example.out: * [new branch] main -> main 2024-05-13T00:58:49.1453814Z actions_verify_example.out:branch 'main' set up to track 'origin/main'. ... 2024-05-13T00:58:49.1458629Z actions_verify_example.out:[main (root-commit) cbf3afb] initial commit 2024-05-13T00:58:49.1458656Z actions_verify_example.out: 3 files changed, 28 insertions(+) 2024-05-13T00:58:49.1458683Z actions_verify_example.out: create mode 100644 .forgejo/workflows/test.yml 2024-05-13T00:58:49.1458711Z actions_verify_example.out: create mode 100755 run.sh 2024-05-13T00:58:49.1458738Z actions_verify_example.out: create mode 100644 teardown.sh 2024-05-13T00:58:49.1458764Z actions_verify_example.out:+ git remote add origin http://root:admin1234@10.201.14.172:3000/root/example-push-cancel 2024-05-13T00:58:49.1458795Z actions_verify_example.out:+ git push --force -u origin main 2024-05-13T00:58:49.1458822Z actions_verify_example.out:Everything up-to-date --- actions/example-push-cancel/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/example-push-cancel/run.sh b/actions/example-push-cancel/run.sh index dbdebb4..d6705d8 100755 --- a/actions/example-push-cancel/run.sh +++ b/actions/example-push-cancel/run.sh @@ -11,7 +11,7 @@ forgejo-test-helper.sh wait_running $url $repo $sha # # push to the same branch # -forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token +forgejo-test-helper.sh push_workflow actions/example-echo $url root example-$example setup-forgejo $token # # wait for the workflow to be canceled as a result of the previous push # From 872e4632bf433cfa29367760a7cac25d522807d4 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 19 May 2024 09:15:40 +0200 Subject: [PATCH 089/203] lib: retry git fetch a few times The instance hosting the forgejo repository may be down or very slow while the build tries to fetch from it, retry a few times instead of giving up immediately. A total retry time of 3 * 60 seconds is probably sufficient since Forgejo startup time is lower than this, even on large instances. --- lib/build.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/build.sh b/lib/build.sh index 9ad74ec..5ccc536 100755 --- a/lib/build.sh +++ b/lib/build.sh @@ -25,6 +25,11 @@ fi if ! [[ "$ref" =~ ^refs/ ]] ; then ref=refs/heads/$ref fi +for retry in 1 2 3 ; do + timeout 15m git fetch --update-head-ok origin +$ref:$ref && break + echo "Retry git fetch in 60 seconds" + sleep 60 +done git fetch --update-head-ok origin +$ref:$ref git switch --force-create $v $ref From f6da41ec8e71790555080f714e773297b27653e9 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 20 May 2024 01:54:22 +0200 Subject: [PATCH 090/203] lib: retry git fetch a few times (take 2) Wrap the failure in a if statement. Otherwise it will fail the first time because the script runs under -e --- lib/build.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/build.sh b/lib/build.sh index 5ccc536..11bdf3a 100755 --- a/lib/build.sh +++ b/lib/build.sh @@ -26,9 +26,12 @@ if ! [[ "$ref" =~ ^refs/ ]] ; then ref=refs/heads/$ref fi for retry in 1 2 3 ; do - timeout 15m git fetch --update-head-ok origin +$ref:$ref && break - echo "Retry git fetch in 60 seconds" - sleep 60 + if timeout 15m git fetch --update-head-ok origin +$ref:$ref ; then + break + else + echo "Retry git fetch in 60 seconds" + sleep 60 + fi done git fetch --update-head-ok origin +$ref:$ref git switch --force-create $v $ref From 57fdd1cd496dada21e8445c949c89c0057a49be9 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 21 May 2024 08:13:15 +0200 Subject: [PATCH 091/203] actions: cron: create /srv/example/cron/contexts first A loop is waiting for /srv/example/cron-volume/DONE to exist before declaring the workflow is successfully run. But it is not really until /srv/example/cron/contexts is created with the event content and they will race. Fixes: https://code.forgejo.org/forgejo/end-to-end/issues/181 --- actions/example-cron/.forgejo/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actions/example-cron/.forgejo/workflows/test.yml b/actions/example-cron/.forgejo/workflows/test.yml index 2eedd14..e2748f8 100644 --- a/actions/example-cron/.forgejo/workflows/test.yml +++ b/actions/example-cron/.forgejo/workflows/test.yml @@ -10,9 +10,6 @@ jobs: options: "--volume /srv/example:/srv/example" steps: - - run: | - touch /srv/example/cron-volume/DONE - - name: save context run: | d=/srv/example/cron/contexts/$GITHUB_EVENT_NAME @@ -20,3 +17,6 @@ jobs: cat > $d/github <<'EOF' ${{ toJSON(github) }} EOF + + - run: | + touch /srv/example/cron-volume/DONE From abe9f5f52d02629eff7d94f4735f1a2ef8b9d970 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 22 May 2024 11:07:45 +0200 Subject: [PATCH 092/203] docs(README): remove unhelpful sentence about actions --- README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 39644c6..004288a 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,14 @@ A series of tests scenarios and assertions covering [Forgejo](https://codeberg.org/forgejo/forgejo) and the [Forgejo -runner](https://code.forgejo.org/forgejo/runner). They partially rely -on [Forgejo actions](https://code.forgejo.org/actions) developed -specifically for testing such as -[setup-forgejo](https://code.forgejo.org/actions/setup-forgejo). +runner](https://code.forgejo.org/forgejo/runner). They are designed to run using Forgejo releases and development versions compiled from designated repositories. # Removing legacy tests -End to end tests cover the supported range of releases and when one of +End-to-end tests cover the supported range of releases and when one of them is EOL, it must be removed as well as the tests that target it specifically. Otherwise the test suite would grow indefinitely. From f9e20e777076145c24fe4f52add2f19b10319663 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 27 May 2024 16:57:05 +0200 Subject: [PATCH 093/203] actions: add automerge example --- .editorconfig | 9 +- actions/actions.sh | 2 +- .../.forgejo/workflows/test.yml | 13 +++ actions/example-automerge/run.sh | 69 +++++++++++ actions/example-automerge/setup.sh | 1 + lib/api.sh | 108 ++++++++++++++++++ lib/lib.sh | 2 + 7 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 actions/example-automerge/.forgejo/workflows/test.yml create mode 100755 actions/example-automerge/run.sh create mode 100755 actions/example-automerge/setup.sh create mode 100644 lib/api.sh diff --git a/.editorconfig b/.editorconfig index c17e595..669640d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,10 @@ root = true + [*] -tab_width: 8 +indent_style = space +indent_size = 4 +tab_width = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/actions/actions.sh b/actions/actions.sh index 32b110b..dd38510 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -114,7 +114,7 @@ function test_actions() { fi if dpkg --compare-versions $version ge 7.1 ; then - for example in post-7-0-schedule ; do + for example in automerge post-7-0-schedule ; do run actions_verify_example $example done fi diff --git a/actions/example-automerge/.forgejo/workflows/test.yml b/actions/example-automerge/.forgejo/workflows/test.yml new file mode 100644 index 0000000..3ce5da0 --- /dev/null +++ b/actions/example-automerge/.forgejo/workflows/test.yml @@ -0,0 +1,13 @@ +on: + pull_request: + +jobs: + test: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + options: "--volume /srv/example:/srv/example" + + steps: + - run: | + ${{ vars.SCRIPT }} diff --git a/actions/example-automerge/run.sh b/actions/example-automerge/run.sh new file mode 100755 index 0000000..e7f5395 --- /dev/null +++ b/actions/example-automerge/run.sh @@ -0,0 +1,69 @@ +TMPDIR=$(mktemp -d) + +trap "rm -fr $TMPDIR" EXIT + +source $EXAMPLE_DIR/../../lib/lib.sh + +api=$url/api/v1 +export d=/srv/example/automerge + +PROOF='some proof' + +function main() { + # + # repository with a pull_request event workflow that always succeeds + # + mkdir -p $d + + forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token + + local repo=root/example-automerge + + forgejo-curl.sh api_json -X DELETE $api/repos/$repo/actions/variables/SCRIPT >&/dev/null || true + forgejo-curl.sh api_json -X POST --data-raw '{"value":"true"}' $api/repos/$repo/actions/variables/SCRIPT + + ( + cd $d + git clone $url/$repo + cd example-automerge + git checkout -b other + git config user.email root@example.com + git config user.name username + touch file-unique-to-the-pr-branch + echo other $PROOF >>README + git add . + git commit -m 'other change' + git push --force -u origin other + ) + + # + # make sure the runner won't race with the sequence that follows + # + forgejo-runner.sh teardown + # + # create a PR and schedule it for automerge when the workflow succeeds + # + api_pr_delete_all $api $repo + forgejo-curl.sh api_json --data-raw '{"title":"PR title","base":"main","head":"other"}' $api/repos/$repo/pulls >$TMPDIR/pr.json + local pr=$(jq -r .number <$TMPDIR/pr.json) + forgejo-curl.sh api_json --data-raw '{"Do":"merge","merge_when_checks_succeed":true}' $api/repos/$repo/pulls/$pr/merge + if api_pr_is_merged $api $repo $pr; then + echo pull request already merged although it should not be + return 1 + fi + # + # run the workflow + # + forgejo-runner.sh run + local sha=$(api_branch_tip $api $repo other) + api_pr_wait_success $api $repo $sha + # + # verify the PR was automerged + # + if ! retry api_pr_is_merged $api $repo $pr; then + echo pull request is not automerged as expected + return 1 + fi +} + +main diff --git a/actions/example-automerge/setup.sh b/actions/example-automerge/setup.sh new file mode 100755 index 0000000..9476a67 --- /dev/null +++ b/actions/example-automerge/setup.sh @@ -0,0 +1 @@ +mkdir -p /srv/example/automerge diff --git a/lib/api.sh b/lib/api.sh new file mode 100644 index 0000000..b58984a --- /dev/null +++ b/lib/api.sh @@ -0,0 +1,108 @@ +#!/bin/bash +# Copyright 2024 The Forgejo Authors +# SPDX-License-Identifier: MIT + +API_TMPDIR=$(mktemp -d) + +function api_branch_tip() { + local api="$1" + local repo="$2" + local branch="$3" + + retry forgejo-curl.sh api_json $api/repos/$repo/branches/$branch >&/dev/null + forgejo-curl.sh api_json $api/repos/$repo/branches/$branch | jq --raw-output .commit.id +} + +function api_pr_is_merged() { + local api="$1" + local repo="$2" + local pr="$3" + + forgejo-curl.sh api_json $api/repos/$repo/pulls/$pr >$API_TMPDIR/pr.json + $(jq -r .merged <$API_TMPDIR/pr.json) +} + +function api_pr_delete_all() { + local api="$1" + local repo="$2" + + forgejo-curl.sh api_json $api/repos/${repo}/pulls | jq --raw-output '.[] | .number' | while read pr; do + forgejo-curl.sh api_json -X DELETE $api/repos/${repo}/issues/$pr + done +} + +function api_pr_get_status() { + local api="$1" + local repo="$2" + local sha="$3" + + forgejo-curl.sh api_json $api/repos/$repo/commits/$sha/status +} + +function api_pr_check_status() { + local api="$1" + local repo="$2" + local sha="$3" + local expected_status="$4" + local expected_description="$5" + + api_pr_get_status $api $repo $sha >$API_TMPDIR/status.json + local status="$(jq --raw-output .state <$API_TMPDIR/status.json)" + local description="$(jq --raw-output .statuses[0].description <$API_TMPDIR/status.json)" + if test "$status" = "$expected_status" && test -z "$expected_description" -o "$description" = "$expected_description"; then + echo OK + elif test "$status" = "failure" -o "$status" = "success"; then + echo NOK + else + echo RETRY + fi +} + +function api_pr_wait_success() { + api_pr_wait_status success "$@" +} + +function api_pr_wait_failure() { + api_pr_wait_status failure "$@" +} + +function api_pr_wait_running() { + api_pr_wait_status pending "$@" "Has started running" +} + +function api_pr_wait_log() { + local sha="$1" expected_status="$2" expected_description="$3" + local status="$(jq --raw-output .state <$API_TMPDIR/status.json)" + local description="$(jq --raw-output .statuses[0].description <$API_TMPDIR/status.json)" + if test "$expected_description"; then + expected_description=" '$expected_description'" + fi + log_info "$sha status waiting '$expected_status'$expected_description, currently '$status' '$description'" +} + +# default loop delay is 3600 sec (1 hour) +: ${API_LOOPS:=100} +: ${API_LOOP_DELAY:=36} + +function api_pr_wait_status() { + local status="$1" + local api="$2" + local repo="$3" + local sha="$4" + local description="$5" + + for i in $(seq $API_LOOPS); do + if test $(api_pr_check_status "$api" "$repo" "$sha" "$status" "$description") != RETRY; then + break + fi + api_pr_wait_log "$sha" "$status" "$description" + sleep $API_LOOP_DELAY + done + if test $(api_pr_check_status "$api" "$repo" "$sha" "$status" "$description") = "OK"; then + log_info "$sha status OK" + else + api_pr_get_status $api $repo $sha | jq .statuses + log_info "$sha status NOK" + return 1 + fi +} diff --git a/lib/lib.sh b/lib/lib.sh index 2daa32e..dc1a319 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -4,6 +4,8 @@ LIB_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $LIB_DIR/api.sh + if ${VERBOSE:-false} ; then set -ex PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: ' From fcb48eff5ce1d4acdf427aa475cb64741d7d4f45 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 27 May 2024 23:08:39 +0200 Subject: [PATCH 094/203] actions: automerge: check when review happens after CI success --- actions/example-automerge/run.sh | 51 ++++++++++++++++++++++++++++---- lib/api.sh | 40 +++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 6 deletions(-) diff --git a/actions/example-automerge/run.sh b/actions/example-automerge/run.sh index e7f5395..2134dc4 100755 --- a/actions/example-automerge/run.sh +++ b/actions/example-automerge/run.sh @@ -5,32 +5,31 @@ trap "rm -fr $TMPDIR" EXIT source $EXAMPLE_DIR/../../lib/lib.sh api=$url/api/v1 +repo=root/example-automerge export d=/srv/example/automerge -PROOF='some proof' - -function main() { +function reset_automerge_pr() { # # repository with a pull_request event workflow that always succeeds # mkdir -p $d + forgejo-curl.sh api_json -X DELETE $api/repos/$repo >&/dev/null || true forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token - local repo=root/example-automerge - forgejo-curl.sh api_json -X DELETE $api/repos/$repo/actions/variables/SCRIPT >&/dev/null || true forgejo-curl.sh api_json -X POST --data-raw '{"value":"true"}' $api/repos/$repo/actions/variables/SCRIPT ( cd $d + rm -fr example-automerge git clone $url/$repo cd example-automerge git checkout -b other git config user.email root@example.com git config user.name username touch file-unique-to-the-pr-branch - echo other $PROOF >>README + echo other >>README git add . git commit -m 'other change' git push --force -u origin other @@ -51,6 +50,11 @@ function main() { echo pull request already merged although it should not be return 1 fi +} + +function verify_automerge_on_status_success() { + reset_automerge_pr + local pr=$(jq -r .number <$TMPDIR/pr.json) # # run the workflow # @@ -66,4 +70,39 @@ function main() { fi } +function verify_automerge_on_reviewer_approval() { + reset_automerge_pr + local pr=$(jq -r .number <$TMPDIR/pr.json) + # + # require at least one review for a PR to be merged + # + api_branch_protect $api $repo main + # + # run the workflow + # + forgejo-runner.sh run + local sha=$(api_branch_tip $api $repo other) + api_pr_wait_success $api $repo $sha + # + # approve the PR + # + local username=user1 + api_user_create $api $username $username@example.com + api_user_make_admin $api $username + user_login $username + DOT=$API_TMPDIR/$username api_pr_approve $api $repo $pr + # + # verify the PR was automerged + # + if ! retry api_pr_is_merged $api $repo $pr; then + echo pull request is not automerged as expected + return 1 + fi +} + +function main() { + verify_automerge_on_status_success + verify_automerge_on_reviewer_approval +} + main diff --git a/lib/api.sh b/lib/api.sh index b58984a..03db36c 100644 --- a/lib/api.sh +++ b/lib/api.sh @@ -3,6 +3,29 @@ # SPDX-License-Identifier: MIT API_TMPDIR=$(mktemp -d) +: ${PASSWORD:=admin1234} + +function api_user_make_admin() { + local api="$1" username="$2" + + forgejo-curl.sh api_json -X PATCH --data '{"admin":true}' $api/admin/users/$username +} + +function api_user_create() { + local api="$1" username="$2" email="$3" + log_info "(re)create user $username" + forgejo-curl.sh api_json -X DELETE $api/admin/users/$username?purge=true >& /dev/null || true + forgejo-curl.sh api_json --data '{"username":"'$username'","email":"'$email'","password":"admin1234","must_change_password":false}' $api/admin/users +} + +function user_login() { + local username=$1 + ( + export DOT=$API_TMPDIR/$username + forgejo-curl.sh logout + forgejo-curl.sh --user $username --password "admin1234" login http://${HOST_PORT} + ) +} function api_branch_tip() { local api="$1" @@ -13,6 +36,23 @@ function api_branch_tip() { forgejo-curl.sh api_json $api/repos/$repo/branches/$branch | jq --raw-output .commit.id } +function api_branch_protect() { + local api="$1" + local repo="$2" + local branch="$3" + + forgejo-curl.sh api_json -X DELETE $api/repos/${repo}/branch_protections/$branch >&/dev/null || true + forgejo-curl.sh api_json --data '{"branch_name":"'$branch'","required_approvals":1}' $api/repos/${repo}/branch_protections +} + +function api_pr_approve() { + local api="$1" + local repo="$2" + local pr="$3" + + forgejo-curl.sh api_json --data '{"event":"APPROVED"}' $api/repos/${repo}/pulls/$pr/reviews +} + function api_pr_is_merged() { local api="$1" local repo="$2" From 9e60ae444938a63855d314a44049204da01d3087 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 1 Jun 2024 09:36:45 +0200 Subject: [PATCH 095/203] actions: post-7-0-schedule: create /srv/example/post-7-0-schedule/contexts first A loop is waiting for /srv/example/post-7-0-schedule-volume/DONE to exist before declaring the workflow is successfully run. But it is not really until /srv/example/post-7-0-schedule/contexts is created with the event content and they will race. Fixes: https://code.forgejo.org/forgejo/end-to-end/issues/181 Exactly the same as 57fdd1cd496dada21e8445c949c89c0057a49be9 but for post-7-0-schedule instead of cron --- .../.forgejo/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/actions/example-post-7-0-schedule/.forgejo/workflows/test.yml b/actions/example-post-7-0-schedule/.forgejo/workflows/test.yml index ee7c233..135364a 100644 --- a/actions/example-post-7-0-schedule/.forgejo/workflows/test.yml +++ b/actions/example-post-7-0-schedule/.forgejo/workflows/test.yml @@ -10,14 +10,14 @@ jobs: 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 \ No newline at end of file + EOF + + - run: | + echo "TEST_SCHEDULE_RUNSON=${{ vars.TEST_SCHEDULE_RUNSON }}" + touch /srv/example/post-7-0-schedule-volume/DONE From 4a19e9c90b077f78321df59f9ebca29e68cb3317 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 4 Jun 2024 12:00:42 +0200 Subject: [PATCH 096/203] lib: get the base of WORK_PATH from app.ini instead of hardcoding forgejo-work-path to be the base of WORK_PATH relative to DIR, read it from the app.ini file. It will allow multiple Forgejo instances to run simultaneously, each using a different directory. --- actions/default-app.ini | 2 +- lib/lib.sh | 14 +++++++++++--- packages/alpine-app.ini | 2 +- storage/default-app.ini | 2 +- storage/specific-app.ini | 2 +- storage/stable-s3-app.ini | 2 +- upgrade/default-app.ini | 2 +- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/actions/default-app.ini b/actions/default-app.ini index 7ef8df1..4f30f27 100644 --- a/actions/default-app.ini +++ b/actions/default-app.ini @@ -1,5 +1,5 @@ RUN_MODE = prod -WORK_PATH = ${WORK_PATH} +WORK_PATH = forgejo-work-path [server] APP_DATA_PATH = ${WORK_PATH}/data diff --git a/lib/lib.sh b/lib/lib.sh index dc1a319..8930e44 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -52,7 +52,7 @@ function dependencies() { if ! which make curl daemon git-lfs jq sqlite3 > /dev/null ; then $SUDO apt-get update -qq - $SUDO apt-get install -y -qq make curl daemon git-lfs jq sqlite3 gettext-base + $SUDO apt-get install -y -qq make curl daemon git-lfs jq sqlite3 fi if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio ; then @@ -247,10 +247,18 @@ function start() { function reset_forgejo() { local config=$1 - local work_path=$DIR/forgejo-work-path + local work_path_base=$(sed -n -e 's/^WORK_PATH *= *\(.*\)/\1/p' < $config) + if test -z "$work_path_base" ; then + echo "no line found starting with WORK_PATH = in the file $config" + return 1 + fi + local work_path=$DIR/$work_path_base rm -fr $work_path mkdir -p $work_path - IP=$IP WORK_PATH=$work_path envsubst < $config > $work_path/app.ini + sed -e "s/\${IP}/$IP/g" \ + -e "s|\${WORK_PATH}|$work_path|g" \ + -e "s|^WORK_PATH = .*|WORK_PATH = $work_path|" \ + < $config > $work_path/app.ini } function reset_minio() { diff --git a/packages/alpine-app.ini b/packages/alpine-app.ini index 113f242..ee378c5 100644 --- a/packages/alpine-app.ini +++ b/packages/alpine-app.ini @@ -1,5 +1,5 @@ RUN_MODE = prod -WORK_PATH = ${WORK_PATH} +WORK_PATH = forgejo-work-path [server] APP_DATA_PATH = ${WORK_PATH}/data diff --git a/storage/default-app.ini b/storage/default-app.ini index 113f242..ee378c5 100644 --- a/storage/default-app.ini +++ b/storage/default-app.ini @@ -1,5 +1,5 @@ RUN_MODE = prod -WORK_PATH = ${WORK_PATH} +WORK_PATH = forgejo-work-path [server] APP_DATA_PATH = ${WORK_PATH}/data diff --git a/storage/specific-app.ini b/storage/specific-app.ini index 980a3b0..c30911e 100644 --- a/storage/specific-app.ini +++ b/storage/specific-app.ini @@ -1,5 +1,5 @@ RUN_MODE = prod -WORK_PATH = ${WORK_PATH} +WORK_PATH = forgejo-work-path [server] APP_DATA_PATH = ${WORK_PATH}/elsewhere diff --git a/storage/stable-s3-app.ini b/storage/stable-s3-app.ini index 667bfba..cedbfa5 100644 --- a/storage/stable-s3-app.ini +++ b/storage/stable-s3-app.ini @@ -1,5 +1,5 @@ RUN_MODE = prod -WORK_PATH = ${WORK_PATH} +WORK_PATH = forgejo-work-path [server] APP_DATA_PATH = ${WORK_PATH}/elsewhere diff --git a/upgrade/default-app.ini b/upgrade/default-app.ini index e8134aa..a39c034 100644 --- a/upgrade/default-app.ini +++ b/upgrade/default-app.ini @@ -1,5 +1,5 @@ RUN_MODE = prod -WORK_PATH = ${WORK_PATH} +WORK_PATH = forgejo-work-path [server] APP_DATA_PATH = ${WORK_PATH}/data From 2461666aca3716d22194596504e8e321eef9c131 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 4 Jun 2024 13:04:05 +0200 Subject: [PATCH 097/203] lib: use the WORK_PATH base instead of forgejo for the daemon Instead of hardcoding "forgejo" as the base for the daemon to store the PID and the logs, use the base of the WORK_PATH so that a given work path can run a dedicated forgejo instance by the same name. --- actions/actions.sh | 2 +- lib/lib.sh | 48 +++++++++++++++++++++++++++++++--------------- packages/alpine.sh | 2 +- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/actions/actions.sh b/actions/actions.sh index dd38510..ac114de 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -74,7 +74,7 @@ function actions_setup() { function actions_teardown() { forgejo-curl.sh logout forgejo-runner.sh teardown - stop_daemon forgejo + stop_forgejo } function actions_runner_version() { diff --git a/lib/lib.sh b/lib/lib.sh index 8930e44..0c4c843 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -141,9 +141,12 @@ function download() { } function cleanup_logs() { - local work_path=$DIR/forgejo-work-path + local config=$1 - rm -f $DIR/*.log + local base=$(work_path_base $config) + local work_path=$DIR/$base + + rm -f $DIR/$base*.log rm -f $work_path/log/*.log } @@ -151,21 +154,30 @@ function clobber() { rm -fr /tmp/forgejo-end-to-end } +function stop_forgejo() { + local config=$1 + + stop_daemon $(work_path_base $config) +} + function start_forgejo() { local version=$1 + local config=$2 download $version - start_forgejo_daemon $version $DIR_BINARIES/forgejo-$version + start_forgejo_daemon $version $DIR_BINARIES/forgejo-$version $config } function start_forgejo_daemon() { local version=$1 local binary=$2 + local config=$3 - local work_path=$DIR/forgejo-work-path - daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $binary --config $work_path/app.ini --work-path $work_path + local base=$(work_path_base $config) + local work_path=$DIR/$base + daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/$base-pid --errlog=$DIR/$base-err.log --output=$DIR/$base-out.log -- $binary --config $work_path/app.ini --work-path $work_path if ! retry grep --no-messages --quiet 'Starting server on' $work_path/log/forgejo.log ; then - grep '' $DIR/*.log + grep '' $DIR/$base*.log grep '' $work_path/log/*.log 2> /dev/null return 1 fi @@ -245,14 +257,18 @@ function start() { start_forgejo $version } +function work_path_base() { + local config="$1" + if test -z "$config" ; then + echo forgejo-work-path + else + sed -n -e 's/^WORK_PATH *= *\(.*\)/\1/p' < $config + fi +} + function reset_forgejo() { local config=$1 - local work_path_base=$(sed -n -e 's/^WORK_PATH *= *\(.*\)/\1/p' < $config) - if test -z "$work_path_base" ; then - echo "no line found starting with WORK_PATH = in the file $config" - return 1 - fi - local work_path=$DIR/$work_path_base + local work_path=$DIR/$(work_path_base $config) rm -fr $work_path mkdir -p $work_path sed -e "s/\${IP}/$IP/g" \ @@ -303,11 +319,13 @@ function stop_daemon() { } function stop() { - stop_daemon forgejo + local config="$1" + + stop_forgejo $config stop_daemon minio stop_daemon garage - cleanup_logs + cleanup_logs $config } function show_logs() { @@ -315,7 +333,7 @@ function show_logs() { cd $DIR set +e grep --with-filename --text '' *.log - grep --with-filename --text '' forgejo-work-path/log/*.log + grep --with-filename --text '' */log/*.log grep --with-filename --text '' *.out ) } diff --git a/packages/alpine.sh b/packages/alpine.sh index b3e5b5d..ae82913 100644 --- a/packages/alpine.sh +++ b/packages/alpine.sh @@ -3,7 +3,7 @@ function test_packages_alpine_version() { local alpine_version=$1 forgejo_version=$2 - stop_daemon forgejo + stop_forgejo reset_forgejo $PACKAGES_DIR/alpine-app.ini start_forgejo $forgejo_version From b62866f3aea6581ef40d019ed069438224beb1bb Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 4 Jun 2024 14:41:56 +0200 Subject: [PATCH 098/203] lib: move forgejocli to the forgejo instance WORK_PATH Instead of having it in $DIR so that there can be one forgejocli per forgejo instance. --- forgejo/fixtures/doctor.sh | 6 ++++-- lib/lib.sh | 14 +++++++++----- upgrade/upgrade.sh | 18 +++++++++--------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/forgejo/fixtures/doctor.sh b/forgejo/fixtures/doctor.sh index 04e5b99..c0d8109 100644 --- a/forgejo/fixtures/doctor.sh +++ b/forgejo/fixtures/doctor.sh @@ -1,7 +1,9 @@ # SPDX-License-Identifier: MIT function doctor_run() { - local version=$1 + local config=$1 + local base=$(work_path_base $config) + local work_path=$DIR/$base - $DIR/forgejocli doctor check --all # --log-file - + $work_path/forgejocli doctor check --all # --log-file - } diff --git a/lib/lib.sh b/lib/lib.sh index 0c4c843..7ed14a1 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -181,9 +181,10 @@ function start_forgejo_daemon() { grep '' $work_path/log/*.log 2> /dev/null return 1 fi - echo "$binary --config $work_path/app.ini --work-path $work_path" '"$@"' > $DIR/forgejocli - chmod +x $DIR/forgejocli - create_user_and_login $version + echo "$binary --config $work_path/app.ini --work-path $work_path" '"$@"' > $work_path/forgejocli + chmod +x $work_path/forgejocli + cp -a $work_path/forgejocli $DIR/forgejocli # because setup-forgejo/forgejo-runner.sh expects it here + create_user_and_login $version $config } function start_minio() { @@ -287,10 +288,13 @@ function reset_garage() { function create_user_and_login() { local version=$1 + local config=$2 + + local work_path=$DIR/$(work_path_base $config) local email="$FORGEJO_USER@example.com" - if ! $DIR/forgejocli admin user list | grep --quiet "$email" ; then - $DIR/forgejocli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email + if ! $work_path/forgejocli admin user list | grep --quiet "$email" ; then + $work_path/forgejocli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email fi forgejo-curl.sh logout diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 3b89393..8d9ccb4 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -4,7 +4,7 @@ UPGRADE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" function upgrade_reset() { local config=$1 - reset_forgejo $UPGRADE_DIR/$config-app.ini + reset_forgejo $config reset_minio } @@ -26,8 +26,8 @@ function cleanup_storage() { function test_successful_upgrades() { stop - for config in default ; do - log_info "using $config app.ini" + for config in $UPGRADE_DIR/default-app.ini ; do + log_info "using $config" upgrade_reset $config version=1.21 @@ -36,7 +36,7 @@ function test_successful_upgrades() { start $version fixture_create fixture_assert - doctor_run $version + doctor_run $config for version in $RELEASE_NUMBERS_AND_DEV ; do stop @@ -44,7 +44,7 @@ function test_successful_upgrades() { start $version verify_storage fixture_assert - doctor_run $version + doctor_run $config done done } @@ -68,8 +68,8 @@ function start_gitea() { function test_gitea_upgrades() { stop - for config in default ; do - log_info "using $config app.ini" + for config in $UPGRADE_DIR/default-app.ini ; do + log_info "using $config" upgrade_reset $config version=1.21.10 @@ -79,7 +79,7 @@ function test_gitea_upgrades() { start_gitea $version fixture_create fixture_assert - doctor_run $version + doctor_run $config for version in 7.0-test ; do stop @@ -87,7 +87,7 @@ function test_gitea_upgrades() { start $version verify_storage fixture_assert - doctor_run $version + doctor_run $config done done } From 078107026b8e76af75b414a654e0d7ce8e29a5b0 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 4 Jun 2024 14:57:36 +0200 Subject: [PATCH 099/203] lib: get_host_port is $IP:3000 or read from app.ini --- lib/lib.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/lib.sh b/lib/lib.sh index 7ed14a1..d900dd9 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -29,7 +29,6 @@ IP=$(hostname -I | cut -f1 -d' ') RELEASE_NUMBERS="7.0 8.0" PREFIX=============== -HOST_PORT=$IP:3000 export DIR=/tmp/forgejo-end-to-end DIR_BINARIES=/srv/forgejo-binaries export DOT_FORGEJO_CURL=$DIR/forgejo-curl @@ -258,6 +257,17 @@ function start() { start_forgejo $version } +function get_host_port() { + local config="$1" + if test -z "$config" ; then + echo "$IP:3000" + else + echo "$IP:$(sed -n -e 's/^HTTP_PORT *= *\(.*\)/\1/p' < $config)" + fi +} + +HOST_PORT=$(get_host_port) + function work_path_base() { local config="$1" if test -z "$config" ; then From 19ce0fe6b1a99fbc0d92a4596ee185056a6281f3 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 4 Jun 2024 15:29:15 +0200 Subject: [PATCH 100/203] lib: add $work_path/forgejo-curl.sh for each Forgejo instance The $work_path/forgejo-curl.sh for each Forgejo instance is logged in with admin permissions and ready to use. The default forgejo-curl.sh remains logged in the last Forgejo instance that was launched. --- lib/lib.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/lib.sh b/lib/lib.sh index d900dd9..7567a08 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -35,7 +35,7 @@ export DOT_FORGEJO_CURL=$DIR/forgejo-curl export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 : ${FORGEJO_USER:=root} : ${FORGEJO_PASSWORD:=admin1234} -RELEASE_NUMBERS_AND_DEV="$(for r in $RELEASE_NUMBERS ; do echo -n "$r $r-dev " ; done)" +: ${RELEASE_NUMBERS_AND_DEV:="$(for r in $RELEASE_NUMBERS ; do echo -n "$r $r-dev " ; done)"} ORGANIZATIONS=$(cat $LIB_DIR/ORGANIZATIONS) function log_info() { @@ -312,7 +312,17 @@ function create_user_and_login() { if echo $version | grep --quiet 1.18 ; then scopes="" fi - forgejo-curl.sh --user "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" $scopes login http://${HOST_PORT} + forgejo-curl.sh --user "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" $scopes login http://$(get_host_port $config) + + local forgejo_curl=$work_path/forgejo-curl.sh + cat > $forgejo_curl < Date: Tue, 4 Jun 2024 16:30:48 +0200 Subject: [PATCH 101/203] federation: stub that checks the nodeinfo of the two instances --- .forgejo/workflows/end-to-end.yml | 11 ++++ end-to-end.sh | 1 + federation/ONE-app.ini | 33 +++++++++++ federation/TWO-app.ini | 33 +++++++++++ federation/federation.sh | 85 ++++++++++++++++++++++++++++ federation/scenario-star/run.sh | 2 + federation/scenario-star/setup.sh | 0 federation/scenario-star/teardown.sh | 0 8 files changed, 165 insertions(+) create mode 100644 federation/ONE-app.ini create mode 100644 federation/TWO-app.ini create mode 100755 federation/federation.sh create mode 100644 federation/scenario-star/run.sh create mode 100644 federation/scenario-star/setup.sh create mode 100644 federation/scenario-star/teardown.sh diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index cb8fa30..c1b9171 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -76,6 +76,17 @@ jobs: if: always() run: su forgejo -c "./end-to-end.sh show_logs" + federation: + needs: [build] + runs-on: lxc-bookworm + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + - uses: ./.forgejo/prepare-end-to-end + - run: su forgejo -c "./end-to-end.sh test_federation" + - name: full logs + if: always() + run: su forgejo -c "./end-to-end.sh show_logs" + actions-docs: needs: [build] runs-on: lxc-bookworm diff --git a/end-to-end.sh b/end-to-end.sh index 04478c3..ab9454b 100755 --- a/end-to-end.sh +++ b/end-to-end.sh @@ -15,6 +15,7 @@ SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SELF="${BASH_SOURCE[0]}" source $SELF_DIR/lib/lib.sh +source $SELF_DIR/federation/federation.sh source $SELF_DIR/actions/actions.sh source $SELF_DIR/forgejo/fixtures.sh source $SELF_DIR/storage/storage.sh diff --git a/federation/ONE-app.ini b/federation/ONE-app.ini new file mode 100644 index 0000000..4dcdacf --- /dev/null +++ b/federation/ONE-app.ini @@ -0,0 +1,33 @@ +RUN_MODE = prod +WORK_PATH = forgejo-ONE + +[server] +APP_DATA_PATH = ${WORK_PATH}/data +DOMAIN = ${IP} +HTTP_PORT = 3001 +SSH_LISTEN_PORT = 2201 + +[queue] +TYPE = immediate + +[database] +DB_TYPE = sqlite3 +PATH = ${WORK_PATH}/forgejo.db + +[log] +MODE = file +LEVEL = trace +ROUTER = file + +[log.file] +FILE_NAME = forgejo.log + +[security] +INSTALL_LOCK = true + +[repository] +ENABLE_PUSH_CREATE_USER = true +DEFAULT_PUSH_CREATE_PRIVATE = false + +[federation] +ENABLED = true diff --git a/federation/TWO-app.ini b/federation/TWO-app.ini new file mode 100644 index 0000000..656588a --- /dev/null +++ b/federation/TWO-app.ini @@ -0,0 +1,33 @@ +RUN_MODE = prod +WORK_PATH = forgejo-TWO + +[server] +APP_DATA_PATH = ${WORK_PATH}/data +DOMAIN = ${IP} +HTTP_PORT = 3002 +SSH_LISTEN_PORT = 2202 + +[queue] +TYPE = immediate + +[database] +DB_TYPE = sqlite3 +PATH = ${WORK_PATH}/forgejo.db + +[log] +MODE = file +LEVEL = trace +ROUTER = file + +[log.file] +FILE_NAME = forgejo.log + +[security] +INSTALL_LOCK = true + +[repository] +ENABLE_PUSH_CREATE_USER = true +DEFAULT_PUSH_CREATE_PRIVATE = false + +[federation] +ENABLED = true diff --git a/federation/federation.sh b/federation/federation.sh new file mode 100755 index 0000000..de1e515 --- /dev/null +++ b/federation/federation.sh @@ -0,0 +1,85 @@ +# Copyright 2024 The Forgejo Authors +# SPDX-License-Identifier: MIT + +FEDERATION_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +export FEDERATION_INSTANCES="ONE TWO" +export FEDERATION_CONFIGS + +function federation_setup_variables() { + if test "$FEDERATION_CONFIGS" ; then + return + fi + for instance in $FEDERATION_INSTANCES ; do + local config=$FEDERATION_DIR/$instance-app.ini + FEDERATION_CONFIGS="$FEDERATION_CONFIGS $config" + local base=$(work_path_base $config) + local work_path=$DIR/$base + local host_port=$(get_host_port $config) + + eval export ${instance}_CONFIG=$config + eval export ${instance}_CURL=$work_path/forgejo-curl.sh + eval export ${instance}_HOST_PORT=$host_port + done +} + +function federation_verify_scenario() { + local scenario=$1 + + export scenario + export SCENARIO_DIR=$FEDERATION_DIR/scenario-$scenario + + if test -f $SCENARIO_DIR/setup.sh ; then + echo "============================ SETUP scenario-$scenario ===================" + bash -ex $SCENARIO_DIR/setup.sh || return 1 + fi + + echo "============================ RUN scenario-$scenario ===================" + bash -ex $SCENARIO_DIR/run.sh || return 1 + + if test -f $SCENARIO_DIR/teardown.sh ; then + echo "============================ TEARDOWN scenario-$scenario ===================" + bash -ex $SCENARIO_DIR/teardown.sh || return 1 + fi +} + +function federation_setup() { + federation_setup_variables + + local version=$1 + federation_teardown + + local config + for config in $FEDERATION_CONFIGS ; do + reset_forgejo $config + start_forgejo $version $config + done +} + +function federation_teardown() { + federation_setup_variables + + local config + for config in $FEDERATION_CONFIGS ; do + stop_forgejo $config + done +} + +function test_federation() { + federation_setup_variables + + local versions="${1:-$RELEASE_NUMBERS_AND_DEV}" + + for version in $versions ; do + + if dpkg --compare-versions $version lt 7.1 ; then + continue + fi + + federation_setup $version + + for scenario in star ; do + run federation_verify_scenario $scenario + done + done +} diff --git a/federation/scenario-star/run.sh b/federation/scenario-star/run.sh new file mode 100644 index 0000000..8d10fd2 --- /dev/null +++ b/federation/scenario-star/run.sh @@ -0,0 +1,2 @@ +test forgejo = $($ONE_CURL api_json $ONE_HOST_PORT/api/v1/nodeinfo | jq -r .software.name) +test forgejo = $($TWO_CURL api_json $TWO_HOST_PORT/api/v1/nodeinfo | jq -r .software.name) diff --git a/federation/scenario-star/setup.sh b/federation/scenario-star/setup.sh new file mode 100644 index 0000000..e69de29 diff --git a/federation/scenario-star/teardown.sh b/federation/scenario-star/teardown.sh new file mode 100644 index 0000000..e69de29 From 233b73d7c828ef5fddea96a38ebc8b16199e6334 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 4 Jun 2024 19:57:31 +0200 Subject: [PATCH 102/203] federation: add star scenario Refs: https://codeberg.org/forgejo/forgejo/pulls/1680 --- README.md | 4 +-- federation/scenario-star/run.sh | 46 +++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 004288a..257e5b6 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,10 @@ cd end-to-end ```sh make TAGS='bindata sqlite sqlite_unlock_notify' generate forgejo -cp -a forgejo /srv/forgejo-binaries/forgejo-7.0-dev +cp -a forgejo /srv/forgejo-binaries/forgejo-8.0-dev ``` -It will be used whenever the version `7.0-dev` is specified in a test. +It will be used whenever the version `8.0-dev` is specified in a test. ## Running actions locally diff --git a/federation/scenario-star/run.sh b/federation/scenario-star/run.sh index 8d10fd2..2d58ca8 100644 --- a/federation/scenario-star/run.sh +++ b/federation/scenario-star/run.sh @@ -1,2 +1,44 @@ -test forgejo = $($ONE_CURL api_json $ONE_HOST_PORT/api/v1/nodeinfo | jq -r .software.name) -test forgejo = $($TWO_CURL api_json $TWO_HOST_PORT/api/v1/nodeinfo | jq -r .software.name) +TMPDIR=$(mktemp -d) +trap "rm -fr $TMPDIR" EXIT + +function star_count() { + local curl=$1 + local host_port=$2 + local count=$3 + + $curl api_json http://$host_port/api/v1/repos/root/test > $TMPDIR/count.json + if test $count != $(jq -r .stars_count < $TMPDIR/count.json) ; then + jq . < $TMPDIR/count.json + return 1 + fi +} + +# +# create a repo on each instance +# +$ONE_CURL api_json --data '{"name":"test","auto_init":true}' $ONE_HOST_PORT/api/v1/user/repos > $TMPDIR/one-repo.json +one_repo_id=$(jq -r .id < $TMPDIR/one-repo.json) +$TWO_CURL api_json --data '{"name":"test","auto_init":true}' $TWO_HOST_PORT/api/v1/user/repos > $TMPDIR/two-repo.json +two_repo_id=$(jq -r .id < $TMPDIR/two-repo.json) + +# +# the repo in instance two is federated with the repo in instance one +# +$ONE_CURL web --form action=federation --form following_repos=http://$TWO_HOST_PORT/api/v1/activitypub/repository-id/$two_repo_id http://$ONE_HOST_PORT/root/test/settings + +# +# check that both repo have 0 star +# +star_count $ONE_CURL $ONE_HOST_PORT 0 +star_count $TWO_CURL $TWO_HOST_PORT 0 + +# +# star the repo on instance one and expect the star to show on instance two +# +$ONE_CURL api_json -X PUT $ONE_HOST_PORT/api/v1/user/starred/root/test + +# +# check that both repo have 1 star +# +star_count $ONE_CURL $ONE_HOST_PORT 1 +star_count $TWO_CURL $TWO_HOST_PORT 1 From c1ce4361b952b3bbf258f5ad6539359835bb2939 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sat, 22 Jun 2024 11:40:33 +0200 Subject: [PATCH 103/203] upgrades: add Gitea 1.22.0 & 1.21.11 to Forgejo 8.0-test --- lib/lib.sh | 39 ++++++++++++++++++++++++-- upgrade/upgrade.sh | 69 ++++++++++++++++++---------------------------- 2 files changed, 63 insertions(+), 45 deletions(-) diff --git a/lib/lib.sh b/lib/lib.sh index 7567a08..96bbb25 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -113,7 +113,7 @@ function full_version() { fi } -function download() { +function download_forgejo() { local version=$1 if ! test -f $DIR_BINARIES/forgejo-$version ; then @@ -129,7 +129,7 @@ function download() { done if test -s $DIR_BINARIES/forgejo-$version ; then if test "$version" != "$full_version" ; then - log_info "downloaded $full_version for $version" + log_info "downloaded Forgejo $full_version for $version" fi else echo unable to download Forgejo $version @@ -139,6 +139,31 @@ function download() { fi } +function download_gitea() { + local version=$1 + + if ! test -f $DIR_BINARIES/gitea-$version ; then + mkdir -p $DIR_BINARIES + if [[ $version =~ ^[0-9]+\.[0-9]+$ ]] ; then + full_version=$(curl -sS "https://api.github.com/repos/go-gitea/gitea/releases?per_page=100" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | grep -v -e '-rc' | sort --reverse --version-sort | head -1) + full_version=${full_version#v} + else + full_version=$version + fi + wget -O $DIR_BINARIES/gitea-$version --quiet https://dl.gitea.com/gitea/$full_version/gitea-$full_version-linux-amd64 + + if test -s $DIR_BINARIES/gitea-$version ; then + if test "$version" != "$full_version" ; then + log_info "downloaded Gitea $full_version for $version" + fi + else + echo unable to download Gitea $version + return 1 + fi + chmod +x $DIR_BINARIES/gitea-$version + fi +} + function cleanup_logs() { local config=$1 @@ -159,11 +184,19 @@ function stop_forgejo() { stop_daemon $(work_path_base $config) } +function start_gitea() { + local version=$1 + local config=$2 + + download_gitea $version + start_forgejo_daemon $version $DIR_BINARIES/gitea-$version $config +} + function start_forgejo() { local version=$1 local config=$2 - download $version + download_forgejo $version start_forgejo_daemon $version $DIR_BINARIES/forgejo-$version $config } diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 8d9ccb4..5b66d8c 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -30,65 +30,50 @@ function test_successful_upgrades() { log_info "using $config" upgrade_reset $config - version=1.21 + version=1.21 log_info "run $version" cleanup_storage - start $version - fixture_create - fixture_assert - doctor_run $config + start $version + fixture_create + fixture_assert + doctor_run $config for version in $RELEASE_NUMBERS_AND_DEV ; do stop log_info "run $version" start $version verify_storage - fixture_assert - doctor_run $config + fixture_assert + doctor_run $config done done } -function download_gitea() { - local version=$1 - - if ! test -f $DIR_BINARIES/gitea-$version ; then - mkdir -p $DIR_BINARIES - wget -O $DIR_BINARIES/gitea-$version --quiet https://dl.gitea.com/gitea/$version/gitea-$version-linux-amd64 - chmod +x $DIR_BINARIES/gitea-$version - fi -} - -function start_gitea() { - local version=$1 - - download_gitea $version - start_forgejo_daemon $version $DIR_BINARIES/gitea-$version -} - function test_gitea_upgrades() { - stop - for config in $UPGRADE_DIR/default-app.ini ; do - log_info "using $config" + local config=$UPGRADE_DIR/default-app.ini + ( + echo gitea 1.21 forgejo 7.0-test + echo gitea 1.21 forgejo 8.0-test + echo gitea 1.22 forgejo 8.0-test + ) | while read gitea gitea_version forgejo forgejo_version ; do + log_info "upgrading from Gitea $gitea_version to Forgejo $forgejo_version" + stop upgrade_reset $config - version=1.21.10 - log_info "run gitea $version" + log_info "run Gitea $gitea_version" cleanup_storage - start_s3 minio - start_gitea $version - fixture_create - fixture_assert - doctor_run $config + start_s3 minio + start_gitea $gitea_version $config + fixture_create + fixture_assert + doctor_run $config - for version in 7.0-test ; do - stop - log_info "run forgejo $version" - start $version - verify_storage - fixture_assert - doctor_run $config - done + stop + log_info "run Forgejo $forgejo_version" + start $forgejo_version + verify_storage + fixture_assert + doctor_run $config done } From dca3641cf36d710afa29284c0544d153ffe282a7 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sat, 22 Jun 2024 20:24:47 +0200 Subject: [PATCH 104/203] actions: use Forgejo runner v3.5.0 --- actions/actions.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/actions/actions.sh b/actions/actions.sh index ac114de..f7a297d 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -3,6 +3,8 @@ ACTIONS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +RUNNER_VERSION=v3.5.0 + function actions_verify_example() { local example=$1 @@ -68,7 +70,7 @@ function actions_setup() { actions_cleanup_example_volume export FORGEJO_RUNNER_CONFIG=$ACTIONS_DIR/runner-config.yaml - forgejo-runner.sh setup '' '' http://${HOST_PORT} + forgejo-runner.sh setup '' $RUNNER_VERSION http://${HOST_PORT} } function actions_teardown() { From 8b3c0a55e7e395c27528268aa85ba6bd85a4be9d Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sat, 22 Jun 2024 20:27:04 +0200 Subject: [PATCH 105/203] actions: test cache/{restore,save}@v4 support --- actions/actions.sh | 2 +- .../example-cache/.forgejo/workflows/test.yml | 51 +++++++++++++++++++ actions/example-cache/runner-config.yaml | 30 +++++++++++ actions/example-cache/setup.sh | 1 + actions/example-cache/teardown.sh | 1 + 5 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 actions/example-cache/.forgejo/workflows/test.yml create mode 100644 actions/example-cache/runner-config.yaml create mode 100755 actions/example-cache/setup.sh create mode 100755 actions/example-cache/teardown.sh diff --git a/actions/actions.sh b/actions/actions.sh index f7a297d..e201d96 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -105,7 +105,7 @@ function test_actions() { done fi - for example in echo checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context ; do + for example in echo cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context ; do run actions_verify_example $example done diff --git a/actions/example-cache/.forgejo/workflows/test.yml b/actions/example-cache/.forgejo/workflows/test.yml new file mode 100644 index 0000000..ab37b75 --- /dev/null +++ b/actions/example-cache/.forgejo/workflows/test.yml @@ -0,0 +1,51 @@ +on: [push] + +jobs: + build: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + steps: + - name: cache restore + id: cachestep1 + uses: https://code.forgejo.org/actions/cache/restore@v4 + with: + path: | + /usr/local/bin/something + key: cachekey + + - name: cache hit + run: | + set -x + test "${{ steps.cachestep1.outputs.cache-hit }}" != true + + - name: create something + run: echo SOMETHING > /usr/local/bin/something + + - name: cache save + uses: https://code.forgejo.org/actions/cache/save@v4 + with: + path: | + /usr/local/bin/something + key: ${{ steps.cachestep1.outputs.cache-primary-key }} + + - name: remove something + run: rm /usr/local/bin/something + + - name: cache restore + id: cachestep2 + uses: https://code.forgejo.org/actions/cache/restore@v4 + with: + path: | + /usr/local/bin/something + key: cachekey + + - name: verify something + run: | + set -x + test SOMETHING = $(cat /usr/local/bin/something) + + - name: cache hit + run: | + set -x + test "${{ steps.cachestep2.outputs.cache-hit }}" = true diff --git a/actions/example-cache/runner-config.yaml b/actions/example-cache/runner-config.yaml new file mode 100644 index 0000000..9b342f1 --- /dev/null +++ b/actions/example-cache/runner-config.yaml @@ -0,0 +1,30 @@ + +log: + level: info + +runner: + file: .runner + capacity: 1 + env_file: .env + timeout: 3h + insecure: false + fetch_timeout: 5s + fetch_interval: 2s + labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"] + +cache: + enabled: true + dir: "/srv/example/cache" + host: "" + port: 0 + +container: + network: "bridge" + privileged: false + options: + workdir_parent: + valid_volumes: ["/srv/example"] + docker_host: "" + +host: + workdir_parent: diff --git a/actions/example-cache/setup.sh b/actions/example-cache/setup.sh new file mode 100755 index 0000000..9c1f5ad --- /dev/null +++ b/actions/example-cache/setup.sh @@ -0,0 +1 @@ +FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload diff --git a/actions/example-cache/teardown.sh b/actions/example-cache/teardown.sh new file mode 100755 index 0000000..b410c51 --- /dev/null +++ b/actions/example-cache/teardown.sh @@ -0,0 +1 @@ +forgejo-runner.sh reload From cc16df533ba3fdadd9cc533e347128eaed12d31f Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sun, 23 Jun 2024 09:10:52 +0200 Subject: [PATCH 106/203] test: upgrade actions/cache@v4 Refs: https://code.forgejo.org/forgejo/runner/issues/209 --- .forgejo/prepare-end-to-end/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/prepare-end-to-end/action.yml b/.forgejo/prepare-end-to-end/action.yml index 0fa2794..de17f29 100644 --- a/.forgejo/prepare-end-to-end/action.yml +++ b/.forgejo/prepare-end-to-end/action.yml @@ -3,7 +3,7 @@ runs: steps: - name: cache S3 binaries id: S3 - uses: https://code.forgejo.org/actions/cache@v3 + uses: https://code.forgejo.org/actions/cache@v4 with: path: | /usr/local/bin/minio From 6b35ea27c3c964de925f6b52966e00cfd20438fb Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sun, 23 Jun 2024 09:13:36 +0200 Subject: [PATCH 107/203] test: make it easier to comment out tests When the build stage is commented out, the /srv/forgejo-binaries directory will not exist. Change the script to work in both cases. --- .forgejo/prepare-end-to-end/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.forgejo/prepare-end-to-end/action.yml b/.forgejo/prepare-end-to-end/action.yml index 0fa2794..3f7f059 100644 --- a/.forgejo/prepare-end-to-end/action.yml +++ b/.forgejo/prepare-end-to-end/action.yml @@ -21,8 +21,9 @@ runs: path: /srv/forgejo-binaries - name: chown/chmod /srv/forgejo-binaries run: | - chmod +x /srv/forgejo-binaries/* + mkdir -p /srv/forgejo-binaries chown -R forgejo /srv/forgejo-binaries + chmod -R +x /srv/forgejo-binaries - run: | script=$(pwd)/end-to-end.sh $script run dependencies From 76ac081fb936ffa80dc48dc489ff81c56c328ab0 Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Sun, 23 Jun 2024 00:22:19 +0200 Subject: [PATCH 108/203] lib: start & stop GitLab The image is saved to disk and cached because it is over 1GB, to save bandwidthc. --- .forgejo/workflows/end-to-end.yml | 13 ++++++- federation/federation.sh | 1 + lib/lib.sh | 59 +++++++++++++++++++++++++++++-- 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index c1b9171..83ce388 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -82,7 +82,18 @@ jobs: steps: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: ./.forgejo/prepare-end-to-end - - run: su forgejo -c "./end-to-end.sh test_federation" + - name: install zstd + run: | + export DEBIAN_FRONTEND=noninteractive + apt-get -q install -y -qq zstd + - name: cache GitLab OCI image + uses: https://code.forgejo.org/actions/cache@v4 + with: + path: | + /srv/forgejo-binaries/gitlab + key: gitlab + - run: | + su forgejo -c "./end-to-end.sh test_federation" - name: full logs if: always() run: su forgejo -c "./end-to-end.sh show_logs" diff --git a/federation/federation.sh b/federation/federation.sh index de1e515..7fbb215 100755 --- a/federation/federation.sh +++ b/federation/federation.sh @@ -66,6 +66,7 @@ function federation_teardown() { } function test_federation() { + # start_gitlab octobus/heptapod:1.5.3 federation_setup_variables local versions="${1:-$RELEASE_NUMBERS_AND_DEV}" diff --git a/lib/lib.sh b/lib/lib.sh index 96bbb25..be371ff 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -49,9 +49,9 @@ function dependencies() { $SUDO chmod +x /usr/local/bin/forgejo-curl.sh fi - if ! which make curl daemon git-lfs jq sqlite3 > /dev/null ; then + if ! which make curl daemon git-lfs jq sqlite3 skopeo > /dev/null ; then $SUDO apt-get update -qq - $SUDO apt-get install -y -qq make curl daemon git-lfs jq sqlite3 + $SUDO apt-get install -y -qq make curl daemon git-lfs jq sqlite3 skopeo fi if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio ; then @@ -178,6 +178,57 @@ function clobber() { rm -fr /tmp/forgejo-end-to-end } +function start_gitlab_cache_load() { + local image=$1 + local d=$DIR_BINARIES/gitlab + if test -d $d ; then + log_info "loading $image from $d" + skopeo copy dir:$d docker-daemon:$image + fi +} + +function start_gitlab_cache_save() { + local image=$1 + local d=$DIR_BINARIES/gitlab + if ! test -d $d ; then + log_info "saving $image to $d" + skopeo copy docker-daemon:$image dir:$d + fi +} + +function start_gitlab() { + local image=$1 + local config=$2 + + start_gitlab_cache_load $image + + local GITLAB_OMNIBUS_CONFIG="nginx['listen_https'] = false ; nginx['listen_port'] = 8181 ; external_url 'http://0.0.0.0:8181'; gitlab_rails['gitlab_shell_ssh_port'] = 2221;" + docker run --name="test-gitlab" --shm-size=128M -d \ + -e GITLAB_OMNIBUS_CONFIG="$GITLAB_OMNIBUS_CONFIG" \ + -p 2221:22 -p 8181:8181 \ + $image >& /dev/null < /dev/null + + start_gitlab_cache_save $image + + for i in $(seq 10) ; do + if test $(curl --silent http://0.0.0.0:8181 -o /dev/null -w "%{http_code}") = 302 ; then + docker exec test-gitlab gitlab-rails runner "user = User.find_by_username 'root'; user.password = 'Wrobyak4'; user.password_confirmation = 'Wrobyak4'; user.password_automatically_set = false ; user.save!" + docker exec test-gitlab$serial gitlab-rails runner "Gitlab::CurrentSettings.current_application_settings.update(default_vcs_type: 'git')" + log_info "GitLab is ready" + return + fi + log_info "waiting for GitLab to come up $i" + sleep 30 + done + log_info "GitLab did not come up" + docker logs test-gitlab + false +} + +function stop_gitlab() { + docker rm -f test-gitlab +} + function stop_forgejo() { local config=$1 @@ -386,6 +437,10 @@ function stop() { } function show_logs() { + if ! test -d $DIR ; then + log_info "$DIR does not exist, no logs to display" + return + fi ( cd $DIR set +e From b43cfb6e0cd58bee17bf3f397a92ecad3708c65d Mon Sep 17 00:00:00 2001 From: Twenty Panda Date: Tue, 25 Jun 2024 18:54:37 +0200 Subject: [PATCH 109/203] cleanup(gitlab): move hardcoded strings to variables [skip ci] --- lib/lib.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/lib.sh b/lib/lib.sh index be371ff..7448536 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -178,6 +178,10 @@ function clobber() { rm -fr /tmp/forgejo-end-to-end } +: ${GITLAB_USER:=root} +: ${GITLAB_PASSWORD:=Wrobyak4} +: ${GITLAB_PORT:=8181} + function start_gitlab_cache_load() { local image=$1 local d=$DIR_BINARIES/gitlab @@ -202,17 +206,17 @@ function start_gitlab() { start_gitlab_cache_load $image - local GITLAB_OMNIBUS_CONFIG="nginx['listen_https'] = false ; nginx['listen_port'] = 8181 ; external_url 'http://0.0.0.0:8181'; gitlab_rails['gitlab_shell_ssh_port'] = 2221;" + local GITLAB_OMNIBUS_CONFIG="nginx['listen_https'] = false ; nginx['listen_port'] = 8181 ; external_url 'http://$IP:$GITLAB_PORT'; gitlab_rails['gitlab_shell_ssh_port'] = 2221; $config" docker run --name="test-gitlab" --shm-size=128M -d \ -e GITLAB_OMNIBUS_CONFIG="$GITLAB_OMNIBUS_CONFIG" \ - -p 2221:22 -p 8181:8181 \ + -p 2221:22 -p $GITLAB_PORT:8181 \ $image >& /dev/null < /dev/null start_gitlab_cache_save $image for i in $(seq 10) ; do - if test $(curl --silent http://0.0.0.0:8181 -o /dev/null -w "%{http_code}") = 302 ; then - docker exec test-gitlab gitlab-rails runner "user = User.find_by_username 'root'; user.password = 'Wrobyak4'; user.password_confirmation = 'Wrobyak4'; user.password_automatically_set = false ; user.save!" + if test $(curl --silent http://$IP:$GITLAB_PORT -o /dev/null -w "%{http_code}") = 302 ; then + docker exec test-gitlab gitlab-rails runner "user = User.find_by_username 'root'; user.password = '$GITLAB_PASSWORD'; user.password_confirmation = '$GITLAB_PASSWORD'; user.password_automatically_set = false ; user.save!" docker exec test-gitlab$serial gitlab-rails runner "Gitlab::CurrentSettings.current_application_settings.update(default_vcs_type: 'git')" log_info "GitLab is ready" return From 87df9095b9aad6efefe9f75fd096d82f2fb51bca Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 2 Jul 2024 20:54:27 +0200 Subject: [PATCH 110/203] Revert "actions: use Forgejo runner v3.5.0" Do not force the runner version, use whatever default setup-forgejo provides. Forcing the version will break the cascading-pr workflow. It will attempt to download a version that does not exist instead of building it from sources. This reverts commit dca3641cf36d710afa29284c0544d153ffe282a7. --- actions/actions.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/actions/actions.sh b/actions/actions.sh index e201d96..4d1f2ef 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -3,8 +3,6 @@ ACTIONS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -RUNNER_VERSION=v3.5.0 - function actions_verify_example() { local example=$1 @@ -70,7 +68,7 @@ function actions_setup() { actions_cleanup_example_volume export FORGEJO_RUNNER_CONFIG=$ACTIONS_DIR/runner-config.yaml - forgejo-runner.sh setup '' $RUNNER_VERSION http://${HOST_PORT} + forgejo-runner.sh setup '' '' http://${HOST_PORT} } function actions_teardown() { From 64489247aa833d990c6c325989b5ade4412a441d Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 4 Jul 2024 20:15:10 +0200 Subject: [PATCH 111/203] actions: run in development mode for debug purposes --- actions/default-app.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/default-app.ini b/actions/default-app.ini index 4f30f27..e4577a5 100644 --- a/actions/default-app.ini +++ b/actions/default-app.ini @@ -1,4 +1,4 @@ -RUN_MODE = prod +RUN_MODE = dev WORK_PATH = forgejo-work-path [server] From 05a341e20141bc04ee916bc330a8462cfdd3a088 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 4 Jul 2024 20:15:32 +0200 Subject: [PATCH 112/203] actions: add an example for workflow-dispatch /repos/{owner}/{repo}/actions/workflows/{workflowname}/dispatches * fails if the required inputs are not provided * sets defaults to inputs that are not provided The type of inputs are only used for building the web UI interface, not for validation. All values are strings. --- actions/actions.sh | 6 ++ .../.forgejo/workflows/test.yml | 57 +++++++++++++++++ actions/example-workflow-dispatch/run.sh | 62 +++++++++++++++++++ actions/example-workflow-dispatch/setup.sh | 1 + 4 files changed, 126 insertions(+) create mode 100644 actions/example-workflow-dispatch/.forgejo/workflows/test.yml create mode 100755 actions/example-workflow-dispatch/run.sh create mode 100755 actions/example-workflow-dispatch/setup.sh diff --git a/actions/actions.sh b/actions/actions.sh index 4d1f2ef..d06027f 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -118,5 +118,11 @@ function test_actions() { run actions_verify_example $example done fi + + if dpkg --compare-versions $version ge 8.0 ; then + for example in workflow-dispatch ; do + run actions_verify_example $example + done + fi done } diff --git a/actions/example-workflow-dispatch/.forgejo/workflows/test.yml b/actions/example-workflow-dispatch/.forgejo/workflows/test.yml new file mode 100644 index 0000000..186fe56 --- /dev/null +++ b/actions/example-workflow-dispatch/.forgejo/workflows/test.yml @@ -0,0 +1,57 @@ +on: + workflow_dispatch: + inputs: + logLevel: + description: 'Log Level' + required: true + default: 'warning' + type: choice + options: + - info + - warning + - debug + tags: + description: 'Test scenario tags' + required: false + type: boolean + boolean_default_true: + description: 'Test scenario tags' + required: true + type: boolean + default: true + boolean_default_false: + description: 'Test scenario tags' + required: false + type: boolean + default: false + number1_default: + description: 'Number w. default' + default: '100' + type: number + number2: + description: 'Number w/o. default' + type: number + string1_default: + description: 'String w. default' + default: 'Hello world' + type: string + string2: + description: 'String w/o. default' + required: true + type: string + +jobs: + test: + runs-on: docker + container: + image: code.forgejo.org/oci/debian:bookworm + options: "--volume /srv/example:/srv/example" + + steps: + - name: save and display context + run: | + d=/srv/example/workflow-dispatch/contexts/$GITHUB_EVENT_NAME + mkdir -p $d + tee $d/github <<'EOF' + ${{ toJSON(github) }} + EOF diff --git a/actions/example-workflow-dispatch/run.sh b/actions/example-workflow-dispatch/run.sh new file mode 100755 index 0000000..ed55070 --- /dev/null +++ b/actions/example-workflow-dispatch/run.sh @@ -0,0 +1,62 @@ +TMPDIR=$(mktemp -d) + +trap "rm -fr $TMPDIR" EXIT + +source $EXAMPLE_DIR/../../lib/lib.sh + +export d=/srv/example/tag +context=/srv/example/workflow-dispatch/contexts/workflow_dispatch/github +api=$url/api/v1 +repo=root/example-$example + +function context_wait() { + if ! forgejo.sh retry test -f $context ; then + cat "$FORGEJO_RUNNER_LOGS" + false + fi +} + +function verify_required() { + local actual=$(forgejo-curl.sh api_json -w '%{http_code}' --data '{"ref":"main","inputs":{}}' $api/repos/$repo/actions/workflows/test.yml/dispatches) + local expected=400 + if test "$actual" != $expected ; then + log_info "dispatch is expected to fail with status $expected because of string2 is a required value but got status $actual instead" + return 1 + fi +} + +function verify_inputs() { + local inputs='{"string2":"value2"}' + forgejo-curl.sh api_json --data '{"ref":"main","inputs":'$inputs'}' $api/repos/$repo/actions/workflows/test.yml/dispatches + cat > $TMPDIR/expected <<'EOF' + { + "boolean_default_false": "false", + "boolean_default_true": "true", + "logLevel": "warning", + "number1_default": "100", + "string1_default": "Hello world", + "string2": "value2" + } +EOF +} + +function run_tests() { + verify_required + + npm --silent install json-diff + verify_inputs + context_wait + node_modules/.bin/json-diff <(jq .event.inputs < $context) $TMPDIR/expected +} + +function main() { + mkdir -p $d + + forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token + + run_tests + + test "workflow_dispatch" = "$(jq -r .event_name < $context)" +} + +main diff --git a/actions/example-workflow-dispatch/setup.sh b/actions/example-workflow-dispatch/setup.sh new file mode 100755 index 0000000..402b08c --- /dev/null +++ b/actions/example-workflow-dispatch/setup.sh @@ -0,0 +1 @@ +mkdir -p /srv/example/workflow-dispatch From ad5790b566fddb9f7d12d96b09ad9350f25dc604 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 7 Jul 2024 09:55:43 +0200 Subject: [PATCH 113/203] federation: wait for the asynchronous star to land The check races with the propagation of the star from one forge to the other. It must wait for it to land instead. --- federation/scenario-star/run.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/federation/scenario-star/run.sh b/federation/scenario-star/run.sh index 2d58ca8..15db8e2 100644 --- a/federation/scenario-star/run.sh +++ b/federation/scenario-star/run.sh @@ -1,6 +1,9 @@ TMPDIR=$(mktemp -d) + trap "rm -fr $TMPDIR" EXIT +source $SCENARIO_DIR/../../lib/lib.sh + function star_count() { local curl=$1 local host_port=$2 @@ -41,4 +44,4 @@ $ONE_CURL api_json -X PUT $ONE_HOST_PORT/api/v1/user/starred/root/test # check that both repo have 1 star # star_count $ONE_CURL $ONE_HOST_PORT 1 -star_count $TWO_CURL $TWO_HOST_PORT 1 +retry star_count $TWO_CURL $TWO_HOST_PORT 1 From 2bc5c804ef7e38932b26628acf7f50876c95e05d Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 18 Jul 2024 08:41:26 +0200 Subject: [PATCH 114/203] forgejo: add 9.0 --- forgejo/sources/8.0 | 2 +- forgejo/sources/9.0 | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 forgejo/sources/9.0 diff --git a/forgejo/sources/8.0 b/forgejo/sources/8.0 index 1412273..3c5a3ec 100644 --- a/forgejo/sources/8.0 +++ b/forgejo/sources/8.0 @@ -1 +1 @@ -https://codeberg.org/forgejo/forgejo forgejo 8.0.0+gitea-1.22.0 +https://codeberg.org/forgejo/forgejo forgejo 8.0.0+gitea-1.21.0 diff --git a/forgejo/sources/9.0 b/forgejo/sources/9.0 new file mode 100644 index 0000000..bd6c2d0 --- /dev/null +++ b/forgejo/sources/9.0 @@ -0,0 +1 @@ +https://codeberg.org/forgejo/forgejo forgejo 9.0.0+gitea-1.22.0 From d5f66e4c0a0de8e6c1574cf785256172bb2fddd5 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 7 Aug 2024 08:31:33 +0200 Subject: [PATCH 115/203] shfmt -w globally --- actions/actions.sh | 116 +++++----- actions/example-automerge/run.sh | 2 +- actions/example-cron/run.sh | 8 +- actions/example-post-7-0-schedule/run.sh | 8 +- actions/example-post-7-0-schedule/setup.sh | 2 +- .../example-pull-request/assert-contexts.sh | 8 +- actions/example-pull-request/run.sh | 55 +++-- actions/example-pull-request/setup.sh | 1 - actions/example-push-cancel/run.sh | 2 +- actions/example-service/setup.sh | 4 +- actions/example-workflow-dispatch/run.sh | 10 +- end-to-end.sh | 2 +- federation/federation.sh | 76 +++---- federation/scenario-star/run.sh | 16 +- federation/scenario-star/setup.sh | 1 + federation/scenario-star/teardown.sh | 1 + forgejo/fixtures.sh | 2 +- forgejo/fixtures/storage.sh | 53 ++--- lib/api.sh | 8 +- lib/build.sh | 18 +- lib/lib.sh | 212 +++++++++--------- packages/alpine-1.21/test.sh | 28 +-- packages/alpine-7.0-test/test.sh | 30 +-- packages/alpine.sh | 8 +- storage/storage.sh | 10 +- upgrade/test-pprof-upload.sh | 60 ++--- upgrade/upgrade.sh | 12 +- 27 files changed, 378 insertions(+), 375 deletions(-) diff --git a/actions/actions.sh b/actions/actions.sh index d06027f..f467ba8 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -1,57 +1,57 @@ # Copyright 2024 The Forgejo Authors # SPDX-License-Identifier: MIT -ACTIONS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ACTIONS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" function actions_verify_example() { - local example=$1 + local example=$1 - export HOST_PORT - export url=http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT} - export token=$(cat $DOT_FORGEJO_CURL/token) + export HOST_PORT + export url=http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT} + export token=$(cat $DOT_FORGEJO_CURL/token) - actions_cleanup_example_volume + actions_cleanup_example_volume - export example - export EXAMPLE_DIR=$ACTIONS_DIR/example-$example + export example + export EXAMPLE_DIR=$ACTIONS_DIR/example-$example - if test -f $EXAMPLE_DIR/setup.sh ; then - echo "============================ SETUP example-$example ===================" - bash -ex $EXAMPLE_DIR/setup.sh || return 1 - fi + if test -f $EXAMPLE_DIR/setup.sh; then + echo "============================ SETUP example-$example ===================" + bash -ex $EXAMPLE_DIR/setup.sh || return 1 + fi - if test -f $EXAMPLE_DIR/run.sh ; then - echo "============================ RUN example-$example ===================" - bash -ex $EXAMPLE_DIR/run.sh || return 1 - else - forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example $example $token || return 1 - fi + if test -f $EXAMPLE_DIR/run.sh; then + echo "============================ RUN example-$example ===================" + bash -ex $EXAMPLE_DIR/run.sh || return 1 + else + forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example $example $token || return 1 + fi - if test -f $EXAMPLE_DIR/teardown.sh ; then - echo "============================ TEARDOWN example-$example ===================" - bash -ex $EXAMPLE_DIR/teardown.sh || return 1 - fi + if test -f $EXAMPLE_DIR/teardown.sh; then + echo "============================ TEARDOWN example-$example ===================" + bash -ex $EXAMPLE_DIR/teardown.sh || return 1 + fi - actions_save_contexts $example + actions_save_contexts $example } function actions_save_contexts() { local example="$1" if test -d /srv/example/$example/contexts; then - mkdir -p /srv/contexts - rsync -av /srv/example/$example/contexts/ /srv/contexts/$example/ + mkdir -p /srv/contexts + rsync -av /srv/example/$example/contexts/ /srv/contexts/$example/ fi } function actions_cleanup_example_volume() { - if test $(id -u) != 0 ; then - $SUDO chown $(id -u) /srv + if test $(id -u) != 0; then + $SUDO chown $(id -u) /srv fi - if ! test -d /srv/example ; then - mkdir -p /srv/example - return + if ! test -d /srv/example; then + mkdir -p /srv/example + return fi $SUDO rm -fr /srv/example/* @@ -79,10 +79,10 @@ function actions_teardown() { function actions_runner_version() { local runner_version=$($DIR/forgejo-runner --version | sed -n -e 's/forgejo-runner version v//p') - if test -z "$runner_version" ; then - $DIR/forgejo-runner --version - echo failed to parse version - false + if test -z "$runner_version"; then + $DIR/forgejo-runner --version + echo failed to parse version + false fi echo $runner_version } @@ -90,37 +90,37 @@ function actions_runner_version() { function test_actions() { local versions="${1:-1.21 $RELEASE_NUMBERS_AND_DEV}" - for version in $versions ; do + for version in $versions; do - actions_setup $version - local runner_version=$(actions_runner_version) + actions_setup $version + local runner_version=$(actions_runner_version) - log_info "Testing actions with Forgejo $version & Forgejo runner $runner_version" + log_info "Testing actions with Forgejo $version & Forgejo runner $runner_version" - if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0 ; then - for example in artifacts-v4 ; do - run actions_verify_example $example - done - fi - - for example in echo cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context ; do - run actions_verify_example $example - done - - if 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 automerge post-7-0-schedule ; do + if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0; then + for example in artifacts-v4; do run actions_verify_example $example done fi - if dpkg --compare-versions $version ge 8.0 ; then - for example in workflow-dispatch ; do + for example in echo cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do + run actions_verify_example $example + done + + if 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 automerge post-7-0-schedule; do + run actions_verify_example $example + done + fi + + if dpkg --compare-versions $version ge 8.0; then + for example in workflow-dispatch; do run actions_verify_example $example done fi diff --git a/actions/example-automerge/run.sh b/actions/example-automerge/run.sh index 2134dc4..1d48860 100755 --- a/actions/example-automerge/run.sh +++ b/actions/example-automerge/run.sh @@ -22,7 +22,7 @@ function reset_automerge_pr() { ( cd $d - rm -fr example-automerge + rm -fr example-automerge git clone $url/$repo cd example-automerge git checkout -b other diff --git a/actions/example-cron/run.sh b/actions/example-cron/run.sh index f95045f..bf19e98 100755 --- a/actions/example-cron/run.sh +++ b/actions/example-cron/run.sh @@ -7,7 +7,7 @@ forgejo-test-helper.sh push_workflow actions/example-$example $url root example- # 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') + local ref=$(sqlite3 $DIR/forgejo-work-path/forgejo.db 'select ref from action_schedule') test "${ref##*/}" = "main" } verify_ref @@ -16,12 +16,12 @@ forgejo-curl.sh api_json --data '{"new_branch_name":"zzzz"}' $api/repos/root/exa verify_ref # cron 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/cron-volume/DONE ; then +if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example/cron-volume/DONE; then cat $FORGEJO_RUNNER_LOGS false fi c=/srv/example/cron/contexts/schedule/github cat $c -test "schedule" = "$(jq -r .event_name < $c)" -test "schedule" = "$(jq -r .event.action < $c)" +test "schedule" = "$(jq -r .event_name <$c)" +test "schedule" = "$(jq -r .event.action <$c)" diff --git a/actions/example-post-7-0-schedule/run.sh b/actions/example-post-7-0-schedule/run.sh index e6e1309..29617c1 100755 --- a/actions/example-post-7-0-schedule/run.sh +++ b/actions/example-post-7-0-schedule/run.sh @@ -10,7 +10,7 @@ forgejo-curl.sh web --form name=TEST_SCHEDULE_RUNSON --form data=docker http://$ # 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') + local ref=$(sqlite3 $DIR/forgejo-work-path/forgejo.db 'select ref from action_schedule') test "${ref##*/}" = "main" } verify_ref @@ -19,12 +19,12 @@ forgejo-curl.sh api_json --data '{"new_branch_name":"zzzz"}' $api/repos/root/exa 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 +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)" \ No newline at end of file +test "schedule" = "$(jq -r .event_name <$c)" +test "schedule" = "$(jq -r .event.action <$c)" diff --git a/actions/example-post-7-0-schedule/setup.sh b/actions/example-post-7-0-schedule/setup.sh index 9e17073..5592dbe 100755 --- a/actions/example-post-7-0-schedule/setup.sh +++ b/actions/example-post-7-0-schedule/setup.sh @@ -1 +1 @@ -mkdir -p /srv/example/post-7-0-schedule-volume \ No newline at end of file +mkdir -p /srv/example/post-7-0-schedule-volume diff --git a/actions/example-pull-request/assert-contexts.sh b/actions/example-pull-request/assert-contexts.sh index 57f0257..83cd660 100755 --- a/actions/example-pull-request/assert-contexts.sh +++ b/actions/example-pull-request/assert-contexts.sh @@ -4,8 +4,8 @@ set -ex c=$d/contexts -test opened = "$(jq -r .event.action < $c/fork-org/pull_request/github)" -test opened = "$(jq -r .event.action < $c/fork-org/pull_request_target/github)" +test opened = "$(jq -r .event.action <$c/fork-org/pull_request/github)" +test opened = "$(jq -r .event.action <$c/fork-org/pull_request_target/github)" -test opened = "$(jq -r .event.action < $c/root/pull_request/github)" -test opened = "$(jq -r .event.action < $c/root/pull_request_target/github)" +test opened = "$(jq -r .event.action <$c/root/pull_request/github)" +test opened = "$(jq -r .event.action <$c/root/pull_request_target/github)" diff --git a/actions/example-pull-request/run.sh b/actions/example-pull-request/run.sh index a262e6f..de54e37 100755 --- a/actions/example-pull-request/run.sh +++ b/actions/example-pull-request/run.sh @@ -12,45 +12,44 @@ function main() { forgejo-curl.sh api_json --data-raw '{"organization":"fork-org"}' $api/repos/root/example-pull-request/forks forgejo-curl.sh api_json -X PUT --data-raw '{"data":"AAAA"}' $api/repos/root/example-pull-request/actions/secrets/SECRET - ( - cd $d - git clone $url/fork-org/example-pull-request fork - cd fork - git config user.email root@example.com - git config user.name username - echo fork $PROOF >> README - touch file-unique-to-the-pr-branch - git add . - git commit -m 'fork change' - git push + cd $d + git clone $url/fork-org/example-pull-request fork + cd fork + git config user.email root@example.com + git config user.name username + echo fork $PROOF >>README + touch file-unique-to-the-pr-branch + git add . + git commit -m 'fork change' + git push ) forgejo.sh retry forgejo-curl.sh api_json --data-raw '{"title":"PR from fork","base":"main","head":"fork-org:main"}' $api/repos/root/example-pull-request/pulls ( - cd $d - git clone $url/root/example-pull-request - cd example-pull-request - git checkout -b other - git config user.email root@example.com - git config user.name username - touch file-unique-to-the-pr-branch - echo other $PROOF >> README - git add . - git commit -m 'other change' - git push --force -u origin other + cd $d + git clone $url/root/example-pull-request + cd example-pull-request + git checkout -b other + git config user.email root@example.com + git config user.name username + touch file-unique-to-the-pr-branch + echo other $PROOF >>README + git add . + git commit -m 'other change' + git push --force -u origin other ) forgejo.sh retry forgejo-curl.sh api_json --data-raw '{"title":"PR same repo","base":"main","head":"other"}' $api/repos/root/example-pull-request/pulls export RETRY_DELAYS="60 60 60 60 60 60 60" - for assert in $EXAMPLE_DIR/assert-*.sh ; do - if ! forgejo.sh retry $assert ; then - find $d - sed -e 's/^/[RUNNER LOGS]/' < $FORGEJO_RUNNER_LOGS - false - fi + for assert in $EXAMPLE_DIR/assert-*.sh; do + if ! forgejo.sh retry $assert; then + find $d + sed -e 's/^/[RUNNER LOGS]/' <$FORGEJO_RUNNER_LOGS + false + fi done } diff --git a/actions/example-pull-request/setup.sh b/actions/example-pull-request/setup.sh index 72c13c0..5f46962 100755 --- a/actions/example-pull-request/setup.sh +++ b/actions/example-pull-request/setup.sh @@ -1,2 +1 @@ mkdir -p /srv/example/pull-request - diff --git a/actions/example-push-cancel/run.sh b/actions/example-push-cancel/run.sh index d6705d8..891798e 100755 --- a/actions/example-push-cancel/run.sh +++ b/actions/example-push-cancel/run.sh @@ -11,7 +11,7 @@ forgejo-test-helper.sh wait_running $url $repo $sha # # push to the same branch # -forgejo-test-helper.sh push_workflow actions/example-echo $url root example-$example setup-forgejo $token +forgejo-test-helper.sh push_workflow actions/example-echo $url root example-$example setup-forgejo $token # # wait for the workflow to be canceled as a result of the previous push # diff --git a/actions/example-service/setup.sh b/actions/example-service/setup.sh index 3a9674e..7bc1672 100755 --- a/actions/example-service/setup.sh +++ b/actions/example-service/setup.sh @@ -1,3 +1,3 @@ -> /srv/example-service-volume-valid -> /srv/example-service-volume-invalid +>/srv/example-service-volume-valid +>/srv/example-service-volume-invalid FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload diff --git a/actions/example-workflow-dispatch/run.sh b/actions/example-workflow-dispatch/run.sh index ed55070..8a49365 100755 --- a/actions/example-workflow-dispatch/run.sh +++ b/actions/example-workflow-dispatch/run.sh @@ -10,7 +10,7 @@ api=$url/api/v1 repo=root/example-$example function context_wait() { - if ! forgejo.sh retry test -f $context ; then + if ! forgejo.sh retry test -f $context; then cat "$FORGEJO_RUNNER_LOGS" false fi @@ -19,7 +19,7 @@ function context_wait() { function verify_required() { local actual=$(forgejo-curl.sh api_json -w '%{http_code}' --data '{"ref":"main","inputs":{}}' $api/repos/$repo/actions/workflows/test.yml/dispatches) local expected=400 - if test "$actual" != $expected ; then + if test "$actual" != $expected; then log_info "dispatch is expected to fail with status $expected because of string2 is a required value but got status $actual instead" return 1 fi @@ -28,7 +28,7 @@ function verify_required() { function verify_inputs() { local inputs='{"string2":"value2"}' forgejo-curl.sh api_json --data '{"ref":"main","inputs":'$inputs'}' $api/repos/$repo/actions/workflows/test.yml/dispatches - cat > $TMPDIR/expected <<'EOF' + cat >$TMPDIR/expected <<'EOF' { "boolean_default_false": "false", "boolean_default_true": "true", @@ -46,7 +46,7 @@ function run_tests() { npm --silent install json-diff verify_inputs context_wait - node_modules/.bin/json-diff <(jq .event.inputs < $context) $TMPDIR/expected + node_modules/.bin/json-diff <(jq .event.inputs <$context) $TMPDIR/expected } function main() { @@ -56,7 +56,7 @@ function main() { run_tests - test "workflow_dispatch" = "$(jq -r .event_name < $context)" + test "workflow_dispatch" = "$(jq -r .event_name <$context)" } main diff --git a/end-to-end.sh b/end-to-end.sh index ab9454b..05865ac 100755 --- a/end-to-end.sh +++ b/end-to-end.sh @@ -11,7 +11,7 @@ # Everything happens in /tmp/forgejo-end-to-end # -SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SELF="${BASH_SOURCE[0]}" source $SELF_DIR/lib/lib.sh diff --git a/federation/federation.sh b/federation/federation.sh index 7fbb215..f0acfcf 100755 --- a/federation/federation.sh +++ b/federation/federation.sh @@ -1,46 +1,46 @@ # Copyright 2024 The Forgejo Authors # SPDX-License-Identifier: MIT -FEDERATION_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +FEDERATION_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" export FEDERATION_INSTANCES="ONE TWO" export FEDERATION_CONFIGS function federation_setup_variables() { - if test "$FEDERATION_CONFIGS" ; then - return + if test "$FEDERATION_CONFIGS"; then + return fi - for instance in $FEDERATION_INSTANCES ; do - local config=$FEDERATION_DIR/$instance-app.ini - FEDERATION_CONFIGS="$FEDERATION_CONFIGS $config" - local base=$(work_path_base $config) - local work_path=$DIR/$base - local host_port=$(get_host_port $config) + for instance in $FEDERATION_INSTANCES; do + local config=$FEDERATION_DIR/$instance-app.ini + FEDERATION_CONFIGS="$FEDERATION_CONFIGS $config" + local base=$(work_path_base $config) + local work_path=$DIR/$base + local host_port=$(get_host_port $config) - eval export ${instance}_CONFIG=$config - eval export ${instance}_CURL=$work_path/forgejo-curl.sh - eval export ${instance}_HOST_PORT=$host_port + eval export ${instance}_CONFIG=$config + eval export ${instance}_CURL=$work_path/forgejo-curl.sh + eval export ${instance}_HOST_PORT=$host_port done } function federation_verify_scenario() { - local scenario=$1 + local scenario=$1 - export scenario - export SCENARIO_DIR=$FEDERATION_DIR/scenario-$scenario + export scenario + export SCENARIO_DIR=$FEDERATION_DIR/scenario-$scenario - if test -f $SCENARIO_DIR/setup.sh ; then - echo "============================ SETUP scenario-$scenario ===================" - bash -ex $SCENARIO_DIR/setup.sh || return 1 - fi + if test -f $SCENARIO_DIR/setup.sh; then + echo "============================ SETUP scenario-$scenario ===================" + bash -ex $SCENARIO_DIR/setup.sh || return 1 + fi - echo "============================ RUN scenario-$scenario ===================" - bash -ex $SCENARIO_DIR/run.sh || return 1 + echo "============================ RUN scenario-$scenario ===================" + bash -ex $SCENARIO_DIR/run.sh || return 1 - if test -f $SCENARIO_DIR/teardown.sh ; then - echo "============================ TEARDOWN scenario-$scenario ===================" - bash -ex $SCENARIO_DIR/teardown.sh || return 1 - fi + if test -f $SCENARIO_DIR/teardown.sh; then + echo "============================ TEARDOWN scenario-$scenario ===================" + bash -ex $SCENARIO_DIR/teardown.sh || return 1 + fi } function federation_setup() { @@ -50,9 +50,9 @@ function federation_setup() { federation_teardown local config - for config in $FEDERATION_CONFIGS ; do - reset_forgejo $config - start_forgejo $version $config + for config in $FEDERATION_CONFIGS; do + reset_forgejo $config + start_forgejo $version $config done } @@ -60,8 +60,8 @@ function federation_teardown() { federation_setup_variables local config - for config in $FEDERATION_CONFIGS ; do - stop_forgejo $config + for config in $FEDERATION_CONFIGS; do + stop_forgejo $config done } @@ -71,16 +71,16 @@ function test_federation() { local versions="${1:-$RELEASE_NUMBERS_AND_DEV}" - for version in $versions ; do + for version in $versions; do - if dpkg --compare-versions $version lt 7.1 ; then - continue - fi + if dpkg --compare-versions $version lt 7.1; then + continue + fi - federation_setup $version + federation_setup $version - for scenario in star ; do - run federation_verify_scenario $scenario - done + for scenario in star; do + run federation_verify_scenario $scenario + done done } diff --git a/federation/scenario-star/run.sh b/federation/scenario-star/run.sh index 15db8e2..ad340d2 100644 --- a/federation/scenario-star/run.sh +++ b/federation/scenario-star/run.sh @@ -9,20 +9,20 @@ function star_count() { local host_port=$2 local count=$3 - $curl api_json http://$host_port/api/v1/repos/root/test > $TMPDIR/count.json - if test $count != $(jq -r .stars_count < $TMPDIR/count.json) ; then - jq . < $TMPDIR/count.json - return 1 + $curl api_json http://$host_port/api/v1/repos/root/test >$TMPDIR/count.json + if test $count != $(jq -r .stars_count <$TMPDIR/count.json); then + jq . <$TMPDIR/count.json + return 1 fi } # # create a repo on each instance # -$ONE_CURL api_json --data '{"name":"test","auto_init":true}' $ONE_HOST_PORT/api/v1/user/repos > $TMPDIR/one-repo.json -one_repo_id=$(jq -r .id < $TMPDIR/one-repo.json) -$TWO_CURL api_json --data '{"name":"test","auto_init":true}' $TWO_HOST_PORT/api/v1/user/repos > $TMPDIR/two-repo.json -two_repo_id=$(jq -r .id < $TMPDIR/two-repo.json) +$ONE_CURL api_json --data '{"name":"test","auto_init":true}' $ONE_HOST_PORT/api/v1/user/repos >$TMPDIR/one-repo.json +one_repo_id=$(jq -r .id <$TMPDIR/one-repo.json) +$TWO_CURL api_json --data '{"name":"test","auto_init":true}' $TWO_HOST_PORT/api/v1/user/repos >$TMPDIR/two-repo.json +two_repo_id=$(jq -r .id <$TMPDIR/two-repo.json) # # the repo in instance two is federated with the repo in instance one diff --git a/federation/scenario-star/setup.sh b/federation/scenario-star/setup.sh index e69de29..8b13789 100644 --- a/federation/scenario-star/setup.sh +++ b/federation/scenario-star/setup.sh @@ -0,0 +1 @@ + diff --git a/federation/scenario-star/teardown.sh b/federation/scenario-star/teardown.sh index e69de29..8b13789 100644 --- a/federation/scenario-star/teardown.sh +++ b/federation/scenario-star/teardown.sh @@ -0,0 +1 @@ + diff --git a/forgejo/fixtures.sh b/forgejo/fixtures.sh index 9e7f5ca..b49abf5 100644 --- a/forgejo/fixtures.sh +++ b/forgejo/fixtures.sh @@ -1,6 +1,6 @@ # SPDX-License-Identifier: MIT -FIXTURES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +FIXTURES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source $FIXTURES_DIR/fixtures/storage.sh source $FIXTURES_DIR/fixtures/doctor.sh diff --git a/forgejo/fixtures/storage.sh b/forgejo/fixtures/storage.sh index 0de79b5..cf893b8 100644 --- a/forgejo/fixtures/storage.sh +++ b/forgejo/fixtures/storage.sh @@ -15,7 +15,7 @@ function fixture_get_paths_s3() { ( mc ls --quiet --recursive testS3/$path | sed -e "s|.* |$path/|" - ) > $DIR/path + ) >$DIR/path } function fixture_content_search_s3() { @@ -23,15 +23,15 @@ function fixture_content_search_s3() { local expected="$2" fixture_get_paths_s3 $path - if test $(wc -l < $DIR/path) -lt 1 ; then - echo expected at least one but got "'$(cat $DIR/path)'" - return 1 + if test $(wc -l <$DIR/path) -lt 1; then + echo expected at least one but got "'$(cat $DIR/path)'" + return 1 fi - for filename in $(cat $DIR/path) ; do - local content=$(mc cat testS3/$filename | base64 -w0) - if test "$content" = "$expected" ; then - return 0 - fi + for filename in $(cat $DIR/path); do + local content=$(mc cat testS3/$filename | base64 -w0) + if test "$content" = "$expected"; then + return 0 + fi done echo nothing in $path found with the expected content "$expected" return 1 @@ -41,7 +41,10 @@ function fixture_get_paths_local() { local path=$1 local work_path=$DIR/forgejo-work-path - ( cd $work_path ; find $path -type f) > $DIR/path + ( + cd $work_path + find $path -type f + ) >$DIR/path } function fixture_get_one_path() { @@ -50,7 +53,7 @@ function fixture_get_one_path() { fixture_get_paths_$storage $path - if test $(wc -l < $DIR/path) != 1 ; then + if test $(wc -l <$DIR/path) != 1; then echo expected one path but got cat $DIR/path return 1 @@ -77,7 +80,7 @@ function fixture_lfs_create() { ( cd $DIR/fixture git lfs track "*.txt" - echo CONTENT > file.txt + echo CONTENT >file.txt git add . git commit -m 'lfs files' git push @@ -87,11 +90,11 @@ function fixture_lfs_create() { function fixture_lfs_assert() { local d=$(mktemp -d) ( - git clone http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO} $d/${FORGEJO_REPO} - cd $d/${FORGEJO_REPO} - rm file.txt + git clone http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO} $d/${FORGEJO_REPO} + cd $d/${FORGEJO_REPO} + rm file.txt git-lfs checkout file.txt - test -f file.txt + test -f file.txt ) rm -fr $d } @@ -110,7 +113,7 @@ function fixture_lfs_assert_local() { } function fixture_packages_create() { - echo PACKAGE_CONTENT > $DIR/fixture/package + echo PACKAGE_CONTENT >$DIR/fixture/package forgejo-curl.sh api_json -X DELETE http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt || true forgejo-curl.sh api_json --upload-file $DIR/fixture/package http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt } @@ -128,7 +131,7 @@ function fixture_packages_assert_local() { } function fixture_avatars_create() { - echo -n $ONEPIXEL | base64 --decode > $DIR/avatar.png + echo -n $ONEPIXEL | base64 --decode >$DIR/avatar.png forgejo-curl.sh web --form avatar=@$DIR/avatar.png http://${HOST_PORT}/user/settings/avatar } @@ -145,7 +148,7 @@ function fixture_avatars_assert_local() { } function fixture_repo_avatars_create() { - echo -n $ONEPIXEL | base64 --decode > $DIR/repo-avatar.png + echo -n $ONEPIXEL | base64 --decode >$DIR/repo-avatar.png forgejo-curl.sh web --form avatar=@$DIR/repo-avatar.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/settings/avatar # v1.21 only #forgejo-curl.sh api_json -X POST --data-raw '{"body":"'$avatar'"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/avatar @@ -166,17 +169,17 @@ function fixture_repo_avatars_assert_local() { } function fixture_attachments_create_1_18() { - echo -n $ONEPIXEL | base64 --decode > $DIR/attachment.png + echo -n $ONEPIXEL | base64 --decode >$DIR/attachment.png forgejo-curl.sh web --trace-ascii - --form file=@$DIR/attachment.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/issues/attachments } function fixture_attachments_create() { - if forgejo-curl.sh api_json http://${HOST_PORT}/api/v1/version | grep --quiet --fixed-strings 1.18. ; then + if forgejo-curl.sh api_json http://${HOST_PORT}/api/v1/version | grep --quiet --fixed-strings 1.18.; then fixture_attachments_create_1_18 return fi id=$(forgejo-curl.sh api_json --data-raw '{"title":"TITLE"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues | jq .id) - echo -n $ONEPIXEL | base64 --decode > $DIR/attachment.png + echo -n $ONEPIXEL | base64 --decode >$DIR/attachment.png forgejo-curl.sh api --form name=attachment.png --form attachment=@$DIR/attachment.png http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues/$id/assets } @@ -206,18 +209,18 @@ function fixture_create() { git remote add origin http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO} git config user.email root@example.com git config user.name username - echo SOMETHING > README + echo SOMETHING >README git add README git commit -m 'initial commit' git push --set-upstream --force origin main ) - for fun in ${STORAGE_FUN} ; do + for fun in ${STORAGE_FUN}; do fixture_${fun}_create done } function fixture_assert() { - for fun in lfs ; do + for fun in lfs; do fixture_${fun}_assert done } diff --git a/lib/api.sh b/lib/api.sh index 03db36c..cc56f50 100644 --- a/lib/api.sh +++ b/lib/api.sh @@ -14,16 +14,16 @@ function api_user_make_admin() { function api_user_create() { local api="$1" username="$2" email="$3" log_info "(re)create user $username" - forgejo-curl.sh api_json -X DELETE $api/admin/users/$username?purge=true >& /dev/null || true + forgejo-curl.sh api_json -X DELETE $api/admin/users/$username?purge=true >&/dev/null || true forgejo-curl.sh api_json --data '{"username":"'$username'","email":"'$email'","password":"admin1234","must_change_password":false}' $api/admin/users } function user_login() { local username=$1 ( - export DOT=$API_TMPDIR/$username - forgejo-curl.sh logout - forgejo-curl.sh --user $username --password "admin1234" login http://${HOST_PORT} + export DOT=$API_TMPDIR/$username + forgejo-curl.sh logout + forgejo-curl.sh --user $username --password "admin1234" login http://${HOST_PORT} ) } diff --git a/lib/build.sh b/lib/build.sh index 11bdf3a..bbef73e 100755 --- a/lib/build.sh +++ b/lib/build.sh @@ -4,16 +4,16 @@ set -ex -SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" version=$1 dir_binaries=$2 v=$(echo $version | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/') src=$dir_binaries/src-$v -read url ref semver < $SELF_DIR/../forgejo/sources/$v +read url ref semver <$SELF_DIR/../forgejo/sources/$v -if ! test -d $src ; then +if ! test -d $src; then mkdir -p $src cd $src git init @@ -22,15 +22,15 @@ else cd $src fi -if ! [[ "$ref" =~ ^refs/ ]] ; then +if ! [[ "$ref" =~ ^refs/ ]]; then ref=refs/heads/$ref fi -for retry in 1 2 3 ; do - if timeout 15m git fetch --update-head-ok origin +$ref:$ref ; then - break +for retry in 1 2 3; do + if timeout 15m git fetch --update-head-ok origin +$ref:$ref; then + break else - echo "Retry git fetch in 60 seconds" - sleep 60 + echo "Retry git fetch in 60 seconds" + sleep 60 fi done git fetch --update-head-ok origin +$ref:$ref diff --git a/lib/lib.sh b/lib/lib.sh index 7448536..295c0eb 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -2,11 +2,11 @@ # Copyright 2024 The Forgejo Authors # SPDX-License-Identifier: MIT -LIB_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source $LIB_DIR/api.sh -if ${VERBOSE:-false} ; then +if ${VERBOSE:-false}; then set -ex PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: ' else @@ -17,8 +17,8 @@ set -o pipefail export DEBIAN_FRONTEND=noninteractive -if test $(id -u) != 0 ; then - SUDO=sudo +if test $(id -u) != 0; then + SUDO=sudo fi IP=$(hostname -I | cut -f1 -d' ') @@ -35,7 +35,7 @@ export DOT_FORGEJO_CURL=$DIR/forgejo-curl export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 : ${FORGEJO_USER:=root} : ${FORGEJO_PASSWORD:=admin1234} -: ${RELEASE_NUMBERS_AND_DEV:="$(for r in $RELEASE_NUMBERS ; do echo -n "$r $r-dev " ; done)"} +: ${RELEASE_NUMBERS_AND_DEV:="$(for r in $RELEASE_NUMBERS; do echo -n "$r $r-dev "; done)"} ORGANIZATIONS=$(cat $LIB_DIR/ORGANIZATIONS) function log_info() { @@ -44,50 +44,50 @@ function log_info() { function dependencies() { - if ! test -f /usr/local/bin/forgejo-curl.sh ; then - $SUDO curl --fail -sS https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh -o /usr/local/bin/forgejo-curl.sh - $SUDO chmod +x /usr/local/bin/forgejo-curl.sh + if ! test -f /usr/local/bin/forgejo-curl.sh; then + $SUDO curl --fail -sS https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh -o /usr/local/bin/forgejo-curl.sh + $SUDO chmod +x /usr/local/bin/forgejo-curl.sh fi - if ! which make curl daemon git-lfs jq sqlite3 skopeo > /dev/null ; then + if ! which make curl daemon git-lfs jq sqlite3 skopeo >/dev/null; then $SUDO apt-get update -qq $SUDO apt-get install -y -qq make curl daemon git-lfs jq sqlite3 skopeo fi - if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio ; then + if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio; then $SUDO curl --fail -sS https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc $SUDO curl --fail -sS https://dl.min.io/server/minio/release/linux-amd64/minio -o /usr/local/bin/minio fi - if ! test -x /usr/local/bin/mc || ! test -x /usr/local/bin/minio ; then + if ! test -x /usr/local/bin/mc || ! test -x /usr/local/bin/minio; then $SUDO chmod +x /usr/local/bin/mc $SUDO chmod +x /usr/local/bin/minio fi - if ! test -f /usr/local/bin/garage > /dev/null ; then + if ! test -f /usr/local/bin/garage >/dev/null; then $SUDO curl --fail -sS https://garagehq.deuxfleurs.fr/_releases/v0.8.2/x86_64-unknown-linux-musl/garage -o /usr/local/bin/garage fi - if ! test -x /usr/local/bin/garage > /dev/null ; then + if ! test -x /usr/local/bin/garage >/dev/null; then $SUDO chmod +x /usr/local/bin/garage fi } function build_all() { - for dev in $RELEASE_NUMBERS ; do - local forgejo=$DIR_BINARIES/forgejo-$dev-dev - if test -f $forgejo ; then - log_info $dev already exists - else - $LIB_DIR/build.sh $dev $DIR_BINARIES - log_info $dev built from sources - fi + for dev in $RELEASE_NUMBERS; do + local forgejo=$DIR_BINARIES/forgejo-$dev-dev + if test -f $forgejo; then + log_info $dev already exists + else + $LIB_DIR/build.sh $dev $DIR_BINARIES + log_info $dev built from sources + fi done } function retry() { rm -f $DIR/wait-for.out success=false - for delay in 1 1 5 5 15 ; do - if "$@" >> $DIR/wait-for.out 2>&1 ; then + for delay in 1 1 5 5 15; do + if "$@" >>$DIR/wait-for.out 2>&1; then success=true break fi @@ -95,7 +95,7 @@ function retry() { echo waiting $delay sleep $delay done - if test $success = false ; then + if test $success = false; then cat $DIR/wait-for.out return 1 fi @@ -105,36 +105,36 @@ function full_version() { local version=$1 local owner=$2 - if [[ $version =~ ^[0-9]+\.[0-9]+$ ]] ; then - full_version=$(curl -sS "https://codeberg.org/api/v1/repos/$owner/forgejo/releases?limit=50" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort --reverse --version-sort | head -1) - echo ${full_version#v} + if [[ $version =~ ^[0-9]+\.[0-9]+$ ]]; then + full_version=$(curl -sS "https://codeberg.org/api/v1/repos/$owner/forgejo/releases?limit=50" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort --reverse --version-sort | head -1) + echo ${full_version#v} else - echo $version + echo $version fi } function download_forgejo() { local version=$1 - if ! test -f $DIR_BINARIES/forgejo-$version ; then + if ! test -f $DIR_BINARIES/forgejo-$version; then mkdir -p $DIR_BINARIES - for owner in $ORGANIZATIONS ; do - full_version=$(full_version $version $owner) - if test "$full_version" = "" ; then - continue - fi - if wget -O $DIR_BINARIES/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64 ; then - break - fi - done - if test -s $DIR_BINARIES/forgejo-$version ; then - if test "$version" != "$full_version" ; then - log_info "downloaded Forgejo $full_version for $version" - fi - else - echo unable to download Forgejo $version - return 1 - fi + for owner in $ORGANIZATIONS; do + full_version=$(full_version $version $owner) + if test "$full_version" = ""; then + continue + fi + if wget -O $DIR_BINARIES/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64; then + break + fi + done + if test -s $DIR_BINARIES/forgejo-$version; then + if test "$version" != "$full_version"; then + log_info "downloaded Forgejo $full_version for $version" + fi + else + echo unable to download Forgejo $version + return 1 + fi chmod +x $DIR_BINARIES/forgejo-$version fi } @@ -142,9 +142,9 @@ function download_forgejo() { function download_gitea() { local version=$1 - if ! test -f $DIR_BINARIES/gitea-$version ; then + if ! test -f $DIR_BINARIES/gitea-$version; then mkdir -p $DIR_BINARIES - if [[ $version =~ ^[0-9]+\.[0-9]+$ ]] ; then + if [[ $version =~ ^[0-9]+\.[0-9]+$ ]]; then full_version=$(curl -sS "https://api.github.com/repos/go-gitea/gitea/releases?per_page=100" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | grep -v -e '-rc' | sort --reverse --version-sort | head -1) full_version=${full_version#v} else @@ -152,8 +152,8 @@ function download_gitea() { fi wget -O $DIR_BINARIES/gitea-$version --quiet https://dl.gitea.com/gitea/$full_version/gitea-$full_version-linux-amd64 - if test -s $DIR_BINARIES/gitea-$version ; then - if test "$version" != "$full_version" ; then + if test -s $DIR_BINARIES/gitea-$version; then + if test "$version" != "$full_version"; then log_info "downloaded Gitea $full_version for $version" fi else @@ -185,18 +185,18 @@ function clobber() { function start_gitlab_cache_load() { local image=$1 local d=$DIR_BINARIES/gitlab - if test -d $d ; then - log_info "loading $image from $d" - skopeo copy dir:$d docker-daemon:$image + if test -d $d; then + log_info "loading $image from $d" + skopeo copy dir:$d docker-daemon:$image fi } function start_gitlab_cache_save() { local image=$1 local d=$DIR_BINARIES/gitlab - if ! test -d $d ; then - log_info "saving $image to $d" - skopeo copy docker-daemon:$image dir:$d + if ! test -d $d; then + log_info "saving $image to $d" + skopeo copy docker-daemon:$image dir:$d fi } @@ -208,21 +208,21 @@ function start_gitlab() { local GITLAB_OMNIBUS_CONFIG="nginx['listen_https'] = false ; nginx['listen_port'] = 8181 ; external_url 'http://$IP:$GITLAB_PORT'; gitlab_rails['gitlab_shell_ssh_port'] = 2221; $config" docker run --name="test-gitlab" --shm-size=128M -d \ - -e GITLAB_OMNIBUS_CONFIG="$GITLAB_OMNIBUS_CONFIG" \ - -p 2221:22 -p $GITLAB_PORT:8181 \ - $image >& /dev/null < /dev/null + -e GITLAB_OMNIBUS_CONFIG="$GITLAB_OMNIBUS_CONFIG" \ + -p 2221:22 -p $GITLAB_PORT:8181 \ + $image >&/dev/null /dev/null + grep '' $work_path/log/*.log 2>/dev/null return 1 fi - echo "$binary --config $work_path/app.ini --work-path $work_path" '"$@"' > $work_path/forgejocli + echo "$binary --config $work_path/app.ini --work-path $work_path" '"$@"' >$work_path/forgejocli chmod +x $work_path/forgejocli cp -a $work_path/forgejocli $DIR/forgejocli # because setup-forgejo/forgejo-runner.sh expects it here create_user_and_login $version $config @@ -277,18 +277,18 @@ function start_forgejo_daemon() { function start_minio() { mkdir -p $DIR/minio daemon --chdir=$DIR --unsafe \ - --env="PATH=$PATH" \ - --env=MINIO_ROOT_USER=123456 \ - --env=MINIO_ROOT_PASSWORD=12345678 \ - --env=MINIO_VOLUMES=$DIR/minio \ - --pidfile=$DIR/minio-pid --errlog=$DIR/minio-err.log --output=$DIR/minio-out.log -- /usr/local/bin/minio server - retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678 >& /dev/null + --env="PATH=$PATH" \ + --env=MINIO_ROOT_USER=123456 \ + --env=MINIO_ROOT_PASSWORD=12345678 \ + --env=MINIO_VOLUMES=$DIR/minio \ + --pidfile=$DIR/minio-pid --errlog=$DIR/minio-err.log --output=$DIR/minio-out.log -- /usr/local/bin/minio server + retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678 >&/dev/null mc alias set testS3 http://127.0.0.1:9000 123456 12345678 } function start_garage() { mkdir -p $DIR/garage/{data,meta} - cat > $DIR/garage/garage.toml <$DIR/garage/garage.toml < $work_path/app.ini + -e "s|\${WORK_PATH}|$work_path|g" \ + -e "s|^WORK_PATH = .*|WORK_PATH = $work_path|" \ + <$config >$work_path/app.ini } function reset_minio() { @@ -391,19 +391,19 @@ function create_user_and_login() { local work_path=$DIR/$(work_path_base $config) local email="$FORGEJO_USER@example.com" - if ! $work_path/forgejocli admin user list | grep --quiet "$email" ; then - $work_path/forgejocli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email + if ! $work_path/forgejocli admin user list | grep --quiet "$email"; then + $work_path/forgejocli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email fi forgejo-curl.sh logout local scopes='--scopes ["all"]' - if echo $version | grep --quiet 1.18 ; then + if echo $version | grep --quiet 1.18; then scopes="" fi forgejo-curl.sh --user "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" $scopes login http://$(get_host_port $config) local forgejo_curl=$work_path/forgejo-curl.sh - cat > $forgejo_curl <$forgejo_curl < $DIR/$fun.out + >$DIR/$fun.out tail --follow $DIR/$fun.out |& sed --unbuffered -n -e "/^$PREFIX/s/^$PREFIX //p" & local pid=$! - if ! VERBOSE=true $SELF $fun "$@" >& $DIR/$fun.out ; then + if ! VERBOSE=true $SELF $fun "$@" >&$DIR/$fun.out; then kill $pid cat $DIR/$fun.out echo Failure running $fun diff --git a/packages/alpine-1.21/test.sh b/packages/alpine-1.21/test.sh index e210879..93a3aba 100755 --- a/packages/alpine-1.21/test.sh +++ b/packages/alpine-1.21/test.sh @@ -33,20 +33,20 @@ sudo -u user APKBUILD=alpine/APKBUILD abuild -r # upload new package cd packages/srv/x86_64/ for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do - # remove old package - curl \ - --fail \ - -H "Authorization: token $forgejo_token" \ - -X DELETE \ - "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174/$file" \ - || true + # remove old package + curl \ + --fail \ + -H "Authorization: token $forgejo_token" \ + -X DELETE \ + "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174/$file" || + true - # upload new package - curl \ - --fail \ - -H "Authorization: token $forgejo_token" \ - -T "$file" \ - "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174" + # upload new package + curl \ + --fail \ + -H "Authorization: token $forgejo_token" \ + -T "$file" \ + "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174" done # ensure that the install-if condition works as expected @@ -54,5 +54,5 @@ apk add openrc (cd /etc/apk/keys && curl -JO $forgejo_url/api/packages/root/alpine/key) echo "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174" >>/etc/apk/repositories apk add forgejo-2174 -[ -e /usr/bin/forgejo_2174 ] # from the installed package +[ -e /usr/bin/forgejo_2174 ] # from the installed package [ -e /etc/init.d/forgejo_2174 ] # from the -openrc package installed because of the install-if condition diff --git a/packages/alpine-7.0-test/test.sh b/packages/alpine-7.0-test/test.sh index 45bb60e..82565d0 100755 --- a/packages/alpine-7.0-test/test.sh +++ b/packages/alpine-7.0-test/test.sh @@ -36,20 +36,20 @@ sudo -u user APKBUILD=alpine/forgejo-2173/APKBUILD abuild -r # upload new package cd packages/alpine/x86_64/ for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do - # remove old package - curl \ - --fail \ - -H "Authorization: token $forgejo_token" \ - -X DELETE \ - "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests/$file" \ - || true + # remove old package + curl \ + --fail \ + -H "Authorization: token $forgejo_token" \ + -X DELETE \ + "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests/$file" || + true - # upload new package - curl \ - --fail \ - -H "Authorization: token $forgejo_token" \ - -T "$file" \ - "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests" + # upload new package + curl \ + --fail \ + -H "Authorization: token $forgejo_token" \ + -T "$file" \ + "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests" done # ensure that the install-if condition works as expected @@ -57,7 +57,7 @@ apk add openrc (cd /etc/apk/keys && curl -JO $forgejo_url/api/packages/root/alpine/key) echo "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests" >>/etc/apk/repositories apk add forgejo-2174 forgejo-2173 -[ -e /usr/bin/forgejo_2174 ] # from the installed package -[ -e /usr/bin/forgejo_2173 ] # from the installed package +[ -e /usr/bin/forgejo_2174 ] # from the installed package +[ -e /usr/bin/forgejo_2173 ] # from the installed package [ -e /etc/init.d/forgejo_2174 ] # from the -openrc package installed because of the install-if condition [ -e /etc/init.d/forgejo_2173 ] # from the -openrc package installed because of the install-if condition diff --git a/packages/alpine.sh b/packages/alpine.sh index ae82913..79595ae 100644 --- a/packages/alpine.sh +++ b/packages/alpine.sh @@ -16,9 +16,9 @@ function test_packages_alpine_version() { } function test_packages_alpine() { - for alpine_version in 3.18 3.19 ; do - for forgejo_version in 1.21 7.0-test 7.0-dev ; do - test_packages_alpine_version $alpine_version $forgejo_version - done + for alpine_version in 3.18 3.19; do + for forgejo_version in 1.21 7.0-test 7.0-dev; do + test_packages_alpine_version $alpine_version $forgejo_version + done done } diff --git a/storage/storage.sh b/storage/storage.sh index a531e50..e96a0d3 100755 --- a/storage/storage.sh +++ b/storage/storage.sh @@ -1,6 +1,6 @@ # SPDX-License-Identifier: MIT -STORAGE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +STORAGE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars" @@ -14,7 +14,7 @@ function storage_reset() { function verify_storage() { local work_path=$DIR/forgejo-work-path - for path in ${STORAGE_PATHS} ; do + for path in ${STORAGE_PATHS}; do test -d $work_path/data/$path done } @@ -22,7 +22,7 @@ function verify_storage() { function cleanup_storage() { local work_path=$DIR/forgejo-work-path - for path in ${STORAGE_PATHS} ; do + for path in ${STORAGE_PATHS}; do rm -fr $work_path/data/$path done } @@ -33,13 +33,13 @@ function test_storage_stable_s3() { log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338" - for version in 1.21 $RELEASE_NUMBERS_AND_DEV ; do + for version in 1.21 $RELEASE_NUMBERS_AND_DEV; do log_info "Forgejo $version & $s3_backend" stop storage_reset stable-s3 start $version $s3_backend fixture_create - for fun in ${STORAGE_FUN} ; do + for fun in ${STORAGE_FUN}; do fixture_${fun}_assert_s3 done done diff --git a/upgrade/test-pprof-upload.sh b/upgrade/test-pprof-upload.sh index e5ab46d..48dada4 100644 --- a/upgrade/test-pprof-upload.sh +++ b/upgrade/test-pprof-upload.sh @@ -1,43 +1,43 @@ # SPDX-License-Identifier: MIT function test_upload_profiles() { - FORGEJO_URL="http://localhost:6060" - PROFILECLI_URL="http://0.0.0.0:4040" + FORGEJO_URL="http://localhost:6060" + PROFILECLI_URL="http://0.0.0.0:4040" - endpoints=("/debug/pprof/allocs" "/debug/pprof/block" "/debug/pprof/goroutine" "/debug/pprof/mutex" "/debug/pprof/profile?seconds=5") - curl -fL https://github.com/grafana/pyroscope/releases/download/v1.1.5/profilecli_1.1.5_linux_amd64.tar.gz -o profilecli.tar.gz - tar xzf profilecli.tar.gz + endpoints=("/debug/pprof/allocs" "/debug/pprof/block" "/debug/pprof/goroutine" "/debug/pprof/mutex" "/debug/pprof/profile?seconds=5") + curl -fL https://github.com/grafana/pyroscope/releases/download/v1.1.5/profilecli_1.1.5_linux_amd64.tar.gz -o profilecli.tar.gz + tar xzf profilecli.tar.gz - for endpoint in "${endpoints[@]}"; do - output=$(basename "$endpoint") - if [[ $endpoint == *"/profile"* ]]; then - output="profile" - fi - output="${output}.pprof" - # Download the content and save it to a file - curl -s "${FORGEJO_URL}${endpoint}" -o "${output}" - ./profilecli upload ${output} --url=${PROFILECLI_URL} + for endpoint in "${endpoints[@]}"; do + output=$(basename "$endpoint") + if [[ $endpoint == *"/profile"* ]]; then + output="profile" + fi + output="${output}.pprof" + # Download the content and save it to a file + curl -s "${FORGEJO_URL}${endpoint}" -o "${output}" + ./profilecli upload ${output} --url=${PROFILECLI_URL} - rm ${output} - done + rm ${output} + done } function test_forgejo_pprof() { - stop - docker rm -f test_pyroscope - docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope + stop + docker rm -f test_pyroscope + docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope - reset_forgejo $UPGRADE_DIR/default-app.ini - log_info "run 7.0-test" - start 7.0-test - test_upload_profiles - stop + reset_forgejo $UPGRADE_DIR/default-app.ini + log_info "run 7.0-test" + start 7.0-test + test_upload_profiles + stop - log_info "run 8.0-test" - start 8.0-test - test_upload_profiles - stop - - docker stop test_pyroscope + log_info "run 8.0-test" + start 8.0-test + test_upload_profiles + stop + + docker stop test_pyroscope } diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 5b66d8c..640cf04 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -1,6 +1,6 @@ # SPDX-License-Identifier: MIT -UPGRADE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +UPGRADE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" function upgrade_reset() { local config=$1 @@ -11,7 +11,7 @@ function upgrade_reset() { function verify_storage() { local work_path=$DIR/forgejo-work-path - for path in ${STORAGE_PATHS} ; do + for path in ${STORAGE_PATHS}; do test -d $work_path/data/$path done } @@ -19,14 +19,14 @@ function verify_storage() { function cleanup_storage() { local work_path=$DIR/forgejo-work-path - for path in ${STORAGE_PATHS} ; do + for path in ${STORAGE_PATHS}; do rm -fr $work_path/data/$path done } function test_successful_upgrades() { stop - for config in $UPGRADE_DIR/default-app.ini ; do + for config in $UPGRADE_DIR/default-app.ini; do log_info "using $config" upgrade_reset $config @@ -38,7 +38,7 @@ function test_successful_upgrades() { fixture_assert doctor_run $config - for version in $RELEASE_NUMBERS_AND_DEV ; do + for version in $RELEASE_NUMBERS_AND_DEV; do stop log_info "run $version" start $version @@ -55,7 +55,7 @@ function test_gitea_upgrades() { echo gitea 1.21 forgejo 7.0-test echo gitea 1.21 forgejo 8.0-test echo gitea 1.22 forgejo 8.0-test - ) | while read gitea gitea_version forgejo forgejo_version ; do + ) | while read gitea gitea_version forgejo forgejo_version; do log_info "upgrading from Gitea $gitea_version to Forgejo $forgejo_version" stop upgrade_reset $config From 50c5908a91954b7b106aba27c8764149937565e5 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 7 Aug 2024 09:12:09 +0200 Subject: [PATCH 116/203] Forgejo v1.21 is EOL, v9.0 is dev --- actions/actions.sh | 2 +- forgejo/fixtures/storage.sh | 2 -- lib/lib.sh | 2 +- storage/storage.sh | 4 +--- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/actions/actions.sh b/actions/actions.sh index f467ba8..089efbf 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -88,7 +88,7 @@ function actions_runner_version() { } function test_actions() { - local versions="${1:-1.21 $RELEASE_NUMBERS_AND_DEV}" + local versions="${1:-$RELEASE_NUMBERS_AND_DEV}" for version in $versions; do diff --git a/forgejo/fixtures/storage.sh b/forgejo/fixtures/storage.sh index cf893b8..80b7c70 100644 --- a/forgejo/fixtures/storage.sh +++ b/forgejo/fixtures/storage.sh @@ -150,8 +150,6 @@ function fixture_avatars_assert_local() { function fixture_repo_avatars_create() { echo -n $ONEPIXEL | base64 --decode >$DIR/repo-avatar.png forgejo-curl.sh web --form avatar=@$DIR/repo-avatar.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/settings/avatar - # v1.21 only - #forgejo-curl.sh api_json -X POST --data-raw '{"body":"'$avatar'"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/avatar } function fixture_repo_avatars_assert_s3() { diff --git a/lib/lib.sh b/lib/lib.sh index 295c0eb..b5101ca 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -26,7 +26,7 @@ IP=$(hostname -I | cut -f1 -d' ') # # Forgejo releases for which a branch exists (7.0/forgejo etc.) # -RELEASE_NUMBERS="7.0 8.0" +RELEASE_NUMBERS="7.0 8.0 9.0" PREFIX=============== export DIR=/tmp/forgejo-end-to-end diff --git a/storage/storage.sh b/storage/storage.sh index e96a0d3..6ace098 100755 --- a/storage/storage.sh +++ b/storage/storage.sh @@ -31,9 +31,7 @@ function test_storage_stable_s3() { local work_path=$DIR/forgejo-work-path local s3_backend=${1:-minio} - log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338" - - for version in 1.21 $RELEASE_NUMBERS_AND_DEV; do + for version in $RELEASE_NUMBERS_AND_DEV; do log_info "Forgejo $version & $s3_backend" stop storage_reset stable-s3 From f46d01885f550caa40748c84a36a6e7cdcd9d869 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 7 Aug 2024 09:17:29 +0200 Subject: [PATCH 117/203] packages: alpine: verify supported versions v8.0-dev should be supported too but it is not LTS: only care for 9.0-dev which is not different for Alpine. --- packages/alpine-1.21/package-source/APKBUILD | 26 --------- .../alpine-1.21/package-source/forgejo_2174 | 3 - .../package-source/forgejo_2174.init | 7 --- packages/alpine-1.21/test.sh | 58 ------------------- packages/alpine-7.0-test/test.sh | 2 +- packages/alpine-9.0-dev | 1 + packages/alpine.sh | 4 +- 7 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 packages/alpine-1.21/package-source/APKBUILD delete mode 100755 packages/alpine-1.21/package-source/forgejo_2174 delete mode 100755 packages/alpine-1.21/package-source/forgejo_2174.init delete mode 100755 packages/alpine-1.21/test.sh create mode 120000 packages/alpine-9.0-dev diff --git a/packages/alpine-1.21/package-source/APKBUILD b/packages/alpine-1.21/package-source/APKBUILD deleted file mode 100644 index ce75e29..0000000 --- a/packages/alpine-1.21/package-source/APKBUILD +++ /dev/null @@ -1,26 +0,0 @@ -# -*- mode: Shell-script; eval: (setq indent-tabs-mode 't); eval: (setq tab-width 4) -*- -# Maintainer: Dominic Meiser -pkgname=forgejo-2174 -pkgver=1.0 -pkgrel=0 -pkgdesc="Forgejo #2174 Reproduction" -url="https://msrd0.dev/msrd0/$pkgname" -arch="x86_64" -license="custom" - -# using x86_64 instead of noarch as a workaround of -# https://codeberg.org/forgejo/forgejo/issues/2173 -subpackages="$pkgname-openrc::x86_64" - -source="forgejo_2174 forgejo_2174.init" -builddir="$srcdir" - -package() { - install -D -m755 "$srcdir/forgejo_2174" "$pkgdir"/usr/bin/forgejo_2174 - install -D -m755 "$srcdir/forgejo_2174.init" "$pkgdir"/etc/init.d/forgejo_2174 -} - -sha512sums=" -651c2a816510a18981bcd45077eb5acd6e58511d641949ddc690e326b81018d851eb7f1c88e2336eada2f216606ce2aa0569eb2d02d7c423c80705cc00acf838 forgejo_2174 -b1cba77139cdaf9e0cdd78de93becbb3891ec59646e8d2cb40620b230bd798d51e6d9c58e65b584812a6bb8eb2b9c9f89262a8700a39c62af8ec8ea09aee4e29 forgejo_2174.init -" diff --git a/packages/alpine-1.21/package-source/forgejo_2174 b/packages/alpine-1.21/package-source/forgejo_2174 deleted file mode 100755 index b12f87b..0000000 --- a/packages/alpine-1.21/package-source/forgejo_2174 +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo "Hello World" diff --git a/packages/alpine-1.21/package-source/forgejo_2174.init b/packages/alpine-1.21/package-source/forgejo_2174.init deleted file mode 100755 index 06b7f20..0000000 --- a/packages/alpine-1.21/package-source/forgejo_2174.init +++ /dev/null @@ -1,7 +0,0 @@ -#!/sbin/openrc-run - -command="/usr/bin/forgejo_2174" - -depend() { - need net -} diff --git a/packages/alpine-1.21/test.sh b/packages/alpine-1.21/test.sh deleted file mode 100755 index 93a3aba..0000000 --- a/packages/alpine-1.21/test.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/busybox ash -set -exuo pipefail - -forgejo_url=$1 -forgejo_token=$2 - -# initialize abuild -apk update -apk add --no-cache alpine-sdk sudo util-linux -adduser -D user -h /home/user -addgroup user abuild -echo "root ALL=(ALL) ALL" >/etc/sudoers -echo "%abuild ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers -mkdir -p /var/cache/distfiles -chgrp abuild /var/cache/distfiles -chmod 775 /var/cache/distfiles -mkdir -p "/home/user/.abuild" -echo "/home/user/.abuild/user.rsa" | abuild-keygen -i -b 4096 -echo 'PACKAGER_PRIVKEY=/home/user/.abuild/user.rsa' >/home/user/.abuild/abuild.conf -chown -R "user:user" /home/user/ - -# make sure we own the relevant directory -cp -r package-source /srv/alpine -cd /srv -mkdir packages -echo "REPODEST=/srv/packages" >>/home/user/.abuild/abuild.conf -cat /home/user/.abuild/abuild.conf -chown -R user:user alpine packages - -# build the package -sudo -u user APKBUILD=alpine/APKBUILD abuild -r - -# upload new package -cd packages/srv/x86_64/ -for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do - # remove old package - curl \ - --fail \ - -H "Authorization: token $forgejo_token" \ - -X DELETE \ - "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174/$file" || - true - - # upload new package - curl \ - --fail \ - -H "Authorization: token $forgejo_token" \ - -T "$file" \ - "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174" -done - -# ensure that the install-if condition works as expected -apk add openrc -(cd /etc/apk/keys && curl -JO $forgejo_url/api/packages/root/alpine/key) -echo "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174" >>/etc/apk/repositories -apk add forgejo-2174 -[ -e /usr/bin/forgejo_2174 ] # from the installed package -[ -e /etc/init.d/forgejo_2174 ] # from the -openrc package installed because of the install-if condition diff --git a/packages/alpine-7.0-test/test.sh b/packages/alpine-7.0-test/test.sh index 82565d0..d830df2 100755 --- a/packages/alpine-7.0-test/test.sh +++ b/packages/alpine-7.0-test/test.sh @@ -6,7 +6,7 @@ forgejo_token=$2 # initialize abuild apk update -apk add --no-cache alpine-sdk sudo util-linux +apk add --no-cache alpine-sdk sudo util-linux curl adduser -D user -h /home/user addgroup user abuild echo "root ALL=(ALL) ALL" >/etc/sudoers diff --git a/packages/alpine-9.0-dev b/packages/alpine-9.0-dev new file mode 120000 index 0000000..a2389c0 --- /dev/null +++ b/packages/alpine-9.0-dev @@ -0,0 +1 @@ +alpine-7.0-test \ No newline at end of file diff --git a/packages/alpine.sh b/packages/alpine.sh index 79595ae..3a4ea78 100644 --- a/packages/alpine.sh +++ b/packages/alpine.sh @@ -16,8 +16,8 @@ function test_packages_alpine_version() { } function test_packages_alpine() { - for alpine_version in 3.18 3.19; do - for forgejo_version in 1.21 7.0-test 7.0-dev; do + for alpine_version in 3.19 3.20; do + for forgejo_version in 7.0-dev 9.0-dev; do test_packages_alpine_version $alpine_version $forgejo_version done done From 497a5d76bbe2fd6d2f9d48cafbbefd70b17e7901 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 7 Aug 2024 09:18:25 +0200 Subject: [PATCH 118/203] actions: trim v1.20 & v1.21 specific comment --- actions/example-if-cancel/.forgejo/workflows/test.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/actions/example-if-cancel/.forgejo/workflows/test.yml b/actions/example-if-cancel/.forgejo/workflows/test.yml index 5a92198..d680017 100644 --- a/actions/example-if-cancel/.forgejo/workflows/test.yml +++ b/actions/example-if-cancel/.forgejo/workflows/test.yml @@ -1,9 +1,3 @@ -# -# As of Forgejo v1.20 running this example would require using the web -# endpoints because there is no API to do the same. -# -# It was manually tested to **not work** with Forgejo v1.21 & runner 3.0.1 -# on: [push] jobs: From d872865242ddc8a078bec8365ef5ee6b6064d0c7 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 7 Aug 2024 09:36:16 +0200 Subject: [PATCH 119/203] test Forgejo upgrades starting with v7.0 instead of v1.21 --- upgrade/upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 640cf04..9d29aa8 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -30,7 +30,7 @@ function test_successful_upgrades() { log_info "using $config" upgrade_reset $config - version=1.21 + version=7.0 log_info "run $version" cleanup_storage start $version From 944dd9872703a75cc2870aeb4f4f10c283970e69 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 7 Aug 2024 09:36:50 +0200 Subject: [PATCH 120/203] test Gitea upgrades with v7.0 and v9.0 the upgrade path from Gitea v1.21 & v1.22 to v8.0 was tested before it was published. The patch releases for v8.0 will only include bug fixes and no database upgrades: they are the only kind of changes that could cause a problem with upgrades. --- upgrade/upgrade.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 9d29aa8..60e6fac 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -52,9 +52,9 @@ function test_successful_upgrades() { function test_gitea_upgrades() { local config=$UPGRADE_DIR/default-app.ini ( - echo gitea 1.21 forgejo 7.0-test - echo gitea 1.21 forgejo 8.0-test - echo gitea 1.22 forgejo 8.0-test + echo gitea 1.21 forgejo 7.0-dev + echo gitea 1.21 forgejo 9.0-dev + echo gitea 1.22 forgejo 9.0-dev ) | while read gitea gitea_version forgejo forgejo_version; do log_info "upgrading from Gitea $gitea_version to Forgejo $forgejo_version" stop From af9305b221fd0b53ab4787a3544bf7c3c9396ef9 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 7 Aug 2024 09:38:32 +0200 Subject: [PATCH 121/203] README: link to v7.0 documentation instead of v1.21 --- README.md | 4 ++-- end-to-end.sh | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 257e5b6..fa8c10e 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,13 @@ as: { "insecure-registries": [ "10.0.0.0/8" ] } -``` +``` Use setup-forgejo from source. The [setup-forgejo](https://code.forgejo.org/actions/setup-forgejo) repository is a [Forgejo -Action](https://forgejo.org/docs/v1.21/user/actions/) which is meant +Action](https://forgejo.org/docs/v7.0/user/actions/) which is meant to be used in workflows. However, it is implemented as shell scripts that can also be used to create Forgejo instances and runners locally. This is convenient for testing and the reason why it needs to be added to the PATH. diff --git a/end-to-end.sh b/end-to-end.sh index 05865ac..3b3a702 100755 --- a/end-to-end.sh +++ b/end-to-end.sh @@ -1,16 +1,6 @@ #!/bin/bash # SPDX-License-Identifier: MIT -# -# Debug loop from the source tree: -# -# ./end-to-end.sh dependencies -# ./end-to-end.sh build_all -# VERBOSE=true ./end-to-end.sh test_downgrade_1.20.2_fails -# -# Everything happens in /tmp/forgejo-end-to-end -# - SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SELF="${BASH_SOURCE[0]}" source $SELF_DIR/lib/lib.sh From 0f4173555f965f46fd0481cbfe5155adaf45abdb Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 7 Aug 2024 09:56:02 +0200 Subject: [PATCH 122/203] forgejo: fix sources Gitea compatibility It is cosmetic, keep it accurate. --- forgejo/sources/7.0 | 2 +- forgejo/sources/8.0 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/forgejo/sources/7.0 b/forgejo/sources/7.0 index b033f01..0e2cc26 100644 --- a/forgejo/sources/7.0 +++ b/forgejo/sources/7.0 @@ -1 +1 @@ -https://codeberg.org/forgejo/forgejo v7.0/forgejo 7.0.0+gitea-1.22.0 +https://codeberg.org/forgejo/forgejo v7.0/forgejo 7.0.0+gitea-1.21.0 diff --git a/forgejo/sources/8.0 b/forgejo/sources/8.0 index 3c5a3ec..42ce80b 100644 --- a/forgejo/sources/8.0 +++ b/forgejo/sources/8.0 @@ -1 +1 @@ -https://codeberg.org/forgejo/forgejo forgejo 8.0.0+gitea-1.21.0 +https://codeberg.org/forgejo/forgejo v8.0/forgejo 8.0.0+gitea-1.22.0 From 6224249696769f138e1c5499a561d6cc821d6791 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 7 Aug 2024 11:49:17 +0200 Subject: [PATCH 123/203] upgrade: test pprof against the two active stable releases --- upgrade/test-pprof-upload.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/upgrade/test-pprof-upload.sh b/upgrade/test-pprof-upload.sh index 48dada4..48e0005 100644 --- a/upgrade/test-pprof-upload.sh +++ b/upgrade/test-pprof-upload.sh @@ -28,13 +28,13 @@ function test_forgejo_pprof() { docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope reset_forgejo $UPGRADE_DIR/default-app.ini - log_info "run 7.0-test" - start 7.0-test + log_info "run 7.0-dev" + start 7.0-dev test_upload_profiles stop - log_info "run 8.0-test" - start 8.0-test + log_info "run 9.0-dev" + start 9.0-dev test_upload_profiles stop From 427c46dbf95685b0e32bb450198f836580d56d60 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 8 Aug 2024 16:48:39 +0200 Subject: [PATCH 124/203] lib: remove RELEASE_NUMBERS_AND_DEV, use RELEASE_NUMBERS In the lifecycle of vX.Y.Z, all tests are run against vX.Y-test before it is published, including when the tag is pushed because the automated release process now runs end-to-end before pushing the release to forgejo-experimental. Running end-to-end against vX.Y-dev is therefore redundant with at least two other runs with exactly the same SHA (the one before the tag is pushed and the one when the tag is pushed). There would be value in doing that if it allowed to detect race conditions in Forgejo. But such races were not found in the past six months and there is a lot more scrutiny on commits merged in Forgejo which makes it even less likely than it was before. Running the tests on vX.Y instead of also including the built version provide the same coverage and reduces the workload. --- actions/actions.sh | 2 +- federation/federation.sh | 2 +- lib/lib.sh | 1 - packages/alpine-7.0-dev | 1 - .../package-source/forgejo-2173/APKBUILD | 0 .../package-source/forgejo-2173/forgejo_2173 | 0 .../package-source/forgejo-2173/forgejo_2173.init | 0 .../package-source/forgejo-2174/APKBUILD | 0 .../package-source/forgejo-2174/forgejo_2174 | 0 .../package-source/forgejo-2174/forgejo_2174.init | 0 packages/{alpine-7.0-test => alpine-7.0}/test.sh | 0 packages/alpine-9.0 | 1 + packages/alpine-9.0-dev | 1 - storage/storage.sh | 2 +- upgrade/upgrade.sh | 2 +- 15 files changed, 5 insertions(+), 7 deletions(-) delete mode 120000 packages/alpine-7.0-dev rename packages/{alpine-7.0-test => alpine-7.0}/package-source/forgejo-2173/APKBUILD (100%) rename packages/{alpine-7.0-test => alpine-7.0}/package-source/forgejo-2173/forgejo_2173 (100%) rename packages/{alpine-7.0-test => alpine-7.0}/package-source/forgejo-2173/forgejo_2173.init (100%) rename packages/{alpine-7.0-test => alpine-7.0}/package-source/forgejo-2174/APKBUILD (100%) rename packages/{alpine-7.0-test => alpine-7.0}/package-source/forgejo-2174/forgejo_2174 (100%) rename packages/{alpine-7.0-test => alpine-7.0}/package-source/forgejo-2174/forgejo_2174.init (100%) rename packages/{alpine-7.0-test => alpine-7.0}/test.sh (100%) create mode 120000 packages/alpine-9.0 delete mode 120000 packages/alpine-9.0-dev diff --git a/actions/actions.sh b/actions/actions.sh index 089efbf..b411778 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -88,7 +88,7 @@ function actions_runner_version() { } function test_actions() { - local versions="${1:-$RELEASE_NUMBERS_AND_DEV}" + local versions="${1:-$RELEASE_NUMBERS}" for version in $versions; do diff --git a/federation/federation.sh b/federation/federation.sh index f0acfcf..e3e7ab7 100755 --- a/federation/federation.sh +++ b/federation/federation.sh @@ -69,7 +69,7 @@ function test_federation() { # start_gitlab octobus/heptapod:1.5.3 federation_setup_variables - local versions="${1:-$RELEASE_NUMBERS_AND_DEV}" + local versions="${1:-$RELEASE_NUMBERS}" for version in $versions; do diff --git a/lib/lib.sh b/lib/lib.sh index b5101ca..9dc8ee3 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -35,7 +35,6 @@ export DOT_FORGEJO_CURL=$DIR/forgejo-curl export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 : ${FORGEJO_USER:=root} : ${FORGEJO_PASSWORD:=admin1234} -: ${RELEASE_NUMBERS_AND_DEV:="$(for r in $RELEASE_NUMBERS; do echo -n "$r $r-dev "; done)"} ORGANIZATIONS=$(cat $LIB_DIR/ORGANIZATIONS) function log_info() { diff --git a/packages/alpine-7.0-dev b/packages/alpine-7.0-dev deleted file mode 120000 index a2389c0..0000000 --- a/packages/alpine-7.0-dev +++ /dev/null @@ -1 +0,0 @@ -alpine-7.0-test \ No newline at end of file diff --git a/packages/alpine-7.0-test/package-source/forgejo-2173/APKBUILD b/packages/alpine-7.0/package-source/forgejo-2173/APKBUILD similarity index 100% rename from packages/alpine-7.0-test/package-source/forgejo-2173/APKBUILD rename to packages/alpine-7.0/package-source/forgejo-2173/APKBUILD diff --git a/packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173 b/packages/alpine-7.0/package-source/forgejo-2173/forgejo_2173 similarity index 100% rename from packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173 rename to packages/alpine-7.0/package-source/forgejo-2173/forgejo_2173 diff --git a/packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173.init b/packages/alpine-7.0/package-source/forgejo-2173/forgejo_2173.init similarity index 100% rename from packages/alpine-7.0-test/package-source/forgejo-2173/forgejo_2173.init rename to packages/alpine-7.0/package-source/forgejo-2173/forgejo_2173.init diff --git a/packages/alpine-7.0-test/package-source/forgejo-2174/APKBUILD b/packages/alpine-7.0/package-source/forgejo-2174/APKBUILD similarity index 100% rename from packages/alpine-7.0-test/package-source/forgejo-2174/APKBUILD rename to packages/alpine-7.0/package-source/forgejo-2174/APKBUILD diff --git a/packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174 b/packages/alpine-7.0/package-source/forgejo-2174/forgejo_2174 similarity index 100% rename from packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174 rename to packages/alpine-7.0/package-source/forgejo-2174/forgejo_2174 diff --git a/packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174.init b/packages/alpine-7.0/package-source/forgejo-2174/forgejo_2174.init similarity index 100% rename from packages/alpine-7.0-test/package-source/forgejo-2174/forgejo_2174.init rename to packages/alpine-7.0/package-source/forgejo-2174/forgejo_2174.init diff --git a/packages/alpine-7.0-test/test.sh b/packages/alpine-7.0/test.sh similarity index 100% rename from packages/alpine-7.0-test/test.sh rename to packages/alpine-7.0/test.sh diff --git a/packages/alpine-9.0 b/packages/alpine-9.0 new file mode 120000 index 0000000..b34295a --- /dev/null +++ b/packages/alpine-9.0 @@ -0,0 +1 @@ +alpine-7.0 \ No newline at end of file diff --git a/packages/alpine-9.0-dev b/packages/alpine-9.0-dev deleted file mode 120000 index a2389c0..0000000 --- a/packages/alpine-9.0-dev +++ /dev/null @@ -1 +0,0 @@ -alpine-7.0-test \ No newline at end of file diff --git a/storage/storage.sh b/storage/storage.sh index 6ace098..8fdb64f 100755 --- a/storage/storage.sh +++ b/storage/storage.sh @@ -31,7 +31,7 @@ function test_storage_stable_s3() { local work_path=$DIR/forgejo-work-path local s3_backend=${1:-minio} - for version in $RELEASE_NUMBERS_AND_DEV; do + for version in $RELEASE_NUMBERS; do log_info "Forgejo $version & $s3_backend" stop storage_reset stable-s3 diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 60e6fac..79c65cc 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -38,7 +38,7 @@ function test_successful_upgrades() { fixture_assert doctor_run $config - for version in $RELEASE_NUMBERS_AND_DEV; do + for version in $RELEASE_NUMBERS; do stop log_info "run $version" start $version From 149c6a545cf206580c1b50899c4a0e1678ffa136 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 8 Aug 2024 17:05:42 +0200 Subject: [PATCH 125/203] lib: source build replace the matching release Instead of having an explicit vX.Y-dev version to be referenced explicitly, a binary built from source replaces the matching version. For instance, if forgejo/build-from-sources contains v9.0, * the development branch is compiled from source * the v9.0 artifact is uploaded * prior to running any test, the artificat is downloaded and used * the v9.0 binary is not downloaded from forgejo/experimental/integration because it is already present The vX.Y release is built daily and the end-to-end tests run on it. If a regression is introduced, it will be spotted within 24h. Compiling from source is used when the Forgejo runs the end-to-end suite on a specific pull request. --- .forgejo/workflows/end-to-end.yml | 16 +++++++++++----- lib/lib.sh | 12 ------------ packages/alpine.sh | 2 +- upgrade/test-pprof-upload.sh | 8 ++++---- upgrade/upgrade.sh | 7 +++---- 5 files changed, 19 insertions(+), 26 deletions(-) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index 83ce388..05d43c5 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -31,8 +31,15 @@ jobs: go-version: "1.22" - name: lib/build.sh run: | - set -x + mkdir $d /tmp/forgejo-upload + touch /tmp/forgejo-upload/PLACEHOLDER + if ! test -f forgejo/build-from-sources; then + echo forgejo/build-from-sources is not present, do not build any version from source + exit 0 + fi + + set -x # # SQLite needs gcc to be compiled # @@ -41,13 +48,12 @@ jobs: apt-get -q install -y -qq build-essential d=/tmp/forgejo-binaries - mkdir $d /tmp/forgejo-upload - for version in $(ls forgejo/sources) ; do - forgejo=$d/forgejo-$version-dev + for version in $(cat forgejo/build-from-sources) ; do lib/build.sh $version $d + forgejo=$d/forgejo-$version-dev $forgejo --version - mv $forgejo /tmp/forgejo-upload + mv $forgejo /tmp/forgejo-upload/forgejo-$version done - uses: actions/upload-artifact@v3 with: diff --git a/lib/lib.sh b/lib/lib.sh index 9dc8ee3..a7471b8 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -70,18 +70,6 @@ function dependencies() { fi } -function build_all() { - for dev in $RELEASE_NUMBERS; do - local forgejo=$DIR_BINARIES/forgejo-$dev-dev - if test -f $forgejo; then - log_info $dev already exists - else - $LIB_DIR/build.sh $dev $DIR_BINARIES - log_info $dev built from sources - fi - done -} - function retry() { rm -f $DIR/wait-for.out success=false diff --git a/packages/alpine.sh b/packages/alpine.sh index 3a4ea78..4ae92ae 100644 --- a/packages/alpine.sh +++ b/packages/alpine.sh @@ -17,7 +17,7 @@ function test_packages_alpine_version() { function test_packages_alpine() { for alpine_version in 3.19 3.20; do - for forgejo_version in 7.0-dev 9.0-dev; do + for forgejo_version in 7.0 9.0; do test_packages_alpine_version $alpine_version $forgejo_version done done diff --git a/upgrade/test-pprof-upload.sh b/upgrade/test-pprof-upload.sh index 48e0005..5c67687 100644 --- a/upgrade/test-pprof-upload.sh +++ b/upgrade/test-pprof-upload.sh @@ -28,13 +28,13 @@ function test_forgejo_pprof() { docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope reset_forgejo $UPGRADE_DIR/default-app.ini - log_info "run 7.0-dev" - start 7.0-dev + log_info "run 7.0" + start 7.0 test_upload_profiles stop - log_info "run 9.0-dev" - start 9.0-dev + log_info "run 9.0" + start 9.0 test_upload_profiles stop diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 79c65cc..fb2f8c8 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -52,9 +52,9 @@ function test_successful_upgrades() { function test_gitea_upgrades() { local config=$UPGRADE_DIR/default-app.ini ( - echo gitea 1.21 forgejo 7.0-dev - echo gitea 1.21 forgejo 9.0-dev - echo gitea 1.22 forgejo 9.0-dev + echo gitea 1.21 forgejo 7.0 + echo gitea 1.21 forgejo 9.0 + echo gitea 1.22 forgejo 9.0 ) | while read gitea gitea_version forgejo forgejo_version; do log_info "upgrading from Gitea $gitea_version to Forgejo $forgejo_version" stop @@ -81,7 +81,6 @@ source $UPGRADE_DIR/test-pprof-upload.sh function test_upgrades() { run dependencies - run build_all run test_successful_upgrades run test_forgejo_pprof From 8636471d6356325f34ea6afbe4a6735201d4ffcf Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 11 Aug 2024 11:38:52 +0200 Subject: [PATCH 126/203] actions: verify the log compression feature If running Forgejo >= v9.0, verify the logs are compressed by default --- actions/actions.sh | 24 +++++++++++++++++++++--- actions/feature-logs-compression/run.sh | 8 ++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100755 actions/feature-logs-compression/run.sh diff --git a/actions/actions.sh b/actions/actions.sh index b411778..7bcc4df 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -3,13 +3,27 @@ ACTIONS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -function actions_verify_example() { - local example=$1 - +function actions_export_variables() { export HOST_PORT export url=http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT} export token=$(cat $DOT_FORGEJO_CURL/token) +} +function actions_verify_feature() { + local feature=$1 + + actions_export_variables + + export FEATURE_DIR=$ACTIONS_DIR/feature-$feature + + echo "============================ RUN feature-$feature ===================" + bash -ex $FEATURE_DIR/run.sh || return 1 +} + +function actions_verify_example() { + local example=$1 + + actions_export_variables actions_cleanup_example_volume export example @@ -124,5 +138,9 @@ function test_actions() { run actions_verify_example $example done fi + + if dpkg --compare-versions $version ge 9.0; then + run actions_verify_feature logs-compression + fi done } diff --git a/actions/feature-logs-compression/run.sh b/actions/feature-logs-compression/run.sh new file mode 100755 index 0000000..c1cd259 --- /dev/null +++ b/actions/feature-logs-compression/run.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +source $FEATURE_DIR/../../lib/lib.sh +source $FEATURE_DIR/../../forgejo/fixtures.sh + +fixture_get_one_path local data/actions_log/root/example-echo/01/1.log.zst From 75503c5396e9a205cf2c8d8f06c2aa5d84865dd7 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 23 Aug 2024 16:19:22 +0200 Subject: [PATCH 127/203] actions: feature: compression: do not hardcode the log path The log path depends on the previous actions run and may not always be 01/1.log.zst. Assuming it is makes this test fragile as it is influenced by which previous tests are run and what they do. --- actions/feature-logs-compression/run.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/actions/feature-logs-compression/run.sh b/actions/feature-logs-compression/run.sh index c1cd259..174a24d 100755 --- a/actions/feature-logs-compression/run.sh +++ b/actions/feature-logs-compression/run.sh @@ -5,4 +5,11 @@ set -e source $FEATURE_DIR/../../lib/lib.sh source $FEATURE_DIR/../../forgejo/fixtures.sh -fixture_get_one_path local data/actions_log/root/example-echo/01/1.log.zst +if ! fixture_get_one_path local data/actions_log/root/example-echo | grep --quiet log.zst; then + ( + cd $DIR/forgejo-work-path + find data + ) + echo expected a single log.zst file in data/actions_log/root/example-echo + exit 1 +fi From 427d9ed2673a618aa92bd20460aea359415674b7 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 23 Aug 2024 14:53:04 +0200 Subject: [PATCH 128/203] tests: upgrade setup-forgejo to v2.0.2 --- .forgejo/prepare-end-to-end/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/prepare-end-to-end/action.yml b/.forgejo/prepare-end-to-end/action.yml index ad0e706..3bf0413 100644 --- a/.forgejo/prepare-end-to-end/action.yml +++ b/.forgejo/prepare-end-to-end/action.yml @@ -11,7 +11,7 @@ runs: /usr/local/bin/garage key: S3 - - uses: https://code.forgejo.org/actions/setup-forgejo@v2 + - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.2 with: install-only: true - run: forgejo-binary.sh ensure_user forgejo From 1f2f98fb2193987190d7f495f416c90bb3c8aa39 Mon Sep 17 00:00:00 2001 From: limiting-factor Date: Mon, 2 Sep 2024 11:45:26 +0200 Subject: [PATCH 129/203] lib: reduce GitLab noise The absence of the test-gitlab container will display Error response from daemon: No such container: test-gitlab which can be mistaken as an actual error where in fact it should be ignored. --- lib/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lib.sh b/lib/lib.sh index a7471b8..3e21377 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -217,7 +217,7 @@ function start_gitlab() { } function stop_gitlab() { - docker rm -f test-gitlab + docker rm -f test-gitlab >&/dev/null } function stop_forgejo() { From 94289bc80dd400634d894bb79f8bcc68e71ad223 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 25 Sep 2024 14:12:49 +0200 Subject: [PATCH 130/203] v10.0 development cycle started --- forgejo/sources/10.0 | 1 + lib/lib.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 forgejo/sources/10.0 diff --git a/forgejo/sources/10.0 b/forgejo/sources/10.0 new file mode 100644 index 0000000..101d770 --- /dev/null +++ b/forgejo/sources/10.0 @@ -0,0 +1 @@ +https://codeberg.org/forgejo/forgejo forgejo 10.0.0+gitea-1.23 diff --git a/lib/lib.sh b/lib/lib.sh index 3e21377..4b489a0 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -26,7 +26,7 @@ IP=$(hostname -I | cut -f1 -d' ') # # Forgejo releases for which a branch exists (7.0/forgejo etc.) # -RELEASE_NUMBERS="7.0 8.0 9.0" +RELEASE_NUMBERS="7.0 9.0 10.0" PREFIX=============== export DIR=/tmp/forgejo-end-to-end From 294ca18400198eec3f2e1d43eaba0199583cd889 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 6 Oct 2024 06:22:58 +0200 Subject: [PATCH 131/203] README: update local testing instructions --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fa8c10e..4b5808a 100644 --- a/README.md +++ b/README.md @@ -50,25 +50,26 @@ cd end-to-end ```sh make TAGS='bindata sqlite sqlite_unlock_notify' generate forgejo -cp -a forgejo /srv/forgejo-binaries/forgejo-8.0-dev +cp -a forgejo /srv/forgejo-binaries/forgejo-10.0 ``` -It will be used whenever the version `8.0-dev` is specified in a test. +It will be used whenever the version `10.0` is specified in a test. ## Running actions locally To run and debug workflows from `actions/example-*`, from the root of the source directory, with docker and forgejo-curl.sh installed, mimic -what `.forgejo/workflows/actions.yml` does. There may be some manual +what `.forgejo/workflows/end-to-end.yml` does. There may be some manual tweaking (such as creating temporary directories) because the tests run as root in the context of Forgejo Actions and assume they have admin permissions. But they do not need to run as root and must work fine when run as a regular user. ```sh -./end-to-end.sh actions_setup 1.21 +./end-to-end.sh run dependencies +./end-to-end.sh actions_setup 10.0 firefox 0.0.0.0:3000 # user root / admin1234 -./end-to-end.sh actions_verify_example artifacts +./end-to-end.sh actions_verify_example echo ./end-to-end.sh actions_teardown ``` ## Running other tests locally From f48fa029169d05e04f2a7fe13fbf099ffd9ed3e7 Mon Sep 17 00:00:00 2001 From: Kwonunn Date: Sun, 6 Oct 2024 16:53:11 +0200 Subject: [PATCH 132/203] WIP: Add test for schedule not being cancelled --- .../.forgejo/workflows/test.yml | 8 ++++++++ actions/example-schedule-noncancel/run.sh | 18 ++++++++++++++++++ actions/example-schedule-noncancel/teardown.sh | 4 ++++ 3 files changed, 30 insertions(+) create mode 100644 actions/example-schedule-noncancel/.forgejo/workflows/test.yml create mode 100755 actions/example-schedule-noncancel/run.sh create mode 100644 actions/example-schedule-noncancel/teardown.sh diff --git a/actions/example-schedule-noncancel/.forgejo/workflows/test.yml b/actions/example-schedule-noncancel/.forgejo/workflows/test.yml new file mode 100644 index 0000000..e0015c3 --- /dev/null +++ b/actions/example-schedule-noncancel/.forgejo/workflows/test.yml @@ -0,0 +1,8 @@ +on: + schedule: + - cron: "* * * * *" +jobs: + test: + runs-on: docker + steps: + - run: sleep 15 diff --git a/actions/example-schedule-noncancel/run.sh b/actions/example-schedule-noncancel/run.sh new file mode 100755 index 0000000..9fa275d --- /dev/null +++ b/actions/example-schedule-noncancel/run.sh @@ -0,0 +1,18 @@ +repo=root/example-$example +# +# push the repository +# +forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token +sha=$(forgejo-test-helper.sh branch_tip $url $repo main) +# +# wait for the workflow (sleep infinity) to start running +# +forgejo-test-helper.sh wait_running $url $repo $sha +# +# push to the same branch +# +forgejo-test-helper.sh push_workflow actions/example-echo $url root example-$example setup-forgejo $token +# +# wait for the workflow to be canceled as a result of the previous push +# +forgejo-test-helper.sh wait_success $url $repo $sha diff --git a/actions/example-schedule-noncancel/teardown.sh b/actions/example-schedule-noncancel/teardown.sh new file mode 100644 index 0000000..ae9987a --- /dev/null +++ b/actions/example-schedule-noncancel/teardown.sh @@ -0,0 +1,4 @@ +# +# this will effectively discard any linger workflow so they do not interfere with other tests +# +forgejo-runner.sh reload From 631055d190d2474a11affb0fb71704fabdd3710c Mon Sep 17 00:00:00 2001 From: Kwonunn Date: Sat, 12 Oct 2024 15:11:14 +0200 Subject: [PATCH 133/203] rewrite schedule cancelling test --- .../{test.yml => schedule_continue.yml} | 0 actions/example-schedule-noncancel/run.sh | 80 +++++++++++++++++-- 2 files changed, 74 insertions(+), 6 deletions(-) rename actions/example-schedule-noncancel/.forgejo/workflows/{test.yml => schedule_continue.yml} (100%) diff --git a/actions/example-schedule-noncancel/.forgejo/workflows/test.yml b/actions/example-schedule-noncancel/.forgejo/workflows/schedule_continue.yml similarity index 100% rename from actions/example-schedule-noncancel/.forgejo/workflows/test.yml rename to actions/example-schedule-noncancel/.forgejo/workflows/schedule_continue.yml diff --git a/actions/example-schedule-noncancel/run.sh b/actions/example-schedule-noncancel/run.sh index 9fa275d..5d0af81 100755 --- a/actions/example-schedule-noncancel/run.sh +++ b/actions/example-schedule-noncancel/run.sh @@ -1,18 +1,86 @@ repo=root/example-$example +# +# delete the repository +# +api=$url/api/v1 +forgejo-curl.sh api_json -X DELETE $api/repos/root/example-$example + # # push the repository # forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token -sha=$(forgejo-test-helper.sh branch_tip $url $repo main) + +# Prevent test failure because the db is occupied +sqlite3 $DIR/forgejo-work-path/forgejo.db "pragma busy_timeout=20000" + # -# wait for the workflow (sleep infinity) to start running +# get the run id of the workflow that just started # -forgejo-test-helper.sh wait_running $url $repo $sha +getScheduleRun() { + sqlite3 $DIR/forgejo-work-path/forgejo.db \ + "select action_run.id \ + 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' \ + order by action_run.created desc limit 1" +} + +run_id=$(getScheduleRun) +while [ -z $run_id ]; do + echo waiting 5... + sleep 5 + run_id=$(getScheduleRun) +done + +echo Schedule run id: $run_id + # -# push to the same branch +# Wait for it to be started +# +checkStarted() { + sqlite3 $DIR/forgejo-work-path/forgejo.db \ + "select id \ + from action_run \ + where id = $run_id \ + and started is not null" +} + +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 + +# +# Push to the repo again # forgejo-test-helper.sh push_workflow actions/example-echo $url root example-$example setup-forgejo $token + # -# wait for the workflow to be canceled as a result of the previous push +# Wait for the workflow to finish anyway # -forgejo-test-helper.sh wait_success $url $repo $sha +echo Wait for workflow to finish + +checkFinished() { + sqlite3 $DIR/forgejo-work-path/forgejo.db \ + "select status \ + from action_run \ + where id = $run_id \ + and status != 6" +} + +finished_status=$(checkFinished) +while [ -z $finished_status ]; do + echo waiting 5... + sleep 5 + finished_status=$(checkFinished) +done + +echo Workflow finished. + +test $finished_status = 1 From c3eb8918b444b8262db0e7c24db9863338a1b20c Mon Sep 17 00:00:00 2001 From: Kwonunn Date: Sun, 13 Oct 2024 12:45:19 +0200 Subject: [PATCH 134/203] implement waiting based on a file --- .../.forgejo/workflows/schedule_continue.yml | 8 +++++++- actions/example-schedule-noncancel/run.sh | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/actions/example-schedule-noncancel/.forgejo/workflows/schedule_continue.yml b/actions/example-schedule-noncancel/.forgejo/workflows/schedule_continue.yml index e0015c3..8fe7177 100644 --- a/actions/example-schedule-noncancel/.forgejo/workflows/schedule_continue.yml +++ b/actions/example-schedule-noncancel/.forgejo/workflows/schedule_continue.yml @@ -4,5 +4,11 @@ on: jobs: test: runs-on: docker + container: + image: code.forgejo.org/oci/debian:bookworm + options: "--volume /srv/example:/srv/example" steps: - - run: sleep 15 + - run: | + while ! [ -f /srv/example/schedule-noncancel/PUSHED ]; do + sleep 3 + done diff --git a/actions/example-schedule-noncancel/run.sh b/actions/example-schedule-noncancel/run.sh index 5d0af81..810e634 100755 --- a/actions/example-schedule-noncancel/run.sh +++ b/actions/example-schedule-noncancel/run.sh @@ -3,7 +3,9 @@ repo=root/example-$example # delete the repository # api=$url/api/v1 -forgejo-curl.sh api_json -X DELETE $api/repos/root/example-$example +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 # # push the repository @@ -61,6 +63,10 @@ echo Push to repo again # forgejo-test-helper.sh push_workflow actions/example-echo $url root example-$example setup-forgejo $token +echo Signal to the workflow that the push has happened +mkdir -p /srv/example/schedule-noncancel +touch /srv/example/schedule-noncancel/PUSHED + # # Wait for the workflow to finish anyway # @@ -71,7 +77,7 @@ checkFinished() { "select status \ from action_run \ where id = $run_id \ - and status != 6" + and (status != 6 and status != 5)" } finished_status=$(checkFinished) From 222313181f79c1d9e72064224393470446e19685 Mon Sep 17 00:00:00 2001 From: Kwonunn Date: Sun, 13 Oct 2024 13:57:07 +0200 Subject: [PATCH 135/203] Add schedule-noncancel test to 9.0 suite --- actions/actions.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/actions/actions.sh b/actions/actions.sh index 7bcc4df..9701e39 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -141,6 +141,7 @@ function test_actions() { if dpkg --compare-versions $version ge 9.0; then run actions_verify_feature logs-compression + run actions_verify_example schedule-noncancel fi done } From f7d1900c5b286983989f1d6218857ab3410fd38a Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 15 Oct 2024 13:42:20 +0300 Subject: [PATCH 136/203] actions: logs-compression check depends on echo There is no guarantee that a test will not reset the actions logs from a previous test. Since logs-compression depends on the logs from the echo test, make that dependency explicit. --- actions/actions.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/actions/actions.sh b/actions/actions.sh index 9701e39..246f725 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -117,7 +117,14 @@ function test_actions() { done fi - for example in echo cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do + run actions_verify_example echo + if dpkg --compare-versions $version ge 9.0; then + # depends on run actions_verify_example echo + # run it immediately after + run actions_verify_feature logs-compression + fi + + for example in cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do run actions_verify_example $example done @@ -140,7 +147,6 @@ function test_actions() { fi if dpkg --compare-versions $version ge 9.0; then - run actions_verify_feature logs-compression run actions_verify_example schedule-noncancel fi done From 3875197a1bd08ebe2c7b6cd30b6b24cfdf6af25b Mon Sep 17 00:00:00 2001 From: Kwonunn Date: Thu, 17 Oct 2024 11:48:22 +0200 Subject: [PATCH 137/203] fix: attempt to avoid database timeouts due to locking --- .../.forgejo/workflows/schedule_continue.yml | 3 +- actions/example-schedule-noncancel/run.sh | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/actions/example-schedule-noncancel/.forgejo/workflows/schedule_continue.yml b/actions/example-schedule-noncancel/.forgejo/workflows/schedule_continue.yml index 8fe7177..58156ea 100644 --- a/actions/example-schedule-noncancel/.forgejo/workflows/schedule_continue.yml +++ b/actions/example-schedule-noncancel/.forgejo/workflows/schedule_continue.yml @@ -6,7 +6,8 @@ jobs: runs-on: docker container: image: code.forgejo.org/oci/debian:bookworm - options: "--volume /srv/example:/srv/example" + volumes: + - /srv/example:/srv/example steps: - run: | while ! [ -f /srv/example/schedule-noncancel/PUSHED ]; do diff --git a/actions/example-schedule-noncancel/run.sh b/actions/example-schedule-noncancel/run.sh index 810e634..b3756bf 100755 --- a/actions/example-schedule-noncancel/run.sh +++ b/actions/example-schedule-noncancel/run.sh @@ -12,20 +12,20 @@ fi # forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token -# Prevent test failure because the db is occupied -sqlite3 $DIR/forgejo-work-path/forgejo.db "pragma busy_timeout=20000" - # # get the run id of the workflow that just started # getScheduleRun() { - sqlite3 $DIR/forgejo-work-path/forgejo.db \ - "select action_run.id \ + 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 \ 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' \ - order by action_run.created desc limit 1" + order by action_run.created desc limit 1" | sed '2q;d' } run_id=$(getScheduleRun) @@ -41,11 +41,14 @@ echo Schedule run id: $run_id # Wait for it to be started # checkStarted() { - sqlite3 $DIR/forgejo-work-path/forgejo.db \ - "select id \ + 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 \ from action_run \ where id = $run_id \ - and started is not null" + and started is not null" | sed '2q;d' } started_check=$(checkStarted) @@ -73,11 +76,14 @@ touch /srv/example/schedule-noncancel/PUSHED echo Wait for workflow to finish checkFinished() { - sqlite3 $DIR/forgejo-work-path/forgejo.db \ - "select status \ + 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 \ from action_run \ where id = $run_id \ - and (status != 6 and status != 5)" + and (status != 6 and status != 5)" | sed '2q;d' } finished_status=$(checkFinished) @@ -88,5 +94,6 @@ while [ -z $finished_status ]; do done echo Workflow finished. +rm -f $DIR/forgejo-work-path/forgejo.copy.db test $finished_status = 1 From 6508a9e2cab43d8cdd8e7b09c3bd5bc3f4b5de08 Mon Sep 17 00:00:00 2001 From: Kwonunn Date: Mon, 28 Oct 2024 13:51:42 +0000 Subject: [PATCH 138/203] set runner loglevel to debug --- actions/runner-config.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/actions/runner-config.yaml b/actions/runner-config.yaml index 12019d7..7d9e764 100644 --- a/actions/runner-config.yaml +++ b/actions/runner-config.yaml @@ -1,6 +1,5 @@ - log: - level: info + level: debug runner: file: .runner From 3433d6ced2e93161d7deb8de2ad2d07243258a54 Mon Sep 17 00:00:00 2001 From: Kwonunn Date: Mon, 28 Oct 2024 14:55:49 +0100 Subject: [PATCH 139/203] forgot two of the configs --- actions/example-cache/runner-config.yaml | 2 +- actions/example-service/runner-config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/example-cache/runner-config.yaml b/actions/example-cache/runner-config.yaml index 9b342f1..11818cc 100644 --- a/actions/example-cache/runner-config.yaml +++ b/actions/example-cache/runner-config.yaml @@ -1,6 +1,6 @@ log: - level: info + level: debug runner: file: .runner diff --git a/actions/example-service/runner-config.yaml b/actions/example-service/runner-config.yaml index 27981ab..c931a24 100644 --- a/actions/example-service/runner-config.yaml +++ b/actions/example-service/runner-config.yaml @@ -1,6 +1,6 @@ log: - level: info + level: debug runner: file: .runner From aca70a3e54d2d947dd9f34e5173267072dcbd1fd Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 10 Nov 2024 08:37:44 +0100 Subject: [PATCH 140/203] lib: retry longer to allow for slower machines The end-to-end tests moved to a slower machine recently. When the daily releases are build, the end-to-end all run simultaneously and slow down the machine to a point where it will take more than 30 seconds for a Forgejo instance to start. Be more forgiving and let it retry for a minute. https://code.forgejo.org/forgejo/end-to-end/actions/runs/1857/jobs/6 --- lib/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lib.sh b/lib/lib.sh index 4b489a0..2c952b8 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -73,7 +73,7 @@ function dependencies() { function retry() { rm -f $DIR/wait-for.out success=false - for delay in 1 1 5 5 15; do + for delay in 1 1 5 5 15 15 15; do if "$@" >>$DIR/wait-for.out 2>&1; then success=true break From 33f3e7eb658fbe8608b41b187041ee09378f2ff8 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 10 Nov 2024 12:09:05 +0100 Subject: [PATCH 141/203] fix: update the docs branches Closes forgejo/end-to-end#188 --- .forgejo/workflows/end-to-end.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index 05d43c5..780332f 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -111,11 +111,11 @@ jobs: strategy: matrix: info: - - version: "7.0" + - version: "10.0" branch: next forgejo: https://codeberg.org owner: forgejo-experimental - - version: "1.21" + - version: "9.0" forgejo: https://codeberg.org owner: forgejo steps: From 8bf5b2c8027a87b77c138f59c260fb6cd7b228aa Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 11 Nov 2024 08:30:01 +0100 Subject: [PATCH 142/203] actions: run echo and compression tests first --- actions/actions.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/actions/actions.sh b/actions/actions.sh index 246f725..e248f7f 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -111,12 +111,6 @@ function test_actions() { log_info "Testing actions with Forgejo $version & Forgejo runner $runner_version" - if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0; then - for example in artifacts-v4; do - run actions_verify_example $example - done - fi - run actions_verify_example echo if dpkg --compare-versions $version ge 9.0; then # depends on run actions_verify_example echo @@ -124,6 +118,12 @@ function test_actions() { run actions_verify_feature logs-compression fi + if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0; then + for example in artifacts-v4; do + run actions_verify_example $example + done + fi + for example in cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do run actions_verify_example $example done From c4b3c61325f70769992b6e4a9fbb43ef596b2f4a Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 12 Nov 2024 15:40:12 +0100 Subject: [PATCH 143/203] actions: fix: wait for the action logs to show up The Forgejo instance completed the echo test successfully, there must be a log at some point. But since Forgejo is still running, it may not had time to write the logs just yet. Retry instead of giving up immediately. --- actions/feature-logs-compression/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/feature-logs-compression/run.sh b/actions/feature-logs-compression/run.sh index 174a24d..7502fbd 100755 --- a/actions/feature-logs-compression/run.sh +++ b/actions/feature-logs-compression/run.sh @@ -5,7 +5,7 @@ set -e source $FEATURE_DIR/../../lib/lib.sh source $FEATURE_DIR/../../forgejo/fixtures.sh -if ! fixture_get_one_path local data/actions_log/root/example-echo | grep --quiet log.zst; then +if ! retry bash -c "find $DIR/forgejo-work-path/data/actions_log/root/example-echo | grep --quiet log.zst"; then ( cd $DIR/forgejo-work-path find data From 48f422b90315d9d0e2148a142ef9636fd4793be2 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 21 Nov 2024 07:32:07 +0000 Subject: [PATCH 144/203] Add renovate.json --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..cd7ea57 --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "local>forgejo/renovate-config" + ] +} From 4f84eefa62d5b107096f92277ddac439e1d822e7 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 21 Nov 2024 13:01:22 +0000 Subject: [PATCH 145/203] Update actions/setup-go action to v5 --- .forgejo/workflows/end-to-end.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index 780332f..690c814 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -26,7 +26,7 @@ jobs: image: 'docker.io/node:20-bookworm' steps: - uses: https://code.forgejo.org/actions/checkout@v4 - - uses: https://code.forgejo.org/actions/setup-go@v4 + - uses: https://code.forgejo.org/actions/setup-go@v5 with: go-version: "1.22" - name: lib/build.sh From 33749f5a5e0f6f43ba0caa8c4f2fb1ecba63c276 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 27 Nov 2024 01:21:38 +0000 Subject: [PATCH 146/203] actions: runner [container].docker_host variations * automount * "" or "-" * unix:///var/run/docker.sock * tcp://127.0.0.1:2375 --- .forgejo/workflows/end-to-end.yml | 1 + README.md | 4 +++ actions/actions.sh | 22 ++++++++++++++ .../.forgejo/workflows/test.yml | 9 ++++++ .../runner-config.yaml | 30 +++++++++++++++++++ actions/example-with-docker-host/setup.sh | 1 + actions/example-with-docker-host/teardown.sh | 1 + .../.forgejo/workflows/test.yml | 9 ++++++ .../runner-config.yaml | 30 +++++++++++++++++++ actions/example-with-docker-socket/setup.sh | 1 + .../example-with-docker-socket/teardown.sh | 1 + .../.forgejo/workflows/test.yml | 11 +++++++ .../runner-config.yaml | 30 +++++++++++++++++++ actions/example-with-docker-tcp/setup.sh | 1 + actions/example-with-docker-tcp/teardown.sh | 1 + .../.forgejo/workflows/test.yml | 6 ++++ 16 files changed, 158 insertions(+) create mode 100644 actions/example-with-docker-host/.forgejo/workflows/test.yml create mode 100644 actions/example-with-docker-host/runner-config.yaml create mode 100755 actions/example-with-docker-host/setup.sh create mode 100755 actions/example-with-docker-host/teardown.sh create mode 100644 actions/example-with-docker-socket/.forgejo/workflows/test.yml create mode 100644 actions/example-with-docker-socket/runner-config.yaml create mode 100755 actions/example-with-docker-socket/setup.sh create mode 100755 actions/example-with-docker-socket/teardown.sh create mode 100644 actions/example-with-docker-tcp/.forgejo/workflows/test.yml create mode 100644 actions/example-with-docker-tcp/runner-config.yaml create mode 100755 actions/example-with-docker-tcp/setup.sh create mode 100755 actions/example-with-docker-tcp/teardown.sh create mode 100644 actions/example-without-docker-socket/.forgejo/workflows/test.yml diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index 690c814..b460f1b 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -77,6 +77,7 @@ jobs: steps: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: ./.forgejo/prepare-end-to-end + - run: ./end-to-end.sh prepare_dockerd - run: su forgejo -c "./end-to-end.sh test_actions" - name: full logs if: always() diff --git a/README.md b/README.md index 4b5808a..4e7ed5b 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,10 @@ firefox 0.0.0.0:3000 # user root / admin1234 ./end-to-end.sh actions_verify_example echo ./end-to-end.sh actions_teardown ``` + +Note that `with-docker-tcp` requires the docker daemon listens to +tcp://127.0.0.1:2375. See `actions/actions.sh` for how to do that. + ## Running other tests locally To run and debug tests, from the root of the source directory. diff --git a/actions/actions.sh b/actions/actions.sh index e248f7f..321524a 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -101,6 +101,21 @@ function actions_runner_version() { echo $runner_version } +function prepare_dockerd() { + mkdir -p /etc/systemd/system/docker.service.d + cat >/etc/systemd/system/docker.service.d/override.conf <<'EOF' +[Service] +ExecStart= +ExecStart=/usr/sbin/dockerd -H unix:///var/run/docker.sock -H tcp://127.0.0.1:2375 --containerd=/run/containerd/containerd.sock $DOCKER_OPTS +EOF + systemctl daemon-reload + if ! systemctl restart docker.service; then + journalctl --no-pager --unit docker.service + return 1 + fi + netstat -lntp | grep 127.0.0.1:2375 +} + function test_actions() { local versions="${1:-$RELEASE_NUMBERS}" @@ -118,6 +133,13 @@ function test_actions() { run actions_verify_feature logs-compression fi + run actions_verify_example with-docker-tcp + if dpkg --compare-versions $runner_version gt 5.0.2; then + for example in with-docker-host with-docker-socket without-docker-socket; do + run actions_verify_example $example + done + fi + if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0; then for example in artifacts-v4; do run actions_verify_example $example diff --git a/actions/example-with-docker-host/.forgejo/workflows/test.yml b/actions/example-with-docker-host/.forgejo/workflows/test.yml new file mode 100644 index 0000000..32a82a4 --- /dev/null +++ b/actions/example-with-docker-host/.forgejo/workflows/test.yml @@ -0,0 +1,9 @@ +on: [push] + +jobs: + build: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + steps: + - run: "test -e /var/run/docker.sock" diff --git a/actions/example-with-docker-host/runner-config.yaml b/actions/example-with-docker-host/runner-config.yaml new file mode 100644 index 0000000..839de20 --- /dev/null +++ b/actions/example-with-docker-host/runner-config.yaml @@ -0,0 +1,30 @@ + +log: + level: debug + +runner: + file: .runner + capacity: 1 + env_file: .env + timeout: 3h + insecure: false + fetch_timeout: 5s + fetch_interval: 2s + labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"] + +cache: + enabled: true + dir: "/srv/example/cache" + host: "" + port: 0 + +container: + network: "bridge" + privileged: false + options: + workdir_parent: + valid_volumes: ["/srv/example"] + docker_host: "unix:///var/run/docker.sock" + +host: + workdir_parent: diff --git a/actions/example-with-docker-host/setup.sh b/actions/example-with-docker-host/setup.sh new file mode 100755 index 0000000..9c1f5ad --- /dev/null +++ b/actions/example-with-docker-host/setup.sh @@ -0,0 +1 @@ +FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload diff --git a/actions/example-with-docker-host/teardown.sh b/actions/example-with-docker-host/teardown.sh new file mode 100755 index 0000000..b410c51 --- /dev/null +++ b/actions/example-with-docker-host/teardown.sh @@ -0,0 +1 @@ +forgejo-runner.sh reload diff --git a/actions/example-with-docker-socket/.forgejo/workflows/test.yml b/actions/example-with-docker-socket/.forgejo/workflows/test.yml new file mode 100644 index 0000000..32a82a4 --- /dev/null +++ b/actions/example-with-docker-socket/.forgejo/workflows/test.yml @@ -0,0 +1,9 @@ +on: [push] + +jobs: + build: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + steps: + - run: "test -e /var/run/docker.sock" diff --git a/actions/example-with-docker-socket/runner-config.yaml b/actions/example-with-docker-socket/runner-config.yaml new file mode 100644 index 0000000..e09edaa --- /dev/null +++ b/actions/example-with-docker-socket/runner-config.yaml @@ -0,0 +1,30 @@ + +log: + level: debug + +runner: + file: .runner + capacity: 1 + env_file: .env + timeout: 3h + insecure: false + fetch_timeout: 5s + fetch_interval: 2s + labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"] + +cache: + enabled: true + dir: "/srv/example/cache" + host: "" + port: 0 + +container: + network: "bridge" + privileged: false + options: + workdir_parent: + valid_volumes: ["/srv/example"] + docker_host: "automount" + +host: + workdir_parent: diff --git a/actions/example-with-docker-socket/setup.sh b/actions/example-with-docker-socket/setup.sh new file mode 100755 index 0000000..9c1f5ad --- /dev/null +++ b/actions/example-with-docker-socket/setup.sh @@ -0,0 +1 @@ +FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload diff --git a/actions/example-with-docker-socket/teardown.sh b/actions/example-with-docker-socket/teardown.sh new file mode 100755 index 0000000..b410c51 --- /dev/null +++ b/actions/example-with-docker-socket/teardown.sh @@ -0,0 +1 @@ +forgejo-runner.sh reload diff --git a/actions/example-with-docker-tcp/.forgejo/workflows/test.yml b/actions/example-with-docker-tcp/.forgejo/workflows/test.yml new file mode 100644 index 0000000..c33c2e7 --- /dev/null +++ b/actions/example-with-docker-tcp/.forgejo/workflows/test.yml @@ -0,0 +1,11 @@ +on: [push] + +jobs: + build: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + steps: + - run: | + ! test -e /var/run/docker.sock + ! env | grep DOCKER_HOST diff --git a/actions/example-with-docker-tcp/runner-config.yaml b/actions/example-with-docker-tcp/runner-config.yaml new file mode 100644 index 0000000..730d9c8 --- /dev/null +++ b/actions/example-with-docker-tcp/runner-config.yaml @@ -0,0 +1,30 @@ + +log: + level: debug + +runner: + file: .runner + capacity: 1 + env_file: .env + timeout: 3h + insecure: false + fetch_timeout: 5s + fetch_interval: 2s + labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"] + +cache: + enabled: true + dir: "/srv/example/cache" + host: "" + port: 0 + +container: + network: "bridge" + privileged: false + options: + workdir_parent: + valid_volumes: ["/srv/example"] + docker_host: "tcp://127.0.0.1:2375" + +host: + workdir_parent: diff --git a/actions/example-with-docker-tcp/setup.sh b/actions/example-with-docker-tcp/setup.sh new file mode 100755 index 0000000..9c1f5ad --- /dev/null +++ b/actions/example-with-docker-tcp/setup.sh @@ -0,0 +1 @@ +FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload diff --git a/actions/example-with-docker-tcp/teardown.sh b/actions/example-with-docker-tcp/teardown.sh new file mode 100755 index 0000000..b410c51 --- /dev/null +++ b/actions/example-with-docker-tcp/teardown.sh @@ -0,0 +1 @@ +forgejo-runner.sh reload diff --git a/actions/example-without-docker-socket/.forgejo/workflows/test.yml b/actions/example-without-docker-socket/.forgejo/workflows/test.yml new file mode 100644 index 0000000..8d5c837 --- /dev/null +++ b/actions/example-without-docker-socket/.forgejo/workflows/test.yml @@ -0,0 +1,6 @@ +on: [push] +jobs: + test: + runs-on: docker + steps: + - run: "! test -e /var/run/docker.sock" From 77e6412295c969aced9580a8eca7ff05154a704b Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 27 Nov 2024 10:26:17 +0000 Subject: [PATCH 147/203] fix(actions): documentation update matrix needs prepare_dockerd It runs all actions tests to collect artefacts relevant to the documentation and has the same dependencies as running the actions tests in a pull request. --- .forgejo/workflows/end-to-end.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index b460f1b..bb0348b 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -129,6 +129,7 @@ jobs: set -x full_version=$(./end-to-end.sh full_version ${{ matrix.info.version }} ${{ matrix.info.owner }}) echo value="$full_version" >> $GITHUB_OUTPUT + - run: ./end-to-end.sh prepare_dockerd - run: su forgejo -c "./end-to-end.sh test_actions ${{ matrix.info.version }}" - name: update documentation uses: https://code.forgejo.org/actions/cascading-pr@v2.1 From bc7eb2f2455eac7afd0d9b090784de4bfdd9a49a Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 27 Nov 2024 12:01:13 +0000 Subject: [PATCH 148/203] Update actions/setup-forgejo action to v2.0.3 --- .forgejo/prepare-end-to-end/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/prepare-end-to-end/action.yml b/.forgejo/prepare-end-to-end/action.yml index 3bf0413..024a2e2 100644 --- a/.forgejo/prepare-end-to-end/action.yml +++ b/.forgejo/prepare-end-to-end/action.yml @@ -11,7 +11,7 @@ runs: /usr/local/bin/garage key: S3 - - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.2 + - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.3 with: install-only: true - run: forgejo-binary.sh ensure_user forgejo From 6ce90814b20492b738867247dd33776255d87ee7 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 4 Dec 2024 14:11:17 +0100 Subject: [PATCH 149/203] fix: do not use api.github.com to avoid being rate limited --- lib/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lib.sh b/lib/lib.sh index 2c952b8..a2a8679 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -132,7 +132,7 @@ function download_gitea() { if ! test -f $DIR_BINARIES/gitea-$version; then mkdir -p $DIR_BINARIES if [[ $version =~ ^[0-9]+\.[0-9]+$ ]]; then - full_version=$(curl -sS "https://api.github.com/repos/go-gitea/gitea/releases?per_page=100" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | grep -v -e '-rc' | sort --reverse --version-sort | head -1) + full_version=$(curl -sS "https://gitea.com/api/v1/repos/gitea/gitea-mirror/tags" | jq -r '.[] | .name | select(startswith("v'$version'"))' | grep -v -e '-rc' | sort --reverse --version-sort | head -1) full_version=${full_version#v} else full_version=$version From 0a782ec58fc3ce011c64e5f46d22ae0176a4c6f7 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 8 Dec 2024 00:01:21 +0000 Subject: [PATCH 150/203] Update actions/setup-forgejo action to v2.0.4 --- .forgejo/prepare-end-to-end/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/prepare-end-to-end/action.yml b/.forgejo/prepare-end-to-end/action.yml index 024a2e2..e2dbbe6 100644 --- a/.forgejo/prepare-end-to-end/action.yml +++ b/.forgejo/prepare-end-to-end/action.yml @@ -11,7 +11,7 @@ runs: /usr/local/bin/garage key: S3 - - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.3 + - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.4 with: install-only: true - run: forgejo-binary.sh ensure_user forgejo From d142c4a60db46bea1f98609022f2ee5c434536b4 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 8 Dec 2024 16:18:15 +0100 Subject: [PATCH 151/203] fix: actions: verify the docker_host socket works It could be mounted but not functional. --- actions/example-with-docker-host/.forgejo/workflows/test.yml | 5 +++-- .../example-with-docker-socket/.forgejo/workflows/test.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actions/example-with-docker-host/.forgejo/workflows/test.yml b/actions/example-with-docker-host/.forgejo/workflows/test.yml index 32a82a4..6089092 100644 --- a/actions/example-with-docker-host/.forgejo/workflows/test.yml +++ b/actions/example-with-docker-host/.forgejo/workflows/test.yml @@ -4,6 +4,7 @@ jobs: build: runs-on: docker container: - image: code.forgejo.org/oci/node:20-bookworm + image: code.forgejo.org/oci/docker:cli steps: - - run: "test -e /var/run/docker.sock" + - run: ls -l /var/run/docker.sock + - run: docker ps diff --git a/actions/example-with-docker-socket/.forgejo/workflows/test.yml b/actions/example-with-docker-socket/.forgejo/workflows/test.yml index 32a82a4..6089092 100644 --- a/actions/example-with-docker-socket/.forgejo/workflows/test.yml +++ b/actions/example-with-docker-socket/.forgejo/workflows/test.yml @@ -4,6 +4,7 @@ jobs: build: runs-on: docker container: - image: code.forgejo.org/oci/node:20-bookworm + image: code.forgejo.org/oci/docker:cli steps: - - run: "test -e /var/run/docker.sock" + - run: ls -l /var/run/docker.sock + - run: docker ps From af5923c7d47128798fee3cec5f61b947afa681bc Mon Sep 17 00:00:00 2001 From: xtex Date: Fri, 13 Dec 2024 21:19:44 +0800 Subject: [PATCH 152/203] feat: test FORGEJO_TOKEN --- actions/actions.sh | 4 ++++ .../.forgejo/workflows/test.yml | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 actions/example-branding-v10/.forgejo/workflows/test.yml diff --git a/actions/actions.sh b/actions/actions.sh index 321524a..8eb7a76 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -171,5 +171,9 @@ function test_actions() { if dpkg --compare-versions $version ge 9.0; then run actions_verify_example schedule-noncancel fi + + if dpkg --compare-versions $version ge 10.0 && dpkg --compare-versions $runner_version gt 5.0.4; then + run actions_verify_example branding-v10 + fi done } diff --git a/actions/example-branding-v10/.forgejo/workflows/test.yml b/actions/example-branding-v10/.forgejo/workflows/test.yml new file mode 100644 index 0000000..a51b8fa --- /dev/null +++ b/actions/example-branding-v10/.forgejo/workflows/test.yml @@ -0,0 +1,14 @@ +on: [push] + +jobs: + test: + runs-on: docker + container: + image: code.forgejo.org/oci/node:20-bookworm + steps: + - name: FORGEJO_TOKEN + run: | + set -x + test "$FORGEJO_TOKEN" + test "$FORGEJO_TOKEN" = "${{ env.FORGEJO_TOKEN }}" + test "$FORGEJO_TOKEN" = "${{ github.TOKEN }}" From 33d36a0e99c43aad6d93ca5921e37f2ddcf2bf7c Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 22 Dec 2024 12:48:09 +0100 Subject: [PATCH 153/203] feat: verify migration warnings when upgrading from Gitea --- upgrade/upgrade.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index fb2f8c8..fd84757 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -49,12 +49,22 @@ function test_successful_upgrades() { done } +function migration_assert() { + local work_path=$DIR/forgejo-work-path + local logfile=$work_path/log/forgejo.log + + grep --quiet 'ORM engine initialization successful' $logfile + if grep --fixed-strings 'serveInstalled() [W] Table' $logfile; then + echo "unexpected warnings in database migration" + return 1 + fi +} + function test_gitea_upgrades() { local config=$UPGRADE_DIR/default-app.ini ( - echo gitea 1.21 forgejo 7.0 - echo gitea 1.21 forgejo 9.0 - echo gitea 1.22 forgejo 9.0 + echo gitea 1.21 forgejo 10.0 + echo gitea 1.22 forgejo 10.0 ) | while read gitea gitea_version forgejo forgejo_version; do log_info "upgrading from Gitea $gitea_version to Forgejo $forgejo_version" stop @@ -74,6 +84,8 @@ function test_gitea_upgrades() { verify_storage fixture_assert doctor_run $config + + migration_assert done } From 186b29a8a0efe62aa624e2a73dd486e50c43981c Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 24 Dec 2024 09:56:36 +0100 Subject: [PATCH 154/203] Revert "feat: test FORGEJO_TOKEN" This reverts commit af5923c7d47128798fee3cec5f61b947afa681bc. --- actions/actions.sh | 4 ---- .../.forgejo/workflows/test.yml | 14 -------------- 2 files changed, 18 deletions(-) delete mode 100644 actions/example-branding-v10/.forgejo/workflows/test.yml diff --git a/actions/actions.sh b/actions/actions.sh index 8eb7a76..321524a 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -171,9 +171,5 @@ function test_actions() { if dpkg --compare-versions $version ge 9.0; then run actions_verify_example schedule-noncancel fi - - if dpkg --compare-versions $version ge 10.0 && dpkg --compare-versions $runner_version gt 5.0.4; then - run actions_verify_example branding-v10 - fi done } diff --git a/actions/example-branding-v10/.forgejo/workflows/test.yml b/actions/example-branding-v10/.forgejo/workflows/test.yml deleted file mode 100644 index a51b8fa..0000000 --- a/actions/example-branding-v10/.forgejo/workflows/test.yml +++ /dev/null @@ -1,14 +0,0 @@ -on: [push] - -jobs: - test: - runs-on: docker - container: - image: code.forgejo.org/oci/node:20-bookworm - steps: - - name: FORGEJO_TOKEN - run: | - set -x - test "$FORGEJO_TOKEN" - test "$FORGEJO_TOKEN" = "${{ env.FORGEJO_TOKEN }}" - test "$FORGEJO_TOKEN" = "${{ github.TOKEN }}" From 346b44a198c5fae961db086ec1075330db760d59 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 29 Dec 2024 16:14:07 +0000 Subject: [PATCH 155/203] upgrade: verify that Forgejo upgrades show no migration warnings Refs: https://codeberg.org/forgejo/forgejo/issues/6389 --- upgrade/upgrade.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index fd84757..b4cab9c 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -46,6 +46,8 @@ function test_successful_upgrades() { fixture_assert doctor_run $config done + + migration_assert done } From 3bfb74d358a4660d40b76093ed68109995019b8a Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 25 Dec 2024 11:50:37 +0100 Subject: [PATCH 156/203] chore(release): cut branch v11.0 --- .forgejo/workflows/end-to-end.yml | 4 ++-- forgejo/sources/10.0 | 2 +- forgejo/sources/11.0 | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 forgejo/sources/11.0 diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index bb0348b..6ffa514 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -112,11 +112,11 @@ jobs: strategy: matrix: info: - - version: "10.0" + - version: "11.0" branch: next forgejo: https://codeberg.org owner: forgejo-experimental - - version: "9.0" + - version: "10.0" forgejo: https://codeberg.org owner: forgejo steps: diff --git a/forgejo/sources/10.0 b/forgejo/sources/10.0 index 101d770..7c1c013 100644 --- a/forgejo/sources/10.0 +++ b/forgejo/sources/10.0 @@ -1 +1 @@ -https://codeberg.org/forgejo/forgejo forgejo 10.0.0+gitea-1.23 +https://codeberg.org/forgejo/forgejo forgejo 10.0.0+gitea-1.22 diff --git a/forgejo/sources/11.0 b/forgejo/sources/11.0 new file mode 100644 index 0000000..0286dca --- /dev/null +++ b/forgejo/sources/11.0 @@ -0,0 +1 @@ +https://codeberg.org/forgejo/forgejo forgejo 11.0.0 From f6f0acae0e69b8b4df4d75e31a22d944d81bb62d Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 11 Jan 2025 09:02:39 +0100 Subject: [PATCH 157/203] actions: verify runner config options for the container - is not restricted to --volume (can use --env, etc.) - --volume is sanitized with valid_volumes --- actions/actions.sh | 2 +- .../.forgejo/workflows/test.yml | 12 ++++++++ .../example-config-options/runner-config.yaml | 30 +++++++++++++++++++ actions/example-config-options/setup.sh | 3 ++ actions/example-config-options/teardown.sh | 1 + 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 actions/example-config-options/.forgejo/workflows/test.yml create mode 100644 actions/example-config-options/runner-config.yaml create mode 100755 actions/example-config-options/setup.sh create mode 100755 actions/example-config-options/teardown.sh diff --git a/actions/actions.sh b/actions/actions.sh index 321524a..230f3b4 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -146,7 +146,7 @@ function test_actions() { done fi - for example in cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do + for example in config-options cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do run actions_verify_example $example done diff --git a/actions/example-config-options/.forgejo/workflows/test.yml b/actions/example-config-options/.forgejo/workflows/test.yml new file mode 100644 index 0000000..83b6b0a --- /dev/null +++ b/actions/example-config-options/.forgejo/workflows/test.yml @@ -0,0 +1,12 @@ +on: [push] + +jobs: + test: + runs-on: docker + steps: + - run: | + test -f /srv/example-config-options-volume-valid + - run: | + ! test -f /srv/example-config-options-volume-invalid + - run: | + test "$FROB" = "NITZ" diff --git a/actions/example-config-options/runner-config.yaml b/actions/example-config-options/runner-config.yaml new file mode 100644 index 0000000..13b9b72 --- /dev/null +++ b/actions/example-config-options/runner-config.yaml @@ -0,0 +1,30 @@ + +log: + level: debug + +runner: + file: .runner + capacity: 1 + env_file: .env + timeout: 3h + insecure: false + fetch_timeout: 5s + fetch_interval: 2s + labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"] + +cache: + enabled: false + dir: "" + host: "" + port: 0 + +container: + network: "" + privileged: false + options: "--volume /srv/example-config-options-volume-valid:/srv/example-config-options-volume-valid --volume /srv/example-config-options-volume-invalid:/srv/example-config-options-volume-invalid --env FROB=NITZ" + workdir_parent: + valid_volumes: ["/srv/example-config-options-volume-valid"] + docker_host: "" + +host: + workdir_parent: diff --git a/actions/example-config-options/setup.sh b/actions/example-config-options/setup.sh new file mode 100755 index 0000000..d9f6ea9 --- /dev/null +++ b/actions/example-config-options/setup.sh @@ -0,0 +1,3 @@ +>/srv/example-config-options-volume-valid +>/srv/example-config-options-volume-invalid +FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload diff --git a/actions/example-config-options/teardown.sh b/actions/example-config-options/teardown.sh new file mode 100755 index 0000000..b410c51 --- /dev/null +++ b/actions/example-config-options/teardown.sh @@ -0,0 +1 @@ +forgejo-runner.sh reload From dbe50bffc7fb01b6e8cee98d445d44f7ebd8a25c Mon Sep 17 00:00:00 2001 From: gratux Date: Sat, 11 Jan 2025 15:27:44 +0000 Subject: [PATCH 158/203] add test for force_rebuild (#448) see also [forgejo/runner #406](https://code.forgejo.org/forgejo/runner/pulls/406) Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/448 Reviewed-by: earl-warren Co-authored-by: gratux Co-committed-by: gratux --- actions/actions.sh | 4 +++ .../.forgejo/local-docker-action/Dockerfile | 5 +++ .../.forgejo/local-docker-action/action.yml | 6 ++++ .../local-docker-action/entrypoint.sh | 3 ++ .../.forgejo/local-docker-action/input.txt | 1 + .../.forgejo/workflows/test.yml | 10 ++++++ actions/example-force-rebuild/run.sh | 34 +++++++++++++++++++ .../runner-config-with-rebuild.yml | 30 ++++++++++++++++ .../runner-config-without-rebuild.yml | 30 ++++++++++++++++ actions/example-force-rebuild/teardown.sh | 1 + 10 files changed, 124 insertions(+) create mode 100644 actions/example-force-rebuild/.forgejo/local-docker-action/Dockerfile create mode 100644 actions/example-force-rebuild/.forgejo/local-docker-action/action.yml create mode 100755 actions/example-force-rebuild/.forgejo/local-docker-action/entrypoint.sh create mode 100644 actions/example-force-rebuild/.forgejo/local-docker-action/input.txt create mode 100644 actions/example-force-rebuild/.forgejo/workflows/test.yml create mode 100755 actions/example-force-rebuild/run.sh create mode 100644 actions/example-force-rebuild/runner-config-with-rebuild.yml create mode 100644 actions/example-force-rebuild/runner-config-without-rebuild.yml create mode 100755 actions/example-force-rebuild/teardown.sh diff --git a/actions/actions.sh b/actions/actions.sh index 230f3b4..0311d68 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -140,6 +140,10 @@ function test_actions() { done fi + if dpkg --compare-versions $runner_version gt 6.0.1; then + run actions_verify_example force-rebuild + fi + if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0; then for example in artifacts-v4; do run actions_verify_example $example diff --git a/actions/example-force-rebuild/.forgejo/local-docker-action/Dockerfile b/actions/example-force-rebuild/.forgejo/local-docker-action/Dockerfile new file mode 100644 index 0000000..23e027e --- /dev/null +++ b/actions/example-force-rebuild/.forgejo/local-docker-action/Dockerfile @@ -0,0 +1,5 @@ +FROM debian:bookworm-slim +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" ] \ No newline at end of file diff --git a/actions/example-force-rebuild/.forgejo/local-docker-action/action.yml b/actions/example-force-rebuild/.forgejo/local-docker-action/action.yml new file mode 100644 index 0000000..e53d627 --- /dev/null +++ b/actions/example-force-rebuild/.forgejo/local-docker-action/action.yml @@ -0,0 +1,6 @@ +name: local docker action +description: local docker action, build depends on "input.txt" + +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/actions/example-force-rebuild/.forgejo/local-docker-action/entrypoint.sh b/actions/example-force-rebuild/.forgejo/local-docker-action/entrypoint.sh new file mode 100755 index 0000000..e2ee36a --- /dev/null +++ b/actions/example-force-rebuild/.forgejo/local-docker-action/entrypoint.sh @@ -0,0 +1,3 @@ +#! /usr/bin/env bash +set -x +exit "$(< /run/input.txt)" \ No newline at end of file diff --git a/actions/example-force-rebuild/.forgejo/local-docker-action/input.txt b/actions/example-force-rebuild/.forgejo/local-docker-action/input.txt new file mode 100644 index 0000000..5a94479 --- /dev/null +++ b/actions/example-force-rebuild/.forgejo/local-docker-action/input.txt @@ -0,0 +1 @@ +this file will be filled by the test \ No newline at end of file diff --git a/actions/example-force-rebuild/.forgejo/workflows/test.yml b/actions/example-force-rebuild/.forgejo/workflows/test.yml new file mode 100644 index 0000000..4151065 --- /dev/null +++ b/actions/example-force-rebuild/.forgejo/workflows/test.yml @@ -0,0 +1,10 @@ +--- +on: + push: +jobs: + test: + runs-on: docker + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - uses: ./.forgejo/local-docker-action diff --git a/actions/example-force-rebuild/run.sh b/actions/example-force-rebuild/run.sh new file mode 100755 index 0000000..2f2cb7e --- /dev/null +++ b/actions/example-force-rebuild/run.sh @@ -0,0 +1,34 @@ +function setup_with_rebuild() { + FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config-with-rebuild.yml forgejo-runner.sh reload +} + +function setup_without_rebuild() { + FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config-without-rebuild.yml forgejo-runner.sh reload +} + +function run() { + local expected="$1" + local repo=root/example-$example + forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token + sha=$(forgejo-test-helper.sh branch_tip $url $repo main) + forgejo-test-helper.sh wait_$expected $url $repo $sha +} + +function main() { + # set up passing docker action + echo "0" > $EXAMPLE_DIR/.forgejo/local-docker-action/input.txt + setup_with_rebuild + run success + + # change docker action to fail + echo "1" > $EXAMPLE_DIR/.forgejo/local-docker-action/input.txt + # ... but without a rebuild, it should still pass + setup_without_rebuild + run success + + # now the action should fail + setup_with_rebuild + run failure +} + +main diff --git a/actions/example-force-rebuild/runner-config-with-rebuild.yml b/actions/example-force-rebuild/runner-config-with-rebuild.yml new file mode 100644 index 0000000..c99a230 --- /dev/null +++ b/actions/example-force-rebuild/runner-config-with-rebuild.yml @@ -0,0 +1,30 @@ +log: + level: debug + +runner: + file: .runner + capacity: 1 + env_file: .env + timeout: 3h + insecure: false + fetch_timeout: 5s + fetch_interval: 2s + labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"] + +cache: + enabled: false + dir: "" + host: "" + port: 0 + +container: + network: "bridge" + privileged: false + options: + workdir_parent: + valid_volumes: ["/srv/example"] + docker_host: "" + force_rebuild: true + +host: + workdir_parent: diff --git a/actions/example-force-rebuild/runner-config-without-rebuild.yml b/actions/example-force-rebuild/runner-config-without-rebuild.yml new file mode 100644 index 0000000..793fbcd --- /dev/null +++ b/actions/example-force-rebuild/runner-config-without-rebuild.yml @@ -0,0 +1,30 @@ +log: + level: debug + +runner: + file: .runner + capacity: 1 + env_file: .env + timeout: 3h + insecure: false + fetch_timeout: 5s + fetch_interval: 2s + labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"] + +cache: + enabled: false + dir: "" + host: "" + port: 0 + +container: + network: "bridge" + privileged: false + options: + workdir_parent: + valid_volumes: ["/srv/example"] + docker_host: "" + force_rebuild: false + +host: + workdir_parent: diff --git a/actions/example-force-rebuild/teardown.sh b/actions/example-force-rebuild/teardown.sh new file mode 100755 index 0000000..b410c51 --- /dev/null +++ b/actions/example-force-rebuild/teardown.sh @@ -0,0 +1 @@ +forgejo-runner.sh reload From dacb3b0fac69265be900abb955b61813d67db239 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 11 Jan 2025 18:05:32 +0100 Subject: [PATCH 159/203] chore(cleanup): log compression test does not belong It is a feature and best tested in Forgejo itself, not in end-to-end. It is a recurring source of false negative and there is little to no value is fixing the associated border case because it only applies to short lived Forgejo instances used during tests. Fixes: https://code.forgejo.org/forgejo/end-to-end/issues/431 --- actions/actions.sh | 9 +-------- actions/feature-logs-compression/run.sh | 15 --------------- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100755 actions/feature-logs-compression/run.sh diff --git a/actions/actions.sh b/actions/actions.sh index 0311d68..e62debf 100755 --- a/actions/actions.sh +++ b/actions/actions.sh @@ -126,13 +126,6 @@ function test_actions() { log_info "Testing actions with Forgejo $version & Forgejo runner $runner_version" - run actions_verify_example echo - if dpkg --compare-versions $version ge 9.0; then - # depends on run actions_verify_example echo - # run it immediately after - run actions_verify_feature logs-compression - fi - run actions_verify_example with-docker-tcp if dpkg --compare-versions $runner_version gt 5.0.2; then for example in with-docker-host with-docker-socket without-docker-socket; do @@ -150,7 +143,7 @@ function test_actions() { done fi - for example in config-options cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do + for example in echo config-options cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do run actions_verify_example $example done diff --git a/actions/feature-logs-compression/run.sh b/actions/feature-logs-compression/run.sh deleted file mode 100755 index 7502fbd..0000000 --- a/actions/feature-logs-compression/run.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -e - -source $FEATURE_DIR/../../lib/lib.sh -source $FEATURE_DIR/../../forgejo/fixtures.sh - -if ! retry bash -c "find $DIR/forgejo-work-path/data/actions_log/root/example-echo | grep --quiet log.zst"; then - ( - cd $DIR/forgejo-work-path - find data - ) - echo expected a single log.zst file in data/actions_log/root/example-echo - exit 1 -fi From 734eb7de64fb4f416c1727070909a0b7ba5cbbf4 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 11 Jan 2025 18:18:13 +0000 Subject: [PATCH 160/203] Update actions/setup-forgejo action to v2.0.5 --- .forgejo/prepare-end-to-end/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/prepare-end-to-end/action.yml b/.forgejo/prepare-end-to-end/action.yml index e2dbbe6..b345b28 100644 --- a/.forgejo/prepare-end-to-end/action.yml +++ b/.forgejo/prepare-end-to-end/action.yml @@ -11,7 +11,7 @@ runs: /usr/local/bin/garage key: S3 - - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.4 + - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.5 with: install-only: true - run: forgejo-binary.sh ensure_user forgejo From 65e3fafd02990b4614d50049e1bf1bfbd41a28e1 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 12 Jan 2025 08:05:37 +0100 Subject: [PATCH 161/203] actions: force-rebuild must use a copy of the repository it may not have permission to write on the repository itself, nor should it. --- actions/example-force-rebuild/run.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/actions/example-force-rebuild/run.sh b/actions/example-force-rebuild/run.sh index 2f2cb7e..d82890a 100755 --- a/actions/example-force-rebuild/run.sh +++ b/actions/example-force-rebuild/run.sh @@ -1,3 +1,7 @@ +TMPDIR=$(mktemp -d) + +trap "rm -fr $TMPDIR" EXIT + function setup_with_rebuild() { FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config-with-rebuild.yml forgejo-runner.sh reload } @@ -7,28 +11,32 @@ function setup_without_rebuild() { } function run() { - local expected="$1" + local dir="$1" + local expected="$2" 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) forgejo-test-helper.sh wait_$expected $url $repo $sha } function main() { + local dir=$TMPDIR/repository + cp -a $EXAMPLE_DIR $dir + # 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 - run success + run $dir success # 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 setup_without_rebuild - run success + run $dir success # now the action should fail setup_with_rebuild - run failure + run $dir failure } main From adb09f901bbeb89661e5f44daacb151687d875aa Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 12 Jan 2025 08:07:07 +0100 Subject: [PATCH 162/203] actions: force-rebuild use code.forgejo.org/oci to avoid throttling --- .../.forgejo/local-docker-action/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/example-force-rebuild/.forgejo/local-docker-action/Dockerfile b/actions/example-force-rebuild/.forgejo/local-docker-action/Dockerfile index 23e027e..2339a39 100644 --- a/actions/example-force-rebuild/.forgejo/local-docker-action/Dockerfile +++ b/actions/example-force-rebuild/.forgejo/local-docker-action/Dockerfile @@ -1,5 +1,5 @@ -FROM debian:bookworm-slim +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" ] \ No newline at end of file +ENTRYPOINT [ "/run/entrypoint.sh" ] From beae8629a6436a89df36b814d3922238b04dcc61 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 13 Jan 2025 05:30:48 +0100 Subject: [PATCH 163/203] fix: use code.forgejo.org instead of docker.io to avoid throttling Fixes: https://code.forgejo.org/forgejo/end-to-end/actions/runs/2316 --- .forgejo/workflows/end-to-end.yml | 2 +- actions/example-container/.forgejo/workflows/test.yml | 2 +- packages/alpine.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/end-to-end.yml b/.forgejo/workflows/end-to-end.yml index 6ffa514..35b27fc 100644 --- a/.forgejo/workflows/end-to-end.yml +++ b/.forgejo/workflows/end-to-end.yml @@ -23,7 +23,7 @@ jobs: build: runs-on: docker container: - image: 'docker.io/node:20-bookworm' + image: 'code.forgejo.org/oci/node:20-bookworm' steps: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: https://code.forgejo.org/actions/setup-go@v5 diff --git a/actions/example-container/.forgejo/workflows/test.yml b/actions/example-container/.forgejo/workflows/test.yml index 583df87..ded75cd 100644 --- a/actions/example-container/.forgejo/workflows/test.yml +++ b/actions/example-container/.forgejo/workflows/test.yml @@ -3,6 +3,6 @@ jobs: test: runs-on: docker container: - image: alpine:3.19 + image: code.forgejo.org/oci/alpine:3.21 steps: - run: grep Alpine /etc/os-release diff --git a/packages/alpine.sh b/packages/alpine.sh index 4ae92ae..092d625 100644 --- a/packages/alpine.sh +++ b/packages/alpine.sh @@ -12,7 +12,7 @@ function test_packages_alpine_version() { local url=http://${HOST_PORT} log_info "alpine:$alpine_version & Forgejo $forgejo_version" - docker run --rm --volume $d:$d:ro --workdir $d docker.io/alpine:$alpine_version ash -c "./test.sh $url $token" + docker run --rm --volume $d:$d:ro --workdir $d code.forgejo.org/oci/alpine:$alpine_version ash -c "./test.sh $url $token" } function test_packages_alpine() { From 135bd00a26101cd317720584b31ed1562f3b6d89 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 13 Jan 2025 05:34:29 +0100 Subject: [PATCH 164/203] feat: use alpine 3.21 and forgejo 10.0 and no longer alpine 3.19 and forgejo 9.0 --- packages/{alpine-9.0 => alpine-10.0} | 0 packages/alpine-7.0/test.sh | 6 +++--- packages/alpine.sh | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) rename packages/{alpine-9.0 => alpine-10.0} (100%) diff --git a/packages/alpine-9.0 b/packages/alpine-10.0 similarity index 100% rename from packages/alpine-9.0 rename to packages/alpine-10.0 diff --git a/packages/alpine-7.0/test.sh b/packages/alpine-7.0/test.sh index d830df2..4676e7c 100755 --- a/packages/alpine-7.0/test.sh +++ b/packages/alpine-7.0/test.sh @@ -41,7 +41,7 @@ for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do --fail \ -H "Authorization: token $forgejo_token" \ -X DELETE \ - "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests/$file" || + "$forgejo_url/api/packages/root/alpine/3.21/e2e-tests/$file" || true # upload new package @@ -49,13 +49,13 @@ for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do --fail \ -H "Authorization: token $forgejo_token" \ -T "$file" \ - "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests" + "$forgejo_url/api/packages/root/alpine/3.21/e2e-tests" done # ensure that the install-if condition works as expected apk add openrc (cd /etc/apk/keys && curl -JO $forgejo_url/api/packages/root/alpine/key) -echo "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests" >>/etc/apk/repositories +echo "$forgejo_url/api/packages/root/alpine/3.21/e2e-tests" >>/etc/apk/repositories apk add forgejo-2174 forgejo-2173 [ -e /usr/bin/forgejo_2174 ] # from the installed package [ -e /usr/bin/forgejo_2173 ] # from the installed package diff --git a/packages/alpine.sh b/packages/alpine.sh index 4ae92ae..59bc0c6 100644 --- a/packages/alpine.sh +++ b/packages/alpine.sh @@ -1,4 +1,4 @@ -# Copyright 2024 The Forgejo Authors +# Copyright 2025 The Forgejo Authors # SPDX-License-Identifier: MIT function test_packages_alpine_version() { @@ -16,8 +16,8 @@ function test_packages_alpine_version() { } function test_packages_alpine() { - for alpine_version in 3.19 3.20; do - for forgejo_version in 7.0 9.0; do + for alpine_version in 3.20 3.21; do + for forgejo_version in 7.0 10.0; do test_packages_alpine_version $alpine_version $forgejo_version done done From 5c2eebc521b653079f822e67aface0769f31e0fd Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 15 Jan 2025 13:18:19 +0100 Subject: [PATCH 165/203] fix: upgrade must use code.forgejo.org/oci Otherwise it may get rate limited in the CI verifying it works --- upgrade/test-pprof-upload.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/upgrade/test-pprof-upload.sh b/upgrade/test-pprof-upload.sh index 5c67687..732fae7 100644 --- a/upgrade/test-pprof-upload.sh +++ b/upgrade/test-pprof-upload.sh @@ -25,7 +25,7 @@ function test_upload_profiles() { function test_forgejo_pprof() { stop docker rm -f test_pyroscope - docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope + docker run --name test_pyroscope --rm -d -p 4040:4040 code.forgejo.org/oci/pyroscope:1.12.0 reset_forgejo $UPGRADE_DIR/default-app.ini log_info "run 7.0" @@ -39,5 +39,4 @@ function test_forgejo_pprof() { stop docker stop test_pyroscope - } From faaa390f15099b2efe60683c6d13ce7e5d5dee58 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 16 Jan 2025 00:01:54 +0000 Subject: [PATCH 166/203] Update actions/setup-forgejo action to v2.0.6 --- .forgejo/prepare-end-to-end/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/prepare-end-to-end/action.yml b/.forgejo/prepare-end-to-end/action.yml index b345b28..d86b6a5 100644 --- a/.forgejo/prepare-end-to-end/action.yml +++ b/.forgejo/prepare-end-to-end/action.yml @@ -11,7 +11,7 @@ runs: /usr/local/bin/garage key: S3 - - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.5 + - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.6 with: install-only: true - run: forgejo-binary.sh ensure_user forgejo From 80b6d688d001133e7748c5592fd2eca4ce4d871c Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 16 Jan 2025 09:43:45 +0100 Subject: [PATCH 167/203] feat: v9.0 is EOL and v11.0 needs testing --- lib/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lib.sh b/lib/lib.sh index a2a8679..590e082 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -26,7 +26,7 @@ IP=$(hostname -I | cut -f1 -d' ') # # Forgejo releases for which a branch exists (7.0/forgejo etc.) # -RELEASE_NUMBERS="7.0 9.0 10.0" +RELEASE_NUMBERS="7.0 10.0 11.0" PREFIX=============== export DIR=/tmp/forgejo-end-to-end From 5f9ea458446124ee41f9c901f905c4189c24f219 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 16 Jan 2025 19:23:06 +0100 Subject: [PATCH 168/203] fix: catch warnings and errors --- upgrade/upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index b4cab9c..377399d 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -56,7 +56,7 @@ function migration_assert() { local logfile=$work_path/log/forgejo.log grep --quiet 'ORM engine initialization successful' $logfile - if grep --fixed-strings 'serveInstalled() [W] Table' $logfile; then + if grep 'serveInstalled() \[[EW]\] Table' $logfile; then echo "unexpected warnings in database migration" return 1 fi From ff2c6790b3293bd265b4274be29f3dbfcb260cca Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 22 Jan 2025 18:46:02 +0100 Subject: [PATCH 169/203] feat: actions: verify that container.options --hostname is valid Refs: https://code.forgejo.org/forgejo/act/pulls/95 --- actions/example-config-options/.forgejo/workflows/test.yml | 4 ++++ actions/example-config-options/runner-config.yaml | 1 + 2 files changed, 5 insertions(+) diff --git a/actions/example-config-options/.forgejo/workflows/test.yml b/actions/example-config-options/.forgejo/workflows/test.yml index 83b6b0a..d9c0324 100644 --- a/actions/example-config-options/.forgejo/workflows/test.yml +++ b/actions/example-config-options/.forgejo/workflows/test.yml @@ -3,6 +3,8 @@ on: [push] jobs: test: runs-on: docker + container: + options: "--hostname customname" steps: - run: | test -f /srv/example-config-options-volume-valid @@ -10,3 +12,5 @@ jobs: ! test -f /srv/example-config-options-volume-invalid - run: | test "$FROB" = "NITZ" + - run: | + test "$(cat /etc/hostname)" = customname diff --git a/actions/example-config-options/runner-config.yaml b/actions/example-config-options/runner-config.yaml index 13b9b72..dff5356 100644 --- a/actions/example-config-options/runner-config.yaml +++ b/actions/example-config-options/runner-config.yaml @@ -1,6 +1,7 @@ log: level: debug + job_level: debug runner: file: .runner From 3275d464e5b2e8d56e0ffd52913b49740e938e93 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 22 Jan 2025 22:41:13 +0000 Subject: [PATCH 170/203] Update https://code.forgejo.org/actions/setup-forgejo action to v2.0.7 --- .forgejo/prepare-end-to-end/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/prepare-end-to-end/action.yml b/.forgejo/prepare-end-to-end/action.yml index d86b6a5..7bc2ed0 100644 --- a/.forgejo/prepare-end-to-end/action.yml +++ b/.forgejo/prepare-end-to-end/action.yml @@ -11,7 +11,7 @@ runs: /usr/local/bin/garage key: S3 - - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.6 + - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.7 with: install-only: true - run: forgejo-binary.sh ensure_user forgejo From a3388d98dc9d01e3e15cae5de67c5381d35d56c4 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 22 Jan 2025 23:09:03 +0000 Subject: [PATCH 171/203] Update https://code.forgejo.org/actions/setup-forgejo action to v2.0.7 (#509) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [https://code.forgejo.org/actions/setup-forgejo](https://code.forgejo.org/actions/setup-forgejo) | action | patch | `v2.0.6` -> `v2.0.7` | --- ### Release Notes
actions/setup-forgejo (https://code.forgejo.org/actions/setup-forgejo) ### [`v2.0.7`](https://code.forgejo.org/actions/setup-forgejo/compare/v2.0.6...v2.0.7) [Compare Source](https://code.forgejo.org/actions/setup-forgejo/compare/v2.0.6...v2.0.7)
--- ### Configuration 📅 **Schedule**: Branch creation - "* 0-3 * * *" (UTC), Automerge - "* 0-3 * * *" (UTC). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/509 Reviewed-by: earl-warren Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- .forgejo/prepare-end-to-end/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/prepare-end-to-end/action.yml b/.forgejo/prepare-end-to-end/action.yml index d86b6a5..7bc2ed0 100644 --- a/.forgejo/prepare-end-to-end/action.yml +++ b/.forgejo/prepare-end-to-end/action.yml @@ -11,7 +11,7 @@ runs: /usr/local/bin/garage key: S3 - - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.6 + - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.7 with: install-only: true - run: forgejo-binary.sh ensure_user forgejo From 8b33ac7b019852bcbd7f5f58707e8f4ffb36a770 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Mon, 27 Jan 2025 00:37:22 +0000 Subject: [PATCH 172/203] cascading-pr update --- last-upgrade | 1 + lib/ORGANIZATIONS | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 last-upgrade diff --git a/last-upgrade b/last-upgrade new file mode 100644 index 0000000..10818cc --- /dev/null +++ b/last-upgrade @@ -0,0 +1 @@ +Mon Jan 27 00:37:22 UTC 2025 diff --git a/lib/ORGANIZATIONS b/lib/ORGANIZATIONS index 8c8989a..60ddbbd 100644 --- a/lib/ORGANIZATIONS +++ b/lib/ORGANIZATIONS @@ -1 +1 @@ -forgejo forgejo-experimental forgejo-integration +forgejo-integration forgejo-experimental forgejo From 12d13427a9e4d52f8315ea252ab0193adfdeb1e3 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Tue, 28 Jan 2025 00:46:12 +0000 Subject: [PATCH 173/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 10818cc..a176823 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Mon Jan 27 00:37:22 UTC 2025 +Tue Jan 28 00:46:12 UTC 2025 From e86837c65826e2e7999f9ee77bc9901734e9eeab Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Wed, 29 Jan 2025 06:57:05 +0000 Subject: [PATCH 174/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index a176823..61835bb 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Tue Jan 28 00:46:12 UTC 2025 +Wed Jan 29 06:57:05 UTC 2025 From d67c3f64d659c4c06bf7e362072aa2ff9c37248d Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Wed, 29 Jan 2025 07:04:13 +0000 Subject: [PATCH 175/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 61835bb..d5c3dcc 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Wed Jan 29 06:57:05 UTC 2025 +Wed Jan 29 07:04:13 UTC 2025 From 61904c556571dada1370ae4613333883de60d437 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Wed, 29 Jan 2025 07:04:21 +0000 Subject: [PATCH 176/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index d5c3dcc..827dc2c 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Wed Jan 29 07:04:13 UTC 2025 +Wed Jan 29 07:04:21 UTC 2025 From c9a4c320b10a3cd9c1ee928c3d8b54081872301e Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Thu, 30 Jan 2025 00:41:57 +0000 Subject: [PATCH 177/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 827dc2c..9a09597 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Wed Jan 29 07:04:21 UTC 2025 +Thu Jan 30 00:41:57 UTC 2025 From fcd27fa94f8512ced69969d75daf0ef486f95ea4 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Thu, 30 Jan 2025 00:45:16 +0000 Subject: [PATCH 178/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 9a09597..95cc0a4 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Thu Jan 30 00:41:57 UTC 2025 +Thu Jan 30 00:45:16 UTC 2025 From 8005e371223385f8f462f3b1c064293b1ee6cb22 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Fri, 31 Jan 2025 00:39:29 +0000 Subject: [PATCH 179/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 95cc0a4..21043a4 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Thu Jan 30 00:45:16 UTC 2025 +Fri Jan 31 00:39:29 UTC 2025 From eb4e3df0f10eb18c103bfe6418cf2c4393087f9f Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Fri, 31 Jan 2025 00:43:04 +0000 Subject: [PATCH 180/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 21043a4..96fb13c 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Fri Jan 31 00:39:29 UTC 2025 +Fri Jan 31 00:43:04 UTC 2025 From c4c44730ee463b11b3f48896d90937ed92781ec7 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Sat, 1 Feb 2025 00:42:14 +0000 Subject: [PATCH 181/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 96fb13c..fc7422d 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Fri Jan 31 00:43:04 UTC 2025 +Sat Feb 1 00:42:14 UTC 2025 From 83c3e832d749d2d6019ebd09d32155d5917bffc0 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Sat, 1 Feb 2025 00:45:48 +0000 Subject: [PATCH 182/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index fc7422d..c03f235 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Sat Feb 1 00:42:14 UTC 2025 +Sat Feb 1 00:45:48 UTC 2025 From 979c0f604dba4a71bf96aae643b5a6bfb3582e8c Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Sun, 2 Feb 2025 00:39:06 +0000 Subject: [PATCH 183/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index c03f235..fb9654f 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Sat Feb 1 00:45:48 UTC 2025 +Sun Feb 2 00:39:06 UTC 2025 From fc0775ecdbf4523f9049c486b9edcc9ab9388657 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Mon, 3 Feb 2025 00:40:35 +0000 Subject: [PATCH 184/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index fb9654f..8325bb5 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Sun Feb 2 00:39:06 UTC 2025 +Mon Feb 3 00:40:35 UTC 2025 From 9c085b74c4436fa8aa67985acda23acd65a6aac7 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Mon, 3 Feb 2025 00:42:57 +0000 Subject: [PATCH 185/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 8325bb5..3c7f2ed 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Mon Feb 3 00:40:35 UTC 2025 +Mon Feb 3 00:42:57 UTC 2025 From 03134ba73759b4034eda0fe9db39a33a99c5d3e0 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Tue, 4 Feb 2025 00:44:43 +0000 Subject: [PATCH 186/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 3c7f2ed..cc60c8e 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Mon Feb 3 00:42:57 UTC 2025 +Tue Feb 4 00:44:43 UTC 2025 From 7a97f04accc8c934c313fb2d659f229def03293f Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Tue, 4 Feb 2025 00:45:16 +0000 Subject: [PATCH 187/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index cc60c8e..3f22cc0 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Tue Feb 4 00:44:43 UTC 2025 +Tue Feb 4 00:45:16 UTC 2025 From 222d33af0c7ac78efea56b60a545b0f37a143774 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Wed, 5 Feb 2025 00:42:42 +0000 Subject: [PATCH 188/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 3f22cc0..a67cf77 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Tue Feb 4 00:45:16 UTC 2025 +Wed Feb 5 00:42:42 UTC 2025 From 2f597ab499309a272f3d6376f0a49b54f0983135 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Wed, 5 Feb 2025 00:44:54 +0000 Subject: [PATCH 189/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index a67cf77..14ee93a 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Wed Feb 5 00:42:42 UTC 2025 +Wed Feb 5 00:44:54 UTC 2025 From 4beaf10fbbde03999657ea06357ec9e9872a3a6b Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Thu, 6 Feb 2025 00:42:32 +0000 Subject: [PATCH 190/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 14ee93a..a00fdb4 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Wed Feb 5 00:44:54 UTC 2025 +Thu Feb 6 00:42:32 UTC 2025 From 7d8218b9656340a2564741767695a9990da05562 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Thu, 6 Feb 2025 07:41:59 +0000 Subject: [PATCH 191/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index a00fdb4..2f929fd 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Thu Feb 6 00:42:32 UTC 2025 +Thu Feb 6 07:41:59 UTC 2025 From e35337144a698ddda93b2c1334aeaf1f3d591c0f Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Thu, 6 Feb 2025 16:43:21 +0000 Subject: [PATCH 192/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 2f929fd..81eb5f8 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Thu Feb 6 07:41:59 UTC 2025 +Thu Feb 6 16:43:21 UTC 2025 From ada284d3081043fa4657195448348b8a35a22029 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Fri, 7 Feb 2025 00:44:48 +0000 Subject: [PATCH 193/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 81eb5f8..4b7297f 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Thu Feb 6 16:43:21 UTC 2025 +Fri Feb 7 00:44:48 UTC 2025 From a2e31f300e2b552fe6a31796624a153c56485432 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Fri, 7 Feb 2025 00:48:06 +0000 Subject: [PATCH 194/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 4b7297f..6688c78 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Fri Feb 7 00:44:48 UTC 2025 +Fri Feb 7 00:48:06 UTC 2025 From d1e4ada7b4b999aa7e413669c6b205da94c91cf3 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Sat, 8 Feb 2025 00:45:22 +0000 Subject: [PATCH 195/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 6688c78..f99b1b7 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Fri Feb 7 00:48:06 UTC 2025 +Sat Feb 8 00:45:22 UTC 2025 From c877850dee57e91d0664ce341fb73c2ed1427dd4 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Sat, 8 Feb 2025 00:47:27 +0000 Subject: [PATCH 196/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index f99b1b7..19e0dfc 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Sat Feb 8 00:45:22 UTC 2025 +Sat Feb 8 00:47:27 UTC 2025 From 55391ea452b183fb805a00c18626713b12dfd5d7 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Sat, 8 Feb 2025 07:02:21 +0000 Subject: [PATCH 197/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 19e0dfc..aeef5a7 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Sat Feb 8 00:47:27 UTC 2025 +Sat Feb 8 07:02:21 UTC 2025 From 2313439adeac2152f1c878c96e75df17c7408125 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Sat, 8 Feb 2025 09:57:46 +0000 Subject: [PATCH 198/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index aeef5a7..62d4bae 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Sat Feb 8 07:02:21 UTC 2025 +Sat Feb 8 09:57:46 UTC 2025 From ffa53456cd44e1bc6e42caf40c0e8711b1647ece Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Sat, 8 Feb 2025 10:04:24 +0000 Subject: [PATCH 199/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 62d4bae..b254227 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Sat Feb 8 09:57:46 UTC 2025 +Sat Feb 8 10:04:24 UTC 2025 From 857cdc9f2920fa586c7de0b2ea1ae15ebc222e47 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Sun, 9 Feb 2025 00:37:52 +0000 Subject: [PATCH 200/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index b254227..2b7d36c 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Sat Feb 8 10:04:24 UTC 2025 +Sun Feb 9 00:37:52 UTC 2025 From 089d35d1dcb58efe8f2e5ec927aaa0e3568b191e Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Sun, 9 Feb 2025 00:51:52 +0000 Subject: [PATCH 201/203] cascading-pr update --- last-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/last-upgrade b/last-upgrade index 2b7d36c..0a10e69 100644 --- a/last-upgrade +++ b/last-upgrade @@ -1 +1 @@ -Sun Feb 9 00:37:52 UTC 2025 +Sun Feb 9 00:51:52 UTC 2025 From 2f7571c0149e53cca4fda4573a262d8fd9974fba Mon Sep 17 00:00:00 2001 From: nm17 Date: Sun, 9 Feb 2025 17:18:53 +0300 Subject: [PATCH 202/203] Add asdawsd --- asdawsd | 1 + 1 file changed, 1 insertion(+) create mode 100644 asdawsd diff --git a/asdawsd b/asdawsd new file mode 100644 index 0000000..87013f2 --- /dev/null +++ b/asdawsd @@ -0,0 +1 @@ +asfdsdfgsdfgdsg \ No newline at end of file From 2985e2f958a7369aea63b946c7d20f486870e019 Mon Sep 17 00:00:00 2001 From: nm17 Date: Sun, 9 Feb 2025 19:16:38 +0300 Subject: [PATCH 203/203] Update .forgejo/workflows/actions.yml --- .forgejo/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/actions.yml b/.forgejo/workflows/actions.yml index 383eed3..7b45c8e 100644 --- a/.forgejo/workflows/actions.yml +++ b/.forgejo/workflows/actions.yml @@ -6,7 +6,7 @@ on: jobs: actions: - runs-on: self-hosted + runs-on: node-bookworm strategy: matrix: info: