Skip to content

Introduce ActionRunAttempt to represent each execution of a run#37119

Merged
silverwind merged 167 commits intogo-gitea:mainfrom
Zettat123:run-attempt
Apr 23, 2026
Merged

Introduce ActionRunAttempt to represent each execution of a run#37119
silverwind merged 167 commits intogo-gitea:mainfrom
Zettat123:run-attempt

Conversation

@Zettat123
Copy link
Copy Markdown
Contributor

@Zettat123 Zettat123 commented Apr 6, 2026

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

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 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.
Screenshots

Run with only one attempt:

image

Rerunning:

image

Latest attempt:

image

Previous attempt (rerun is not allowed):

image

Dropdown for attempt records:

image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 6, 2026
@Zettat123 Zettat123 added the topic/gitea-actions related to the actions of Gitea label Apr 6, 2026
@Zettat123 Zettat123 force-pushed the run-attempt branch 2 times, most recently from 3da69e5 to 7f338dd Compare April 6, 2026 05:11
Comment thread services/actions/job_emitter.go Outdated
Comment thread services/actions/context.go Outdated
Comment thread services/actions/job_emitter.go Outdated
Comment thread services/actions/run.go
Comment thread routers/web/repo/actions/view.go Outdated
Comment thread models/actions/run_attempt.go Outdated
Comment thread models/actions/run_attempt.go Outdated
Comment thread templates/repo/actions/view_component.tmpl Outdated
@Zettat123 Zettat123 changed the title Introduce RunAttempt to represent each execution of a run Introduce ActionRunAttempt to represent each execution of a run Apr 6, 2026
@wxiaoguang
Copy link
Copy Markdown
Contributor

wxiaoguang commented Apr 22, 2026

That relative-time change was unnecessary, I reverted and converted at the call site in 1e4d241.

No, it is necessary. I don't think keeping writing new Date(attempt.triggeredAt * 1000).toISOString() is right.

If you don't want to include it here, there can be separate PR to make it accept unix timestamp (before this one)

@silverwind
Copy link
Copy Markdown
Member

Hmm I can re-add but then it must be consistently used at all call sites, IIRC, there is more than 1.

@wxiaoguang
Copy link
Copy Markdown
Contributor

We should never encourage such style code, why keep copying&pasting the redundant code? Framework can do pretty well.

image image

Zettat123 and others added 2 commits April 22, 2026 13:48
Extend the vendored component's datetime parsing to recognise
integer/decimal/negative numeric strings as unix seconds, in addition
to ISO 8601 handled by Date.parse. This lets callers bind raw
int64-unix-seconds values from the Go backend directly.

Simplifies three call sites that were doing `new Date(x * 1000).toISOString()`
and removes the `runTriggeredAtIso` computed. Adds coverage for integer,
fractional, negative, and partial-numeric inputs.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member

Fixed in 90f8f1a and made all 3 call sites use it.

@wxiaoguang
Copy link
Copy Markdown
Contributor

Fixed in 90f8f1a and made all 3 call sites use it.

Number(xxx) and isNaN work pretty well. Why it needs a regexp unixSecondsRe = /^-?\d+(?:\.\d+)?$/;?

@silverwind
Copy link
Copy Markdown
Member

silverwind commented Apr 22, 2026

Number(xxx) and isNaN work pretty well. Why it needs a regexp unixSecondsRe = /^-?\d+(?:\.\d+)?$/;?

Number has edge cases, like Number("") = 0 which would render as 1970.

Go's time.Time.Unix() returns int64, never fractional; realistic
backend timestamps bound to <relative-time> are always positive.
Drop the negative and decimal branches so out-of-domain inputs
fall through to Date.parse and render the fallback slot.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member

Tailored the implementation a bit more to backend in 515b595, only positive integers.

@wxiaoguang
Copy link
Copy Markdown
Contributor

Tailored the implementation a bit more to backend in 515b595, only positive integers.

But .... why it needs to pass empty string as fallback? Backend never sends empty value for it

image image

And do we have a clear definition for what "relative-time" should do for datetime=''? The tests just set "fallback" as textContent and check it again.

Not blocker, but I just found it's difficult to understand.

@silverwind
Copy link
Copy Markdown
Member

silverwind commented Apr 22, 2026

The previous code also had the '' fallback, it was preserved as-is. Probably overly defensive.

90f8f1a#diff-2694e5409a944101daf84d16093d51b87f3cb841def732a59c1e75ad3b1c35e6L21

Comment thread web_src/js/components/ActionRunArtifacts.test.ts Outdated
@wxiaoguang wxiaoguang marked this pull request as ready for review April 23, 2026 00:30
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 23, 2026
@silverwind silverwind enabled auto-merge (squash) April 23, 2026 23:05
@silverwind silverwind merged commit 899ede1 into go-gitea:main Apr 23, 2026
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 23, 2026
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 24, 2026
* origin/main:
  Allow fast-forward-only merge when signed commits are required (go-gitea#37335)
  Introduce `ActionRunAttempt` to represent each execution of a run (go-gitea#37119)
  Move review request functions to a standalone file (go-gitea#37358)
  Fix repo init README EOL (go-gitea#37388)
  Fix org team assignee/reviewer lookups for team member permissions (go-gitea#37365)
  Remove external service dependencies in migration tests (go-gitea#36866)
  Extend issue context popup beyond markdown content (go-gitea#36908)

# Conflicts:
#	routers/api/v1/repo/action.go
#	web_src/js/components/RepoActionView.vue
@wxiaoguang wxiaoguang deleted the run-attempt branch April 24, 2026 05:30
silverwind added a commit to mohammad-rj/gitea that referenced this pull request Apr 24, 2026
* origin/main: (127 commits)
  Refactor pull request view (1) (go-gitea#37380)
  Improve AGENTS.md (go-gitea#37382)
  Remove dead CSS (go-gitea#37376)
  Add pr-review e2e test and speed up e2e tests (go-gitea#37345)
  Drop Fomantic tab, checkbox and form patches (go-gitea#37377)
  fix: dump with default zip type produces uncompressed zip (go-gitea#37401)
  Allow fast-forward-only merge when signed commits are required (go-gitea#37335)
  Introduce `ActionRunAttempt` to represent each execution of a run (go-gitea#37119)
  Move review request functions to a standalone file (go-gitea#37358)
  Fix repo init README EOL (go-gitea#37388)
  Fix org team assignee/reviewer lookups for team member permissions (go-gitea#37365)
  Remove external service dependencies in migration tests (go-gitea#36866)
  Extend issue context popup beyond markdown content (go-gitea#36908)
  fix: commit status reporting (go-gitea#37372)
  Support for Custom URI Schemes in OAuth2 Redirect URIs (go-gitea#37356)
  Fix cmd tests by mocking builtin paths (go-gitea#37369)
  chore: upgrade Go version in devcontainer image to 1.26 (go-gitea#37374)
  Fix button layout shift when collapsing file tree in editor (go-gitea#37363)
  Update `Block a user` form (go-gitea#37359)
  Remove IsValidExternalURL/IsAPIURL and use IsValidURL at call sites (go-gitea#37364)
  ...

# Conflicts:
#	modules/eventsource/event.go
#	tests/e2e/events.test.ts
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 25, 2026
* origin/main: (51 commits)
  Fix color regressions, add `priority` color (go-gitea#37417)
  [skip ci] Updated translations via Crowdin
  Stabilize e2e logout propagation test (go-gitea#37403)
  refactor: serve site manifest via `/assets/site-manifest.json` endpoint (go-gitea#37405)
  feat(security): set X-Content-Type-Options: nosniff by default (go-gitea#37354)
  Refactor pull request view (1) (go-gitea#37380)
  Improve AGENTS.md (go-gitea#37382)
  Remove dead CSS (go-gitea#37376)
  Add pr-review e2e test and speed up e2e tests (go-gitea#37345)
  Drop Fomantic tab, checkbox and form patches (go-gitea#37377)
  fix: dump with default zip type produces uncompressed zip (go-gitea#37401)
  Allow fast-forward-only merge when signed commits are required (go-gitea#37335)
  Introduce `ActionRunAttempt` to represent each execution of a run (go-gitea#37119)
  Move review request functions to a standalone file (go-gitea#37358)
  Fix repo init README EOL (go-gitea#37388)
  Fix org team assignee/reviewer lookups for team member permissions (go-gitea#37365)
  Remove external service dependencies in migration tests (go-gitea#36866)
  Extend issue context popup beyond markdown content (go-gitea#36908)
  fix: commit status reporting (go-gitea#37372)
  Support for Custom URI Schemes in OAuth2 Redirect URIs (go-gitea#37356)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-update-needed The document needs to be updated synchronously lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/gitea-actions related to the actions of Gitea

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants