1
0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2026-10-24 16:59:19 +03:00

16 Commits

Author SHA1 Message Date
Mathieu Fenniak
1a633ad513 chore: prepare for runner v13 release (#1645)
Global search and replace of `runner/v12` for `runner/v13`.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1645): <!--number 1645 --><!--line 0 --><!--description Y2hvcmU6IHByZXBhcmUgZm9yIHJ1bm5lciB2MTMgcmVsZWFzZQ==-->chore: prepare for runner v13 release<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1645
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.code.forgejo.org>
2026-08-03 15:55:53 +00:00
gtker
2af96a754f feat(interpreter): Add support for case statements (#1590)
Implements https://code.forgejo.org/forgejo/forgejo-actions-feature-requests/issues/101.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- features
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1590): <!--number 1590 --><!--line 0 --><!--description ZmVhdChpbnRlcnByZXRlcik6IEFkZCBzdXBwb3J0IGZvciBgY2FzZWAgc3RhdGVtZW50cw==-->feat(interpreter): Add support for `case` statements<!--description-->
<!--end release-notes-assistant-->

Co-authored-by: Gtker <dhh@logos.dk>
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1590
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.code.forgejo.org>
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
2026-07-07 20:04:20 +00:00
Mathieu Fenniak
1f6b35ba1c fix: expression evaluation fixes discovered while refactoring 'if' detection (#1572)
#1563 made changes to the `exprparser` library to allow detecting access to `env.*` and `secrets.*`.  Two bugs were discovered during failed refactoring efforts (#1566):
- `env.*` and `secrets.*` weren't detected as access; in the event that these expressions were used in an `if` block they wouldn't have caused Forgejo to defer execution to the runner rather than doing server-side `if` evaluation
- `toJSON(matrix)` outputs a wrapping `"Matrix"` element, which was missed when dynamic `runs-on` capabilities were added, but missed until tests triggered similar problems in `env`

More comprehensive unit test cases around both are fixed here.  Practically speaking neither bug is likely to occur in reality.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- bug fixes
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1572): <!--number 1572 --><!--line 0 --><!--description Zml4OiBleHByZXNzaW9uIGV2YWx1YXRpb24gZml4ZXMgZGlzY292ZXJlZCB3aGlsZSByZWZhY3RvcmluZyAnaWYnIGRldGVjdGlvbg==-->fix: expression evaluation fixes discovered while refactoring 'if' detection<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1572
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.code.forgejo.org>
2026-06-12 20:11:02 +00:00
Mathieu Fenniak
428a691ed0 feat(jobparser): implement jobparser capability to evaluate 'if' clauses (#1563)
The intent of this change is to allow Forgejo to evaluate `if` without having to send jobs to a runner.  When you send a job to a runner just for it to return "skipped!", it takes up 1 runner capacity for a `fetch_interval` period, which can be avoided if Forgejo can evaluate the `if` condition itself.

Creates a new `EvaluateIf` function in the jobparser library's `Job` which evaluates the `if` clause, with these conditions:
- Requires that the `Job` is parsed by `jobparser.Parse` and has parsing context, such as job inputs, job results.  If `Job` was serialized to yaml, then deserialized, this information would be missing and `EvaluateIf` would return an error.
- Accessing `env` and `secrets` is prohibited, and returns an error.  Forgejo will react to this specific error by falling back to the current behaviour: send the task to the runner for `if` to be evaluated on the runner.
    - `env` -- Currently Forgejo Runner can have configured [environment variables](22ebc7d1ab/internal/pkg/config/config.example.yaml (L26-L32)).  As these values wouldn't be known to Forgejo, it doesn't make sense to access `env` in an `if` block from Forgejo.
    - `secrets` -- Currently Forgejo doesn't provide secrets to the `jobparser`.  I think it's risky to change this -- giving this information to the jobparser opens the door for it to end up in a marshalled `SingleWorkflow` through some error or future change, and be stored in the database insecurely and unencrypted.

Forgejo's implementation using these new APIs is https://codeberg.org/forgejo/forgejo/pulls/13030.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- features
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1563): <!--number 1563 --><!--line 0 --><!--description ZmVhdChqb2JwYXJzZXIpOiBpbXBsZW1lbnQgam9icGFyc2VyIGNhcGFiaWxpdHkgdG8gZXZhbHVhdGUgJ2lmJyBjbGF1c2Vz-->feat(jobparser): implement jobparser capability to evaluate 'if' clauses<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1563
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.code.forgejo.org>
2026-06-11 21:08:03 +00:00
Andreas Ahlenstorf
1cc2af0e4a chore: incorporate go-git's gitignore matching (#1497)
Reduce Forgejo Runner's dependency on go-git further by incorporating its gitignore parsing and matching functionality into Forgejo Runner's source tree. Various alternative libraries were considered. However, those are either abandoned or have compatibility issues, or both.

Some unused functions in `dir.go` have been removed. go-git's internal abstractions were replaced with functionality provided by Go's standard library.

The original code can be found in 5b47ae8a22/plumbing/format/gitignore.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1497): <!--number 1497 --><!--line 0 --><!--description Y2hvcmU6IGluY29ycG9yYXRlIGdvLWdpdCdzIGdpdGlnbm9yZSBtYXRjaGluZw==-->chore: incorporate go-git's gitignore matching<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1497
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
2026-04-26 01:20:39 +00:00
limiting-factor
c196605572 chore: bump version to v12 (#1176)
<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1176): <!--number 1176 --><!--line 0 --><!--description Y2hvcmU6IGJ1bXAgdmVyc2lvbiB0byB2MTI=-->chore: bump version to v12<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1176
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
Co-authored-by: limiting-factor <limiting-factor@posteo.com>
Co-committed-by: limiting-factor <limiting-factor@posteo.com>
2025-11-22 16:25:20 +00:00
Crown0815
da3a0ef1af Windows-specific-fixes (#1152)
This PR contains two fixes to the production code:

- 20d56ace53adf26f66e7eb14f3f899087aec70eb fixes the `hashFile` function in an action misinterpreting paths on Windows
- 4e2609329dc2e3e630a67c3237e38a92dd7dc784 fixes the `validate` command outputting full paths due to OS-unspecific path trimming logic

The remaining changes adopt tests to properly deal with

- Docker with Linux containers not being available on standard Windows runners c492fe121e2f2d2eb6dbc8fd5b1cef543437fa99
- Windows paths (6781d823683428d5cf8b9bac4753a458882b5994), (8ca14d0f4d4274e808fb027e021bac701279381e), (eb70aca72c89c08cdc03c35dd26f3e57bdeaacac), (4e2609329dc2e3e630a67c3237e38a92dd7dc784), (c00d4e0a81634c098086b822884eb6b525ebe933)
- Revert a change causing a test-runner panic on Windows (6608fec705f7e7ed48c7ffed3839f2b4c4c1defb)
- Exclude the daemon suicide test because it cannot be properly observed on Windows (3ef33b93b6c3422ce47325bc5330d2d954998cf4)

or in one case separate dedicated Windows and Linux test setups (709a1d3fdbfc8a6149a57fcf00570e842ef4d040)

I tried to keep the changes as minimal as possible and focussed on getting the tests to run again.
I only added skips for tests that I could not get to run due to the Docker requirements, or the different shutdown behaviors on Linux and Windows.

In the future, I will investigate why the defensive `chdir` in `linux_container_environment_extensions_test.go` (6608fec705f7e7ed48c7ffed3839f2b4c4c1defb) is necessary and whether I can get all of the docker tests (c492fe121e2f2d2eb6dbc8fd5b1cef543437fa99) to run on GitHub Actions

The passing of all tests on windows has been confirmed [here](https://github.com/Crown0815/Forgejo-runner-windows-builder/actions/runs/19344650459).

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1152): <!--number 1152 --><!--line 0 --><!--description V2luZG93cy1zcGVjaWZpYy1maXhlcw==-->Windows-specific-fixes<!--description-->
<!--end release-notes-assistant-->

Co-authored-by: Felix Kröner <felix.kroener@bruker.com>
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1152
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
Co-authored-by: Crown0815 <crown0815@noreply.code.forgejo.org>
Co-committed-by: Crown0815 <crown0815@noreply.code.forgejo.org>
2025-11-16 15:56:57 +00:00
Earl Warren
8a7f760d3c chore: bump version to v11 (#940)
the license change from MIT to GPLv3+ is a breaking change

Refs forgejo/runner#773

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/940): <!--number 940 --><!--line 0 --><!--description Y2hvcmU6IGJ1bXAgdmVyc2lvbiB0byB2MTE=-->chore: bump version to v11<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/940
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-09-05 07:29:38 +00:00
Michael Kriese
27f425987c chore: modernize code (#857)
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/857
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Reviewed-by: Gusted <gusted@noreply.code.forgejo.org>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-committed-by: Michael Kriese <michael.kriese@visualon.de>
2025-08-15 04:54:13 +00:00
Earl Warren
ec99579451 chore: to allow the runner to be imported, v9 needs to be in the go module (#777)
It will be imported by Forgejo.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/777): <!--number 777 --><!--line 0 --><!--description Y2hvcmU6IHRvIGFsbG93IHRoZSBydW5uZXIgdG8gYmUgaW1wb3J0ZWQsIHY5IG5lZWRzIHRvIGJlIGluIHRoZSBnbyBtb2R1bGU=-->chore: to allow the runner to be imported, v9 needs to be in the go module<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/777
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-31 10:35:11 +00:00
Earl Warren
ebc7758c1f chore: s|github.com/nektos/act/pkg|code.forgejo.org/forgejo/runner/act| 2025-07-28 19:23:07 +02:00
Earl Warren
c377159121 chore: use the same .golangci.yml as the runner & gofumpt over gofmt (#206)
To prepare for a smooth merge in the runner codebase.

- run with --fix for gofumpt and golangci
- manual edits for
  - disabling useless package naming warning
  - rename variables that had underscore in their name
  - remove trailing else at the end of a few functions

Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/206
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-28 12:26:41 +00:00
Jason Song
e29fd4cac7 fix: return err in walk (#1667)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-03-08 15:13:11 +00:00
Randolph Chung
76d766bcd1 fix: handle subdirectors and exclusions (#1012) (#1446) 2022-11-21 14:47:38 +00:00
ChristopherHX
d890923f0e Fix: tojson(null) == 'null' (#1068)
* Fix: tojson(null) == 'null'

* Update test

* Update functions_test.go
2022-03-22 08:55:13 +00:00
Björn Brauer
61c66784dd Refactor expression evaluator to use parser from actionlint package (#908)
* feat: implement expression evaluator

Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se>

* feat: integrate exprparser into act

Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se>

* Escape { and }, do not fail on missing properties

* Fix empty inputs context

* fix: contains() comparison for complex values

Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se>
Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
2022-01-21 08:07:20 -08:00