Skip to content
Source
Sign inSign up

Pull requests from a fork

CI / Secrets and trust

Pull requests from a fork

You opened a pull request from your fork, and its CI run says "This run is waiting for a maintainer to approve it." Nobody with write access has read your code yet, so the run starts at the lowest trust level, untrusted, after a maintainer approves it.

7 min read

Why your run waits

  • Your run is untrusted because you have no write access to the base repository. It starts when a person with write access approves it. On some repositories, a clean security audit of your commit also starts it.
  • Each push to your branch starts a new run, and each new run waits for its own approval.
  • If screening holds your pull request, no run starts until a maintainer shows the pull request.
  • After the approval, your jobs wait in a queue. By default, at most 4 of your untrusted jobs run at the same time. Together they get at most 4 hours of container time each UTC day. A job past these limits waits. It does not fail.

Note

The software factory jobs on your pull request count toward these limits too.

1. Read what failed

Open your pull request. The merge box in the right column lists each required check that failed or has not finished.

To find the cause, run the failing job on your machine: see Reproduce a failing job.

2. Push a fix to your branch

Push the fix to the head branch of your pull request. The push starts a new run.

3. Wait for a maintainer to approve the new run

The new run waits for its own approval, like the first one. On some repositories, a clean security audit of your new commit starts it. See Why your run started by itself.

4. Bring your branch up to date

If your branch is not up to date, push a merge of the base branch into it.

Done

When each required check shows Passed, your pull request is green, and a maintainer can merge it.

Why your run started by itself

Your run started, and no maintainer clicked Approve and run. The maintainers of the repository turned on Start checks after a clean audit. Then the security audit of the software factory read your commit, and found it clean. The TanStack Source bot then approved your run.

  • The audit is for the exact commit of the run. After each push, a new clean audit starts the new run.
  • If the audit of your commit is not clean, your run waits for a maintainer.
  • Your run is still untrusted. It can do only what What your run can do lists.

What your run can do

Your run:

  • Runs the code of your commit, and reads the repository.
  • Gets a secret only from a CI environment that takes untrusted runs. The job holds a placeholder (tss_ph_ and 40 letters and digits). The forge swaps it for the value only in a request header to a host that the secret is bound to.
  • Reaches only the hosts that the base branch lists for the job.
  • Reads the cache, and writes only the cache of your pull request.
  • Runs each job in a fresh VM on Ravion, on a clean disk.

Your run cannot:

  • Use a CI environment that needs a trusted or protected run, with its secret values.
  • Push, comment, or change issues and pull requests. Its run token only reads.
  • Use a secret, a host or a permission that your pull request adds to a workflow. The run shows a warning, and the job runs without it until a maintainer merges the change.
  • Send a placeholder to another host, or put one in a URL. The forge refuses the request and records a leak attempt.
  • Keep the disk of its VM. Ravion starts each job on a clean disk, and keeps none of it.

If a job names an environment that your run does not pass, the job is skipped, with the reason. The rules for each level are in Trust levels and secrets.

What your run shows on the pull request

A workflow can write a card with its results on the Conversation tab of your pull request. See Show results on a pull request. Your untrusted run can write the card of its own workflow, the same as any other run.

  • The card says From a fork, not trusted, so readers know that your code wrote it.
  • A URL button shows its host next to its label.
  • A workflow button on your card starts an untrusted run, also when a maintainer clicks it. That run waits for an approval, like your other runs.

Let CI fix your branch

Some jobs end with a fixup() step, for example a formatter. The forge then commits the change to the head branch in your fork, when all of these are true:

  • Your head branch is still at the commit that the run tested.
  • The patch is at most 5 MiB, and it changes nothing in .source/.
  • Your pull request allows edits from maintainers. This is on by default.

If one of them is false, the pull request shows the patch as a suggestion with an Apply button. You can apply it, because you have write access to your fork.

The new commit starts a new untrusted run. That run also waits for an approval.

The new commit also takes your pull request out of the merge queue, and turns off merge when ready. A push to your fork does the same. The patch comes from the CI code of your pull request, so a maintainer must read it first. When a person with write access to the upstream repository applies the fixup, the pull request keeps its place, and merge when ready stays on.

To stop maintainers and CI from changing your branch, clear Allow edits from maintainers on the pull request page. You can also run this command:

src ci maintainer-edits 7 --off

On a pull request from GitHub

On a synced repository, a pull request from GitHub has its head branch on GitHub. CI never commits a fixup to that branch by itself. The pull request shows the patch as a suggestion, and its reason says that a person with write access and GitHub connected can apply it.

To apply it, you need write access here and GitHub connected for sync. See Connect GitHub.

  1. Open the pull request.
  2. Click Apply on the suggestion. In a terminal, run src ci fixup apply <id>.

The forge commits the patch, and pushes it to the head branch on GitHub with your GitHub token. The head here moves only after GitHub takes the push.

Agents and jobs are refused, so a person must apply it. The other refusals are the same as for Update branch on a pull request from GitHub. For example, the author must allow edits from maintainers on GitHub.

Reproduce a failing job

On the run page, each job that started shows a command under "Run this job on your machine". The command runs the job with the matrix cell, the inputs and the needs of that run.

  1. Set the forge variables. TSS_REPO is the base repository, not your fork.

    export TSS_FORGE_URL=https://forge.example/api/v1
    export TSS_TOKEN=<your personal access token>
    export TSS_REPO=acme/app
  2. Check out the commit of the run:

    git fetch origin <commit>
    git checkout --detach <commit>
  3. Run the command that you copied from the run page:

    src ci run --repro '<run>/test (shard: 2)'

To run a job without the forge, put your own values in .env. Then give the workflow and the job to src ci run:

echo 'NX_CLOUD_ACCESS_TOKEN=<your own token>' >> .env
src ci run pr test
  • Secrets come from the environment, then from .env. If a required secret has no value, the command stops before any job runs.
  • The run has the trust level local. Unless you add --live, writes to the forge are a dry run.
  • A fixup() step writes a patch file, and prints the git apply command for it.

Do not commit .env. More about local runs is in Run CI on your machine.

Note

A required check with a name that starts with hidden: comes from a hidden workflow. Such a check shows no log. Its result shows a summary, and a command under "Reproduce it locally" that a maintainer wrote.