Repository navigation
feat(cli): port Tale's workflows to Forgejo - #4984
Merged
Merged
Conversation
yannickmonney
marked this pull request as ready for review
October 14, 2026 07:14
yannickmonney
marked this pull request as draft
October 14, 2026 12:20
The Forgejo port rewrites workflows written for GitHub. Where an event or a job cannot exist on Forgejo, the conditions that mention it have to be decided at generation time, which takes a real expression parser and not text substitution. This is that parser, a printer, and a folder that follows GitHub's own semantics for what it folds (operands of && and ||, loose equality, falsy values) and carries everything else through unchanged. Nothing calls it yet: it is the base of the generator that turns .github/workflows into .forgejo/workflows at cut-over.
A workflow is read with its comments, its anchors are expanded so removing a job cannot orphan an alias, and every string and condition is folded by what the generated file's own triggers and left-out jobs decide. A condition that holds always is dropped, one that can never hold removes the job or step it guards, an action input that comes to nothing is not given, and what does not change is written back as it was. All fifteen current workflows round-trip with identical content.
Forgejo never fires merge_group, repository_dispatch, workflow_run or branch_protection_rule, and accepts a workflow that lists them without a word, so the generated file says what it will really do: those events are gone, the pull request activities Forgejo has no event for are gone, and a workflow that GitHub validated in its merge queue runs on a push to the merge train's mq/** branches instead (with no paths filter: a new branch has no files to compare). A dispatch that existed for release candidates is dropped. The events that remain are what github.event_name can be, which the folder uses to decide the conditions that mention the others.
The structural rules of the Forgejo port, each saying what it did: - every pull request runs the full suite, so the scope jobs and the steps that ask for a scope go, and the jobs that read them are answered "everything"; the jobs Tale already lists as merge-queue-only (CHECKS_MERGE_QUEUE_ONLY) lose the condition that held them back; - Forgejo's runner never starts services: for a host-mode job, so each one becomes the docker run it stands for, on the loopback address and waited for when its options define a health check; - the runner never fills strategy.job-total, so the size of a plain matrix is written where a job asks for it; - environments and SARIF uploads, which mean nothing on Forgejo, are dropped; - an output that is empty is a fact for the jobs that read it. portWorkflow runs the triggers, these rules and the folder until nothing new is learned. On the fifteen current workflows it removes every candidate job.
Facts a rule learns now hold per job (a matrix size, the steps a job lost), rules can run after the fold, and a composite action can be ported on its own. The port also folds with a pull request that is never a draft: Forgejo raises no event when work in progress is marked ready, and the merge train refuses a draft itself.
Every action a workflow uses is looked up in one table: kept (it runs on Forgejo as it is), replaced (the artifact actions by Forgejo's forks), dropped (the runner cache is per instance, a code scanning upload has nowhere to go) or unportable, which fails the port instead of passing a step that cannot run. BuildKit's type=gha cache becomes a registry cache in Forgejo's own registry, written by the merge train's pushes only.
CI ready is the one check branch protection and the merge train read. On Forgejo the ported workflow runs a job that hands every pull request and every merge train batch to Tale's own readiness policy, as a merge group at full scope, so the verdict is the one the merge queue reaches today. A removed job counts as skipped, and a pull request from a fork is held: a maintainer pushes its branch to the repository to have it validated.
The few rewrites that cannot be general: the readiness job the merge train reads, jobs and matrix rows the pool has no runner for, the range a batch's commitlint job lints, run URLs, the package publisher's remote and the GitHub token the web site's release feed needs. Each anchors on a name or a line the repository already holds still and reports when the anchor is gone, so a workflow edited tomorrow is flagged, not carried through wrong.
generate() is a function of text: the workflows, composite actions and scripts of .github go in, the files of .forgejo come out together with what was done to each and what Forgejo would refuse. The manifest says which workflows are ported, which stay on GitHub and why. The validator holds a generated file to what the pinned forgejo-runner accepts: its keys, its labels, the services it never starts, the events that never fire and the expressions it cannot read.
A pull request owes what GitHub's pull request tier owes: the fast lanes, with Build, E2E, CLI and the backend integration check held for the merge train, and Security on every pull request. A batch of the train, a push to mq/**, owes everything, as a merge group does. The scope action's answers are a function of the event, so the port no longer runs it: the folder learns what each output is for a pull request and for any other run, and the conditions that read it become conditions on the event. A merge group is a push for the same reason. The readiness job is handed what each removed job would have reported, for each kind of run, so Tale's policy is judged unchanged.
report, check, generate, checks and github run the port over a checkout. check lists what Forgejo would refuse, compares the declared checks with the generated ones, and with a forgejo-runner runs validate and exec --list on every file; the tests do the same with the pinned runner on linux/amd64 and print, without failing, what the workflows of today would need. The publisher pins a release's package snapshots on a tag pushed to Forgejo, because the push mirror deletes the refs only GitHub made; the one edit GitHub's own copy needs is described by github. A README says what the port does, what stays on GitHub and how the cut-over goes, and CI.md points to it.
The tier is full by default: a pull request owes what a batch of the merge train owes, so a failure shows on the pull request and not in the train. fast keeps GitHub's pull request tier. It is set for the manifest, replaced by a workflow's plan or by --tier, and carried to the readiness job, which judges a pull request of the full tier as the merge group the policy knows. The README holds the daily cost of both.
A plan can now name events that make no sense on Forgejo. The CLI's manual dispatch builds the binaries of a release tag to attach them to a GitHub release, with gh and GitHub's API, so the ported workflow has the pull request and the batch only.
Run against a Forgejo 15.0.9 and a runner 13.2.0, the port's pin of forgejo/upload-artifact (branch-v6) is refused at the upload, because its client drops the padding of the signature in the signed URL. The v5 fork uploads with every input Tale gives the action, and the v7 download fork downloads by name, by id and by pattern.
The report lists the external actions the generated files use, and the README says what else the workflows need of the instance and the runner: the mirrors, the labels, the tools and size of a runner, the two secrets and the registry. A test holds the README's list of mirrors to the generated one, and the daily figures count the CLI's macOS and Windows legs where they run, on GitHub.
The service is gone from Tale's Build workflow, so the site images that build without a layer cache are web, docs and ui-docs.
The advisory scan's job-level continue-on-error, step summaries and SARIF uploads behave differently on Forgejo and are left alone on purpose. The README now says so, and how to run the pinned runner's checks on a workstation that is not Linux.
The link check takes HEAD^1 as its base under GitHub Actions because a pull request is checked out there as a merge commit. A Forgejo run checks out the pull request's head and a batch is one squash commit per pull request, so HEAD^1 is only the previous commit and a page retired in an earlier one escapes the retired-page and published-line rules. The port now fetches the whole history for the Format job and runs the check with LINT_LINKS_BASE set to the merge base with main. The step fails when there is no merge base instead of falling back to HEAD^1.
The generated header named deployments/tale/train/pr/repositories.yml, a path the ops repository no longer has: the declaration is deployments/tale/merge-train/pr/repositories.yml. The check command compared only the list of checks, so a stale header was never reported. It now compares the whole file with what checks --write generates.
The unit test compared the README's list of mirrored actions with the actions the live workflows use and failed. A pull request that adds any external action to a ported workflow could not go green until its author edited the port's README, although the port is applied at the cut-over. The comparison is now part of the check command, where it fails, and the unit test prints what it finds as a warning like the other facts about today's workflows. The README says what can fail the unit tests: the generator crashing, or declared-checks.yml drifting.
The section said nothing in the CI reads the port and that it adds no condition to a GitHub workflow. The unit tests do run it over the live workflows, and the cut-over adds one condition to publish-packages.yml. It also now says that Security is not path-scoped in the port's fast tier.
A service with volumes became a docker run with no -v and no warning, so an edited workflow could change meaning silently. The port now reports the volumes of a service as not carried over, as it does credentials and unmapped ports. The comment on the generated step also said the service starts while the next steps check out the code. Steps run one after another, and a service with a health check blocks its step until it is healthy, so the step goes first only to have the service up before any step needs it.
The runner was cached at a predictable path under the temporary directory and executed by path after its digest was checked. On a shared Linux machine another user could create that directory first and swap the file between the check and the run. The cache directory is now the user's own, closed to the group and to others, and not a link; anything else is refused with a warning. A response that is not ok and a digest that does not match are reported too, where they used to skip the runner check without a word.
The generated files tell people to edit them by hand after the cut-over, yet generate --write overwrote any file that differed and deleted every file of .forgejo/workflows, .forgejo/actions and .forgejo/scripts that it did not generate, a hand-written one included, at once. It now lists them as the dry run does and refuses until --force is given. The doc comment and the README say what the command deletes.
Two comments pointed at a planning note that is not in the repository and one told how the artifact fork was found. They now say what holds: the site images have no registry login before their cache step, and the upload action is pinned at v5 because the v6 client drops the padding of the signature in the signed URL and the server refuses the upload.
The expression parser is hand-written although GitHub publishes @actions/expressions, and nothing said why. The package's parser refuses any context or function name it was not given, which would stop a whole condition from folding on one new name. Its lexer decodes only the first escaped quote of a string literal, and it has no printer and no partial evaluation, so the folder and printer would stay. The header of expression.ts records this, and two tests pin what the package cannot do: every escaped quote is read, and what is known folds around a name that is not.
Windows has no getuid, reports every directory with the mode bits of every user and ignores the mode given to mkdir, so the cache directory check refused every cache there and the runner tests failed on the Windows leg of the CLI workflow. Where there is no owner to compare, the directory itself is all that is checked. The tests that need modes, a link or an executable bit skip on Windows.
A rule of the port that no longer finds its text leaves the file as the GitHub workflow has it and says so as an anchor warning, which check did not read. A step of checks.yml edited from lint:links to anything else kept HEAD^1 and a shallow checkout in the ported file, and the cut-over check still came out clean. check now reports each anchor warning as a problem, and a test ports a Format job with the link check and holds the merge base and the full history it needs.
The tests also fail on a composite action or script the manifest names that is renamed or removed, on a tier that e2e.yml or sast.yml no longer carries, and on a README without a row for a manifest entry, so the sentence that said they fail only on a crash and a stale declared-checks.yml was wrong.
The test that shows the runner can fail edited the generated sast.yml and replaced a `needs: [sast]` that exists only while that workflow has one job. Adding a job to sast.yml, or renaming its job, made the replace a no-op and failed the Linux unit job, which is a workflow edited today failing the port. The probes are now a small workflow in the test, with a control that the runner reads it clean.
An `if:` that calls no status function waits for its needs to succeed. `always() || github.event_name == 'push'` in a workflow that only pushes folded to true, true dropped the `if:`, and the job was then skipped after a failure where the source ran it. The same held for `cancelled()` and `failure()`, for a true operand on either side of `||`, and for a negated `&&` that folds to true. A condition that called a status function and folds to one that calls none now keeps `always()`, with the rest of the condition after it when something still decides it. A condition that folds to false is false whatever the status.
A rule that is not in the generator's list changes nothing, says nothing and warns of nothing, and the tests that run the generator over the live workflows read only the checks, the file counts and the tier. Dropping batchEvent left the batch build reading merge_group with every test green. A table now gives each rule a workflow it has something to change in and asks the report for the change it names; the matrix totals, which report nothing, are held by the text they write.
A workflow that calls a composite action the manifest does not name got a warning that it is GitHub-only, and the generated file kept the call. check read only the anchor warnings, so it printed ok and the first step of the cut-over passed over a file that calls what the port itself says cannot run on Forgejo. check now fails on that warning too, and the README says so wherever it lists what check fails on.
foldCondition kept a status function only on the simplify path. A condition that holds for each event the workflow has, such as `always() || push || pull_request` in a workflow with those two events, returned `always` and the `if:` was deleted, so the job waited for success() where the source ran it after a failed need. It now returns `always()` when the condition called a status function, as the README says, and the test holds both shapes the review probed.
ruleProblems has no importer outside forgejo-port.ts, so knip's unused export check failed on the branch.
yannickmonney
force-pushed
the
feat/forgejo-ci
branch
from
October 19, 2026 10:18
ccf11a5 to
975878e
Compare
yannickmonney
marked this pull request as ready for review
October 19, 2026 10:18
yannickmonney
added this pull request to the merge queue
Oct 19, 2026
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tools/cli/scripts/forgejo-port/generates the workflows Forgejo's runner runs (.forgejo/) from the ones GitHub runs (.github/), for the day the repository moves to the application node's Forgejo. It is a function of text with a command line,bun tools/cli/scripts/forgejo-port.ts; its README says what it does and why. The port is applied once, at the cut-over; after that.forgejo/workflows/is edited by hand. Until then it only reads.github/.What it changes
full(the default) is what a batch owes,fastis GitHub's pull request tier; a batch of the merge train, a push tomq/**, always owes everythingif:is folded by what the port knows (the events the workflow has, the jobs it lost, a matrix's size); a condition that called a status function still calls one when it folds to trueCI ready (…)job hands its needs toci-ready.tsunchanged, as a pull request or as a merge groupservices:becomedocker runsteps (volumes and credentials are reported, not carried over);strategy.job-totalis written as the number; rows for runners the pool does not serve are removedtype=ghacache becomes a registry cachelint:linksruns against the merge base withmain, asHEAD^1is not the base on Forgejorelease.yml, the candidate workflows, Scorecard, Load and the workspace upgrade stay on GitHub; the publisher also pins snapshots on a release tagdeclared-checks.ymllists the 7 checks the merge train waits forgenerate --writerefuses to overwrite or delete a file edited by hand unless--forceis given..github/CI.mdgains a section that points to the README.What stays dormant
.github/workflows/or.github/actions/changes, and nothing in the CI that runs today reads the port..forgejo/does not exist in this change.CI ready (…)workflows and the release lane keep the bytes the release adopter binds.github --write, aTALE_SOURCEcondition) is not made here; it belongs to the cut-over.How it was tested
bun run checkon the branch rebased ontomain(b7b18ea): exit 0;@tale/cliruns 3731 tests, 0 fail, 35 skipped.scripts/forgejo-port/(expression folder, workflow reader and writer, every rule, the readiness policy for both tiers, the generator) and 23 inforgejo-port.test.ts(the command line). They run the port over the 17 workflows of today: no problem, anddeclared-checks.ymlmatches.forgejo-port.ts check --runnerrunsforgejo-runner validateandexec --list(13.2.0, the build the node pins) on all 10 generated files: ok, 10 files, 7 checks. The tests do the same on linux/amd64 with the pinned build, and show that a broken file fails.bun run knip:check,bun run lint:sastand commitlint over the branch's commits: 0 problems.echo, passed all sevenCI ready (…)checks on a pull request and on a push tomq/**; a failing job turned its workflow's check red and no other; a tag run of the publisher took its tooling frommainand its source from the tag;forgejo/upload-artifactatv5andforgejo/download-artifactatv7work on that version.Not shown: real jobs (package installs, builds, browsers, image builds), the pool under load, Docker on the golden image, the registry push of a full image set and the Trivy database download behind the node's egress rules. A problem the port reports about today's workflows is printed as a warning, so that a workflow edited today is not held to a port applied later; the tests fail only when the port itself fails or the declared checks drift.
Ops follow-up
Nothing runs until ops switches Forgejo on. The ops repository's
docs/guides/tale-cutover.mdis the order of the move (accounts, secrets, the mirror, the merge train's declaration) and its manual suitetests/manual/suites/tale-port.mdjudges the parts above on the node. At the cut-over:check --runner, thengenerate --writein a branch of the Forgejo repository, thengithub --writein a branch of the GitHub repository, merged before the push mirror is switched on.bun tools/cli/scripts/forgejo-port.ts report bun tools/cli/scripts/forgejo-port.ts generate --write --out /tmp/forgejo-port && diff -r .github /tmp/forgejo-port/.forgejoChecklist
bun run checkpasses (format, lint, typecheck, all tests).bun run lint:sastpasses (Opengrep)..github/CI.mdand the port's README describe the port; nodocs/{en,de,fr}/page is affected.README.md/README.de.md/README.fr.md: N/A, a build tool inside@tale/cli.