|
|
@@ -1,30 +1,47 @@
|
|
|
-# Reusable workflow that builds, tests and then pushes the runtime Docker image to the ghcr.io repository
|
|
|
+# Workflow that builds, tests and then pushes the runtime docker images to the ghcr.io repository
|
|
|
name: Build, Test and Publish Runtime Image
|
|
|
|
|
|
-# Indicate that this is a reusable workflow
|
|
|
+# Only run one workflow of the same group at a time.
|
|
|
+# There can be at most one running and one pending job in a concurrency group at any time.
|
|
|
+concurrency:
|
|
|
+ group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
+ cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
+
|
|
|
+# Always run on "main"
|
|
|
+# Always run on tags
|
|
|
+# Always run on PRs
|
|
|
+# Can also be triggered manually
|
|
|
on:
|
|
|
- workflow_call:
|
|
|
+ push:
|
|
|
+ branches:
|
|
|
+ - main
|
|
|
+ tags:
|
|
|
+ - '*'
|
|
|
+ pull_request:
|
|
|
+ workflow_dispatch:
|
|
|
inputs:
|
|
|
- # The base_image name used to build the runtime Docker image
|
|
|
- base_image:
|
|
|
- required: true
|
|
|
- type: string
|
|
|
- # The tag to use for the built runtime Docker image
|
|
|
- image_tag:
|
|
|
- required: true
|
|
|
- type: string
|
|
|
- secrets:
|
|
|
- CODECOV_TOKEN:
|
|
|
+ reason:
|
|
|
+ description: 'Reason for manual trigger'
|
|
|
required: true
|
|
|
+ default: ''
|
|
|
|
|
|
jobs:
|
|
|
# Builds the runtime Docker images
|
|
|
ghcr_build_runtime:
|
|
|
- name: Build Image ${{ inputs.image_tag }}
|
|
|
+ name: Build Image
|
|
|
runs-on: ubuntu-latest
|
|
|
permissions:
|
|
|
contents: read
|
|
|
packages: write
|
|
|
+ strategy:
|
|
|
+ matrix:
|
|
|
+ base_image:
|
|
|
+ - image: 'nikolaik/python-nodejs:python3.11-nodejs22'
|
|
|
+ tag: nikolaik
|
|
|
+ - image: 'python:3.11-bookworm'
|
|
|
+ tag: python
|
|
|
+ - image: 'node:22-bookworm'
|
|
|
+ tag: node
|
|
|
steps:
|
|
|
- name: Checkout
|
|
|
uses: actions/checkout@v4
|
|
|
@@ -63,31 +80,34 @@ jobs:
|
|
|
- name: Install Python dependencies using Poetry
|
|
|
run: make install-python-dependencies
|
|
|
- name: Create source distribution and Dockerfile
|
|
|
- run: poetry run python3 openhands/runtime/utils/runtime_build.py --base_image ${{ inputs.base_image }} --build_folder containers/runtime --force_rebuild
|
|
|
- - name: Build and push runtime image ${{ inputs.base_image }}
|
|
|
+ run: poetry run python3 openhands/runtime/utils/runtime_build.py --base_image ${{ matrix.base_image.image }} --build_folder containers/runtime --force_rebuild
|
|
|
+ - name: Build and push runtime image ${{ matrix.base_image.image }}
|
|
|
if: "!github.event.pull_request.head.repo.fork"
|
|
|
run: |
|
|
|
- ./containers/build.sh runtime ${{ github.repository_owner }} --push ${{ inputs.image_tag }}
|
|
|
+ ./containers/build.sh runtime ${{ github.repository_owner }} --push ${{ matrix.base_image.tag }}
|
|
|
# Forked repos can't push to GHCR, so we need to upload the image as an artifact
|
|
|
- - name: Build runtime image ${{ inputs.base_image }} for fork
|
|
|
+ - name: Build runtime image ${{ matrix.base_image.image }} for fork
|
|
|
if: "github.event.pull_request.head.repo.fork"
|
|
|
uses: docker/build-push-action@v6
|
|
|
with:
|
|
|
- tags: ghcr.io/all-hands-ai/runtime:${{ github.sha }}-${{ inputs.image_tag }}
|
|
|
- outputs: type=docker,dest=/tmp/runtime-${{ inputs.image_tag }}.tar
|
|
|
+ tags: ghcr.io/all-hands-ai/runtime:${{ github.sha }}-${{ matrix.base_image.tag }}
|
|
|
+ outputs: type=docker,dest=/tmp/runtime-${{ matrix.base_image.tag }}.tar
|
|
|
context: containers/runtime
|
|
|
- name: Upload runtime image for fork
|
|
|
if: "github.event.pull_request.head.repo.fork"
|
|
|
uses: actions/upload-artifact@v4
|
|
|
with:
|
|
|
- name: runtime-${{ inputs.image_tag }}
|
|
|
- path: /tmp/runtime-${{ inputs.image_tag }}.tar
|
|
|
+ name: runtime-${{ matrix.base_image.tag }}
|
|
|
+ path: /tmp/runtime-${{ matrix.base_image.tag }}.tar
|
|
|
|
|
|
- # Run unit tests with the runtime Docker images
|
|
|
+ # Run unit tests with the EventStream runtime Docker images
|
|
|
test_runtime:
|
|
|
- name: Runtime Unit Tests with ${{ inputs.image_tag }}
|
|
|
+ name: Test Runtime
|
|
|
runs-on: ubuntu-latest
|
|
|
needs: [ghcr_build_runtime]
|
|
|
+ strategy:
|
|
|
+ matrix:
|
|
|
+ base_image: ['nikolaik', 'python', 'node']
|
|
|
steps:
|
|
|
- uses: actions/checkout@v4
|
|
|
- name: Free Disk Space (Ubuntu)
|
|
|
@@ -104,12 +124,12 @@ jobs:
|
|
|
if: "github.event.pull_request.head.repo.fork"
|
|
|
uses: actions/download-artifact@v4
|
|
|
with:
|
|
|
- name: runtime-${{ inputs.image_tag }}
|
|
|
+ name: runtime-${{ matrix.base_image }}
|
|
|
path: /tmp
|
|
|
- name: Load runtime image for fork
|
|
|
if: "github.event.pull_request.head.repo.fork"
|
|
|
run: |
|
|
|
- docker load --input /tmp/runtime-${{ inputs.image_tag }}.tar
|
|
|
+ docker load --input /tmp/runtime-${{ matrix.base_image }}.tar
|
|
|
- name: Install poetry via pipx
|
|
|
run: pipx install poetry
|
|
|
- name: Set up Python
|
|
|
@@ -121,7 +141,7 @@ jobs:
|
|
|
run: make install-python-dependencies
|
|
|
- name: Run runtime tests
|
|
|
run: |
|
|
|
- image_name=ghcr.io/${{ github.repository_owner }}/runtime:${{ github.sha }}-${{ inputs.image_tag }}
|
|
|
+ image_name=ghcr.io/${{ github.repository_owner }}/runtime:${{ github.sha }}-${{ matrix.base_image }}
|
|
|
image_name=$(echo $image_name | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
|
TEST_RUNTIME=eventstream \
|
|
|
@@ -134,11 +154,15 @@ jobs:
|
|
|
env:
|
|
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
|
|
- # Run integration tests with the runtime Docker image
|
|
|
+ # Run integration tests with the eventstream runtime Docker image
|
|
|
runtime_integration_tests_on_linux:
|
|
|
- name: Runtime Integration Tests with ${{ inputs.image_tag }}
|
|
|
+ name: Runtime Integration Tests on Linux
|
|
|
runs-on: ubuntu-latest
|
|
|
needs: [ghcr_build_runtime]
|
|
|
+ strategy:
|
|
|
+ fail-fast: false
|
|
|
+ matrix:
|
|
|
+ base_image: ['nikolaik', 'python', 'node']
|
|
|
steps:
|
|
|
- uses: actions/checkout@v4
|
|
|
# Forked repos can't push to GHCR, so we need to download the image as an artifact
|
|
|
@@ -146,12 +170,12 @@ jobs:
|
|
|
if: "github.event.pull_request.head.repo.fork"
|
|
|
uses: actions/download-artifact@v4
|
|
|
with:
|
|
|
- name: runtime-${{ inputs.image_tag }}
|
|
|
+ name: runtime-${{ matrix.base_image }}
|
|
|
path: /tmp
|
|
|
- name: Load runtime image for fork
|
|
|
if: "github.event.pull_request.head.repo.fork"
|
|
|
run: |
|
|
|
- docker load --input /tmp/runtime-${{ inputs.image_tag }}.tar
|
|
|
+ docker load --input /tmp/runtime-${{ matrix.base_image }}.tar
|
|
|
- name: Install poetry via pipx
|
|
|
run: pipx install poetry
|
|
|
- name: Set up Python
|
|
|
@@ -163,7 +187,7 @@ jobs:
|
|
|
run: make install-python-dependencies
|
|
|
- name: Run integration tests
|
|
|
run: |
|
|
|
- image_name=ghcr.io/${{ github.repository_owner }}/runtime:${{ github.sha }}-${{ inputs.image_tag }}
|
|
|
+ image_name=ghcr.io/${{ github.repository_owner }}/runtime:${{ github.sha }}-${{ matrix.base_image }}
|
|
|
image_name=$(echo $image_name | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
|
TEST_RUNTIME=eventstream \
|
|
|
@@ -179,7 +203,7 @@ jobs:
|
|
|
|
|
|
# Checks that all runtime tests have passed
|
|
|
all_runtime_tests_passed:
|
|
|
- name: Runtime Tests Passed with ${{ inputs.image_tag }}
|
|
|
+ name: All Runtime Tests Passed
|
|
|
runs-on: ubuntu-latest
|
|
|
needs: [test_runtime, runtime_integration_tests_on_linux]
|
|
|
steps:
|