Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/scripts/docling-serve-image-bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env bash
#
# Bumps DoclingServeContainerConfig.DOCLING_IMAGE_VERSION to the newest docling-serve tag
# that passed the version tests (within the current major version).
#
# Usage: docling-serve-image-bump.sh <path-to-results.md>
#
# Environment:
# DRY_RUN If "true", report what would change without modifying any file.
# GITHUB_OUTPUT If set, `current`, `new`, `updated` and `skipped` are appended to it.
#
set -euo pipefail

RESULTS_FILE="${1:-}"
DRY_RUN="${DRY_RUN:-false}"

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_FILE="${CONFIG_FILE:-${SCRIPT_DIR}/../../docling-testcontainers/src/main/java/ai/docling/testcontainers/serve/config/DoclingServeContainerConfig.java}"

if [[ -z "${RESULTS_FILE}" || ! -f "${RESULTS_FILE}" ]]; then
echo "Usage: $0 <path-to-results.md>" >&2
exit 1
fi

if [[ ! -f "${CONFIG_FILE}" ]]; then
echo "Config file not found: ${CONFIG_FILE}" >&2
exit 1
fi

CURRENT="$(sed -nE 's/.*String DOCLING_IMAGE_VERSION = "(v[0-9]+\.[0-9]+\.[0-9]+)".*/\1/p' "${CONFIG_FILE}" | head -n 1)"
if [[ -z "${CURRENT}" ]]; then
echo "Could not determine the current DOCLING_IMAGE_VERSION from ${CONFIG_FILE}" >&2
exit 1
fi

MAJOR="${CURRENT%%.*}"
MAJOR="${MAJOR#v}"

# Stable tags within the current major, by result: "SUCCESS" or anything else
tags_with_result() {
local pattern="$1"
sed -nE "s/^\| (v${MAJOR}\.[0-9]+\.[0-9]+) \| ${pattern} \|.*/\1/p" "${RESULTS_FILE}" | sort -V
}

NEW="$( (tags_with_result '✅ SUCCESS' || true) | tail -n 1)"
NEW="${NEW:-${CURRENT}}"

# Never downgrade
if [[ "$(printf '%s\n%s\n' "${CURRENT}" "${NEW}" | sort -V | tail -n 1)" == "${CURRENT}" ]]; then
NEW="${CURRENT}"
fi

# Newer tags (within the major) that did not succeed
SKIPPED=""
while IFS= read -r tag; do
[[ -z "${tag}" ]] && continue
if [[ "$(printf '%s\n%s\n' "${CURRENT}" "${tag}" | sort -V | tail -n 1)" == "${tag}" && "${tag}" != "${CURRENT}" ]]; then
SKIPPED="${SKIPPED:+${SKIPPED},}${tag}"
fi
done < <(sed -nE "s/^\| (v${MAJOR}\.[0-9]+\.[0-9]+) \| ❌.*/\1/p" "${RESULTS_FILE}" | sort -V)

UPDATED="false"
if [[ "${NEW}" != "${CURRENT}" ]]; then
UPDATED="true"
if [[ "${DRY_RUN}" == "true" ]]; then
echo "[dry run] Would bump DOCLING_IMAGE_VERSION ${CURRENT} -> ${NEW}"
else
TMP_FILE="$(mktemp)"
sed -E "s/(String DOCLING_IMAGE_VERSION = \")${CURRENT//./\\.}(\")/\1${NEW}\2/" "${CONFIG_FILE}" > "${TMP_FILE}"
cat "${TMP_FILE}" > "${CONFIG_FILE}"
rm -f "${TMP_FILE}"
echo "Bumped DOCLING_IMAGE_VERSION ${CURRENT} -> ${NEW}"
fi
else
echo "DOCLING_IMAGE_VERSION ${CURRENT} is already up to date"
fi

[[ -n "${SKIPPED}" ]] && echo "Newer tags that did not pass: ${SKIPPED}"

if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
{
echo "current=${CURRENT}"
echo "new=${NEW}"
echo "updated=${UPDATED}"
echo "skipped=${SKIPPED}"
} >> "${GITHUB_OUTPUT}"
fi
41 changes: 40 additions & 1 deletion .github/workflows/version-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ on:
required: true
type: boolean
default: true
updateDefaultImage:
description: Open a PR bumping the default docling-serve image version to the newest passing tag
required: true
type: boolean
default: true

concurrency:
group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}"
Expand Down Expand Up @@ -131,7 +136,11 @@ jobs:
${{ env.TAGS }} ${{ env.CREATE_GITHUB_ISSUE_FLAG }}

- name: Copy output markdown to docs
run: find docling-testing/docling-version-tests/${{ env.OUTPUT_DIR }} -name 'results.md' -exec cp -r '{}' docs/src/doc/docs/includes/docling-serve/serve-compatibility.md ';'
id: copy-results
run: |
RESULTS_FILE="$(find docling-testing/docling-version-tests/${{ env.OUTPUT_DIR }} -name 'results.md' | sort | tail -n 1)"
echo "results-file=$RESULTS_FILE" >> "$GITHUB_OUTPUT"
cp "$RESULTS_FILE" docs/src/doc/docs/includes/docling-serve/serve-compatibility.md

- name: Generate fresh token for PR
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
Expand Down Expand Up @@ -167,3 +176,33 @@ jobs:
env:
GH_TOKEN: ${{ steps.pr-token.outputs.token }}
run: gh pr merge --merge --admin --delete-branch "${{ steps.create-pr.outputs.pull-request-url }}"

- name: Bump default docling-serve image version
id: bump-image
if: (inputs.updateDefaultImage != false) && (env.IMAGE == 'docling-project/docling-serve') && (env.REGISTRY == 'ghcr.io')
run: ./.github/scripts/docling-serve-image-bump.sh "${{ steps.copy-results.outputs.results-file }}"

- name: Create image bump PR
if: steps.bump-image.outputs.updated == 'true'
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ steps.pr-token.outputs.token }}
add-paths: docling-testcontainers/src/main/java/ai/docling/testcontainers/serve/config/DoclingServeContainerConfig.java
commit-message: "chore(testcontainers): bump default docling-serve image to ${{ steps.bump-image.outputs.new }}"
branch: update-docling-serve-image/${{ steps.bump-image.outputs.new }}
delete-branch: true
base: main
signoff: true
sign-commits: true
title: "chore(testcontainers): bump default docling-serve image to ${{ steps.bump-image.outputs.new }}"
body: |
Bumps the default docling-serve image version from `${{ steps.bump-image.outputs.current }}` to `${{ steps.bump-image.outputs.new }}`.

`${{ steps.bump-image.outputs.new }}` is the newest tag that passed the version tests in [${{ github.workflow }} run # ${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}). See the [compatibility table](${{ github.server_url }}/${{ github.repository }}/blob/main/docs/src/doc/docs/includes/docling-serve/serve-compatibility.md).

Newer tags that did not pass: ${{ steps.bump-image.outputs.skipped || 'none' }}
labels: |
automation
version-upgrade
module:docling-testcontainers
area:docling-serve
14 changes: 14 additions & 0 deletions docling-testing/docling-version-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,20 @@ GitHub Actions workflow ([`version-tests.yml`](../../.github/workflows/version-t
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

#### Automatic default image bump

After the compatibility table PR, the workflow runs
[`.github/scripts/docling-serve-image-bump.sh`](../../.github/scripts/docling-serve-image-bump.sh)
against the generated `results.md`. It picks the newest stable `vX.Y.Z` tag that passed
(`✅ SUCCESS`) within the current major version of `DoclingServeContainerConfig.DOCLING_IMAGE_VERSION`
and, if it is newer, opens a PR (branch `update-docling-serve-image/<version>`) for human review
that updates the constant. Tags that failed are listed in the PR description.

- Scheduled runs always bump; manual runs can disable it with the `updateDefaultImage` input
(default `true`).
- The bump only runs for the `ghcr.io/docling-project/docling-serve` image.
- To try it locally: `DRY_RUN=true .github/scripts/docling-serve-image-bump.sh path/to/results.md`

## Requirements

- **Java 17+** (tested on 17, 21, 25)
Expand Down
Loading