From bc716490af23c28a4197ea2973ac5e4150728800 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 30 Jul 2025 13:18:50 +0000 Subject: [PATCH] chore: remove unused/unmaintained files (#767) - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/767): chore: remove unused/unmaintained files Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/767 Reviewed-by: Michael Kriese Co-authored-by: Earl Warren Co-committed-by: Earl Warren --- .github/workflows/build-release.yml | 151 ---------------------------- contrib/forgejo-runner.service | 18 ---- scripts/rootless.sh | 9 -- scripts/run.sh | 48 --------- scripts/supervisord.conf | 13 --- scripts/systemd.md | 67 ------------ 6 files changed, 306 deletions(-) delete mode 100644 .github/workflows/build-release.yml delete mode 100644 contrib/forgejo-runner.service delete mode 100755 scripts/rootless.sh delete mode 100755 scripts/run.sh delete mode 100644 scripts/supervisord.conf delete mode 100644 scripts/systemd.md diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml deleted file mode 100644 index d179d7bb..00000000 --- a/.github/workflows/build-release.yml +++ /dev/null @@ -1,151 +0,0 @@ -# This workflow: -# - builds and uploads a binary artifact for each Windows architecture -# - tests the runner on Windows with a Forgejo server container running on Windows Subsystem for Linux (WSL) -# - releases the binary artifact (if triggered on a pushed tag) -# -# This build is currently supported on https://github.com/Crown0815/forgejo-runner-windows - -name: Build Release - -on: - push: - tags: ['v*'] - branches: [ main ] - -jobs: - build: - name: Build ${{matrix.architecture}} - runs-on: ubuntu-latest - strategy: - matrix: - architecture: ['386', amd64, arm, arm64] - steps: - - uses: actions/checkout@v4 - - name: Build for ${{matrix.architecture}} - run: | - env GOOS=windows GOARCH=${{matrix.architecture}} \ - go build \ - -ldflags "-s -w -X code.forgejo.org/forgejo/runner/internal/pkg/ver.version=${{ github.ref_name }}" \ - -o forgejo-runner-windows-${{matrix.architecture}}.exe - - - uses: actions/upload-artifact@v4 - with: - name: forgejo-runner-windows-${{matrix.architecture}} - path: forgejo-runner-windows-${{matrix.architecture}}.exe - - - test: - name: Run Tests on Windows with Linux Forgejo Server - runs-on: windows-latest - env: - FORGEJO_ROOT_URL: 'http://localhost:3000/' - FORGEJO_ADMIN_USER: 'admin_user' - FORGEJO_ADMIN_PASSWORD: 'admin_password' - FORGEJO_RUNNER_SECRET: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' - MAX_WAIT_ITERATIONS: 30 - - steps: - - name: Windows - Checkout code - uses: actions/checkout@v4 - - - name: Windows - Setup Windows Subsystem for Linux (WSL) - uses: Vampire/setup-wsl@v5 - with: - distribution: Alpine - wsl-shell-user: root - additional-packages: bash - - - name: WSL - Install Docker - shell: wsl-bash {0} - 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; } - - - name: WSL - Start Forgejo Server - shell: wsl-bash {0} - 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 }} \ - codeberg.org/forgejo/forgejo:11.0-rootless - - - name: Windows - Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Windows - Install dependencies - run: go mod download - - - 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 - 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 }} - - - name: Windows - Connect to Forgejo server - run: | - $configFileContent = @" - log: - level: debug - runner: - labels: - - windows:host - - docker:docker://node:20 - "@ - Set-Content -Path temporaryConfig.yml -Value $configFileContent - - # Register the runner - 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 ./... - env: - FORGEJO_URL: ${{ env.FORGEJO_ROOT_URL }} - FORGEJO_RUNNER_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }} - FORGEJO_RUNNER_HEX_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }} - - - release: - runs-on: ubuntu-latest - needs: [build, test] - if: github.event_name == 'push' && github.ref_type == 'tag' - steps: - - uses: actions/download-artifact@v4 - with: - path: . - - - name: Create Release - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ github.ref_name }} - files: forgejo-runner-windows-*/forgejo-runner-windows-*.exe - draft: false - prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') }} - token: ${{ secrets.RELEASE_TOKEN }} - fail_on_unmatched_files: true - body: See [original release notes](https://code.forgejo.org/forgejo/runner/releases/tag/${{ github.ref_name }}). diff --git a/contrib/forgejo-runner.service b/contrib/forgejo-runner.service deleted file mode 100644 index ace922af..00000000 --- a/contrib/forgejo-runner.service +++ /dev/null @@ -1,18 +0,0 @@ -[Unit] -Description=Forgejo Runner -Documentation=https://forgejo.org/docs/latest/admin/actions/ -After=docker.service - -[Service] -ExecStart=forgejo-runner daemon -ExecReload=/bin/kill -s HUP $MAINPID - -# This user and working directory must already exist -User=runner -WorkingDirectory=/home/runner -Restart=on-failure -TimeoutSec=0 -RestartSec=10 - -[Install] -WantedBy=multi-user.target diff --git a/scripts/rootless.sh b/scripts/rootless.sh deleted file mode 100755 index 310a03bd..00000000 --- a/scripts/rootless.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -# wait for docker daemon -while ! nc -z localhost 2376 &1 | tee /tmp/reg.log - - cat /tmp/reg.log | grep 'Runner registered successfully' > /dev/null - if [[ $? -eq 0 ]]; then - echo "SUCCESS" - success=1 - else - echo "Waiting to retry ..." - sleep 5 - fi - done -fi -# Prevent reading the token from the forgejo-runner process -unset GITEA_RUNNER_REGISTRATION_TOKEN - -forgejo-runner daemon ${CONFIG_ARG} diff --git a/scripts/supervisord.conf b/scripts/supervisord.conf deleted file mode 100644 index 8c45f5be..00000000 --- a/scripts/supervisord.conf +++ /dev/null @@ -1,13 +0,0 @@ -[supervisord] -nodaemon=true -logfile=/dev/null -logfile_maxbytes=0 - -[program:dockerd] -command=/usr/local/bin/dockerd-entrypoint.sh - -[program:act_runner] -stdout_logfile=/dev/fd/1 -stdout_logfile_maxbytes=0 -redirect_stderr=true -command=/opt/act/rootless.sh diff --git a/scripts/systemd.md b/scripts/systemd.md deleted file mode 100644 index 089dd618..00000000 --- a/scripts/systemd.md +++ /dev/null @@ -1,67 +0,0 @@ -# Forgejo Runner with systemd User Services - -It is possible to use systemd's user services together with -[podman](https://podman.io/) to run `forgejo-runner` using a normal user -account without any privileges and automatically start on boot. - -This was last tested on Fedora 39 on 2024-02-19, but should work elsewhere as -well. - -Place the `forgejo-runner` binary in `/usr/local/bin/forgejo-runner` and make -sure it can be executed (`chmod +x /usr/local/bin/forgejo-runner`). - -Install and enable `podman` as a user service: - -```bash -$ sudo dnf -y install podman -``` - -You *may* need to reboot your system after installing `podman` as it -modifies some system configuration(s) that may need to be activated. Without -rebooting the system my runner errored out when trying to set firewall rules, a -reboot fixed it. - -Enable `podman` as a user service: - -``` -$ systemctl --user start podman.socket -$ systemctl --user enable podman.socket -``` - -Make sure processes remain after your user account logs out: - -```bash -$ loginctl enable-linger -``` - -Create the file `/etc/systemd/user/forgejo-runner.service` with the following -content: - -``` -[Unit] -Description=Forgejo Runner - -[Service] -Type=simple -ExecStart=/usr/local/bin/forgejo-runner daemon -Restart=on-failure - -[Install] -WantedBy=default.target -``` - -Now activate it as a user service: - -```bash -$ systemctl --user daemon-reload -$ systemctl --user start forgejo-runner -$ systemctl --user enable forgejo-runner -``` - -To see/follow the log of `forgejo-runner`: - -```bash -$ journalctl -f -t forgejo-runner -``` - -If you reboot your system, all should come back automatically.