The `vars.ROLE` in each repository was set as follows: - https://code.forgejo.org/forgejo/runner => forgejo-coding - https://code.forgejo.org/forgejo-integration/runner => forgejo-integration - https://invisible.forgejo.org/forgejo/runner => forgejo-release It reflects how Forgejo roles are dispatched. Update all workflows to use the ROLE to determine if it is relevant for them to run. It is more straightforward than the previous approach based on the name of the owner. There were cases where the logic was wrong and workflows ran needlessly, for instance because the runner release is now published from an organization that is forgejo and not forgejo-release. <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/790): <!--number 790 --><!--line 0 --><!--description Y2hvcmUoY2xlYW51cCk6IGRpc3BhdGNoIHdvcmtmbG93cyBhY2NvcmRpbmcgdG8gdGhlIHJvbGUgb2YgdGhlIHJlcG9zaXRvcnk=-->chore(cleanup): dispatch workflows according to the role of the repository<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/790 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
129 lines
4.2 KiB
YAML
129 lines
4.2 KiB
YAML
name: checks
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
pull_request:
|
|
|
|
enable-email-notifications: true
|
|
|
|
env:
|
|
FORGEJO_HOST_PORT: 'forgejo:3000'
|
|
FORGEJO_ADMIN_USER: 'root'
|
|
FORGEJO_ADMIN_PASSWORD: 'admin1234'
|
|
FORGEJO_RUNNER_SECRET: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
|
FORGEJO_SCRIPT: |
|
|
/usr/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
|
|
GOPROXY: https://goproxy.io,direct
|
|
|
|
jobs:
|
|
build-and-tests:
|
|
name: build and test
|
|
if: vars.ROLE == 'forgejo-coding'
|
|
runs-on: docker
|
|
container:
|
|
image: 'code.forgejo.org/oci/ci:1'
|
|
|
|
services:
|
|
forgejo:
|
|
image: code.forgejo.org/forgejo/forgejo:11
|
|
env:
|
|
FORGEJO__security__INSTALL_LOCK: "true"
|
|
FORGEJO__log__LEVEL: "debug"
|
|
FORGEJO__actions__ENABLED: "true"
|
|
FORGEJO_ADMIN_USER: root
|
|
FORGEJO_ADMIN_PASSWORD: admin1234
|
|
FORGEJO_RUNNER_SECRET: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
|
cmd:
|
|
- 'bash'
|
|
- '-c'
|
|
- '/usr/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'
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: validate go version
|
|
run: |
|
|
set -ex
|
|
toolchain=$(grep -oP '(?<=toolchain ).+' go.mod)
|
|
version=$(go version | cut -d' ' -f3)
|
|
if dpkg --compare-versions ${version#go} lt ${toolchain#go}; then
|
|
echo "go version too low: $toolchain >= $version"
|
|
exit 1
|
|
fi
|
|
|
|
- run: make vet
|
|
|
|
- run: make build
|
|
|
|
- uses: https://code.forgejo.org/actions/upload-artifact@v3
|
|
with:
|
|
name: forgejo-runner
|
|
path: forgejo-runner
|
|
|
|
- name: check the forgejo server is responding
|
|
run: |
|
|
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)'
|
|
|
|
- run: make FORGEJO_URL=http://$FORGEJO_HOST_PORT test
|
|
|
|
runner-exec-tests:
|
|
needs: [build-and-tests]
|
|
name: runner exec tests
|
|
if: vars.ROLE == 'forgejo-coding'
|
|
runs-on: lxc-bookworm
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: https://code.forgejo.org/actions/download-artifact@v3
|
|
with:
|
|
name: forgejo-runner
|
|
|
|
- run: chmod +x 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
|
|
./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
|
|
|
|
- name: forgejo-runner exec --var
|
|
run: |
|
|
set -x
|
|
./forgejo-runner exec --var MY_VAR=testvariable --workflows .forgejo/testdata/var.yml |& tee /tmp/var.out
|
|
grep --quiet 'Success - Main echo "VAR -> testvariable"' /tmp/var.out
|