1
- # Reusable workflow that builds, tests and then pushes the runtime Docker image to the ghcr.io repository
1
+ # Workflow that builds, tests and then pushes the runtime docker images to the ghcr.io repository
2
2
name : Build, Test and Publish Runtime Image
3
3
4
- # Indicate that this is a reusable workflow
4
+ # Only run one workflow of the same group at a time.
5
+ # There can be at most one running and one pending job in a concurrency group at any time.
6
+ concurrency :
7
+ group : ${{ github.workflow }}-${{ github.ref }}
8
+ cancel-in-progress : ${{ github.ref != 'refs/heads/main' }}
9
+
10
+ # Always run on "main"
11
+ # Always run on tags
12
+ # Always run on PRs
13
+ # Can also be triggered manually
5
14
on :
6
- workflow_call :
15
+ push :
16
+ branches :
17
+ - main
18
+ tags :
19
+ - ' *'
20
+ pull_request :
21
+ workflow_dispatch :
7
22
inputs :
8
- # The base_image name used to build the runtime Docker image
9
- base_image :
10
- required : true
11
- type : string
12
- # The tag to use for the built runtime Docker image
13
- image_tag :
14
- required : true
15
- type : string
16
- secrets :
17
- CODECOV_TOKEN :
23
+ reason :
24
+ description : ' Reason for manual trigger'
18
25
required : true
26
+ default : ' '
19
27
20
28
jobs :
21
29
# Builds the runtime Docker images
22
30
ghcr_build_runtime :
23
- name : Build Image ${{ inputs.image_tag }}
31
+ name : Build Image
24
32
runs-on : ubuntu-latest
25
33
permissions :
26
34
contents : read
27
35
packages : write
36
+ strategy :
37
+ matrix :
38
+ base_image :
39
+ - image : ' nikolaik/python-nodejs:python3.11-nodejs22'
40
+ tag : nikolaik
41
+ - image : ' python:3.11-bookworm'
42
+ tag : python
43
+ - image : ' node:22-bookworm'
44
+ tag : node
28
45
steps :
29
46
- name : Checkout
30
47
uses : actions/checkout@v4
@@ -63,31 +80,34 @@ jobs:
63
80
- name : Install Python dependencies using Poetry
64
81
run : make install-python-dependencies
65
82
- name : Create source distribution and Dockerfile
66
- run : poetry run python3 openhands/runtime/utils/runtime_build.py --base_image ${{ inputs .base_image }} --build_folder containers/runtime --force_rebuild
67
- - name : Build and push runtime image ${{ inputs .base_image }}
83
+ run : poetry run python3 openhands/runtime/utils/runtime_build.py --base_image ${{ matrix .base_image.image }} --build_folder containers/runtime --force_rebuild
84
+ - name : Build and push runtime image ${{ matrix .base_image.image }}
68
85
if : " !github.event.pull_request.head.repo.fork"
69
86
run : |
70
- ./containers/build.sh runtime ${{ github.repository_owner }} --push ${{ inputs.image_tag }}
87
+ ./containers/build.sh runtime ${{ github.repository_owner }} --push ${{ matrix.base_image.tag }}
71
88
# Forked repos can't push to GHCR, so we need to upload the image as an artifact
72
- - name : Build runtime image ${{ inputs .base_image }} for fork
89
+ - name : Build runtime image ${{ matrix .base_image.image }} for fork
73
90
if : " github.event.pull_request.head.repo.fork"
74
91
uses : docker/build-push-action@v6
75
92
with :
76
- tags : ghcr.io/all-hands-ai/runtime:${{ github.sha }}-${{ inputs.image_tag }}
77
- outputs : type=docker,dest=/tmp/runtime-${{ inputs.image_tag }}.tar
93
+ tags : ghcr.io/all-hands-ai/runtime:${{ github.sha }}-${{ matrix.base_image.tag }}
94
+ outputs : type=docker,dest=/tmp/runtime-${{ matrix.base_image.tag }}.tar
78
95
context : containers/runtime
79
96
- name : Upload runtime image for fork
80
97
if : " github.event.pull_request.head.repo.fork"
81
98
uses : actions/upload-artifact@v4
82
99
with :
83
- name : runtime-${{ inputs.image_tag }}
84
- path : /tmp/runtime-${{ inputs.image_tag }}.tar
100
+ name : runtime-${{ matrix.base_image.tag }}
101
+ path : /tmp/runtime-${{ matrix.base_image.tag }}.tar
85
102
86
- # Run unit tests with the runtime Docker images
103
+ # Run unit tests with the EventStream runtime Docker images
87
104
test_runtime :
88
- name : Runtime Unit Tests with ${{ inputs.image_tag }}
105
+ name : Test Runtime
89
106
runs-on : ubuntu-latest
90
107
needs : [ghcr_build_runtime]
108
+ strategy :
109
+ matrix :
110
+ base_image : ['nikolaik', 'python', 'node']
91
111
steps :
92
112
- uses : actions/checkout@v4
93
113
- name : Free Disk Space (Ubuntu)
@@ -104,12 +124,12 @@ jobs:
104
124
if : " github.event.pull_request.head.repo.fork"
105
125
uses : actions/download-artifact@v4
106
126
with :
107
- name : runtime-${{ inputs.image_tag }}
127
+ name : runtime-${{ matrix.base_image }}
108
128
path : /tmp
109
129
- name : Load runtime image for fork
110
130
if : " github.event.pull_request.head.repo.fork"
111
131
run : |
112
- docker load --input /tmp/runtime-${{ inputs.image_tag }}.tar
132
+ docker load --input /tmp/runtime-${{ matrix.base_image }}.tar
113
133
- name : Install poetry via pipx
114
134
run : pipx install poetry
115
135
- name : Set up Python
@@ -121,7 +141,7 @@ jobs:
121
141
run : make install-python-dependencies
122
142
- name : Run runtime tests
123
143
run : |
124
- image_name=ghcr.io/${{ github.repository_owner }}/runtime:${{ github.sha }}-${{ inputs.image_tag }}
144
+ image_name=ghcr.io/${{ github.repository_owner }}/runtime:${{ github.sha }}-${{ matrix.base_image }}
125
145
image_name=$(echo $image_name | tr '[:upper:]' '[:lower:]')
126
146
127
147
TEST_RUNTIME=eventstream \
@@ -134,24 +154,28 @@ jobs:
134
154
env :
135
155
CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
136
156
137
- # Run integration tests with the runtime Docker image
157
+ # Run integration tests with the eventstream runtime Docker image
138
158
runtime_integration_tests_on_linux :
139
- name : Runtime Integration Tests with ${{ inputs.image_tag }}
159
+ name : Runtime Integration Tests on Linux
140
160
runs-on : ubuntu-latest
141
161
needs : [ghcr_build_runtime]
162
+ strategy :
163
+ fail-fast : false
164
+ matrix :
165
+ base_image : ['nikolaik', 'python', 'node']
142
166
steps :
143
167
- uses : actions/checkout@v4
144
168
# Forked repos can't push to GHCR, so we need to download the image as an artifact
145
169
- name : Download runtime image for fork
146
170
if : " github.event.pull_request.head.repo.fork"
147
171
uses : actions/download-artifact@v4
148
172
with :
149
- name : runtime-${{ inputs.image_tag }}
173
+ name : runtime-${{ matrix.base_image }}
150
174
path : /tmp
151
175
- name : Load runtime image for fork
152
176
if : " github.event.pull_request.head.repo.fork"
153
177
run : |
154
- docker load --input /tmp/runtime-${{ inputs.image_tag }}.tar
178
+ docker load --input /tmp/runtime-${{ matrix.base_image }}.tar
155
179
- name : Install poetry via pipx
156
180
run : pipx install poetry
157
181
- name : Set up Python
@@ -163,7 +187,7 @@ jobs:
163
187
run : make install-python-dependencies
164
188
- name : Run integration tests
165
189
run : |
166
- image_name=ghcr.io/${{ github.repository_owner }}/runtime:${{ github.sha }}-${{ inputs.image_tag }}
190
+ image_name=ghcr.io/${{ github.repository_owner }}/runtime:${{ github.sha }}-${{ matrix.base_image }}
167
191
image_name=$(echo $image_name | tr '[:upper:]' '[:lower:]')
168
192
169
193
TEST_RUNTIME=eventstream \
@@ -179,7 +203,7 @@ jobs:
179
203
180
204
# Checks that all runtime tests have passed
181
205
all_runtime_tests_passed :
182
- name : Runtime Tests Passed with ${{ inputs.image_tag }}
206
+ name : All Runtime Tests Passed
183
207
runs-on : ubuntu-latest
184
208
needs : [test_runtime, runtime_integration_tests_on_linux]
185
209
steps :
0 commit comments