runner/.forgejo/workflows/test.yml

113 lines
3.6 KiB
YAML
Raw Normal View History

2023-04-30 16:26:17 +00:00
name: checks
on:
push:
branches:
- 'main'
pull_request:
2023-04-30 16:26:17 +00:00
env:
2023-07-11 20:45:49 +00:00
FORGEJO_HOST_PORT: 'forgejo:3000'
FORGEJO_ADMIN_USER: 'root'
FORGEJO_ADMIN_PASSWORD: 'admin1234'
FORGEJO_RUNNER_SECRET: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
FORGEJO_SCRIPT: |
2024-11-12 10:48:32 +00:00
/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
2023-04-30 16:26:17 +00:00
GOPROXY: https://goproxy.io,direct
jobs:
2023-12-02 18:18:51 +00:00
build-and-tests:
name: build and test
2023-04-30 16:26:17 +00:00
if: github.repository_owner != 'forgejo-integration' && github.repository_owner != 'forgejo-experimental' && github.repository_owner != 'forgejo-release'
2023-07-11 20:45:49 +00:00
runs-on: docker
2024-11-20 09:50:07 +00:00
container:
image: 'code.forgejo.org/oci/node:20-bookworm'
2023-07-11 20:45:49 +00:00
services:
forgejo:
image: codeberg.org/forgejo/forgejo:9
2023-07-11 20:45:49 +00:00
env:
FORGEJO__security__INSTALL_LOCK: "true"
FORGEJO__log__LEVEL: "debug"
FORGEJO__actions__ENABLED: "true"
FORGEJO_ADMIN_USER: ${{ env.FORGEJO_ADMIN_USER }}
FORGEJO_ADMIN_PASSWORD: ${{ env.FORGEJO_ADMIN_PASSWORD }}
FORGEJO_RUNNER_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }}
cmd:
- 'bash'
- '-c'
- ${{ env.FORGEJO_SCRIPT }}
2023-04-30 16:26:17 +00:00
steps:
2024-11-12 10:48:32 +00:00
- uses: actions/checkout@v4
2024-11-12 10:05:45 +00:00
- uses: actions/setup-go@v5
2023-04-30 16:26:17 +00:00
with:
2024-11-12 10:48:32 +00:00
go-version-file: go.mod
2023-07-11 20:45:49 +00:00
- run: make vet
- run: make build
2023-12-02 18:18:51 +00:00
- uses: https://code.forgejo.org/actions/upload-artifact@v3
with:
name: forgejo-runner
path: forgejo-runner
2023-07-11 20:45:49 +00:00
- name: check the forgejo server is responding
run: |
apt-get update -qq
apt-get install -y -qq jq curl retry
sleep 10 # matches the sleep 10 in the bootstrap of the Forgejo instance
# in case of a slow machine, give it time to bootstrap
retry --delay=10 --times=6 bash -c 'test $FORGEJO_ADMIN_USER = $(curl -sS http://$FORGEJO_ADMIN_USER:$FORGEJO_ADMIN_PASSWORD@$FORGEJO_HOST_PORT/api/v1/user | jq --raw-output .login)'
2023-07-11 20:45:49 +00:00
- run: make FORGEJO_URL=http://$FORGEJO_HOST_PORT test
2023-12-02 18:18:51 +00:00
runner-exec-tests:
needs: [build-and-tests]
name: runner exec tests
if: github.repository_owner != 'forgejo-integration' && github.repository_owner != 'forgejo-experimental' && github.repository_owner != 'forgejo-release'
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- uses: https://code.forgejo.org/actions/download-artifact@v3
with:
name: forgejo-runner
- name: install docker
run: |
mkdir /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"ipv6": true,
"experimental": true,
"ip6tables": true,
"fixed-cidr-v6": "fd05:d0ca:1::/64",
"default-address-pools": [
{
"base": "172.19.0.0/16",
"size": 24
},
{
"base": "fd05:d0ca:2::/104",
"size": 112
}
]
}
EOF
apt --quiet install --yes -qq docker.io
- name: forgejo-runner exec --enable-ipv6
run: |
set -x
chmod +x forgejo-runner
./forgejo-runner exec --enable-ipv6 --workflows .forgejo/testdata/ipv6.yml
if ./forgejo-runner exec --workflows .forgejo/testdata/ipv6.yml >& /tmp/out ; then
cat /tmp/out
echo "IPv6 not enabled, should fail"
exit 1
fi