runner/.forgejo/workflows/act.yml
Earl Warren 83e7b4ae10
chore(cleanup): dispatch workflows according to the role of the repository (#790)
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>
2025-08-03 08:34:09 +00:00

80 lines
2.2 KiB
YAML

name: act
on:
push:
branches:
- 'main'
pull_request:
env:
GOPROXY: https://goproxy.io,direct
GOPATH: /go_path
GOCACHE: /go_cache
jobs:
unit:
runs-on: docker
if: vars.ROLE == 'forgejo-coding'
container:
image: 'code.forgejo.org/oci/node:22-bookworm'
steps:
- name: cache go path
id: cache-go-path
uses: https://code.forgejo.org/actions/cache@v4
with:
path: /go_path
key: go_path-${{ forge.repository }}-${{ forge.ref_name }}
restore-keys: |
go_path-${{ forge.repository }}-
go_path-
- name: cache go cache
id: cache-go-cache
uses: https://code.forgejo.org/actions/cache@v4
with:
path: /go_cache
key: go_cache-${{ forge.repository }}-${{ forge.ref_name }}
restore-keys: |
go_cache-${{ forge.repository }}-
go_cache-
- uses: https://code.forgejo.org/actions/checkout@v4
- uses: https://code.forgejo.org/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
- name: unit test
run: |
go test -short ./act/container
go test ./act/artifactcache/... ./act/workflowpattern/... ./act/filecollector/... ./act/common/... ./act/jobparser ./act/model ./act/exprparser ./act/schema
integration:
runs-on: lxc-bookworm
if: vars.ROLE == 'forgejo-coding'
needs: [unit]
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- uses: https://code.forgejo.org/actions/setup-go@v5
with:
go-version-file: go.mod
- name: apt install docker.io
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get -q install -qq -y docker.io
- name: integration test
run: |
go test ./act/container
go test ./act/runner/...