Repository navigation
Fill the github context and runner environment as GitHub does #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
69ea2dd
Fill the github context's identity values and the run and job fields …
waynesun09 d7b8497
Render the github context as GitHub does; accept a job token on /inst…
waynesun09 b249396
Render a re-run's own github.run_attempt
waynesun09 2d51814
Record the github context fixes in the bug ledger
waynesun09 af8afdb
Finish deferred expressions in the emulator's runner; fill ref_protec…
waynesun09 1ef3140
Bind values for the runner without expression delimiters
waynesun09 691df5d
Bind objects whole, read Actions string literals exactly, and defer i…
waynesun09 4e26700
Tokenize '...' literals the Actions way; send index notation in dot form
waynesun09 412a480
Teach the emulator's runner the rest of what deferred expressions use
waynesun09 fb8f438
Look up ref_protected on the async session, not through repo.branches
waynesun09 75a9c73
Read a new run's github identity before its INSERT
waynesun09 b58c3e0
Keep server-resolved text inert on the runner; runner accessors and l…
waynesun09 f5bbd83
Keep every server-resolved fragment inert; failure state for deferred…
waynesun09 5c897cf
Lint the files this change touches
waynesun09 c986516
Expect 401 from a revoked installation token on /installation/reposit…
waynesun09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
44 changes: 44 additions & 0 deletions
44
docs/bugs/fixed/github-context-identity-values-are-empty.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Bug: the github context's identity values are empty | ||
|
|
||
| Status: fixed 2026-11-18. | ||
|
|
||
| ## Summary | ||
|
|
||
| Compared with the same workflow run on GitHub, these `github` context values | ||
| were empty in expressions the emulator rendered (a step's `env:`, `run:` and | ||
| `with:`): `actor`, `actor_id`, `triggering_actor`, `api_url`, `graphql_url`, | ||
| `repository_id`, `repository_owner_id`, `run_attempt` and `workflow_ref`. | ||
|
|
||
| The job message's github context, which the runner exports as `GITHUB_*` | ||
| variables, lacked `actor`, `actor_id`, `triggering_actor` and `workflow_ref`, so | ||
| `GITHUB_ACTOR`, `GITHUB_ACTOR_ID`, `GITHUB_TRIGGERING_ACTOR` and | ||
| `GITHUB_WORKFLOW_REF` were unset in every step. The other five were already | ||
| there. | ||
|
|
||
| The REST run and job objects also lacked fields GitHub fills: runs had no | ||
| `run_started_at` or `display_title`, and jobs had no `created_at`, `head_sha` | ||
| or `head_branch`. | ||
|
|
||
| ## Fix | ||
|
|
||
| - Server-side rendering and the job message's github context carry the nine | ||
| values. Ids and `run_attempt` are strings, as GitHub gives them. | ||
| - Runs report `run_started_at` and `display_title`: the head commit's first | ||
| line (a push payload now carries `head_commit`), the pull request's or issue's title, or the workflow name. | ||
| - Jobs report `created_at`, `head_sha` and `head_branch`. | ||
| - A re-run renders its own `github.run_attempt`: the attempt is set before the | ||
| steps render, and the re-run's jobs report it too. | ||
|
|
||
| ## Known gaps | ||
|
|
||
| - A re-run is a new run whose actor is the user who asked for it, so | ||
| `actor` and `triggering_actor` are both that user. On GitHub `actor` stays | ||
| the user who started the first attempt. | ||
| - `display_title` does not use the workflow's `run-name:`. | ||
|
|
||
| Tests: `tests/actions/test_github_identity_context.py` | ||
| (`test_step_env_renders_the_identity_values`, | ||
| `test_the_job_message_carries_them_for_the_runner`, | ||
| `test_run_and_job_fields_github_fills`, | ||
| `test_a_rerun_renders_its_own_attempt`, | ||
| `test_a_push_run_is_titled_by_its_commit_and_knows_branch_protection`). |
77 changes: 77 additions & 0 deletions
77
docs/bugs/fixed/rendered-github-context-differs-from-github.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Bug: the rendered github context differs from GitHub's | ||
|
|
||
| Status: fixed 2026-11-18. | ||
|
|
||
| ## Summary | ||
|
|
||
| Compared with the same workflow on GitHub, the emulator's server-side | ||
| rendering of a step's `run:`, `with:` and `env:` differed: | ||
|
|
||
| | Expression | GitHub | Emulator | | ||
| | --- | --- | --- | | ||
| | a `false` value, e.g. `${{ inputs.flag }}` | `false` | `False` | | ||
| | a `false` comparison, e.g. `${{ github.event_name == 'x' }}` | `false` | empty | | ||
| | `${{ a \|\| b }}` with `a` empty and `b` false | `false` | `False` | | ||
| | `github.ref_name`, `ref_type`, `ref_protected`, `workflow_sha`, `repository_visibility`, `repositoryUrl`, `retention_days` | set | empty | | ||
| | `github.token`, `github.workspace`, `github.job`, `github.event_path`, `github.action`, `job.status` ... | the runner's value | empty | | ||
| | `${{ github.token != '' }}` | `true` | empty | | ||
|
|
||
| The runner exports `GITHUB_REF_NAME`, `GITHUB_REF_TYPE`, | ||
| `GITHUB_REF_PROTECTED` and `GITHUB_WORKFLOW_SHA` from the job message's github | ||
| context, and those keys were missing there, so the variables were unset. | ||
| `RUNNER_ENVIRONMENT` was unset too. | ||
|
|
||
| Two authentication answers differed as well: | ||
|
|
||
| - A job's `GITHUB_TOKEN` on `GET /installation/repositories` got 403 | ||
| "Resource not accessible by personal access token". On GitHub | ||
| `GITHUB_TOKEN` is an installation token, and the route lists the run's | ||
| repository. Clients that probe this route to tell an installation token | ||
| from a personal access token took a job token for a PAT. | ||
| - A refused credential (unknown, revoked or expired) got 401 "Requires | ||
| authentication". GitHub answers "Bad credentials" and keeps "Requires | ||
| authentication" for a request that sent none. | ||
|
|
||
| ## Fix | ||
|
|
||
| - A false result renders `false`, a null one stays empty, and `a || b` is the | ||
| first truthy alternative, else the last. | ||
| - The ref, sha and repository facts are filled (`ref_protected` as a boolean: whether the branch is protected) for rendering and in the job | ||
| message's github context. `RUNNER_ENVIRONMENT` is `github-hosted`. | ||
| - An expression that reads a value only the runner knows is left for the | ||
| runner, with the server's own contexts bound in, in `run:`, `with:` and | ||
| `env:`. Elsewhere (a concurrency group, say) nothing evaluates it again, so | ||
| it still renders empty. `job.workflow_*` stay the server's: the runner has | ||
| no job context for them. | ||
| - A server value bound into an expression left for the runner quotes a quote | ||
| the Actions way (`''`), not with a backslash, which the runner rejects. An | ||
| object or array is bound whole (`fromJSON('...')`), so a function or | ||
| `a && b` gets the value; the runner applies truthiness itself. A bound string that holds a brace is bound as JSON | ||
| too, with its braces escaped, so event data such as an issue title can | ||
| never end the expression it is bound into. | ||
| - `working-directory` and `shell` are left for the runner the same way as | ||
| `run`. | ||
| - In `run:`, `with:`, `env:`, `working-directory` and `shell`, which the runner | ||
| renders again, a value the server resolved that holds `$`, `{` or `}` (an | ||
| issue title, say) is sent as an expression that yields the text itself, so | ||
| the runner never evaluates it, even where two values or a value and the | ||
| text beside it would together spell `${{`. | ||
| - Index notation (`github['workspace']`) is recognised like dot notation and | ||
| sent to the runner in dot form. | ||
| - A `'...'` literal's only escape is a doubled quote, as in Actions, in the | ||
| server's and the emulator runner's tokenizers and decoders alike; a | ||
| backslash is an ordinary character, so bound JSON keeps its escapes and a | ||
| value may end in a backslash. | ||
| - The emulator's own runner finishes what the server leaves: it reads `''` | ||
| inside a string, writes a false result as `false`, knows `job.status`, has | ||
| `fromJSON`, `toJSON` and `join`, the `<`, `>`, `<=` and `>=` operators, a | ||
| leading `!`, `.name` and `[index]` after a call, and compares with `==` as | ||
| Actions does (strings case-insensitively), and gives `github.env`, `github.output`, | ||
| `github.path` and `github.event_path` their file paths. | ||
| - `GET /installation/repositories` with a job token lists the run's | ||
| repository with `repository_selection: selected`. A personal access token | ||
| still gets 403. | ||
| - A 401 says "Bad credentials" when an `Authorization` header was sent. | ||
|
|
||
| Tests: `tests/actions/test_render_github_parity.py`, | ||
| `tests/actions/test_job_token_installation_routes.py`. |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.