diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index b98e60e..3302bb5 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -1,23 +1,28 @@ -name: devcontainer GHCR publication +name: devcontainer on: - workflow_call: - inputs: - candidate: - type: boolean - required: false - default: false - outputs: - image_ref: - description: Immutable image reference. - value: ${{ jobs.publish.outputs.image_ref }} + push: + branches: + - main + paths: + - '.github/workflows/devcontainer.yml' + - '.github/scripts/devcontainer/**' + - 'Dockerfile.ci-image-base' + - 'docker-bake.ci-image-base.hcl' + pull_request: + paths: + - '.github/workflows/devcontainer.yml' + - '.github/scripts/devcontainer/**' + - 'Dockerfile.ci-image-base' + - 'docker-bake.ci-image-base.hcl' + workflow_dispatch: permissions: contents: read jobs: prepare: - if: github.repository == 'WasmEdge/devcontainer' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || inputs.candidate) + if: github.repository == 'WasmEdge/devcontainer' runs-on: ubuntu-latest outputs: tag: ${{ steps.identity.outputs.tag }} @@ -32,7 +37,7 @@ jobs: RUN_ID: ${{ github.run_id }} ATTEMPT: ${{ github.run_attempt }} run: | - if [ '${{ inputs.candidate }}' = true ]; then + if [ '${{ github.event_name }}' = pull_request ]; then tag=$(python3 .github/scripts/devcontainer/publication.py candidate --pr '${{ github.event.number }}' \ --source-sha "$SOURCE_SHA" --run-id "$RUN_ID" --attempt "$ATTEMPT") else @@ -43,7 +48,7 @@ jobs: build: needs: prepare - if: github.repository == 'WasmEdge/devcontainer' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || inputs.candidate) + if: github.repository == 'WasmEdge/devcontainer' runs-on: ${{ matrix.runner }} permissions: contents: read @@ -52,10 +57,10 @@ jobs: fail-fast: false matrix: include: - - runner: ubuntu-latest + - runner: ubuntu-26.04 target: x86_64 arch: amd64 - - runner: ubuntu-24.04-arm + - runner: ubuntu-26.04-arm target: aarch64 arch: arm64 steps: @@ -117,11 +122,42 @@ jobs: echo "Failed to obtain image digest" >&2 exit 1 fi - if [ '${{ inputs.candidate }}' != true ]; then + if [ '${{ github.event_name }}' != pull_request ]; then docker buildx imagetools create --tag "$image:latest" "$image@$digest" fi echo "image_ref=$image@$digest" >> "$GITHUB_OUTPUT" + validate: + needs: publish + if: needs.publish.result == 'success' + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + include: + - runner: ubuntu-26.04 + architecture: amd64 + - runner: ubuntu-26.04-arm + architecture: arm64 + permissions: + contents: read + steps: + - name: Validate published image + env: + IMAGE_REF: ${{ needs.publish.outputs.image_ref }} + EXPECTED_ARCHITECTURE: ${{ matrix.architecture }} + run: | + docker pull "$IMAGE_REF" + architecture=$(docker run --rm "$IMAGE_REF" uname -m) + docker run --rm "$IMAGE_REF" docker --version + case "$EXPECTED_ARCHITECTURE:$architecture" in + amd64:x86_64|arm64:aarch64) ;; + *) + echo "Unexpected architecture: expected $EXPECTED_ARCHITECTURE, got $architecture" >&2 + exit 1 + ;; + esac + summarize-publication: needs: - prepare @@ -135,8 +171,11 @@ jobs: TAG: ${{ needs.prepare.outputs.tag }} run: | image=ghcr.io/wasmedge/devcontainer + digest=${IMAGE_REF#*@} { echo "## Published GHCR image" echo - echo "- Immutable reference: \`$image:$TAG@${IMAGE_REF#*@}\`" + echo "| Tag | Immutable reference |" + echo "| --- | --- |" + echo "| \`$TAG\` | \`$image@$digest\` |" } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/docker.yml b/.github/workflows/wasmedge-devcontainer.yml similarity index 65% rename from .github/workflows/docker.yml rename to .github/workflows/wasmedge-devcontainer.yml index c4994cc..615799c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/wasmedge-devcontainer.yml @@ -1,4 +1,4 @@ -name: docker +name: wasmedge-devcontainer concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} @@ -9,10 +9,13 @@ on: branches: - main paths: - - '.github/workflows/docker.yml' - - '.github/workflows/devcontainer.yml' - - 'Dockerfile.*' - - 'docker-bake.*.hcl' + - '.github/workflows/wasmedge-devcontainer.yml' + - 'docker-bake.alpine-base.hcl' + - 'docker-bake.manylinux.hcl' + - 'docker-bake.ubuntu.hcl' + - 'Dockerfile.alpine-base' + - 'Dockerfile.manylinux**' + - 'Dockerfile.ubuntu-**' - 'SHA256SUM.*' - 'build-manylinux.sh' - 'scripts/ffmpeg/**' @@ -21,9 +24,13 @@ on: - 'scripts/wasi-nn/**' pull_request: paths: - - '.github/workflows/docker.yml' - - 'Dockerfile.*' - - 'docker-bake.*.hcl' + - '.github/workflows/wasmedge-devcontainer.yml' + - 'docker-bake.alpine-base.hcl' + - 'docker-bake.manylinux.hcl' + - 'docker-bake.ubuntu.hcl' + - 'Dockerfile.alpine-base' + - 'Dockerfile.manylinux**' + - 'Dockerfile.ubuntu-**' - 'SHA256SUM.*' - 'build-manylinux.sh' - 'scripts/ffmpeg/**' @@ -77,7 +84,6 @@ jobs: pull-requests: read outputs: # Set outputs to true if not pull_request - ci-image-base: ${{ github.event_name == 'pull_request' && steps.filter.outputs.ci-image-base || 'true' }} alpine-base: ${{ github.event_name == 'pull_request' && steps.filter.outputs.alpine-base || 'true' }} manylinux: ${{ github.event_name == 'pull_request' && steps.filter.outputs.manylinux || 'true' }} ubuntu: ${{ github.event_name == 'pull_request' && steps.filter.outputs.ubuntu || 'true' }} @@ -93,17 +99,12 @@ jobs: uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 with: filters: | - ci-image-base: - - '.github/workflows/docker.yml' - - '.github/workflows/devcontainer.yml' - - 'docker-bake.ci-image-base.hcl' - - 'Dockerfile.ci-image-base' alpine-base: - - '.github/workflows/docker.yml' + - '.github/workflows/wasmedge-devcontainer.yml' - 'docker-bake.alpine-base.hcl' - 'Dockerfile.alpine-base' manylinux: - - '.github/workflows/docker.yml' + - '.github/workflows/wasmedge-devcontainer.yml' - 'docker-bake.manylinux.hcl' - 'Dockerfile.manylinux**' - 'scripts/ffmpeg/**' @@ -111,7 +112,7 @@ jobs: - 'scripts/wasi-crypto/**' - 'scripts/wasi-nn/**' ubuntu: - - '.github/workflows/docker.yml' + - '.github/workflows/wasmedge-devcontainer.yml' - 'docker-bake.ubuntu.hcl' - 'Dockerfile.ubuntu-**' - 'scripts/ffmpeg/**' @@ -119,50 +120,6 @@ jobs: - 'scripts/wasi-crypto/**' - 'scripts/wasi-nn/**' - bake-base-images: - needs: - - prep - - paths-filter - - name: CI image base - runs-on: ubuntu-latest - - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1 - with: - egress-policy: audit - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} - - # DO NOT skip the whole job to prevent descending jobs to be skipped - - if: ${{ needs.paths-filter.outputs.ci-image-base == 'true' }} - name: Bake and Push - uses: docker/bake-action@59cb1203cd42bcefd40a1b6d73b589e48c86040e # v7.5.0 - with: - files: docker-bake.ci-image-base.hcl - push: ${{ github.event_name != 'pull_request' }} - - devcontainer-ghcr: - needs: [prep, paths-filter] - name: devcontainer GHCR publication - permissions: - contents: read - packages: write - # Fork-origin PR package permissions remain a rollout decision; keep this - # path free of fork-specific handling until that behavior is verified. - uses: ./.github/workflows/devcontainer.yml - with: - candidate: ${{ github.event_name == 'pull_request' && needs.paths-filter.outputs.ci-image-base == 'true' }} - build-alpine-base-images: needs: - prep @@ -182,19 +139,12 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} - - name: Bake and Push uses: docker/bake-action@59cb1203cd42bcefd40a1b6d73b589e48c86040e # v7.5.0 with: # Point to your new HCL file here files: docker-bake.alpine-base.hcl - push: ${{ github.event_name != 'pull_request' }} + push: false set: | *.labels.org.opencontainers.image.title=${{ github.event.repository.name }} *.labels.org.opencontainers.image.description=${{ github.event.repository.description }} @@ -208,9 +158,7 @@ jobs: needs: - prep - paths-filter - - bake-base-images - - devcontainer-ghcr - if: ${{ !cancelled() && needs.prep.result == 'success' && needs.paths-filter.result == 'success' && needs.paths-filter.outputs.ubuntu == 'true' && (needs.paths-filter.outputs.ci-image-base != 'true' || needs.devcontainer-ghcr.result == 'success' || needs.devcontainer-ghcr.result == 'skipped') }} + if: ${{ needs.prep.result == 'success' && needs.paths-filter.result == 'success' && needs.paths-filter.outputs.ubuntu == 'true' }} strategy: fail-fast: false @@ -225,7 +173,7 @@ jobs: contents: read packages: read container: - image: ${{ needs.devcontainer-ghcr.result == 'success' && needs.devcontainer-ghcr.outputs.image_ref || 'wasmedge/wasmedge:ci-image-base' }} + image: wasmedge/wasmedge:ci-image-base steps: - name: Harden the runner (Audit all outbound calls) @@ -236,19 +184,12 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} - - name: Bake and Push uses: docker/bake-action@59cb1203cd42bcefd40a1b6d73b589e48c86040e # v7.5.0 with: files: docker-bake.ubuntu.hcl targets: ${{ matrix.targets }} - push: ${{ github.event_name != 'pull_request' }} + push: false set: | *.labels.org.opencontainers.image.title=${{ github.event.repository.name }} *.labels.org.opencontainers.image.description=${{ github.event.repository.description }} @@ -262,9 +203,7 @@ jobs: needs: - prep - paths-filter - - bake-base-images - - devcontainer-ghcr - if: ${{ !cancelled() && needs.prep.result == 'success' && needs.paths-filter.result == 'success' && needs.paths-filter.outputs.manylinux == 'true' && (needs.paths-filter.outputs.ci-image-base != 'true' || needs.devcontainer-ghcr.result == 'success' || needs.devcontainer-ghcr.result == 'skipped') }} + if: ${{ needs.prep.result == 'success' && needs.paths-filter.result == 'success' && needs.paths-filter.outputs.manylinux == 'true' }} strategy: fail-fast: false @@ -287,7 +226,7 @@ jobs: contents: read packages: read container: - image: ${{ needs.devcontainer-ghcr.result == 'success' && needs.devcontainer-ghcr.outputs.image_ref || matrix.host_container }} + image: ${{ matrix.host_container }} steps: - name: Harden the runner (Audit all outbound calls) @@ -298,19 +237,12 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} - - name: Bake and Push uses: docker/bake-action@59cb1203cd42bcefd40a1b6d73b589e48c86040e # v7.5.0 with: files: docker-bake.manylinux.hcl targets: ${{ matrix.targets }} - push: ${{ github.event_name != 'pull_request' }} + push: false set: | *.labels.org.opencontainers.image.title=${{ github.event.repository.name }} *.labels.org.opencontainers.image.description=${{ github.event.repository.description }} diff --git a/README.md b/README.md index 9544c1b..908cf2b 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,22 @@ Current WasmEdge snapshot: `512db9f513fff9facac396ac72f31748de638797` This repository owns the Dockerfiles, dependency scripts, Bake definitions, -and image-building workflow for reusable WasmEdge development environments. -The consolidated `.github/workflows/docker.yml` builds CI base, Ubuntu, -manylinux, and Alpine LLD dependency images. Static-build and legacy definitions -are retained, but CI does not build them or OpenWrt images. +and image-building workflows for reusable WasmEdge development environments. +The workflows separate CI-base publication from the remaining image builds: + +- `.github/workflows/devcontainer.yml` builds `Dockerfile.ci-image-base`, + publishes a multi-platform image to `ghcr.io/wasmedge/devcontainer`, and + smoke-tests the published digest on native AMD64 and ARM64 Ubuntu 26.04 + runners. It runs for relevant pull requests, pushes to `main`, and manual + dispatches. Pull requests publish candidate tags without updating `latest`. +- `.github/workflows/wasmedge-devcontainer.yml` builds Ubuntu, manylinux, and + Alpine LLD dependency images for relevant pull requests and pushes to `main`. + Ubuntu and manylinux jobs continue to use the existing Docker Hub CI-base + tags, independently of GHCR publication. This workflow does not log in to + Docker Hub or publish images; migration of these images to GHCR is deferred. + +Static-build and legacy definitions are retained, but CI does not build them +or OpenWrt images. ## Layout @@ -21,4 +33,4 @@ are retained, but CI does not build them or OpenWrt images. | `SHA256SUM.*` | Checksums used by the manylinux image definitions. | | `build-manylinux.sh` | Legacy manylinux image build helper. | | `scripts/` | Dockerfile-consumed dependency installers, build helpers, test data helpers, and patches, grouped by dependency family. | -| `.github/workflows/` | Consolidated image build/publication workflow (`docker.yml`) and repository lint workflow (`super-linter.yml`). | +| `.github/workflows/` | CI-base GHCR publication and validation (`devcontainer.yml`), remaining-image builds (`wasmedge-devcontainer.yml`), and repository lint (`super-linter.yml`). |