mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-08-06 08:54:21 +02:00
feat: wait for healthy services and fill the job context (#1107)
Service containers were started and then left alone, so a job's first step could run while a database was still starting up. The runner now waits for every service whose image or `options` declare a healthcheck, as GitHub does. An unhealthy service fails the job with its container log, one that never becomes healthy fails it after `container.service_ready_timeout` (default `5m`, negative disables the wait), and one that exits without a healthcheck only gets its log and a warning.
The started containers also fill the `job` context, whose fields existed but were never populated: `job.container.{id,network}` and `job.services.<id>.{id,network,ports}`. `ports` is keyed by the plain container port, so `job.services.postgres.ports['5432']` resolves to the host port Docker picked.
---------
Co-authored-by: silverwind <me@silverwind.io>
Reviewed-on: https://gitea.com/gitea/runner/pulls/1107
Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com>
Co-authored-by: bircni <bircni@icloud.com>
This commit is contained in:
6
act/runner/testdata/services/push.yaml
vendored
6
act/runner/testdata/services/push.yaml
vendored
@@ -15,3 +15,9 @@ jobs:
|
||||
echo "id: ${{ job.services.postgres.id }}"
|
||||
echo "network: ${{ job.services.postgres.network }}"
|
||||
echo "ports: ${{ job.services.postgres.ports }}"
|
||||
- name: The job context describes the started containers
|
||||
run: |
|
||||
test -n "${{ job.container.id }}"
|
||||
test -n "${{ job.services.postgres.id }}"
|
||||
test -n "${{ job.services.postgres.ports['80'] }}"
|
||||
test "${{ job.services.postgres.network }}" = "${{ job.container.network }}"
|
||||
|
||||
Reference in New Issue
Block a user