Skip to content

Wire runtime idle threshold through runtime-api chart #628

Wire runtime idle threshold through runtime-api chart

Wire runtime idle threshold through runtime-api chart #628

name: Preview Helm Charts
on:
pull_request:
paths:
- 'charts/**'
jobs:
validate-chart-versions:
uses: ./.github/workflows/validate-chart-versions.yml
with:
base_ref: origin/${{ github.event.pull_request.base.ref }}
enforce_version_bump: false
detect-changes:
runs-on: ubuntu-latest
outputs:
crd-check: ${{ steps.changes.outputs.crd-check }}
runtime-api: ${{ steps.changes.outputs.runtime-api }}
image-loader: ${{ steps.changes.outputs.image-loader }}
automation: ${{ steps.changes.outputs.automation }}
plugin-directory: ${{ steps.changes.outputs.plugin-directory }}
integrations-hub: ${{ steps.changes.outputs.integrations-hub }}
openhands: ${{ steps.changes.outputs.openhands }}
openhands-secrets: ${{ steps.changes.outputs.openhands-secrets }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Detect chart changes
id: changes
run: |
BASE_REF="origin/${{ github.event.pull_request.base.ref }}"
echo "Comparing against: $BASE_REF"
# Get list of changed files
CHANGED_FILES=$(git diff --name-only $BASE_REF...HEAD)
echo "Changed files:"
echo "$CHANGED_FILES"
# Check each chart for changes
for chart in crd-check runtime-api image-loader automation plugin-directory integrations-hub openhands openhands-secrets; do
if echo "$CHANGED_FILES" | grep -q "^charts/${chart}/"; then
echo "${chart}=true" >> $GITHUB_OUTPUT
echo "Changes detected in charts/${chart}"
else
echo "${chart}=false" >> $GITHUB_OUTPUT
echo "No changes in charts/${chart}"
fi
done
publish-charts:
runs-on: ubuntu-latest
needs: [validate-chart-versions, detect-changes]
permissions:
contents: read
packages: write
defaults:
run:
shell: bash
strategy:
matrix:
chart:
# Order matters! Charts that are dependencies must be published first.
# crd-check, automation, plugin-directory, integrations-hub, and runtime-api are dependencies of openhands.
- name: crd-check
path: charts/crd-check
- name: automation
path: charts/automation
- name: plugin-directory
path: charts/plugin-directory
- name: integrations-hub
path: charts/integrations-hub
- name: runtime-api
path: charts/runtime-api
- name: image-loader
path: charts/image-loader
- name: openhands
path: charts/openhands
- name: openhands-secrets
path: charts/openhands-secrets
max-parallel: 1
steps:
- name: Check if chart should be published
id: check
env:
HAS_CHANGES_CRD_CHECK: ${{ needs.detect-changes.outputs.crd-check }}
HAS_CHANGES_RUNTIME_API: ${{ needs.detect-changes.outputs.runtime-api }}
HAS_CHANGES_IMAGE_LOADER: ${{ needs.detect-changes.outputs.image-loader }}
HAS_CHANGES_AUTOMATION: ${{ needs.detect-changes.outputs.automation }}
HAS_CHANGES_PLUGIN_DIRECTORY: ${{ needs.detect-changes.outputs.plugin-directory }}
HAS_CHANGES_INTEGRATIONS_HUB: ${{ needs.detect-changes.outputs.integrations-hub }}
HAS_CHANGES_OPENHANDS: ${{ needs.detect-changes.outputs.openhands }}
HAS_CHANGES_OPENHANDS_SECRETS: ${{ needs.detect-changes.outputs.openhands-secrets }}
IS_PUBLISHABLE_CRD_CHECK: ${{ needs.validate-chart-versions.outputs.crd-check-publishable }}
IS_PUBLISHABLE_RUNTIME_API: ${{ needs.validate-chart-versions.outputs.runtime-api-publishable }}
IS_PUBLISHABLE_IMAGE_LOADER: ${{ needs.validate-chart-versions.outputs.image-loader-publishable }}
IS_PUBLISHABLE_AUTOMATION: ${{ needs.validate-chart-versions.outputs.automation-publishable }}
IS_PUBLISHABLE_PLUGIN_DIRECTORY: ${{ needs.validate-chart-versions.outputs.plugin-directory-publishable }}
IS_PUBLISHABLE_INTEGRATIONS_HUB: ${{ needs.validate-chart-versions.outputs.integrations-hub-publishable }}
IS_PUBLISHABLE_OPENHANDS: ${{ needs.validate-chart-versions.outputs.openhands-publishable }}
IS_PUBLISHABLE_OPENHANDS_SECRETS: ${{ needs.validate-chart-versions.outputs.openhands-secrets-publishable }}
run: |
CHART_NAME="${{ matrix.chart.name }}"
case "$CHART_NAME" in
crd-check)
HAS_CHANGES="$HAS_CHANGES_CRD_CHECK"
IS_PUBLISHABLE="$IS_PUBLISHABLE_CRD_CHECK"
;;
runtime-api)
HAS_CHANGES="$HAS_CHANGES_RUNTIME_API"
IS_PUBLISHABLE="$IS_PUBLISHABLE_RUNTIME_API"
;;
image-loader)
HAS_CHANGES="$HAS_CHANGES_IMAGE_LOADER"
IS_PUBLISHABLE="$IS_PUBLISHABLE_IMAGE_LOADER"
;;
automation)
HAS_CHANGES="$HAS_CHANGES_AUTOMATION"
IS_PUBLISHABLE="$IS_PUBLISHABLE_AUTOMATION"
;;
plugin-directory)
HAS_CHANGES="$HAS_CHANGES_PLUGIN_DIRECTORY"
IS_PUBLISHABLE="$IS_PUBLISHABLE_PLUGIN_DIRECTORY"
;;
integrations-hub)
HAS_CHANGES="$HAS_CHANGES_INTEGRATIONS_HUB"
IS_PUBLISHABLE="$IS_PUBLISHABLE_INTEGRATIONS_HUB"
;;
openhands)
HAS_CHANGES="$HAS_CHANGES_OPENHANDS"
IS_PUBLISHABLE="$IS_PUBLISHABLE_OPENHANDS"
;;
openhands-secrets)
HAS_CHANGES="$HAS_CHANGES_OPENHANDS_SECRETS"
IS_PUBLISHABLE="$IS_PUBLISHABLE_OPENHANDS_SECRETS"
;;
esac
# Default IS_PUBLISHABLE to true if not set (assume publishable unless explicitly marked otherwise)
IS_PUBLISHABLE="${IS_PUBLISHABLE:-true}"
echo "Chart $CHART_NAME - has changes: $HAS_CHANGES, is publishable: $IS_PUBLISHABLE"
# Only publish if chart has changes AND version was bumped
if [ "$HAS_CHANGES" = "true" ] && [ "$IS_PUBLISHABLE" = "true" ]; then
echo "should_publish=true" >> $GITHUB_OUTPUT
echo "✅ Chart $CHART_NAME will be published"
else
echo "should_publish=false" >> $GITHUB_OUTPUT
if [ "$HAS_CHANGES" != "true" ]; then
echo "⏭️ Chart $CHART_NAME skipped - no changes"
else
echo "⏭️ Chart $CHART_NAME skipped - version not bumped"
fi
fi
- name: Checkout
if: steps.check.outputs.should_publish == 'true'
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Helm
if: steps.check.outputs.should_publish == 'true'
uses: azure/setup-helm@v3
with:
version: 'latest'
- name: Use PR version suffix
if: steps.check.outputs.should_publish == 'true'
run: |
# Create a preview version like 0.1.0-alpha.123
# This should confirm to SemVer, the last number is the GitHub PR number
CHART_VERSION=$(yq '.version' charts/${{ matrix.chart.name }}/Chart.yaml)
PREVIEW_VERSION="${CHART_VERSION}-alpha.${{ github.event.pull_request.number }}"
# Update Chart.yaml with preview version
yq -i ".version = \"${PREVIEW_VERSION}\"" charts/${{ matrix.chart.name }}/Chart.yaml
- name: Update runtime-api dependency version
if: steps.check.outputs.should_publish == 'true' && matrix.chart.name == 'openhands' && needs.detect-changes.outputs.runtime-api == 'true'
run: |
RUNTIME_API_VERSION=$(yq '.version' charts/runtime-api/Chart.yaml)
RUNTIME_API_PREVIEW="${RUNTIME_API_VERSION}-alpha.${{ github.event.pull_request.number }}"
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
RUNTIME_API_PREVIEW_REPOSITORY="oci://ghcr.io/${REPO_OWNER}/helm-charts"
yq -i "(.dependencies[] | select(.name == \"runtime-api\")).version = \"${RUNTIME_API_PREVIEW}\"" charts/openhands/Chart.yaml
yq -i "(.dependencies[] | select(.name == \"runtime-api\")).repository = \"${RUNTIME_API_PREVIEW_REPOSITORY}\"" charts/openhands/Chart.yaml
- name: Update automation dependency version
if: steps.check.outputs.should_publish == 'true' && matrix.chart.name == 'openhands' && needs.detect-changes.outputs.automation == 'true'
run: |
AUTOMATION_VERSION=$(yq '.version' charts/automation/Chart.yaml)
AUTOMATION_PREVIEW="${AUTOMATION_VERSION}-alpha.${{ github.event.pull_request.number }}"
yq -i "(.dependencies[] | select(.name == \"automation\")).version = \"${AUTOMATION_PREVIEW}\"" charts/openhands/Chart.yaml
- name: Update crd-check dependency version
if: steps.check.outputs.should_publish == 'true' && matrix.chart.name == 'openhands' && needs.detect-changes.outputs.crd-check == 'true'
run: |
CRD_CHECK_VERSION=$(yq '.version' charts/crd-check/Chart.yaml)
CRD_CHECK_PREVIEW="${CRD_CHECK_VERSION}-alpha.${{ github.event.pull_request.number }}"
yq -i "(.dependencies[] | select(.name == \"crd-check\")).version = \"${CRD_CHECK_PREVIEW}\"" charts/openhands/Chart.yaml
- name: Update plugin-directory dependency version
if: steps.check.outputs.should_publish == 'true' && matrix.chart.name == 'openhands' && needs.detect-changes.outputs.plugin-directory == 'true'
run: |
PLUGIN_DIRECTORY_VERSION=$(yq '.version' charts/plugin-directory/Chart.yaml)
PLUGIN_DIRECTORY_PREVIEW="${PLUGIN_DIRECTORY_VERSION}-alpha.${{ github.event.pull_request.number }}"
yq -i "(.dependencies[] | select(.name == \"plugin-directory\")).version = \"${PLUGIN_DIRECTORY_PREVIEW}\"" charts/openhands/Chart.yaml
- name: Update integrations-hub dependency version
if: steps.check.outputs.should_publish == 'true' && matrix.chart.name == 'openhands' && needs.detect-changes.outputs.integrations-hub == 'true'
run: |
INTEGRATIONS_HUB_VERSION=$(yq '.version' charts/integrations-hub/Chart.yaml)
INTEGRATIONS_HUB_PREVIEW="${INTEGRATIONS_HUB_VERSION}-alpha.${{ github.event.pull_request.number }}"
yq -i "(.dependencies[] | select(.name == \"integrations-hub\")).version = \"${INTEGRATIONS_HUB_PREVIEW}\"" charts/openhands/Chart.yaml
- name: Test ${{ matrix.chart.name }} chart with default values
if: steps.check.outputs.should_publish == 'true'
run: |
echo "Testing ${{ matrix.chart.name }} chart with default values"
echo "Updating dependencies for ${{ matrix.chart.name }}"
helm dependency update ${{ matrix.chart.path }}
echo "Running helm lint for ${{ matrix.chart.name }}"
helm lint ${{ matrix.chart.path }}
if [ $? -ne 0 ]; then
echo "Helm lint test failed for ${{ matrix.chart.name }}"
exit 1
fi
echo "Helm lint test passed for ${{ matrix.chart.name }}"
if grep -q '^type: library' ${{ matrix.chart.path }}/Chart.yaml; then
echo "Skipping helm template for library chart ${{ matrix.chart.name }}"
else
echo "Running helm template for ${{ matrix.chart.name }}"
helm template ${{ matrix.chart.path }} --debug
if [ $? -ne 0 ]; then
echo "Helm template test failed for ${{ matrix.chart.name }}"
exit 1
fi
echo "Helm template test passed for ${{ matrix.chart.name }}"
fi
- name: Extract chart version and prepare repository
if: steps.check.outputs.should_publish == 'true'
id: chart_info
run: |
VERSION=$(grep '^version:' ${{ matrix.chart.path }}/Chart.yaml | awk '{print $2}')
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Using chart version: ${VERSION}"
# Ensure we are publishing to an "alpha" version.
if [[ "$VERSION" != *alpha* ]]; then
echo "Error: Version '$VERSION' does not contain 'alpha'"
exit 1
fi
# Convert repository owner to lowercase for GHCR
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
echo "REPO_OWNER=${REPO_OWNER}" >> $GITHUB_OUTPUT
echo "Using repository owner: ${REPO_OWNER}"
- name: Publish ${{ matrix.chart.name }} chart to GHCR
if: steps.check.outputs.should_publish == 'true'
uses: appany/helm-oci-chart-releaser@v0.4.2
with:
name: ${{ matrix.chart.name }}
repository: helm-charts
path: ${{ matrix.chart.path }}
registry: ghcr.io/${{ steps.chart_info.outputs.REPO_OWNER }}
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
update_dependencies: 'true'
tag: ${{ steps.chart_info.outputs.VERSION }}
lint-and-test:
runs-on: ubuntu-latest
needs: [publish-charts, detect-changes]
strategy:
matrix:
chart:
- name: crd-check
path: charts/crd-check
- name: runtime-api
path: charts/runtime-api
- name: image-loader
path: charts/image-loader
- name: automation
path: charts/automation
- name: plugin-directory
path: charts/plugin-directory
- name: integrations-hub
path: charts/integrations-hub
- name: openhands
path: charts/openhands
- name: openhands-secrets
path: charts/openhands-secrets
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: 'latest'
- name: Update runtime-api dependency version for openhands
if: matrix.chart.name == 'openhands' && needs.detect-changes.outputs.runtime-api == 'true'
run: |
RUNTIME_API_VERSION=$(yq '.version' charts/runtime-api/Chart.yaml)
RUNTIME_API_PREVIEW="${RUNTIME_API_VERSION}-alpha.${{ github.event.pull_request.number }}"
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
RUNTIME_API_PREVIEW_REPOSITORY="oci://ghcr.io/${REPO_OWNER}/helm-charts"
echo "Updating openhands runtime-api dependency to ${RUNTIME_API_PREVIEW} from ${RUNTIME_API_PREVIEW_REPOSITORY}"
yq -i "(.dependencies[] | select(.name == \"runtime-api\")).version = \"${RUNTIME_API_PREVIEW}\"" charts/openhands/Chart.yaml
yq -i "(.dependencies[] | select(.name == \"runtime-api\")).repository = \"${RUNTIME_API_PREVIEW_REPOSITORY}\"" charts/openhands/Chart.yaml
- name: Update automation dependency version for openhands
if: matrix.chart.name == 'openhands' && needs.detect-changes.outputs.automation == 'true'
run: |
AUTOMATION_VERSION=$(yq '.version' charts/automation/Chart.yaml)
AUTOMATION_PREVIEW="${AUTOMATION_VERSION}-alpha.${{ github.event.pull_request.number }}"
echo "Updating openhands automation dependency to ${AUTOMATION_PREVIEW}"
yq -i "(.dependencies[] | select(.name == \"automation\")).version = \"${AUTOMATION_PREVIEW}\"" charts/openhands/Chart.yaml
- name: Update crd-check dependency version for openhands
if: matrix.chart.name == 'openhands' && needs.detect-changes.outputs.crd-check == 'true'
run: |
CRD_CHECK_VERSION=$(yq '.version' charts/crd-check/Chart.yaml)
CRD_CHECK_PREVIEW="${CRD_CHECK_VERSION}-alpha.${{ github.event.pull_request.number }}"
echo "Updating openhands crd-check dependency to ${CRD_CHECK_PREVIEW}"
yq -i "(.dependencies[] | select(.name == \"crd-check\")).version = \"${CRD_CHECK_PREVIEW}\"" charts/openhands/Chart.yaml
- name: Update plugin-directory dependency version for openhands
if: matrix.chart.name == 'openhands' && needs.detect-changes.outputs.plugin-directory == 'true'
run: |
PLUGIN_DIRECTORY_VERSION=$(yq '.version' charts/plugin-directory/Chart.yaml)
PLUGIN_DIRECTORY_PREVIEW="${PLUGIN_DIRECTORY_VERSION}-alpha.${{ github.event.pull_request.number }}"
echo "Updating openhands plugin-directory dependency to ${PLUGIN_DIRECTORY_PREVIEW}"
yq -i "(.dependencies[] | select(.name == \"plugin-directory\")).version = \"${PLUGIN_DIRECTORY_PREVIEW}\"" charts/openhands/Chart.yaml
- name: Update integrations-hub dependency version for openhands
if: matrix.chart.name == 'openhands' && needs.detect-changes.outputs.integrations-hub == 'true'
run: |
INTEGRATIONS_HUB_VERSION=$(yq '.version' charts/integrations-hub/Chart.yaml)
INTEGRATIONS_HUB_PREVIEW="${INTEGRATIONS_HUB_VERSION}-alpha.${{ github.event.pull_request.number }}"
echo "Updating openhands integrations-hub dependency to ${INTEGRATIONS_HUB_PREVIEW}"
yq -i "(.dependencies[] | select(.name == \"integrations-hub\")).version = \"${INTEGRATIONS_HUB_PREVIEW}\"" charts/openhands/Chart.yaml
- name: Lint ${{ matrix.chart.name }} chart
run: |
echo "Testing ${{ matrix.chart.name }} chart"
echo "Updating dependencies for ${{ matrix.chart.name }}"
helm dependency update ${{ matrix.chart.path }}
echo "Running helm lint for ${{ matrix.chart.name }}"
helm lint ${{ matrix.chart.path }}
if [ $? -ne 0 ]; then
echo "Helm lint failed for ${{ matrix.chart.name }}"
exit 1
fi
echo "Helm lint passed for ${{ matrix.chart.name }}"
- name: Template ${{ matrix.chart.name }} chart
run: |
if grep -q '^type: library' ${{ matrix.chart.path }}/Chart.yaml; then
echo "Skipping helm template for library chart ${{ matrix.chart.name }}"
exit 0
fi
echo "Running helm template for ${{ matrix.chart.name }}"
helm template ${{ matrix.chart.path }} --debug
if [ $? -ne 0 ]; then
echo "Helm template failed for ${{ matrix.chart.name }}"
exit 1
fi
echo "Helm template passed for ${{ matrix.chart.name }}"