1
0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2026-10-24 16:59:19 +03:00
Files
Mathieu Fenniak 7acb2083b1 feat(jobparser): support referencing ${{ needs... }} variables in strategy.matrix (#1190)
https://code.forgejo.org/forgejo/forgejo-actions-feature-requests/issues/71 requires partial implementation in runner, and partial in Forgejo; this is the runner implementation.

Extends the jobparser module to support matrix jobs that reference the outputs of other needed jobs, for example:
```yaml
jobs:
  define-matrix:
    outputs:
      colors: ${{ steps.colors.outputs.colors }}
    steps:
      - name: Define Colors
        id: colors
        run: |
          echo 'colors=["red", "green", "blue"]' >> "$GITHUB_OUTPUT"
  produce-artifacts:
    needs: define-matrix
    strategy:
      matrix:
        color: ${{ fromJSON(needs.define-matrix.outputs.colors) }}
```

The intended workflow for `jobparser` to support this is:
- The workflow is passed to jobparser as usual, but the new `ParseOption` `WithJobOutputs()` is provided.  It can be an empty set of outputs at the beginning of a workflow.
- The `SingleWorkflow` that is returned may be tagged with `IncompleteMatrix: true`.  If so, this is a job that has `needs` that must be completed before its matrix can be evaluated.
- Later when the jobs listed in `needs` are complete, the `SingleWorkflow`'s content can be passed back to the jobparser with `WithJobOutputs()` that includes all of the needed jobs' outputs.  At this point the single job will be reevaluated and multiple jobs may be returned.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- features
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1190): <!--number 1190 --><!--line 0 --><!--description ZmVhdChqb2JwYXJzZXIpOiBzdXBwb3J0IHJlZmVyZW5jaW5nICR7eyBuZWVkcy4uLiB9fSB2YXJpYWJsZXMgaW4gYHN0cmF0ZWd5Lm1hdHJpeGA=-->feat(jobparser): support referencing ${{ needs... }} variables in `strategy.matrix`<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1190
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2025-11-28 15:41:26 +00:00
..