89
89
echo "hash_from_app_image=$hash_from_app_image" >> $GITHUB_OUTPUT
90
90
echo "Hash from app image: $hash_from_app_image"
91
91
92
+ # Builds the replay.io runner image
93
+ ghcr_build_runner :
94
+ name : Build Runner Image
95
+ runs-on : ubuntu-latest
96
+ permissions :
97
+ contents : read
98
+ packages : write
99
+ outputs :
100
+ hash_from_runner_image : ${{ steps.get_hash_in_runner_image.outputs.hash_from_runner_image }}
101
+ steps :
102
+ - name : Checkout
103
+ uses : actions/checkout@v4
104
+ - name : Free Disk Space (Ubuntu)
105
+ uses : jlumbroso/free-disk-space@main
106
+ with :
107
+ # this might remove tools that are actually needed,
108
+ # if set to "true" but frees about 6 GB
109
+ tool-cache : true
110
+ # all of these default to true, but feel free to set to
111
+ # "false" if necessary for your workflow
112
+ android : true
113
+ dotnet : true
114
+ haskell : true
115
+ large-packages : true
116
+ docker-images : false
117
+ swap-storage : true
118
+ - name : Set up QEMU
119
+
120
+ with :
121
+ image : tonistiigi/binfmt:latest
122
+ - name : Login to GHCR
123
+ uses : docker/login-action@v3
124
+ with :
125
+ registry : ghcr.io
126
+ username : ${{ github.repository_owner }}
127
+ password : ${{ secrets.GITHUB_TOKEN }}
128
+ - name : Set up Docker Buildx
129
+ id : buildx
130
+ uses : docker/setup-buildx-action@v3
131
+ - name : Build and push runner image
132
+ if : " !github.event.pull_request.head.repo.fork"
133
+ run : |
134
+ ./containers/build.sh -i runner -o ${{ github.repository_owner }} --push
135
+ - name : Build runner image
136
+ if : " github.event.pull_request.head.repo.fork"
137
+ run : |
138
+ ./containers/build.sh -i runner -o ${{ github.repository_owner }} --load
139
+ - name : Get hash in Runner Image
140
+ id : get_hash_in_runner_image
141
+ run : |
142
+ # Lowercase the repository owner
143
+ export REPO_OWNER=${{ github.repository_owner }}
144
+ REPO_OWNER=$(echo $REPO_OWNER | tr '[:upper:]' '[:lower:]')
145
+ # Run the build script in the runner image
146
+ docker run -e SANDBOX_USER_ID=0 -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/${REPO_OWNER}/runner:${{ env.RELEVANT_SHA }} /bin/bash -c "mkdir -p containers/runtime; python3 openhands/runtime/utils/runtime_build.py --base_image ${{ env.BASE_IMAGE_FOR_HASH_EQUIVALENCE_TEST }} --build_folder containers/runtime --force_rebuild" 2>&1 | tee docker-outputs.txt
147
+ # Get the hash from the build script
148
+ hash_from_runner_image=$(cat docker-outputs.txt | grep "Hash for docker build directory" | awk -F "): " '{print $2}' | uniq | head -n1)
149
+ echo "hash_from_runner_image=$hash_from_runner_image" >> $GITHUB_OUTPUT
150
+ echo "Hash from runner image: $hash_from_runner_image"
151
+
92
152
# Builds the runtime Docker images
93
153
ghcr_build_runtime :
94
154
name : Build Image
@@ -169,10 +229,10 @@ jobs:
169
229
name : runtime-${{ matrix.base_image.tag }}
170
230
path : /tmp/runtime-${{ matrix.base_image.tag }}.tar
171
231
172
- verify_hash_equivalence_in_runtime_and_app :
173
- name : Verify Hash Equivalence in Runtime and Docker images
232
+ verify_hash_equivalence_in_runtime_and_runner_and_app :
233
+ name : Verify Hash Equivalence in App, Runner, and Runtime images
174
234
runs-on : ubuntu-latest
175
- needs : [ghcr_build_runtime, ghcr_build_app]
235
+ needs : [ghcr_build_runtime, ghcr_build_runner, ghcr_build_app]
176
236
strategy :
177
237
fail-fast : false
178
238
matrix :
@@ -200,6 +260,10 @@ jobs:
200
260
run : |
201
261
echo "Hash from app image: ${{ needs.ghcr_build_app.outputs.hash_from_app_image }}"
202
262
echo "hash_from_app_image=${{ needs.ghcr_build_app.outputs.hash_from_app_image }}" >> $GITHUB_ENV
263
+ - name : Get hash in Runner Image
264
+ run : |
265
+ echo "Hash from runner image: ${{ needs.ghcr_build_runner.outputs.hash_from_runner_image }}"
266
+ echo "hash_from_runner_image=${{ needs.ghcr_build_runner.outputs.hash_from_runner_image }}" >> $GITHUB_ENV
203
267
204
268
- name : Get hash using code (development mode)
205
269
run : |
@@ -211,8 +275,9 @@ jobs:
211
275
- name : Compare hashes
212
276
run : |
213
277
echo "Hash from App Image: ${{ env.hash_from_app_image }}"
278
+ echo "Hash from Runner Image: ${{ env.hash_from_runner_image }}"
214
279
echo "Hash from Code: ${{ env.hash_from_code }}"
215
- if [ "${{ env.hash_from_app_image }}" = "${{ env.hash_from_code }}" ]; then
280
+ if [ "${{ env.hash_from_app_image }}" = "${{ env.hash_from_code }}" -a "${{ env.hash_from_runner_image }}" = "${{ env.hash_from_code }}" ]; then
216
281
echo "Hashes match!"
217
282
else
218
283
echo "Hashes do not match!"
0 commit comments