forgejo-runner

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

 1name: Integration tests for the release process
 2
 3on:
 4  push:
 5    paths:
 6      - go.mod
 7      - Dockerfile
 8      - .forgejo/workflows/build-release.yml
 9      - .forgejo/workflows/build-release-integration.yml
10  pull_request:
11    paths:
12      - go.mod
13      - Dockerfile
14      - .forgejo/workflows/build-release.yml
15      - .forgejo/workflows/build-release-integration.yml
16
17jobs:
18  release-simulation:
19    runs-on: self-hosted
20    if: github.repository_owner != 'forgejo-integration' && github.repository_owner != 'forgejo-release'
21    steps:
22      - uses: actions/checkout@v3
23
24      - id: forgejo
25        uses: https://code.forgejo.org/actions/setup-forgejo@v1
26        with:
27          user: root
28          password: admin1234
29          image-version: 1.20
30          lxc-ip-prefix: 10.0.9
31
32      - name: publish
33        run: |
34          set -x
35
36          version=1.2.3
37          cat > /etc/docker/daemon.json <<EOF
38            {
39              "insecure-registries" : ["${{ steps.forgejo.outputs.host-port }}"]
40            }
41          EOF
42          systemctl restart docker
43
44          dir=$(mktemp -d)
45          trap "rm -fr $dir" EXIT
46
47          url=http://root:admin1234@${{ steps.forgejo.outputs.host-port }}
48          export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}"
49
50          #
51          # Create a new project with the runner and the release workflow only
52          #
53          rsync -a --exclude .git ./ $dir/
54          rm $(find $dir/.forgejo/workflows/*.yml | grep -v build-release.yml)
55          forgejo-test-helper.sh push $dir $url root runner
56          sha=$(forgejo-test-helper.sh branch_tip $url root/runner main)
57
58          #
59          # Push a tag to trigger the release workflow and wait for it to complete
60          #
61          forgejo-curl.sh api_json --data-raw '{"tag_name": "v'$version'", "target": "'$sha'"}' $url/api/v1/repos/root/runner/tags
62          LOOPS=180 forgejo-test-helper.sh wait_success "$url" root/runner $sha
63
64          #
65          # uncomment to see the logs even when everything is reported to be working ok
66          #
67          #cat $FORGEJO_RUNNER_LOGS
68
69          #
70          # Minimal sanity checks. e2e test is for the setup-forgejo action
71          #
72          for arch in amd64 arm64 ; do
73            binary=forgejo-runner-$version-linux-$arch
74            for suffix in '' '.xz' ; do
75              curl --fail -L -sS $url/root/runner/releases/download/v$version/$binary$suffix > $binary$suffix
76              if test "$suffix" = .xz ; then
77                 unxz --keep $binary$suffix
78              fi
79              chmod +x $binary
80              ./$binary --version | grep $version
81              curl --fail -L -sS $url/root/runner/releases/download/v$version/$binary$suffix.sha256 > $binary$suffix.sha256
82              shasum -a 256 --check $binary$suffix.sha256
83              rm $binary$suffix
84            done
85          done
86
87          docker pull ${{ steps.forgejo.outputs.host-port }}/root/runner:$version
88
89          docker inspect ${{ steps.forgejo.outputs.host-port}}/root/runner:$version > labels.json
90          python3 .forgejo/labelscompare.py