chore: refactor internal exprparser wrappers to reduce complexity, add new test cases #1566

Closed
mfenniak wants to merge 3 commits from mfenniak/forgejo-runner:refactor-wrappers into main
Owner

#1563 introduced some new internal types in the exprparser library to allow detecting access to env.* and secrets.*. I realized that the fixes in that PR to allow toJSON(env) to work were a bit hacky, and so this PR replaces those internal wrapper types with a map[string]X where X is specific to each wrapped context, allowing toJSON(...) to work without specific detection of the wrappers. This was applied to the older matrix wrapper as well.

An additional minor issue where env.* and secrets.* (not likely to be used in an if block) weren't detected as accesses to those contexts is also fixed, and unit tests are added to cover that case.

  • other
    • PR: chore: refactor internal exprparser wrappers to reduce complexity, add new test cases
#1563 introduced some new internal types in the `exprparser` library to allow detecting access to `env.*` and `secrets.*`. I realized that the fixes in that PR to allow `toJSON(env)` to work were a bit hacky, and so this PR replaces those internal wrapper types with a `map[string]X` where `X` is specific to each wrapped context, allowing `toJSON(...)` to work without specific detection of the wrappers. This was applied to the older matrix wrapper as well. An additional minor issue where `env.*` and `secrets.*` (not likely to be used in an `if` block) weren't detected as accesses to those contexts is also fixed, and unit tests are added to cover that case. <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/1566): <!--number 1566 --><!--line 0 --><!--description Y2hvcmU6IHJlZmFjdG9yIGludGVybmFsIGV4cHJwYXJzZXIgd3JhcHBlcnMgdG8gcmVkdWNlIGNvbXBsZXhpdHksIGFkZCBuZXcgdGVzdCBjYXNlcw==-->chore: refactor internal exprparser wrappers to reduce complexity, add new test cases<!--description--> <!--end release-notes-assistant-->
mfenniak force-pushed refactor-wrappers from 404e9bb844
Some checks failed
checks / validate mocks (pull_request) Failing after 1m19s
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / Build Forgejo Runner (pull_request) Failing after 1m21s
checks / validate pre-commit-hooks file (pull_request) Successful in 1m32s
checks / Build unsupported platforms (pull_request) Has been cancelled
checks / runner exec tests (pull_request) Has been cancelled
checks / Run integration tests with Docker (docker-latest) (pull_request) Has been cancelled
checks / Run integration tests with Docker (docker-stable) (pull_request) Has been cancelled
checks / Run integration tests with Podman (pull_request) Has been cancelled
to 288f3eac49
Some checks failed
issue-labels / release-notes (pull_request_target) Successful in 9s
checks / Build Forgejo Runner (pull_request) Successful in 44s
checks / validate mocks (pull_request) Successful in 39s
checks / validate pre-commit-hooks file (pull_request) Successful in 50s
checks / Build unsupported platforms (pull_request) Successful in 55s
checks / runner exec tests (pull_request) Successful in 2m5s
checks / Run integration tests with Docker (docker-latest) (pull_request) Failing after 9m39s
checks / Run integration tests with Podman (pull_request) Failing after 11m31s
checks / Run integration tests with Docker (docker-stable) (pull_request) Failing after 12m1s
test-multi-platform / validate pre-commit-hooks file (pull_request) Has been skipped
test-multi-platform / validate mocks (pull_request) Has been skipped
cascade / debug (pull_request_target) Has been skipped
test-multi-platform / Build Forgejo Runner (pull_request) Has been skipped
test-multi-platform / Build unsupported platforms (pull_request) Has been skipped
cascade / end-to-end (pull_request_target) Successful in 6s
test-multi-platform / Run integration tests with Docker (docker-latest) (pull_request) Has been skipped
test-multi-platform / runner exec tests (pull_request) Has been skipped
test-multi-platform / Run integration tests with Docker (docker-stable) (pull_request) Has been skipped
test-multi-platform / Run integration tests with Podman (pull_request) Has been skipped
test-multi-platform / arm64 (pull_request) Has been skipped
cascade / forgejo (pull_request_target) Successful in 1m38s
2026-06-12 00:48:52 +00:00
Compare
Member

All three integration tests agree that TestRunner_RunEvent/job-container-image has problems. That means it could be a real test failure.

All three integration tests agree that `TestRunner_RunEvent/job-container-image` has problems. That means it could be a real test failure.
Author
Owner

Yikes, that was a mess to debug. This refactor won't work for a subtle reason that tests barely caught -- when running a job, the runner creates an evaluation context that references the env map in-memory, then evaluates the contents of the env map, and then uses that context for runs-on. The problem with this change is that data is copied into the evaluation context to change its type, so the middle evaluation isn't reflected.

I'm going to close this PR, rescue the other tests and bugfixes, and leave the refactoring idea dead.

Yikes, that was a mess to debug. This refactor won't work for a subtle reason that tests barely caught -- when running a job, the runner creates an evaluation context that references the `env` map in-memory, then evaluates the contents of the env map, and then uses that context for `runs-on`. The problem with this change is that data is *copied* into the evaluation context to change its type, so the middle evaluation isn't reflected. I'm going to close this PR, rescue the other tests and bugfixes, and leave the refactoring idea dead.
mfenniak closed this pull request 2026-06-12 15:28:08 +00:00
Some checks failed
issue-labels / release-notes (pull_request_target) Successful in 9s
checks / Build Forgejo Runner (pull_request) Successful in 44s
Required
Details
checks / validate mocks (pull_request) Successful in 39s
checks / validate pre-commit-hooks file (pull_request) Successful in 50s
checks / Build unsupported platforms (pull_request) Successful in 55s
checks / runner exec tests (pull_request) Successful in 2m5s
Required
Details
checks / Run integration tests with Docker (docker-latest) (pull_request) Failing after 9m39s
Required
Details
checks / Run integration tests with Podman (pull_request) Failing after 11m31s
Required
Details
checks / Run integration tests with Docker (docker-stable) (pull_request) Failing after 12m1s
Required
Details
test-multi-platform / validate pre-commit-hooks file (pull_request) Has been skipped
test-multi-platform / validate mocks (pull_request) Has been skipped
cascade / debug (pull_request_target) Has been skipped
Required
Details
test-multi-platform / Build Forgejo Runner (pull_request) Has been skipped
test-multi-platform / Build unsupported platforms (pull_request) Has been skipped
cascade / end-to-end (pull_request_target) Successful in 6s
Required
Details
test-multi-platform / Run integration tests with Docker (docker-latest) (pull_request) Has been skipped
test-multi-platform / runner exec tests (pull_request) Has been skipped
test-multi-platform / Run integration tests with Docker (docker-stable) (pull_request) Has been skipped
test-multi-platform / Run integration tests with Podman (pull_request) Has been skipped
test-multi-platform / arm64 (pull_request) Has been skipped
cascade / forgejo (pull_request_target) Successful in 1m38s
Required
Details

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
forgejo/runner!1566
No description provided.