From 29c8f0e2765d41946578f6f6d4e476fc7efcd6d5 Mon Sep 17 00:00:00 2001 From: Crown0815 Date: Fri, 6 Feb 2026 08:17:10 +0100 Subject: [PATCH 1/8] ci: Add support for linux containers in tests --- .github/workflows/build-release.yml | 89 +++++++++++++++++------------ 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 3ac6fbd..11272af 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -84,39 +84,34 @@ jobs: ref: ${{ inputs.tag }} token: ${{ secrets.CODE_FORGEJO_TOKEN }} - - name: Windows - Setup Windows Subsystem for Linux (WSL) - uses: Vampire/setup-wsl@v6 - with: - distribution: Alpine - wsl-shell-user: root - additional-packages: bash - - - name: WSL - Install Docker - shell: wsl-bash {0} + - name: Install OCI-Container Runtime run: | - apk --update add --no-cache docker curl - - rc-update add docker default - openrc default - - # Wait for Docker to be ready - i=0 - until docker info > /dev/null 2>&1 || (( i == ${{ env.MAX_WAIT_ITERATIONS }} )); do - echo "Waiting for Docker to be ready... ($(( ++i ))/${{ env.MAX_WAIT_ITERATIONS }})" - sleep 1 - done - [ $i -lt ${{ env.MAX_WAIT_ITERATIONS }} ] && echo "Docker is ready!" || { echo "Timed out waiting for Docker" ; exit 1; } + winget install --exact ` + --id RedHat.Podman ` + --version "5.7.1" ` + --source winget ` + --accept-package-agreements ` + --accept-source-agreements ` + --silent + "C:\Program Files\RedHat\Podman" >> $env:GITHUB_PATH + + - name: Create Linux-Container machine + run: | + podman machine init + podman machine set --rootful + podman machine start - name: WSL - Start Forgejo Server - shell: wsl-bash {0} + env: + DOCKER_HOST: npipe:////./pipe/podman-machine-default run: | - docker run -d --name forgejo \ - -p 3000:3000 \ - -e USER_UID=1000 \ - -e USER_GID=1000 \ - -e FORGEJO__security__INSTALL_LOCK=true \ - -e FORGEJO__server__DOMAIN=localhost \ - -e FORGEJO__server__ROOT_URL=${{ env.FORGEJO_ROOT_URL }} \ + docker run -d --name forgejo ` + -p 3000:3000 ` + -e USER_UID=1000 ` + -e USER_GID=1000 ` + -e FORGEJO__security__INSTALL_LOCK=true ` + -e FORGEJO__server__DOMAIN=localhost ` + -e FORGEJO__server__ROOT_URL=${{ env.FORGEJO_ROOT_URL }} ` codeberg.org/forgejo/forgejo:11.0-rootless - name: Windows - Set up Go @@ -130,16 +125,15 @@ jobs: - name: WSL - Register Runner on Forgejo Server # Starting the Forgejo server takes some time. # That time used to install go. - shell: wsl-bash {0} run: | - i=0 - until curl -s ${{ env.FORGEJO_ROOT_URL }}/api/v1/version > /dev/null || (( i == ${{ env.MAX_WAIT_ITERATIONS }} )); do - echo "Waiting for Forgejo to be ready... ($(( ++i ))/${{ env.MAX_WAIT_ITERATIONS }})" - sleep 1 - done - [ $i -lt ${{ env.MAX_WAIT_ITERATIONS }} ] && echo "Forgejo is ready!" || { echo "Timed out waiting for Forgejo" ; exit 1; } - - # Create admin user and generate runner token + $i=0 + while($i -lt [int]${{ env.MAX_WAIT_ITERATIONS }}){ + try{ iwr (($env:FORGEJO_ROOT_URL.TrimEnd('/')+'/api/v1/version')) -UseBasicParsing -TimeoutSec 2 | Out-Null; break }catch{} + "Waiting for Forgejo to be ready... ({0}/{1})" -f (++$i),${{ env.MAX_WAIT_ITERATIONS }} + Start-Sleep 1 + } + if($i -lt [int]${{ env.MAX_WAIT_ITERATIONS }}){"Forgejo is ready!"}else{"Timed out waiting for Forgejo"; exit 1} + docker exec forgejo forgejo admin user create --admin --username ${{ env.FORGEJO_ADMIN_USER }} --password ${{ env.FORGEJO_ADMIN_PASSWORD }} --email root@example.com docker exec forgejo forgejo forgejo-cli actions register --labels docker --name therunner --secret ${{ env.FORGEJO_RUNNER_SECRET }} @@ -164,6 +158,7 @@ jobs: FORGEJO_URL: ${{ env.FORGEJO_ROOT_URL }} FORGEJO_RUNNER_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }} FORGEJO_RUNNER_HEX_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }} + DOCKER_HOST: npipe:////./pipe/podman-machine-default test-act: name: Run Act Tests on Windows @@ -178,6 +173,23 @@ jobs: ref: ${{ inputs.tag }} token: ${{ secrets.CODE_FORGEJO_TOKEN }} + - name: Install OCI-Container Runtime + run: | + winget install --exact ` + --id RedHat.Podman ` + --version "5.7.1" ` + --source winget ` + --accept-package-agreements ` + --accept-source-agreements ` + --silent + "C:\Program Files\RedHat\Podman" >> $env:GITHUB_PATH + + - name: Create Linux-Container machine + run: | + podman machine init + podman machine set --rootful + podman machine start + - name: Windows - Set up Go uses: actions/setup-go@v5 with: @@ -190,6 +202,7 @@ jobs: run: go test -v ./act/... env: ACT_REPOSITORY: ${{ inputs.goal == 'test-fork' && vars.TEST_FORK || 'forgejo/runner' }} # Needed for TestRunContext_GetBindsAndMounts test case + DOCKER_HOST: npipe:////./pipe/podman-machine-default release: runs-on: ubuntu-latest From c073b0150581d881a18d0f3b16b19e1bdb47a611 Mon Sep 17 00:00:00 2001 From: Crown0815 Date: Sat, 7 Feb 2026 08:30:48 +0100 Subject: [PATCH 2/8] ci: Remove waiting step Due to the long installation of go, the waiting is unnecessary --- .github/workflows/build-release.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 11272af..d9850d2 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -74,6 +74,7 @@ jobs: FORGEJO_ADMIN_PASSWORD: 'admin_password' FORGEJO_RUNNER_SECRET: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' MAX_WAIT_ITERATIONS: 30 + DOCKER_HOST: npipe:////./pipe/podman-machine-default steps: - name: Windows - Checkout code @@ -102,8 +103,6 @@ jobs: podman machine start - name: WSL - Start Forgejo Server - env: - DOCKER_HOST: npipe:////./pipe/podman-machine-default run: | docker run -d --name forgejo ` -p 3000:3000 ` @@ -126,14 +125,6 @@ jobs: # Starting the Forgejo server takes some time. # That time used to install go. run: | - $i=0 - while($i -lt [int]${{ env.MAX_WAIT_ITERATIONS }}){ - try{ iwr (($env:FORGEJO_ROOT_URL.TrimEnd('/')+'/api/v1/version')) -UseBasicParsing -TimeoutSec 2 | Out-Null; break }catch{} - "Waiting for Forgejo to be ready... ({0}/{1})" -f (++$i),${{ env.MAX_WAIT_ITERATIONS }} - Start-Sleep 1 - } - if($i -lt [int]${{ env.MAX_WAIT_ITERATIONS }}){"Forgejo is ready!"}else{"Timed out waiting for Forgejo"; exit 1} - docker exec forgejo forgejo admin user create --admin --username ${{ env.FORGEJO_ADMIN_USER }} --password ${{ env.FORGEJO_ADMIN_PASSWORD }} --email root@example.com docker exec forgejo forgejo forgejo-cli actions register --labels docker --name therunner --secret ${{ env.FORGEJO_RUNNER_SECRET }} @@ -158,7 +149,6 @@ jobs: FORGEJO_URL: ${{ env.FORGEJO_ROOT_URL }} FORGEJO_RUNNER_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }} FORGEJO_RUNNER_HEX_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }} - DOCKER_HOST: npipe:////./pipe/podman-machine-default test-act: name: Run Act Tests on Windows From 47b5220ad0634ffb5d3c161e8acc260cbbe61f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kr=C3=B6ner?= Date: Mon, 9 Mar 2026 17:00:55 +0100 Subject: [PATCH 3/8] ci: Add proper test reports for runner tests --- .github/workflows/build-release.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index d9850d2..7f18a97 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -119,7 +119,9 @@ jobs: go-version-file: go.mod - name: Windows - Install dependencies - run: go mod download + run: |- + go mod download + go install gotest.tools/gotestsum@v1.13.0 - name: WSL - Register Runner on Forgejo Server # Starting the Forgejo server takes some time. @@ -144,12 +146,20 @@ jobs: go run main.go create-runner-file --config temporaryConfig.yml --instance ${{ env.FORGEJO_ROOT_URL }} --secret ${{ env.FORGEJO_RUNNER_SECRET }} --name "windows-test-runner" - name: Windows - Run tests - run: go test -v ./internal/... + run: gotestsum --junitfile test-results.xml --format pkgname -- ./internal/... env: FORGEJO_URL: ${{ env.FORGEJO_ROOT_URL }} FORGEJO_RUNNER_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }} FORGEJO_RUNNER_HEX_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }} + - name: Report test results + uses: dorny/test-reporter@v2.6.0 + if: ${{ !cancelled() }} + with: + name: Runner Tests + path: test-results.xml + reporter: java-junit + test-act: name: Run Act Tests on Windows runs-on: windows-latest From 469b1ab0ff11ede223a75541e8a899bda1634335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kr=C3=B6ner?= Date: Tue, 10 Mar 2026 11:23:50 +0100 Subject: [PATCH 4/8] ci: Add proper test reports for act tests --- .github/workflows/build-release.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 7f18a97..58aec1d 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -196,14 +196,24 @@ jobs: go-version-file: go.mod - name: Windows - Install dependencies - run: go mod download + run: |- + go mod download + go install gotest.tools/gotestsum@v1.13.0 - name: Windows - Run tests - run: go test -v ./act/... + run: gotestsum --junitfile test-results.xml --format pkgname -- ./act/... env: ACT_REPOSITORY: ${{ inputs.goal == 'test-fork' && vars.TEST_FORK || 'forgejo/runner' }} # Needed for TestRunContext_GetBindsAndMounts test case DOCKER_HOST: npipe:////./pipe/podman-machine-default + - name: Report test results + uses: dorny/test-reporter@v2.6.0 + if: ${{ !cancelled() }} + with: + name: Act Tests + path: test-results.xml + reporter: java-junit + release: runs-on: ubuntu-latest needs: [build, test-runner, test-act] From ccd925846ec66d15c3fd1ec6863534bda3d05351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kr=C3=B6ner?= Date: Wed, 11 Mar 2026 08:13:01 +0100 Subject: [PATCH 5/8] ci: Upgrade GitHub actions --- .github/workflows/build-release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 58aec1d..c00f625 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -37,7 +37,7 @@ jobs: - architecture: arm64 os: windows-11-arm steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: github-server-url: https://code.forgejo.org repository: ${{ inputs.goal == 'test-fork' && vars.TEST_FORK || 'forgejo/runner' }} @@ -60,7 +60,7 @@ jobs: exit 1 } - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v7 with: name: forgejo-runner-windows-${{ matrix.architecture }} path: forgejo-runner-windows-${{ matrix.architecture }}.exe @@ -78,7 +78,7 @@ jobs: steps: - name: Windows - Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: github-server-url: https://code.forgejo.org repository: ${{ inputs.goal == 'test-fork' && vars.TEST_FORK || 'forgejo/runner' }} @@ -166,7 +166,7 @@ jobs: steps: - name: Windows - Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: github-server-url: https://code.forgejo.org repository: ${{ inputs.goal == 'test-fork' && vars.TEST_FORK || 'forgejo/runner' }} @@ -221,7 +221,7 @@ jobs: permissions: contents: write steps: - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v8 with: path: . From 1f57ee5031ce8c3a221b287c24257e117893d5a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kr=C3=B6ner?= Date: Wed, 11 Mar 2026 09:40:58 +0100 Subject: [PATCH 6/8] ci: Switch from Java test output to native go-json --- .github/workflows/build-release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index c00f625..8f76cfa 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -146,7 +146,7 @@ jobs: go run main.go create-runner-file --config temporaryConfig.yml --instance ${{ env.FORGEJO_ROOT_URL }} --secret ${{ env.FORGEJO_RUNNER_SECRET }} --name "windows-test-runner" - name: Windows - Run tests - run: gotestsum --junitfile test-results.xml --format pkgname -- ./internal/... + run: gotestsum --jsonfile test-results.json --format pkgname -- ./internal/... env: FORGEJO_URL: ${{ env.FORGEJO_ROOT_URL }} FORGEJO_RUNNER_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }} @@ -157,8 +157,8 @@ jobs: if: ${{ !cancelled() }} with: name: Runner Tests - path: test-results.xml - reporter: java-junit + path: test-results.json + reporter: golang-json test-act: name: Run Act Tests on Windows @@ -201,7 +201,7 @@ jobs: go install gotest.tools/gotestsum@v1.13.0 - name: Windows - Run tests - run: gotestsum --junitfile test-results.xml --format pkgname -- ./act/... + run: gotestsum --jsonfile test-results.json --format pkgname -- ./act/... env: ACT_REPOSITORY: ${{ inputs.goal == 'test-fork' && vars.TEST_FORK || 'forgejo/runner' }} # Needed for TestRunContext_GetBindsAndMounts test case DOCKER_HOST: npipe:////./pipe/podman-machine-default @@ -211,8 +211,8 @@ jobs: if: ${{ !cancelled() }} with: name: Act Tests - path: test-results.xml - reporter: java-junit + path: test-results.json + reporter: golang-json release: runs-on: ubuntu-latest From f9f00f79c96d1bb31104a3380d2a459cbb7ba5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kr=C3=B6ner?= Date: Wed, 11 Mar 2026 17:14:08 +0100 Subject: [PATCH 7/8] ci: Fix test failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without the `-v` flag, the tests in `./internal/app/cmd` will fail with an error like this: ``` ✖ internal/app/cmd (584ms) === Failed === FAIL: internal/app/cmd TestCommandConnectTokenComplainsAboutMissingFlags (unknown) time="2026-03-11T17:11:13+01:00" level=info msg="Creating runner file" time="2026-03-11T17:11:13+01:00" level=info msg="Starting runner daemon" time="2026-03-11T17:11:13+01:00" level=info msg="runner: received shutdown signal" time="2026-03-11T17:11:13+01:00" level=info msg="runner: shutdown initiated, waiting [runner].shutdown_timeout=30s for running jobs to complete before shutting down" time="2026-03-11T17:11:13+01:00" level=info msg="runner: ephemeral runner shutting down after job has completed" time="2026-03-11T17:11:13+01:00" level=info msg="runner: ephemeral runner shutting down after job has completed" time="2026-03-11T17:11:13+01:00" level=info msg="runner: received shutdown signal" time="2026-03-11T17:11:13+01:00" level=info msg="runner: received shutdown signal" time="2026-03-11T17:11:13+01:00" level=info msg="runner: test-runner, with version: v1.0.0, with labels: [test-label], ephemeral: true, declared successfully" time="2026-03-11T17:11:13+01:00" level=info msg="Starting runner daemon" time="2026-03-11T17:11:13+01:00" level=info msg="runner: received shutdown signal" time="2026-03-11T17:11:13+01:00" level=info msg="runner: shutdown initiated, waiting [runner].shutdown_timeout=30s for running jobs to complete before shutting down" time="2026-03-11T17:11:13+01:00" level=info msg="No configuration file specified; using default settings." time="2026-03-11T17:11:13+01:00" level=info msg="Runner name is empty, use hostname 'FELIXKROENED610'." time="2026-03-11T17:11:13+01:00" level=error msg="Invalid input, please re-run act command." error="unsupported schema: invalid" DONE 1 tests, 1 failure in 0.584s ``` I do not fully understand why, but adding the `-v` flag solves the problem. Maybe it is a concurrency issue? --- .github/workflows/build-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 8f76cfa..917a5cb 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -146,7 +146,7 @@ jobs: go run main.go create-runner-file --config temporaryConfig.yml --instance ${{ env.FORGEJO_ROOT_URL }} --secret ${{ env.FORGEJO_RUNNER_SECRET }} --name "windows-test-runner" - name: Windows - Run tests - run: gotestsum --jsonfile test-results.json --format pkgname -- ./internal/... + run: gotestsum --jsonfile test-results.json --format pkgname -- -v ./internal/... env: FORGEJO_URL: ${{ env.FORGEJO_ROOT_URL }} FORGEJO_RUNNER_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }} @@ -201,7 +201,7 @@ jobs: go install gotest.tools/gotestsum@v1.13.0 - name: Windows - Run tests - run: gotestsum --jsonfile test-results.json --format pkgname -- ./act/... + run: gotestsum --jsonfile test-results.json --format pkgname -- -v ./act/... env: ACT_REPOSITORY: ${{ inputs.goal == 'test-fork' && vars.TEST_FORK || 'forgejo/runner' }} # Needed for TestRunContext_GetBindsAndMounts test case DOCKER_HOST: npipe:////./pipe/podman-machine-default From 3f4ec694a9b1a7727361e0ba71ebebe11ff39bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kr=C3=B6ner?= Date: Thu, 12 Mar 2026 10:59:30 +0100 Subject: [PATCH 8/8] build: Upgrade setup-go to v6 --- .github/workflows/build-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 917a5cb..b9cd813 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -114,7 +114,7 @@ jobs: codeberg.org/forgejo/forgejo:11.0-rootless - name: Windows - Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version-file: go.mod @@ -191,7 +191,7 @@ jobs: podman machine start - name: Windows - Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version-file: go.mod