forgejo/services
Mathieu Fenniak c2649d4055 fix: dynamic Action jobs can stall by marking themselves blocked (#10658)
#10647 introduced a regression which was detected by the [matrix-dynamic end-to-end test](0e0b1429e6/actions/example-matrix-dynamic/.forgejo/workflows/test.yml), resulting in [test failures](https://code.forgejo.org/forgejo/end-to-end/actions/runs/4608/jobs/2/attempt/1).

The cause of this regression was an added code path which is invoked when a job is being reparsed due to being incomplete, in which the original `needs` value of the job is preserved.  To describe it in detail, here's an incomplete job...

```
on: [push]
jobs:
  # ...
  matrix-job:
    runs-on: docker
    needs: define-matrix
    strategy:
      matrix: ${{ fromJSON(needs.define-matrix.outputs.matrix-value) }}
    steps: # ...
```

This job is "incomplete" when it is parsed initially because the `define-matrix` job needs to be completed before its matrix can be evaluated into the correct jobs to run.  It `needs: define-matrix`.  When it is first parsed by Forgejo, `needs: define-matrix` is pulled out of the job definition and stored in the database, in the `action_run_job` table's `needs` column, because Forgejo will be the one managing when it is run by detecting the completion of the `define-matrix` job.

During #10647, a change was made which caused new jobs' which have their own `needs` (from reusable workflows) to have their `needs` be merged with the `needs` that were stored in the database.  The regression is that when a job is expanded, it will still be considered a blocked job because it has a `needs` list (even though we know that those jobs are complete):

03e2ecfbc4/models/actions/run.go (L369-L370)

As for why it was originally added in #10647?  Unfortunately the comment that I left in the code doesn't explain the functional problem it was attempting to solve, and just describes it as-if the original needs are still needed for *something*. 🙄  It makes perfect sense to me, right now, that we would **not** keep `needs` values that are already known to be complete.

I've run through my new reusable workflow end-to-end test (https://code.forgejo.org/forgejo/end-to-end/pulls/1362) with this codepath removed and it works perfectly fine.

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests

- I added test coverage for Go changes...
  - [x] in their respective `*_test.go` for unit tests.
  - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I added test coverage for JavaScript changes...
  - [ ] in `web_src/js/*.test.js` if it can be unit tested.
  - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [x] I do not want this change to show in the release notes.
- [ ] I want the title to show in the release notes with a link to this pull request.
- [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10658
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.codeberg.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2026-01-01 14:22:11 +01:00
..
actions fix: dynamic Action jobs can stall by marking themselves blocked (#10658) 2026-01-01 14:22:11 +01:00
agit fix: correctly mark reviews as stale for AGit PRs (#8450) 2025-07-09 07:38:00 +02:00
asymkey chore: do not clobber ~/.ssh/authorized_keys in certain tests (#10163) 2025-11-19 16:14:16 +01:00
attachment fix: allow instance API URLs in release assets (#7644) 2025-06-09 10:01:59 +02:00
auth feat: allow sync quota groups with oauth2 auth source (#8554) 2025-12-01 14:12:00 +01:00
automerge fix: check PR reference on base repository (#8431) 2025-07-06 14:23:47 +02:00
context feat: UI for the pull request trust management panel 2025-11-06 11:07:39 +01:00
contexttest Replace the 'relative-time' element scripting with custom, translatable rewrite (#6154) 2025-05-03 14:11:01 +00:00
convert chore: revise runner REST API endpoints (#10450) 2025-12-21 17:21:02 +01:00
cron fix: garbage collect lingering actions logs (#10009) 2025-11-18 18:59:01 +01:00
doctor feat: ensure only expected ssh public keys are in authorized_keys file (#10010) 2025-11-09 01:06:04 +01:00
externalaccount chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
f3 chore: ensure consistent import aliasing for services and models (#10253) 2025-11-30 17:00:57 +01:00
federation fix(user): set ActivityPub users to ProhibitLogin (#10434) 2025-12-17 15:38:32 +01:00
feed fix: very long commit messages cause pushed commits to fail to display on the action feed on MySQL (#9098) 2025-08-30 22:23:43 +02:00
forgejo chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
forms feat: allow sync quota groups with oauth2 auth source (#8554) 2025-12-01 14:12:00 +01:00
gitdiff feat: improve getting shortstat (#9587) 2025-10-10 14:15:38 +02:00
indexer chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
issue feat: use keying for webhook secrets (#10059) 2025-12-22 15:51:37 +01:00
lfs fix: return on error if an LFS token cannot be parsed 2025-10-25 10:41:49 -06:00
mailer chore: ensure consistent import aliasing for services and models (#10253) 2025-11-30 17:00:57 +01:00
markup chore: remove branding from context imports (#9628) 2025-10-11 01:52:51 +02:00
migrations feat: Add YYYY-MM-DD date format support for Pagure milestone migration (#10299) 2025-12-09 21:06:29 +01:00
mirror fix: don't push LFS when using SSH authentication (#10475) 2025-12-18 23:23:07 +01:00
moderation feat: render a link to poster profile next to the ID within shadow copy details (#10194) 2025-12-09 15:19:10 +01:00
notify chore: Dead Code: DeleteIssue Notify Topic (#10046) 2025-11-17 02:13:38 +01:00
org chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
packages fix: reduce runtime of container cleanup by relying on mass digest cleanup (#10297) 2025-12-05 15:45:47 +01:00
pull fix: allow for merge message template with empty message (#9930) 2025-12-10 19:57:19 +01:00
redirect chore: add repo redirect unit test 2025-08-30 09:37:38 +02:00
release 2025-11-21 combined security patches (#10037) 2025-11-21 05:23:43 +01:00
remote chore: tune down remote user promotion debug message shown as error (#7687) 2025-04-27 20:50:48 +00:00
repository fix: display orphan branches separately in commit graph (#10484) 2025-12-29 02:53:54 +01:00
secrets feat: migrate action secrets to keying to store them more securely (#8692) 2025-07-29 01:03:36 +02:00
shared/automerge fix: suppress false-positive error log when PR is already in the automerge queue (#9784) 2025-10-21 08:19:33 +02:00
stats fix: possible cause of invalid issue counts; cache invalidation occurs before a active transaction is committed (#10130) 2025-11-17 01:07:29 +01:00
task feat: cache derived keys for faster keying (#10114) 2025-11-16 14:29:14 +01:00
uinotification chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
user chore: ensure consistent import aliasing for services and models (#10253) 2025-11-30 17:00:57 +01:00
webhook feat: improve Discord webhook message formatting (#10626) 2025-12-30 18:01:17 +01:00
wiki chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00