feat: allow --memory in workflow container options #1079

Merged
earl-warren merged 1 commit from earl-warren/runner:wip-resources into main 2025-10-10 14:33:07 +00:00
Contributor

First hand experience to implement this feature can be found at https://codeberg.org/forgejo/forgejo/issues/9406. In a nutshell it is a service container in the CI that randomly uses massive amounts of memory (>50GB RSS) but normally less than 100MB.


See also the matching documentation pull request.


It is already possible to limit the memory used by all containers in the config file:

container:
  options: --memory 200M

This limit can be further reduced (but not increased) by the same option in a job:

jobs:
  job:
    runs-on: docker
    container:
      image: code.forgejo.org/oci/node:20-bookworm
      options: --memory 200M
    steps:
      - run: echo OK

or a service container:

job:
  my-job:
    runs-on: docker
    services:
      pgsql:
        image: postgres:15
        options: --memory 1G

Refs https://docs.docker.com/engine/containers/resource_constraints/#limit-a-containers-access-to-memory

  • features
    • PR: feat: allow --memory in workflow container options
First hand experience to implement this feature can be found at https://codeberg.org/forgejo/forgejo/issues/9406. In a nutshell it is a service container in the CI that randomly uses massive amounts of memory (>50GB RSS) but normally less than 100MB. --- See also the [matching documentation pull request](https://codeberg.org/forgejo/docs/pulls/1539). --- It is already possible to limit the memory used by all containers in the config file: ```yaml container: options: --memory 200M ``` This limit can be further reduced (but not increased) by the same option in a job: ```yaml jobs: job: runs-on: docker container: image: code.forgejo.org/oci/node:20-bookworm options: --memory 200M steps: - run: echo OK ``` or a service container: ```yaml job: my-job: runs-on: docker services: pgsql: image: postgres:15 options: --memory 1G ``` Refs https://docs.docker.com/engine/containers/resource_constraints/#limit-a-containers-access-to-memory <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - features - [PR](https://code.forgejo.org/forgejo/runner/pulls/1079): <!--number 1079 --><!--line 0 --><!--description ZmVhdDogYWxsb3cgLS1tZW1vcnkgaW4gd29ya2Zsb3cgY29udGFpbmVyIG9wdGlvbnM=-->feat: allow --memory in workflow container options<!--description--> <!--end release-notes-assistant-->
earl-warren force-pushed wip-resources from 6b2eb36b32
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
checks / validate pre-commit-hooks file (pull_request) Successful in 1m22s
checks / validate mocks (pull_request) Successful in 2m2s
checks / build and test (pull_request) Failing after 2m7s
checks / runner exec tests (pull_request) Has been skipped
checks / runner integration tests (pull_request) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / integration tests (pull_request) Successful in 15m44s
to f4d3a2c3a4
All checks were successful
checks / validate pre-commit-hooks file (pull_request) Successful in 58s
checks / validate mocks (pull_request) Successful in 1m19s
checks / build and test (pull_request) Successful in 1m31s
checks / runner exec tests (pull_request) Successful in 40s
checks / runner integration tests (pull_request) Successful in 5m48s
checks / integration tests (pull_request) Successful in 12m14s
issue-labels / release-notes (pull_request_target) Successful in 8s
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Successful in 9s
cascade / forgejo (pull_request_target) Successful in 1m2s
2025-10-10 13:10:57 +00:00
Compare
Contributor

cascading-pr updated at actions/setup-forgejo#715

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/715
Contributor
cascading-pr updated at https://codeberg.org/forgejo/forgejo/pulls/9613
viceice approved these changes 2025-10-10 13:39:34 +00:00
viceice left a comment

writing test was more complex than the implementation 😁

writing test was more complex than the implementation 😁
mfenniak approved these changes 2025-10-10 13:53:53 +00:00
Author
Contributor

Indeed, but not that much: most of the code is copy/pasted from other tests. There probably is enough to keep them DRY, adding helpers. But that will be fore another time.

Indeed, but not that much: most of the code is copy/pasted from other tests. There probably is enough to keep them DRY, adding helpers. But that will be fore another time.
earl-warren deleted branch wip-resources 2025-10-10 14:33:08 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
4 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!1079
No description provided.