This is an automated email from the ASF dual-hosted git repository. sciabarracom pushed a commit to branch 0.9.0 in repository https://gitbox.apache.org/repos/asf/openserverless-runtimes.git
commit 659ec51257b91946f68b17e7e4df64bb91a97cb1 Author: Michele Sciabarra <[email protected]> AuthorDate: Sun Sep 6 12:15:56 2026 +0200 splitjob --- .github/workflows/image.yaml | 129 ++++++++++++++++++++++++++++++++++++++++--- Taskfile.yml | 63 +++++++++++---------- 2 files changed, 156 insertions(+), 36 deletions(-) diff --git a/.github/workflows/image.yaml b/.github/workflows/image.yaml index 96d963d..23cc8b5 100644 --- a/.github/workflows/image.yaml +++ b/.github/workflows/image.yaml @@ -39,14 +39,12 @@ on: - java - php - experimental - jobs: - images: - name: Build OpenServerless runtime images + # 0. Fail fast, once, before any build work starts: pushing these images + # needs a PAT because their names do not match the repository. + check: + name: Check secrets runs-on: ubuntu-22.04 - permissions: - contents: write - packages: write steps: - name: Check GHCR_TOKEN is set if: ${{ github.repository_owner != 'apache' }} @@ -79,6 +77,21 @@ jobs: echo "::error title=Missing GHCR_TOKEN::This repository publishes multiple images and needs a PAT with write:packages stored as the secret GHCR_TOKEN. See the job summary for step-by-step instructions." exit 1 fi + # 1. Build and push the common base image, and decide what the matrix + # should build. Every runtime image FROMs common, so this job must + # finish before any matrix shard starts. + common: + name: Common image and matrix + needs: check + runs-on: ubuntu-22.04 + permissions: + contents: write + packages: write + outputs: + # "all", "common", or a single language: the scope encoded in the tag + scope: ${{ steps.scope.outputs.scope }} + tag: ${{ steps.scope.outputs.tag }} + steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -125,17 +138,117 @@ jobs: # Manual run: create a new snapshot tag on the current HEAD for the # selected runtimes. The tag is not pushed, so no second run is started: # this same run goes on and builds it. + - name: Set up QEMU + uses: docker/setup-qemu-action@1f40c72289eff860ee54a304f1438e3cff362e0a # v4.3.0 + with: + image: tonistiigi/binfmt:qemu-v7.0.0-28 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 + # A manual run tags HEAD here, once. The matrix shards never tag: + # they check out this exact tag, so every image in the run carries + # the same timestamp. - name: Tag HEAD (manual run) if: ${{ github.event_name == 'workflow_dispatch' }} run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" task tag RT="${{ inputs.runtime }}" + - name: Build and push common + run: task buildx FILTER=runtime-common:common1.17.1 + # The tag looks like <scope>_<timestamp>; the runtime shards use the + # scope to decide whether they apply to this run. + - name: Read tag scope + id: scope + run: | + TAG=$(git for-each-ref --sort=-creatordate --count=1 \ + --format='%(refname:short)' refs/tags) + echo "tag=$TAG" >> "$GITHUB_OUTPUT" + echo "scope=${TAG%%_*}" >> "$GITHUB_OUTPUT" + + # 2. One job per runtime image, built in parallel. + runtimes: + name: ${{ matrix.rt }}:${{ matrix.ver }} + needs: [check, common] + # build this shard only when the tag selects it: "all_*" builds every + # runtime, "<lang>_*" builds just that language, "common_*" builds none + if: >- + ${{ needs.common.outputs.scope == 'all' + || needs.common.outputs.scope == matrix.rt }} + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write + strategy: + fail-fast: false + max-parallel: 6 + # One job per image. Edit this list by hand when a runtime version is + # added or dropped: each entry runs "task buildx FILTER=<rt>:<ver>". + # A shard is skipped unless the tag scope selects it (see "if" below), + # so entries for every language can stay listed here all the time. + matrix: + include: + - { rt: go, ver: v1.20 } + - { rt: go, ver: v1.21 } + - { rt: go, ver: v1.22 } + - { rt: nodejs, ver: v18 } + - { rt: nodejs, ver: v20 } + - { rt: nodejs, ver: v21 } + - { rt: python, ver: v3.11 } + - { rt: python, ver: v3.12 } + - { rt: python, ver: v3.13 } + - { rt: java, ver: v8 } + - { rt: java, ver: v11 } + - { rt: java, ver: v17 } + - { rt: java, ver: v21 } + # php is currently disabled in the Taskfile's RUNTIMES variable + #- { rt: php, ver: v8.2 } + #- { rt: php, ver: v8.3 } + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + submodules: recursive + # build the exact tag the common job created/selected + ref: ${{ needs.common.outputs.tag }} + fetch-depth: 0 + - name: Setup CI + run: bash .github/cisetup.sh + - name: Use ghcr.io repo + if: ${{ github.repository_owner != 'apache' }} + run: | + echo "REPO_URL=ghcr.io" >> "$GITHUB_ENV" + echo "REGISTRY_USER=${{ github.actor }}" >> "$GITHUB_ENV" + echo "DOCKERHUB_REGISTRY=ghcr.io" >> "$GITHUB_ENV" + echo "DOCKERHUB_USER=${{ github.repository_owner }}" >> "$GITHUB_ENV" + - name: Use docker.io repo + if: ${{ github.repository_owner == 'apache' }} + run: | + echo "REPO_URL=docker.io" >> "$GITHUB_ENV" + echo "REGISTRY_USER=${{ secrets.DOCKERHUB_USER }}" >> "$GITHUB_ENV" + echo "DOCKERHUB_REGISTRY=docker.io" >> "$GITHUB_ENV" + echo "DOCKERHUB_USER=apache" >> "$GITHUB_ENV" + # the Taskfile reads DOCKERHUB_REGISTRY and DOCKERHUB_USER from .env + - name: Create .env + run: | + { + echo "DOCKERHUB_REGISTRY=$DOCKERHUB_REGISTRY" + echo "DOCKERHUB_USER=$DOCKERHUB_USER" + } > .env + cat .env + - name: Registry login + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + with: + registry: ${{ env.REPO_URL }} + username: ${{ env.REGISTRY_USER }} + password: ${{ github.repository_owner == 'apache' && secrets.DOCKERHUB_TOKEN || secrets.GHCR_TOKEN }} + # Manual run: create a new snapshot tag on the current HEAD for the + # selected runtimes. The tag is not pushed, so no second run is started: + # this same run goes on and builds it. - name: Set up QEMU uses: docker/setup-qemu-action@1f40c72289eff860ee54a304f1438e3cff362e0a # v4.3.0 with: image: tonistiigi/binfmt:qemu-v7.0.0-28 - name: Set up Docker Buildx uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 - - name: Build and push - run: task buildx + - name: Build and push ${{ matrix.rt }}:${{ matrix.ver }} + run: task buildx FILTER="${{ matrix.rt }}:${{ matrix.ver }}" diff --git a/Taskfile.yml b/Taskfile.yml index ed189eb..16455cb 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -21,8 +21,10 @@ dotenv: [.env] vars: DRY: "" + DRY2: "" PUSH: "" BASETAG: "" + FILTER: "" J: "{}" COMMIT_ID: sh: git rev-parse --short HEAD @@ -38,7 +40,6 @@ vars: TAG: sh: git for-each-ref --sort=-creatordate --count=1 --format='%(refname:short)' refs/tags 2>/dev/null | grep . || echo snapshot COMMON: "{{.BASEIMG}}/openserverless-runtime-common:{{.COMMON_VER}}-{{.TAG}}" - #RUNTIMES: "go,nodejs,php,python,java" temp disabled php RUNTIMES: "go,nodejs,python,java" @@ -86,9 +87,9 @@ tasks: cmds: - | if ! /usr/local/bin/python --version | grep 'Python 3' - then echo 'you need to link a python 3 to /usr/local/bin/python to run the tests (do not ask why)' - echo tast test-init does it for you if you have a python3 and sudo - exit 1 + then echo 'you need to link a python 3 to /usr/local/bin/python to run the tests (do not ask why)' + echo tast test-init does it for you if you have a python3 and sudo + exit 1 fi - go test -v @@ -110,40 +111,46 @@ tasks: - yes | docker buildx prune build-common: + silent: true dir: "runtime/common/{{.COMMON_VER}}" cmds: - | - if test -n "{{.PUSH}}" + if echo '{{.COMMON}}' | grep '{{.FILTER}}' then - echo ">>> Building arm/amd and pushing {{.COMMON}}" - {{.DRY}} docker buildx build -t "{{.COMMON}}" --platform linux/amd64,linux/arm64 . --push - else - echo ">>> Building {{.COMMON}}" - {{.DRY}} docker buildx build -t "{{.COMMON}}" . --load + if test -n "{{.PUSH}}" + then + echo ">>> Building arm/amd and pushing {{.COMMON}}" + {{.DRY2}} docker buildx build -t "{{.COMMON}}" --platform linux/amd64,linux/arm64 . --push + else + echo ">>> Building {{.COMMON}}" + {{.DRY2}} docker buildx build -t "{{.COMMON}}" . --load + fi + echo "<<< Built {{.COMMON}}" fi - echo "<<< Built {{.COMMON}}" build-runtime: + silent: true requires: { vars: [RT, VER] } vars: RUNTIME: "{{.BASEIMG}}/openserverless-runtime-{{.RT}}:{{.VER}}-{{.TAG}}" dir: "runtime/{{.RT}}/{{.VER}}" cmds: - | - if test -n "{{.PUSH}}" + if echo '{{.RUNTIME}}' | grep '{{.FILTER}}' then - echo ">>> Building arm/amd and pushing {{.RUNTIME}}" - {{.DRY}} docker buildx build -t "{{.RUNTIME}}" \ - --build-arg COMMON="{{.COMMON}}" \ - --platform linux/amd64,linux/arm64 . --push - else - echo ">>> Building {{.RUNTIME}}" - {{.DRY}} docker buildx build -t "{{.RUNTIME}}" \ - --build-arg COMMON="{{.COMMON}}" . --load + if test -n "{{.PUSH}}" + then + echo ">>> Building arm/amd and pushing {{.RUNTIME}}" + {{.DRY2}} docker buildx build -t "{{.RUNTIME}}" --build-arg COMMON="{{.COMMON}}" --platform linux/amd64,linux/arm64 . --push + else + echo ">>> Building {{.RUNTIME}}" + {{.DRY2}} docker buildx build -t "{{.RUNTIME}}" --build-arg COMMON="{{.COMMON}}" . --load + fi + echo "<<< Built {{.RUNTIME}}" fi - echo "<<< Built {{.RUNTIME}}" build-lang: + silent: true desc: build images for one runtime requires: { vars: [RT] } vars: @@ -155,7 +162,7 @@ tasks: vars: VER: "{{base .ITEM}}" - # run this + # build all build: silent: true desc: build the runtimes selected by task tag @@ -167,21 +174,21 @@ tasks: echo Building: $T case "$T" in all_*) - {{.DRY}} task build-common TAG="$TS" PUSH="{{.PUSH}}" + {{.DRY}} task build-common TAG="$TS" PUSH="{{.PUSH}}" DRY2={{.DRY2}} FILTER={{.FILTER}} for runtime in $(echo {{.RUNTIMES}} | tr ',' ' ') - do {{.DRY}} task build-lang RT="$runtime" TAG="$TS" PUSH="{{.PUSH}}" + do {{.DRY}} task build-lang RT="$runtime" TAG="$TS" PUSH="{{.PUSH}}" DRY2={{.DRY2}} FILTER={{.FILTER}} done ;; common_*) - {{.DRY}} task build-common TAG="$TS" PUSH="{{.PUSH}}" + {{.DRY}} task build-common TAG="$TS" PUSH="{{.PUSH}}" DRY2={{.DRY2}} FILTER={{.FILTER}} ;; experimental_*) {{.DRY}} task x:build-experimental-runtimes TAG="$TS" PUSH="{{.PUSH}}" ;; *_*) TS="${T#*_}" - {{.DRY}} task build-common TAG="$TS" PUSH="{{.PUSH}}" - {{.DRY}} task build-lang RT="$RT" TAG="$TS" PUSH="{{.PUSH}}" + {{.DRY}} task build-common TAG="$TS" PUSH="{{.PUSH}}" DRY2={{.DRY2}} FILTER={{.FILTER}} + {{.DRY}} task build-lang RT="$RT" TAG="$TS" PUSH="{{.PUSH}}" DRY2={{.DRY2}} FILTER={{.FILTER}} ;; *) echo this should not happen - did you read the README @@ -192,7 +199,7 @@ tasks: desc: build and push the runtimes selected by task tag silent: false cmds: - - task build PUSH=y + - task build PUSH=y FILTER="{{.FILTER}}" run: desc: run a runtime
