forgejo-runner

git clone git://git.lin.moe/forgejo-runner.git

  1name: checks
  2on:
  3  push:
  4    branches:
  5      - 'main'
  6  pull_request:
  7
  8env:
  9  FORGEJO_HOST_PORT: 'forgejo:3000'
 10  FORGEJO_ADMIN_USER: 'root'
 11  FORGEJO_ADMIN_PASSWORD: 'admin1234'
 12  FORGEJO_RUNNER_SECRET: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
 13  FORGEJO_SCRIPT: |
 14    /bin/s6-svscan /etc/s6 & sleep 10 ; su -c "forgejo admin user create --admin --username $FORGEJO_ADMIN_USER --password $FORGEJO_ADMIN_PASSWORD --email root@example.com" git && su -c "forgejo forgejo-cli actions register --labels docker --name therunner --secret $FORGEJO_RUNNER_SECRET" git && sleep infinity  
 15  GOPROXY: https://goproxy.io,direct
 16
 17jobs:
 18  build-and-tests:
 19    name: build and test
 20    if: github.repository_owner != 'forgejo-integration' && github.repository_owner != 'forgejo-experimental' && github.repository_owner != 'forgejo-release'
 21    runs-on: docker
 22
 23    services:
 24      forgejo:
 25        image: codeberg.org/forgejo/forgejo:1.21
 26        env:
 27          FORGEJO__security__INSTALL_LOCK: "true"
 28          FORGEJO__log__LEVEL: "debug"
 29          FORGEJO__actions__ENABLED: "true"
 30          FORGEJO_ADMIN_USER: ${{ env.FORGEJO_ADMIN_USER }}
 31          FORGEJO_ADMIN_PASSWORD: ${{ env.FORGEJO_ADMIN_PASSWORD }}
 32          FORGEJO_RUNNER_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }}
 33        cmd:
 34          - 'bash'
 35          - '-c'
 36          - ${{ env.FORGEJO_SCRIPT }}
 37
 38    steps:
 39      - uses: actions/setup-go@v3
 40        with:
 41          go-version: '1.21'
 42
 43      - uses: actions/checkout@v4
 44
 45      - run: make vet
 46
 47      - run: make build
 48
 49      - uses: https://code.forgejo.org/actions/upload-artifact@v3
 50        with:
 51          name: forgejo-runner
 52          path: forgejo-runner
 53
 54      - name: check the forgejo server is responding
 55        run: |
 56          apt-get update -qq
 57          apt-get install -y -qq jq curl
 58          test $FORGEJO_ADMIN_USER = $(curl -sS http://$FORGEJO_ADMIN_USER:$FORGEJO_ADMIN_PASSWORD@$FORGEJO_HOST_PORT/api/v1/user | jq --raw-output .login)
 59
 60      - run: make FORGEJO_URL=http://$FORGEJO_HOST_PORT test
 61
 62  runner-exec-tests:
 63    needs: [build-and-tests]
 64    name: runner exec tests
 65    if: github.repository_owner != 'forgejo-integration' && github.repository_owner != 'forgejo-experimental' && github.repository_owner != 'forgejo-release'
 66    runs-on: self-hosted
 67
 68    steps:
 69
 70      - uses: actions/checkout@v4
 71
 72      - uses: https://code.forgejo.org/actions/download-artifact@v3
 73        with:
 74          name: forgejo-runner
 75
 76      - name: install docker
 77        run: |
 78          mkdir /etc/docker
 79          cat > /etc/docker/daemon.json  <<EOF
 80          {
 81            "ipv6": true,
 82            "experimental": true,
 83            "ip6tables": true,
 84            "fixed-cidr-v6": "fd05:d0ca:1::/64",
 85            "default-address-pools": [
 86              {
 87                "base": "172.19.0.0/16",
 88                "size": 24
 89              },
 90              {
 91                "base": "fd05:d0ca:2::/104",
 92                "size": 112
 93              }
 94            ]
 95          }
 96          EOF
 97          apt --quiet install --yes -qq docker.io
 98
 99      - name: forgejo-runner exec --enable-ipv6
100        run: |
101          set -x
102          chmod +x forgejo-runner
103          ./forgejo-runner exec --enable-ipv6 --workflows .forgejo/testdata/ipv6.yml
104          if ./forgejo-runner exec --workflows .forgejo/testdata/ipv6.yml >& /tmp/out ; then
105             cat /tmp/out
106             echo "IPv6 not enabled, should fail"
107             exit 1
108          fi