bug: dynamic matrix strategy fails on Forgejo and works with runner's exec command #525

Closed
opened 2025-03-28 12:52:38 +00:00 by bziemons · 7 comments

Can you reproduce the bug on the Forgejo test instance?

No

Description

I have a workflow that runs a matrix strategy perfectly fine when using forgejo-runner exec (with rootless podman) on my PC, but runs a single job instead of the matrix within Forgejo. I have reproduced the issue here on https://code.forgejo.org with a test workflow, see
https://code.forgejo.org/bziemons/actions-test/src/commit/4926a1e05ec547bc53ee96161ebe83143f35d241/.forgejo/workflows/test.yml.

Forgejo Version

10.0.3

Runner Version

6.2.2, 6.3.1

How are you running Forgejo?

Forgejo runs in a podman container on my end built from the Dockerfile provided in the sources.

How are you running the Runner?

I use rootless podman to run the runner image data.forgejo.org/forgejo/runner:6, providing the runner image access to the user's podman socket.

Logs

Please refer to https://code.forgejo.org/bziemons/actions-test/actions/runs/2 and the working local runner exec log is attached as test-local-exec.log.

Workflow file

name: test
on: [push, workflow_dispatch]

env:
  DEFAULT_IMAGE: "data.forgejo.org/oci/node:22-alpine"

jobs:
  matrixgen:
    runs-on: docker-global-bookworm
    outputs:
      matrix: ${{ steps.generate_matrix.outputs.matrix }}
    steps:
      - name: generate matrix
        id: generate_matrix
        run: |
          echo 'matrix={"obj": [{"other": ""}, {"image": "data.forgejo.org/oci/node:22-alpine3.20"}, {"image": "data.forgejo.org/oci/node:22-alpine3.21"}]}' >> $GITHUB_OUTPUT
  test:
    needs: matrixgen
    runs-on: docker-global-bookworm
    strategy:
      matrix: ${{ fromJSON(needs.matrixgen.outputs.matrix) }}
    container:
      image: ${{ matrix.obj.image || env.DEFAULT_IMAGE }}
    steps:
      - run: cat /etc/os-release
### Can you reproduce the bug on the Forgejo test instance? No ### Description I have a workflow that runs a matrix strategy perfectly fine when using forgejo-runner exec (with rootless podman) on my PC, but runs a single job instead of the matrix within Forgejo. I have reproduced the issue here on https://code.forgejo.org with a test workflow, see <https://code.forgejo.org/bziemons/actions-test/src/commit/4926a1e05ec547bc53ee96161ebe83143f35d241/.forgejo/workflows/test.yml>. ### Forgejo Version 10.0.3 ### Runner Version 6.2.2, 6.3.1 ### How are you running Forgejo? Forgejo runs in a podman container on my end built from the Dockerfile provided in the sources. ### How are you running the Runner? I use rootless podman to run the runner image `data.forgejo.org/forgejo/runner:6`, providing the runner image access to the user's podman socket. ### Logs Please refer to https://code.forgejo.org/bziemons/actions-test/actions/runs/2 and the working local runner exec log is attached as `test-local-exec.log`. ### Workflow file ```yaml name: test on: [push, workflow_dispatch] env: DEFAULT_IMAGE: "data.forgejo.org/oci/node:22-alpine" jobs: matrixgen: runs-on: docker-global-bookworm outputs: matrix: ${{ steps.generate_matrix.outputs.matrix }} steps: - name: generate matrix id: generate_matrix run: | echo 'matrix={"obj": [{"other": ""}, {"image": "data.forgejo.org/oci/node:22-alpine3.20"}, {"image": "data.forgejo.org/oci/node:22-alpine3.21"}]}' >> $GITHUB_OUTPUT test: needs: matrixgen runs-on: docker-global-bookworm strategy: matrix: ${{ fromJSON(needs.matrixgen.outputs.matrix) }} container: image: ${{ matrix.obj.image || env.DEFAULT_IMAGE }} steps: - run: cat /etc/os-release ```
bziemons changed title from bug: to bug: matrix strategy fails on Forgejo and works with runner's exec command 2025-03-28 12:53:28 +00:00
Author

The feature was implemented in act here: https://github.com/nektos/act/pull/964
Is gitea/Forgejo missing the mid-workflow changes in the amount of jobs?

The feature was implemented in act here: https://github.com/nektos/act/pull/964 Is gitea/Forgejo missing the mid-workflow changes in the amount of jobs?
Contributor
FWIW https://code.forgejo.org/forgejo/act/commit/d1e0216039d92a4253fecc2b11a775a37ba43ceb has the commit from https://github.com/nektos/act/pull/964
Contributor

This is a limitation of the runner and is probably related to some missing values being passed from one job to another in this context. IIRC there was a similar issue somewhere. Maybe related https://codeberg.org/forgejo/forgejo/issues/2188.

This is a limitation of the runner and is probably related to some missing values being passed from one job to another in this context. IIRC there was a similar issue somewhere. Maybe related https://codeberg.org/forgejo/forgejo/issues/2188.
Contributor

Since each matrix element leads to an independent job, Forgejo evaluates the matrix statically in order to create the jobs that are sent to the runner. There is no logic to do that in a multi-step process where the matrix is computed based on the outcome of a previous job. Of course ACT has no such problem because it is a single binary and not a server communicating with a client.

Example: https://codeberg.org/forgejo/forgejo/actions/runs/66599

image

Where

  test-remote-cacher:
    if: vars.ROLE == 'forgejo-coding' || vars.ROLE == 'forgejo-testing'
    runs-on: docker
    needs: [backend-checks, frontend-checks, test-unit]
    container:
      image: 'data.forgejo.org/oci/node:22-bookworm'
      options: --tmpfs /tmp:exec,noatime
    name: ${{ format('test-remote-cacher ({0})', matrix.cacher.name) }}
    strategy:
      matrix:
        cacher:
          - name: redis
            image: data.forgejo.org/oci/bitnami/redis:7.2
            options: --tmpfs /bitnami/redis/data:noatime
          - name: redict
            image: registry.redict.io/redict:7.3.0-scratch
            options: --tmpfs /data:noatime
          - name: valkey
            image: data.forgejo.org/oci/bitnami/valkey:7.2
            options: --tmpfs /bitnami/redis/data:noatime
          - name: garnet
            image: ghcr.io/microsoft/garnet-alpine:1.0.14
            options: --tmpfs /data:noatime
    services:
      cacher:
        image: ${{ matrix.cacher.image }}
        options: ${{ matrix.cacher.options }}
    steps:
      - uses: https://data.forgejo.org/actions/checkout@v4
      - uses: ./.forgejo/workflows-composite/setup-env
      - name: install git >= 2.42
        uses: ./.forgejo/workflows-composite/apt-install-from
        with:
          packages: git
      - uses: ./.forgejo/workflows-composite/build-backend
      - run: |
          su forgejo -c 'make test-remote-cacher test-check'
        timeout-minutes: 120
        env:
          RACE_ENABLED: 'true'
          TAGS: bindata
          TEST_REDIS_SERVER: cacher:${{ matrix.cacher.port }}
Since each matrix element leads to an independent job, Forgejo evaluates the matrix statically in order to create the jobs that are sent to the runner. There is no logic to do that in a multi-step process where the matrix is computed based on the outcome of a previous job. Of course ACT has no such problem because it is a single binary and not a server communicating with a client. Example: https://codeberg.org/forgejo/forgejo/actions/runs/66599 ![image](/attachments/06071730-9400-48d0-8144-24c3f7199b3e) Where ```yaml test-remote-cacher: if: vars.ROLE == 'forgejo-coding' || vars.ROLE == 'forgejo-testing' runs-on: docker needs: [backend-checks, frontend-checks, test-unit] container: image: 'data.forgejo.org/oci/node:22-bookworm' options: --tmpfs /tmp:exec,noatime name: ${{ format('test-remote-cacher ({0})', matrix.cacher.name) }} strategy: matrix: cacher: - name: redis image: data.forgejo.org/oci/bitnami/redis:7.2 options: --tmpfs /bitnami/redis/data:noatime - name: redict image: registry.redict.io/redict:7.3.0-scratch options: --tmpfs /data:noatime - name: valkey image: data.forgejo.org/oci/bitnami/valkey:7.2 options: --tmpfs /bitnami/redis/data:noatime - name: garnet image: ghcr.io/microsoft/garnet-alpine:1.0.14 options: --tmpfs /data:noatime services: cacher: image: ${{ matrix.cacher.image }} options: ${{ matrix.cacher.options }} steps: - uses: https://data.forgejo.org/actions/checkout@v4 - uses: ./.forgejo/workflows-composite/setup-env - name: install git >= 2.42 uses: ./.forgejo/workflows-composite/apt-install-from with: packages: git - uses: ./.forgejo/workflows-composite/build-backend - run: | su forgejo -c 'make test-remote-cacher test-check' timeout-minutes: 120 env: RACE_ENABLED: 'true' TAGS: bindata TEST_REDIS_SERVER: cacher:${{ matrix.cacher.port }} ```
image.png
112 KiB
Author

I was unaware that the jobs to run are determined before even starting the first job, but it makes sense. Reading into it I saw that, e.g., "runs-on" is (of course) important to Forgejo to orchestrate which runner to use. That information is difficult to obtain when new jobs are generated as the workflow progresses and requires the runner to communicate that somehow as you mention. Thank you for your insight.

What are the implications?

Is it okay to make changes to the actions/runner api endpoint here downstream on Forgejo or should this be done upstream? I am willing to put some work into this. I am very much interested in the Forgejo api for the runners.

Edit: just going to update the text after reading a bit more into it. I agree with the last paragraph here: https://forgejo.org/2024-02-forking-forward/#consequences-of-becoming-a-hard-fork
I am not even sure if a change to the actions API is necessary, so the upstream question is too hypothetical. As of writing I see that Forgejo Actions is still using https://gitea.com/gitea/actions-proto-def, which currently means there is a common API. I wanted to explore what is possible with the current API and (I think) a discussion about whether this feature should be implemented and how to move forward would be more appropriate then.

I was unaware that the jobs to run are determined before even starting the first job, but it makes sense. Reading into it I saw that, e.g., "runs-on" is (of course) important to Forgejo to orchestrate which runner to use. That information is difficult to obtain when new jobs are generated as the workflow progresses and requires the runner to communicate that somehow as you mention. Thank you for your insight. What are the implications? <del> Is it okay to make changes to the actions/runner api endpoint here downstream on Forgejo or should this be done upstream? I am willing to put some work into this. I am very much interested in the Forgejo api for the runners. </del> Edit: just going to update the text after reading a bit more into it. I agree with the last paragraph here: https://forgejo.org/2024-02-forking-forward/#consequences-of-becoming-a-hard-fork I am not even sure if a change to the actions API is necessary, so the upstream question is too hypothetical. As of writing I see that Forgejo Actions is still using https://gitea.com/gitea/actions-proto-def, which currently means there is a common API. I wanted to explore what is possible with the current API and (I think) a discussion about whether this feature should be implemented and how to move forward would be more appropriate then.
Author

There also is an upstream issue on gitea: https://gitea.com/gitea/act_runner/issues/393

There also is an upstream issue on gitea: https://gitea.com/gitea/act_runner/issues/393
bziemons changed title from bug: matrix strategy fails on Forgejo and works with runner's exec command to bug: dynamic matrix strategy fails on Forgejo and works with runner's exec command 2025-03-29 15:34:23 +00:00
Author

I have created https://codeberg.org/forgejo/docs/pulls/1119 for documenting this behaviour.

I have created https://codeberg.org/forgejo/docs/pulls/1119 for documenting this behaviour.
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
forgejo/runner#525
No description provided.