1
1
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-24 20:41:18 +02:00
gitea/models
Zettat123 899ede1d55
Introduce ActionRunAttempt to represent each execution of a run (#37119)
This PR introduces a new `ActionRunAttempt` model and makes Actions
execution attempt-scoped.

**Main Changes**

- Each workflow run trigger generates a new `ActionRunAttempt`. The
triggered jobs are then associated with this new `ActionRunAttempt`
record.
- Each rerun now creates:
  - a new `ActionRunAttempt` record for the workflow run
- a full new set of `ActionRunJob` records for the new
`ActionRunAttempt`
- For jobs that need to be rerun, the new job records are created as
runnable jobs in the new attempt.
- For jobs that do not need to be rerun, new job records are still
created in the new attempt, but they reuse the result of the previous
attempt instead of executing again.
- Introduce `rerunPlan` to manage each rerun and refactored rerun flow
into a two-phase plan-based model:
  - `buildRerunPlan`
  - `execRerunPlan`
- `RerunFailedWorkflowRun` and `RerunFailed` no longer directly derives
all jobs that need to be rerun; this step is now handled by
`buildRerunPlan`.
- Converted artifacts from run-scoped to attempt-scoped:
  - uploads are now associated with `RunAttemptID`
  - listing, download, and deletion resolve against the current attempt
- Added attempt-aware web Actions views:
- the default run page shows the latest attempt
(`/actions/runs/{run_id}`)
- previous attempt pages show jobs and artifacts for that attempt
(`/actions/runs/{run_id}/attempts/{attempt_num}`)
- New APIs:
  - `/repos/{owner}/{repo}/actions/runs/{run}/attempts/{attempt}`
  - `/repos/{owner}/{repo}/actions/runs/{run}/attempts/{attempt}/jobs`
- New configuration `MAX_RERUN_ATTEMPTS`
  - https://gitea.com/gitea/docs/pulls/383

**Compatibility**

- Existing legacy runs use `LatestAttemptID = 0` and legacy jobs use
`RunAttemptID = 0`. Therefore, these fields can be used to identify
legacy runs and jobs and provide backward compatibility.
- If a legacy run is rerun, an `ActionRunAttempt` with `attempt=1` will
be created to represent the original execution. Then a new
`ActionRunAttempt` with `attempt=2` will be created for the real rerun.
- Existing artifact records are not backfilled; legacy artifacts
continue to use `RunAttemptID = 0`.

**Improvements**

- It is now easier to inspect and download logs from previous attempts.
-
[`run_attempt`](https://docs.github.com/en/actions/reference/workflows-and-actions/contexts#github-context)
semantics are now aligned with GitHub.
- > A unique number for each attempt of a particular workflow run in a
repository. This number begins at 1 for the workflow run's first
attempt, and increments with each re-run.
- Rerun behavior is now clearer and more explicit.
- Instead of mutating the status of previous jobs in place, each rerun
creates a new attempt with a full new set of job records.
- Artifacts produced by different reruns can now be listed separately.

Signed-off-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
2026-04-23 23:33:41 +00:00
..
actions Introduce ActionRunAttempt to represent each execution of a run (#37119) 2026-04-23 23:33:41 +00:00
activities Remove dead code identified by deadcode tool (#37271) 2026-04-20 07:52:48 +00:00
admin Don't block site admin's operation if SECRET_KEY is lost (#35721) 2025-10-22 12:35:56 +08:00
asymkey Remove dead code identified by deadcode tool (#37271) 2026-04-20 07:52:48 +00:00
auth Support for Custom URI Schemes in OAuth2 Redirect URIs (#37356) 2026-04-22 21:33:27 +00:00
avatars Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
db Replace custom Go formatter with golangci-lint fmt (#37194) 2026-04-17 17:45:22 +00:00
dbfs Fix dbfs error handling (#36844) 2026-03-07 00:28:46 +08:00
fixtures Support for Custom URI Schemes in OAuth2 Redirect URIs (#37356) 2026-04-22 21:33:27 +00:00
git Remove dead code identified by deadcode tool (#37271) 2026-04-20 07:52:48 +00:00
issues Fix typos (#37346) 2026-04-21 19:56:14 +00:00
migrations Introduce ActionRunAttempt to represent each execution of a run (#37119) 2026-04-23 23:33:41 +00:00
organization Fix org team assignee/reviewer lookups for team member permissions (#37365) 2026-04-23 18:14:29 +02:00
packages Swift registry metadata: preserve more JSON fields and accept empty metadata (#37254) 2026-04-18 04:16:26 +08:00
perm Fix issue label deletion with Actions tokens (#37013) 2026-03-29 09:21:14 +00:00
project Remove dead code identified by deadcode tool (#37271) 2026-04-20 07:52:48 +00:00
pull Fix incorrect viewed files counter if file has changed (#36009) 2025-11-27 14:02:03 +00:00
renderhelper Frontend iframe renderer framework: 3D models, OpenAPI (#37233) 2026-04-17 22:30:17 +00:00
repo Fix org team assignee/reviewer lookups for team member permissions (#37365) 2026-04-23 18:14:29 +02:00
secret Don't block site admin's operation if SECRET_KEY is lost (#35721) 2025-10-22 12:35:56 +08:00
shared/types Refactor locale&string&template related code (#29165) 2024-02-14 21:48:45 +00:00
system Remove dead code identified by deadcode tool (#37271) 2026-04-20 07:52:48 +00:00
unit Run gopls modernize on codebase (#34751) 2025-06-18 01:48:09 +00:00
unittest Remove external service dependencies in migration tests (#36866) 2026-04-23 15:18:53 +00:00
user Update Block a user form (#37359) 2026-04-23 02:07:02 +08:00
webhook Add webhook name field to improve webhook identification (#37025) (#37040) 2026-04-01 09:56:20 +08:00
main_test.go make writing main test easier (#27270) 2023-09-28 01:38:53 +00:00
repo_test.go Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
repo.go Replace custom Go formatter with golangci-lint fmt (#37194) 2026-04-17 17:45:22 +00:00