diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 000000000000..9e3bb5a472bd --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,16 @@ +# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause + +# Configuration for actionlint (https://github.com/rhysd/actionlint), run by pre-commit. +self-hosted-runner: + labels: + - gpu + - gpu-windows + - arm64 + - multi-gpu +config-variables: + - ACTIVE_RELEASE_BACKPORT_BRANCH + - NVIDIA_BACKPORT_FALLBACK_MODEL + - NVIDIA_BACKPORT_MODEL diff --git a/.github/actions/_lib/compute-deps-hash/action.yml b/.github/actions/_lib/compute-deps-hash/action.yml index 413421f54b99..9f8abf642d0d 100644 --- a/.github/actions/_lib/compute-deps-hash/action.yml +++ b/.github/actions/_lib/compute-deps-hash/action.yml @@ -7,8 +7,7 @@ name: 'Compute deps hash' description: > Compute the deps-cache hash for the Isaac Lab Docker build. Shared by the docker-build (local-store check) and ecr-build-push-pull (registry check) - actions so a local hit and a registry hit always agree on the same - `deps-` tag. Hashes the install-relevant files, resolved base image + actions. Hashes the install-relevant files, resolved base image digest, and target platform. inputs: @@ -50,12 +49,12 @@ runs: .dockerignore docker/docker-compose.yaml docker/scripts/install_carb_env_shim.sh + docker/patches docker/utils/volume_mounts.py + # Run by the Dockerfile's verify stage: a deps-cache hit serves an image verified against it. + docker/test/test_image_invariants.py source/isaaclab/isaaclab/cli tools/wheel_builder/uv-overrides.txt - # Pins the CI pytest deps layered onto the image after build, so a - # change to that list must invalidate the deps cache. - .github/actions/docker-build/action.yml ) deps_manifest_pattern='(setup\.py|pyproject\.toml|setup\.cfg|extension\.toml|requirements[^/]*\.txt|uv\.lock)$' diff --git a/.github/actions/_lib/setup-docker-config/action.yml b/.github/actions/_lib/setup-docker-config/action.yml index 0ec8e233f74f..e1384f542bfe 100644 --- a/.github/actions/_lib/setup-docker-config/action.yml +++ b/.github/actions/_lib/setup-docker-config/action.yml @@ -9,7 +9,7 @@ description: > log into nvcr.io. Shared by the docker-build and ecr-build-push-pull actions. Idempotent: re-invoking it in the same job reuses the existing config, and a base-image-ref already checked with that config is not probed again, so callers - (e.g. ecr-build-push-pull delegating to docker-build) don't need to coordinate. + (e.g. ecr-build-push-pull falling back to docker-build) don't need to coordinate. Reads NGC_API_KEY from the environment (optional; warns when missing). When base-image-ref names an nvcr.io image that the configured credentials are refused, falls back to anonymous access for that registry. @@ -33,7 +33,7 @@ runs: env: BASE_IMAGE_REF: ${{ inputs.base-image-ref }} STRIP_HELPER: ${{ github.action_path }}/strip_registry_auth.py - run: | + run: | # zizmor: ignore[github-env] -- writes runner-generated temp paths, never event data # The runner's credential helper backend is broken ("not implemented") # and causes docker login calls to fail unless we point DOCKER_CONFIG at # a temp config with credsStore disabled. The value is written to @@ -71,7 +71,7 @@ runs: exit 0 fi - # ecr-build-push-pull delegates to docker-build, so this action can run + # ecr-build-push-pull can fall back to docker-build, so this action can run # twice in one job with the same ref. The probes are network calls with # backoff, and the first run already settled the outcome, so a ref # checked with the current config is not probed again. diff --git a/.github/actions/_lib/test_performance_workflow.py b/.github/actions/_lib/test_performance_workflow.py index 8d033714624b..99f67dfee00f 100644 --- a/.github/actions/_lib/test_performance_workflow.py +++ b/.github/actions/_lib/test_performance_workflow.py @@ -95,37 +95,6 @@ def test_ci_activation_and_runner_selection() -> None: assert stopped.returncode != 0, "Unactivated PR explanation step exited successfully" -def test_parallel_baseline_route() -> None: - route = yaml.safe_load(_WORKFLOW.read_text())["jobs"]["performance-regression-route"]["steps"][0] - script = """ -const source = require('node:fs').readFileSync(0, 'utf8'); -const assert = require('node:assert/strict'); -const run = new (Object.getPrototypeOf(async function() {}).constructor)('github', 'context', source); -const context = {repo: {owner: 'owner', repo: 'lab'}, payload: {pull_request: {number: 42, head: {ref: 'feature'}}}}; -process.env.BASE_COMMIT = 'base'; -(async () => { - for (const [label, runCount, artifacts, artifactCount, expected] of [ - ['fresh', 1, [], 0, true], ['reusable on retry', 1, [{expired: false}], 1, false], - ['expired', 1, [{expired: true}], 1, true], ['partial run list', 2, [], 0, false], - ['partial artifact list', 1, [], 1, false], - ]) { - const actions = { - listWorkflowRuns: async ({branch}) => { - assert.equal(branch, 'feature'); - return {data: {workflow_runs: [{run_attempt: 2}], total_count: runCount}}; - }, - listArtifactsForRepo: async ({name}) => { - assert.match(name, /^performance-pr-baseline-42-base-[12]$/); - return {data: name.endsWith('-2') ? {artifacts, total_count: artifactCount} : {artifacts: [], total_count: 0}}; - }, - }; - assert.equal(await run({rest: {actions}}, context), expected, label); - } -})(); -""" - subprocess.run(["node", "-e", script], input=route["with"]["script"], text=True, check=True) - - def test_run_docker_ci_command_options(tmp_path: Path) -> None: workflow = yaml.safe_load(_RUN_CI_WORKFLOW.read_text(encoding="utf-8")) job = workflow["jobs"]["request-docker-ci"] diff --git a/.github/actions/_lib/test_registry_credential_fallback.py b/.github/actions/_lib/test_registry_credential_fallback.py index 40f0ec418f54..7b2f546be0e6 100644 --- a/.github/actions/_lib/test_registry_credential_fallback.py +++ b/.github/actions/_lib/test_registry_credential_fallback.py @@ -10,11 +10,11 @@ import importlib.util import json import os -import re import shlex import subprocess from pathlib import Path +import pytest import yaml _LIB_DIR = Path(__file__).resolve().parent @@ -26,6 +26,8 @@ _HUB = "https://index.docker.io/v1/" _DIGEST = "sha256:" + "a" * 64 +pytestmark = pytest.mark.pr + def _load_helper(): spec = importlib.util.spec_from_file_location("strip_registry_auth", _STRIP_HELPER) @@ -295,67 +297,39 @@ def test_successful_read_ignores_stderr_noise(tmp_path: Path) -> None: assert hashes[1] != hashes[2] -def test_dependency_cache(tmp_path: Path, subtests) -> None: - """Exercise the real cache/push shells with state left by an older base-side action.""" - action = yaml.safe_load((_LIB_DIR.parent / "ecr-build-push-pull/action.yml").read_text()) - steps = {step["name"]: step for step in action["runs"]["steps"]} - bin_dir = tmp_path / "bin" - trace = tmp_path / "docker-calls.log" - _write_stub_docker( - bin_dir, - 'if [ "$1 $2" = "manifest inspect" ]; then [ "$CACHE" = deps ]; exit $?; fi', - ) - for cache in ("exact", "deps", "miss"): - with subtests.test(dependency_cache=cache): - cache_path = tmp_path / cache - cache_path.mkdir(parents=True) - trace.unlink(missing_ok=True) - env = { - **os.environ, - "PATH": f"{bin_dir}:{os.environ['PATH']}", - "CACHE": cache, - "ECR_URL": "registry.example/lab", - "ECR_IMAGE": "registry.example/lab:PR", - "DEPS_ECR_IMAGE": "registry.example/lab:deps-BASE", - "PUSH_DEPS_IMAGE": "true", - "GITHUB_ENV": str(cache_path / "env"), - "GITHUB_OUTPUT": str(cache_path / "output"), - } - values = {"inputs.image-tag": "local:PR", "steps.deps-hash.outputs.hash": "PR"} - - def expand(text): - return re.sub(r"\$\{\{\s*([^}]+?)\s*}}", lambda match: values.get(match[1], ""), text) - - def run(body): - result = subprocess.run(["bash", "-e", "-c", expand(body)], env=env, capture_output=True, text=True) - assert result.returncode == 0, result.stderr - - if cache != "exact": - run(steps["Check deps cache"]["run"]) - for file, destination, prefix in (("env", env, ""), ("output", values, "steps.deps-cache.outputs.")): - path = cache_path / file - if path.exists(): - for line in path.read_text().splitlines(): - key, value = line.split("=", 1) - destination[prefix + key] = value - push = steps["Push deps tag"] - context = {**values, **{f"env.{key}": value for key, value in env.items()}} - condition = re.sub( - r"\b(?:env|steps)\.[\w.-]+", - lambda match: json.dumps(context.get(match[0], "")), - push["if"].strip().removeprefix("${{").removesuffix("}}"), - ) - enabled = subprocess.check_output(["node", "-p", f"Boolean({condition})"], text=True).strip() == "true" - if enabled: - env.update({key: expand(value) for key, value in push.get("env", {}).items()}) - run(push["run"]) - commands = trace.read_text().splitlines() if trace.exists() else [] - publications = [line for line in commands if line.startswith(("tag ", "push "))] - assert publications == ( - ["tag local:PR registry.example/lab:deps-PR", "push registry.example/lab:deps-PR"] - if cache == "miss" - else [] - ) +def test_dependency_cache(tmp_path: Path) -> None: + """A deps hit aliases the commit tag registry-side; a miss builds and publishes under both tags.""" + steps = {step["name"]: step for step in yaml.safe_load((_LIB_DIR.parent / "ecr-build-push-pull/action.yml").read_text())["runs"]["steps"]} + check = steps["Check deps cache"]["run"] + for cache in ("deps", "miss"): + out = tmp_path / cache / "output" + out.parent.mkdir() + bin_dir = tmp_path / cache / "bin" + _write_stub_docker(bin_dir, 'if [ "$1 $2 $3" = "buildx imagetools inspect" ]; then [ "$CACHE" = deps ]; exit $?; fi') + env = { + **os.environ, + "PATH": f"{bin_dir}:{os.environ['PATH']}", + "CACHE": cache, + "ECR_IMAGE": "registry.example/lab:PR", + "DEPS_IMAGE": "registry.example/lab:deps-HASH", + "GITHUB_OUTPUT": str(out), + } + subprocess.run(["bash", "-e", "-c", check], env=env, check=True, capture_output=True, text=True) + calls = (bin_dir.parent / "docker-calls.log").read_text().splitlines() + aliases = [line for line in calls if line.startswith("buildx imagetools create")] + outputs = dict(line.split("=", 1) for line in out.read_text().splitlines()) + assert outputs["image"] == "registry.example/lab:deps-HASH" + if cache == "deps": + assert aliases == ["buildx imagetools create -t registry.example/lab:PR registry.example/lab:deps-HASH"] + assert "miss" not in outputs + else: + assert aliases == [] + assert outputs["miss"] == "true" + + build = steps["Build and push"] + assert build["if"] == steps["Set up BuildKit"]["if"] == "steps.deps.outputs.miss == 'true'" + assert build["with"]["tags"].splitlines() == ["${{ steps.ecr.outputs.image }}", "${{ steps.deps.outputs.image }}"] + assert "push=true" in build["with"]["outputs"] _PYPROJECT = '[project]\nname = "isaaclab"\nversion = "1.0.0"\ndependencies = ["torch==2.10.0"]\n' diff --git a/.github/actions/docker-build/action.yml b/.github/actions/docker-build/action.yml index 16b985e21fb4..70233323ace0 100644 --- a/.github/actions/docker-build/action.yml +++ b/.github/actions/docker-build/action.yml @@ -3,8 +3,11 @@ # # SPDX-License-Identifier: BSD-3-Clause -name: 'Build Docker Image' -description: 'Builds a Docker image with IsaacSim and IsaacLab dependencies' +name: 'Build Docker Image Locally' +description: > + Builds an image in the runner's own Docker store, for runners without ECR (the ARM Spark). + A local `deps-` tag stands in for the registry deps cache: an image whose install + inputs are unchanged is retagged instead of rebuilt. inputs: image-tag: @@ -20,101 +23,43 @@ inputs: description: 'Path to Dockerfile' default: 'docker/Dockerfile.base' required: false - context-path: - description: 'Build context path' - default: '.' - required: false platform: description: 'Target platform for `docker buildx build --platform`.' default: 'linux/amd64' required: false - cache-from: - description: > - Optional value for `docker buildx build --cache-from`. Typically a - `type=registry,ref=` for cross-host layer cache. Leave empty for - pure local-only builds. - default: '' - required: false - cache-to: - description: > - Optional value for `docker buildx build --cache-to`. Pairs with - `cache-from` for registry-backed layer cache writes. - default: '' - required: false - deps-hash: - description: > - Pre-computed deps-hash to use for the local deps-tag check. When empty, - this action computes the hash itself via the `_lib/compute-deps-hash` - action. Set by callers (e.g. `ecr-build-push-pull`) that already compute - the hash for a registry-side check, to avoid recomputing here. + verify-target: + description: 'Dockerfile stage asserting invariants, built before the image is tagged' default: '' required: false evict-stale-cache: description: > - When 'true', evict `isaac-lab*:deps-*` tags older than 14 days at the - end of the build to bound disk growth on long-lived self-hosted - runners. Default 'false' β€” no implicit cleanup. + 'true' removes `isaac-lab*:deps-*` tags older than 14 days, bounding disk growth on a + long-lived runner. default: 'false' required: false runs: using: composite steps: - - ##### 1: Setup docker config + login to nvcr.io (optional) ##### - - name: Setup docker config and login to nvcr.io uses: ./.github/actions/_lib/setup-docker-config with: base-image-ref: ${{ inputs.isaacsim-base-image }}:${{ inputs.isaacsim-version }} - ##### 2: Host disk snapshot (pre) ##### - - - name: Host disk snapshot (pre) - shell: bash - run: | - set +e - docker_root=$(docker info --format '{{.DockerRootDir}}' 2>/dev/null || echo "/var/lib/docker") - deps_count=$(docker images --filter 'reference=isaac-lab*:deps-*' -q 2>/dev/null | wc -l) - commit_count=$(docker images --filter 'reference=isaac-lab*' -q 2>/dev/null | wc -l) - { - echo "## Disk snapshot (pre)" - echo '```' - echo "Filesystem:" - df -h / "${docker_root}" 2>/dev/null | sort -u - echo - echo "docker system df:" - docker system df - echo - echo "Tag counts:" - echo " isaac-lab* (commit + deps tags): ${commit_count}" - echo " isaac-lab*:deps-* (deps cache) : ${deps_count}" - echo - echo "Deps tags (newest first):" - docker images --filter 'reference=isaac-lab*:deps-*' \ - --format 'table {{.Repository}}:{{.Tag}}\t{{.Size}}\t{{.CreatedSince}}' 2>/dev/null \ - | head -20 - echo '```' - } | tee -a "$GITHUB_STEP_SUMMARY" - - ##### 3: Local exact-tag short-circuit ##### - - name: Check image locally id: local shell: bash + env: + IMAGE_TAG: ${{ inputs.image-tag }} run: | - if docker image inspect "${{ inputs.image-tag }}" >/dev/null 2>&1; then - echo "🟒 Image already in local docker store: ${{ inputs.image-tag }}" + if docker image inspect "${IMAGE_TAG}" >/dev/null 2>&1; then + echo "🟒 ${IMAGE_TAG} is already in the local Docker store" echo "hit=true" >> "$GITHUB_OUTPUT" - else - echo "πŸ”΅ Image not present locally, will check deps-cache / build" fi - ##### 4: Local deps-tag short-circuit ##### - - name: Compute deps hash id: deps-hash - if: steps.local.outputs.hit != 'true' && inputs.deps-hash == '' + if: steps.local.outputs.hit != 'true' uses: ./.github/actions/_lib/compute-deps-hash with: dockerfile-path: ${{ inputs.dockerfile-path }} @@ -122,169 +67,53 @@ runs: isaacsim-version: ${{ inputs.isaacsim-version }} platform: ${{ inputs.platform }} - - name: Check deps-tag locally - id: local-deps + # Builds in the daemon itself, so the image, layer cache and uv cache mount stay on the + # runner. zstd level 1 compresses the multi-GB venv layer several times faster than gzip. + - name: Build image if: steps.local.outputs.hit != 'true' shell: bash + env: + IMAGE_TAG: ${{ inputs.image-tag }} + DEPS_HASH: ${{ steps.deps-hash.outputs.hash }} + DOCKERFILE: ${{ inputs.dockerfile-path }} + PLATFORM: ${{ inputs.platform }} + VERIFY_TARGET: ${{ inputs.verify-target }} + BASE_IMAGE: ${{ inputs.isaacsim-base-image }} + BASE_VERSION: ${{ inputs.isaacsim-version }} run: | - DEPS_HASH="${{ inputs.deps-hash || steps.deps-hash.outputs.hash }}" - LOCAL_DEPS_TAG="$(echo "${{ inputs.image-tag }}" | cut -d: -f1):deps-${DEPS_HASH}" - - echo "πŸ”΅ Local deps tag: ${LOCAL_DEPS_TAG}" - echo "LOCAL_DEPS_TAG=${LOCAL_DEPS_TAG}" >> "$GITHUB_ENV" - - if docker image inspect "${LOCAL_DEPS_TAG}" >/dev/null 2>&1; then - echo "🟒 Local deps-cache HIT! Retagging as ${{ inputs.image-tag }}" - docker tag "${LOCAL_DEPS_TAG}" "${{ inputs.image-tag }}" - echo "hit=true" >> "$GITHUB_OUTPUT" - else - echo "🟠 Local deps-cache MISS (will build then tag for future hits)" + set -euo pipefail + DEPS_TAG="${IMAGE_TAG%%:*}:deps-${DEPS_HASH}" + if docker image inspect "${DEPS_TAG}" >/dev/null 2>&1; then + echo "🟒 Local deps cache hit: ${DEPS_TAG}" + docker tag "${DEPS_TAG}" "${IMAGE_TAG}" + exit 0 fi - - ##### 5: Full build ##### - - - name: Build image - id: build - if: > - steps.local.outputs.hit != 'true' && - steps.local-deps.outputs.hit != 'true' - shell: bash - run: | - BUILD_ARGS=( - --progress=plain - --platform "${{ inputs.platform }}" - -f "${{ inputs.dockerfile-path }}" - --build-arg "ISAACSIM_BASE_IMAGE_ARG=${{ inputs.isaacsim-base-image }}" - --build-arg "ISAACSIM_VERSION_ARG=${{ inputs.isaacsim-version }}" + home=/root + if [ "${DOCKERFILE}" = docker/Dockerfile.kitless ]; then home=/home/isaaclab; fi + # Explicit even where they equal the Dockerfile defaults: older release branches declare them without one. + args=( + --progress=plain --builder default --platform "${PLATFORM}" -f "${DOCKERFILE}" + --build-arg "ISAACSIM_BASE_IMAGE_ARG=${BASE_IMAGE}" + --build-arg "ISAACSIM_VERSION_ARG=${BASE_VERSION}" --build-arg "ISAACSIM_ROOT_PATH_ARG=/isaac-sim" --build-arg "ISAACLAB_PATH_ARG=/workspace/isaaclab" - --build-arg "DOCKER_USER_HOME_ARG=/root" - -t "${{ inputs.image-tag }}" + --build-arg "DOCKER_USER_HOME_ARG=${home}" ) - if [ -n "${{ inputs.cache-from }}" ]; then - BUILD_ARGS+=( --cache-from "${{ inputs.cache-from }}" ) - fi - if [ -n "${{ inputs.cache-to }}" ]; then - BUILD_ARGS+=( --cache-to "${{ inputs.cache-to }}" ) - fi - - # Registry cache export needs a docker-container builder, whose image must - # then be exported and loaded into the daemon. Callers without a registry - # cache (ARM, which has no ECR) build in the daemon itself instead, so the - # image, layer cache and uv cache mount stay on the runner. A containerd - # image store still compresses new layers; zstd level 1 is several times - # faster than the default gzip for the multi-GB venv layer. - if [ -n "${{ inputs.cache-from }}${{ inputs.cache-to }}" ]; then - BUILDER_NAME="docker-build-${{ github.run_id }}-${{ github.job }}" - docker buildx create --driver docker-container --name "${BUILDER_NAME}" \ - || true - trap 'docker buildx rm "${BUILDER_NAME}" || true' EXIT - BUILD_ARGS+=( --builder "${BUILDER_NAME}" --load ) - else - BUILD_ARGS+=( - --builder default - --provenance=false - --output "type=image,name=${{ inputs.image-tag }},compression=zstd,compression-level=1" - ) - fi - - echo "πŸ”΅ Building ${{ inputs.image-tag }}..." - docker buildx build "${BUILD_ARGS[@]}" "${{ inputs.context-path }}" - echo "was-built=true" >> "$GITHUB_OUTPUT" - - ##### 6: Layer the CI pytest harness onto the built image ##### - - # Kept out of the tracked Dockerfiles, which build local dev containers and - # ship via publish-images.yaml. Only on a real build; cache hits have it. - - - name: Layer CI test dependencies - if: steps.build.outputs.was-built == 'true' - shell: bash - run: | - set -euo pipefail - # Install as root, then restore the image's default user. Disable the - # build-time cache so it cannot leave root-owned files in the runtime - # user's uv cache when both users share HOME. - image_user="$(docker image inspect --format '{{.Config.User}}' "${{ inputs.image-tag }}")" - # Dockerfile on stdin (no context to stage). Quoted heredoc so the - # shell leaves ISAACLAB_PATH and IMAGE_USER for Docker to expand; the - # image tag is an action input, substituted before bash ever runs. - docker build --platform "${{ inputs.platform }}" \ - --build-arg "IMAGE_USER=${image_user:-root}" \ - -t "${{ inputs.image-tag }}" - <<'DOCKERFILE' - FROM ${{ inputs.image-tag }} - ARG IMAGE_USER - USER root - RUN uv pip install --no-cache --python ${VIRTUAL_ENV}/bin/python \ - pytest pytest-mock junitparser flaky "coverage>=7.6.1" - USER ${IMAGE_USER} - DOCKERFILE - - ##### 7: Tag built image with local deps-tag ##### - - # Runs only when a real build happened (not on cache hits). Populates the - # deps-tag so the next build with identical deps short-circuits at step 4. - - - name: Tag built image with local deps-tag - if: steps.build.outputs.was-built == 'true' - shell: bash - run: | - if [ -n "${LOCAL_DEPS_TAG:-}" ]; then - docker tag "${{ inputs.image-tag }}" "${LOCAL_DEPS_TAG}" - echo "🟒 Tagged local deps-cache: ${LOCAL_DEPS_TAG}" - else - echo "🟠 LOCAL_DEPS_TAG not set, skipping local deps-cache tag" + if [ -n "${VERIFY_TARGET}" ]; then + docker buildx build "${args[@]}" --target "${VERIFY_TARGET}" --output type=cacheonly . fi + docker buildx build "${args[@]}" --provenance=false \ + --output "type=image,\"name=${IMAGE_TAG},${DEPS_TAG}\",compression=zstd,compression-level=1" . - ##### 8: Evict stale local deps-cache tags (>14d) β€” opt-in ##### - - - name: Evict stale local deps-cache tags (>14d) + - name: Evict stale local deps-cache tags if: always() && inputs.evict-stale-cache == 'true' shell: bash run: | - set +e - TTL_DAYS=14 - cutoff=$(date -u -d "${TTL_DAYS} days ago" +%s) - evicted=0 - while IFS='|' read -r created tag; do - [ -z "$tag" ] && continue - created_epoch=$(date -d "$created" +%s 2>/dev/null) || continue - if [ "$created_epoch" -lt "$cutoff" ]; then - days_old=$(( (cutoff - created_epoch) / 86400 + TTL_DAYS )) - echo "🟠 Evicting deps tag (~${days_old}d old): ${tag}" - docker rmi -f "$tag" >/dev/null 2>&1 || true - evicted=$(( evicted + 1 )) - fi - done < <(docker images --filter 'reference=isaac-lab*:deps-*' \ - --format '{{.CreatedAt}}|{{.Repository}}:{{.Tag}}' 2>/dev/null) - echo "πŸ”΅ Evicted ${evicted} deps tag(s) older than ${TTL_DAYS}d" - - ##### 9: Host disk snapshot (post) ##### - - - name: Host disk snapshot (post) - if: always() - shell: bash - run: | - set +e - docker_root=$(docker info --format '{{.DockerRootDir}}' 2>/dev/null || echo "/var/lib/docker") - deps_count=$(docker images --filter 'reference=isaac-lab*:deps-*' -q 2>/dev/null | wc -l) - commit_count=$(docker images --filter 'reference=isaac-lab*' -q 2>/dev/null | wc -l) - { - echo "## Disk snapshot (post)" - echo '```' - echo "Filesystem:" - df -h / "${docker_root}" 2>/dev/null | sort -u - echo - echo "docker system df:" - docker system df - echo - echo "Tag counts:" - echo " isaac-lab* (commit + deps tags): ${commit_count}" - echo " isaac-lab*:deps-* (deps cache) : ${deps_count}" - echo - echo "Deps tags (newest first):" - docker images --filter 'reference=isaac-lab*:deps-*' \ - --format 'table {{.Repository}}:{{.Tag}}\t{{.Size}}\t{{.CreatedSince}}' 2>/dev/null \ - | head -20 - echo '```' - } | tee -a "$GITHUB_STEP_SUMMARY" + cutoff=$(date -u -d '14 days ago' +%s) + docker images --filter 'reference=isaac-lab*:deps-*' --format '{{.CreatedAt}}|{{.Repository}}:{{.Tag}}' | + while IFS='|' read -r created tag; do + if [ "$(date -d "${created% *}" +%s 2>/dev/null || echo "${cutoff}")" -lt "${cutoff}" ]; then + echo "🟠 Evicting ${tag}" + docker rmi "${tag}" >/dev/null || true + fi + done diff --git a/.github/actions/ecr-build-push-pull/README.md b/.github/actions/ecr-build-push-pull/README.md index 3b897ee0c913..d3cfe84a7279 100644 --- a/.github/actions/ecr-build-push-pull/README.md +++ b/.github/actions/ecr-build-push-pull/README.md @@ -1,9 +1,14 @@ # ecr-build-push-pull -Builds a Docker image and pushes it to ECR, or pulls it if the tag already exists. -ECR is also used as the BuildKit layer cache. +Makes an image tag exist in ECR, cheapest path first: -## Usage +1. **Commit tag exists**: nothing to do. +2. **Deps cache hit**: an image built from the same install inputs (`deps-`, see + `_lib/compute-deps-hash`) is aliased to the commit tag registry-side. Nothing is downloaded. + Test jobs bind-mount the checkout over the image's source, so the source baked into that + older image never runs. +3. **Miss**: BuildKit builds the image and pushes it straight to ECR under the commit and deps + tags, as zstd layers. ECR also holds the BuildKit layer cache (`cache-tag`). ```yaml - uses: ./.github/actions/ecr-build-push-pull @@ -13,25 +18,26 @@ ECR is also used as the BuildKit layer cache. isaacsim-version: 6.2.0 dockerfile-path: docker/Dockerfile.base cache-tag: cache-base - ecr-url: (optional, complete url for ECR storage) + verify-target: verify # optional + pull: 'true' # optional ``` -## Verifying a freshly built image +## Pulling -Pass `verify-test-path` to assert against the image before it is published: +Jobs that `docker run` the image pass `pull: 'true'`. The ECR login is removed when the action +ends, so later steps cannot pull it themselves. Build-only jobs leave `pull` unset: a cold pull of +the Isaac Sim based images takes minutes. -```yaml - verify-test-path: docker/test/test_image_invariants.py -``` +## Verifying before publishing -The tests run only on a full build, with `IMAGE_TAG` set, so the caller's job needs `uv` -(`astral-sh/setup-uv`). A failure fails the action with nothing pushed, so the next run -rebuilds rather than serving the bad image from the deps cache. Exact-tag and deps-cache hits skip -them: that image passed when it was built. +`verify-target` names a Dockerfile stage that asserts invariants inside the image (for +`Dockerfile.base`, the `verify` stage runs `docker/test/test_image_invariants.py`). It is built +before the push, so an image that fails it is never published, and a later deps-cache hit can only +ever serve a verified image. ## ECR URL resolution order 1. `ecr-url` input 2. `ECR_CACHE_URL` environment variable on the runner 3. SSM parameter `/github-runner//ecr-cache-url` -4. If none resolve, ECR is skipped and the image is built locally +4. If none resolve, the image is built in the local Docker store with `docker-build` diff --git a/.github/actions/ecr-build-push-pull/action.yml b/.github/actions/ecr-build-push-pull/action.yml index 2de0b9087e05..e294586b4617 100644 --- a/.github/actions/ecr-build-push-pull/action.yml +++ b/.github/actions/ecr-build-push-pull/action.yml @@ -5,9 +5,10 @@ name: 'ECR Build-Push-Pull' description: > - Builds a Docker image and pushes it to ECR, using ECR as the layer cache. - If the image already exists in ECR (same tag), pulls it instead of building. - Drop-in replacement for docker-build/action.yml with ECR-backed caching. + Makes `image-tag` exist in ECR, cheapest path first: the commit tag is already there; or an + image with the same dependency hash is, and is aliased registry-side; or BuildKit builds the + image and pushes it straight to ECR. With `pull: 'true'` the image is then pulled into the + local Docker store. Without an ECR URL, it builds locally with docker-build instead. inputs: image-tag: @@ -29,184 +30,97 @@ inputs: required: false ecr-url: description: > - ECR repository URL (e.g. "123456789.dkr.ecr.us-west-2.amazonaws.com/my-repo"). - Resolved in the following order: - 1. ecr-url input, if provided. - 2. ECR_CACHE_URL environment variable on the runner. - 3. SSM parameter /github-runner//ecr-cache-url. - 4. If still empty, ECR cache is skipped and the image is built locally. + ECR repository URL (e.g. "123456789.dkr.ecr.us-west-2.amazonaws.com/my-repo"). Falls back + to the runner's ECR_CACHE_URL, then to the SSM parameter /github-runner//ecr-cache-url. required: false default: '' cache-tag: description: Tag used for the ECR layer cache image (e.g. "cache-base", "cache-curobo"). required: false default: 'cache' - verify-test-path: + verify-target: description: > - Path to a test file or directory asserted against a freshly built image, before it is - tagged or pushed. Tests run with IMAGE_TAG set; a failure fails the action with nothing - published, so the next run rebuilds instead of inheriting the bad image from the cache. - - Not run on an exact-tag or deps-cache hit: those serve an image that already passed when it - was built. + Dockerfile stage that asserts invariants against the image (e.g. "verify"). Built before + the push, so an image that fails it is never published under the commit or deps tag. required: false default: '' - pull-on-deps-hit: + pull: description: > - Pull the image locally after a deps-cache hit. Needed by jobs that run - the image in later steps of the same job: the ECR login lives in a - temporary docker config that is removed when this action ends, so - steps after the action cannot pull. - - Opt-in, unlike the exact-tag hit in step 4b which always pulls: a - deps-cache hit is common on dependency-stable branches, so pulling - unconditionally would download a multi-gigabyte image for the callers - that only need the tag pushed. + 'true' pulls the image into the local Docker store, for jobs that `docker run` it. The ECR + login only lives until this action ends, so later steps cannot pull it themselves. required: false default: 'false' + +outputs: + image: + description: The image's ECR reference, empty when the runner has no ECR and it was built locally. + value: ${{ steps.ecr.outputs.image }} + runs: using: composite steps: - - ##### 1: Setup docker config + Login to nvcr.io ##### - - # Create a temp docker config with credsStore disabled before any login. - # The runner's credential store backend is broken ("not implemented") and - # causes all docker login calls to fail unless we bypass it upfront. - # The temp config is exported as DOCKER_CONFIG so all subsequent steps - # (including ECR login in step 3) inherit it automatically. - + # Points DOCKER_CONFIG at a temp config (the runner's credential store is broken) and logs into nvcr.io. - name: Setup docker config and login to nvcr.io uses: ./.github/actions/_lib/setup-docker-config with: base-image-ref: ${{ inputs.isaacsim-base-image }}:${{ inputs.isaacsim-version }} - ##### 2: Resolve ECR URL ##### - - # Tries: explicit input >> ECR_CACHE_URL env var >> SSM parameter on EC2. - # Exports ECR_URL to GITHUB_ENV and sets output `available`. - - - name: Resolve ECR URL - id: resolve-ecr + - name: Log into ECR + id: ecr shell: bash env: + IMAGE_TAG: ${{ inputs.image-tag }} INPUT_ECR_URL: ${{ inputs.ecr-url }} + CACHE_TAG: ${{ inputs.cache-tag }} run: | - ECR_URL="${INPUT_ECR_URL:-}" - - if [ -z "${ECR_URL}" ]; then - echo "πŸ”΅ ecr-url input not set, trying ECR_CACHE_URL env var..." - ECR_URL="${ECR_CACHE_URL:-}" - [ -n "${ECR_URL}" ] && echo "🟒 Using ECR_CACHE_URL env var: ${ECR_URL}" - fi - - if [ -z "${ECR_URL}" ]; then - echo "πŸ”΅ ECR_CACHE_URL env var not set, trying SSM..." - IMDS_TOKEN=$(curl -sf -X PUT "http://169.254.169.254/latest/api/token" \ - -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") || true - INSTANCE_ID=$(curl -sf -H "X-aws-ec2-metadata-token: ${IMDS_TOKEN}" \ - "http://169.254.169.254/latest/meta-data/instance-id") || true - INSTANCE_REGION=$(curl -sf -H "X-aws-ec2-metadata-token: ${IMDS_TOKEN}" \ - "http://169.254.169.254/latest/meta-data/placement/region") || true - - if [ -n "${INSTANCE_ID}" ]; then - ECR_URL=$(aws ssm get-parameter \ - --name "/github-runner/${INSTANCE_ID}/ecr-cache-url" \ - --region "${INSTANCE_REGION}" \ - --query 'Parameter.Value' --output text 2>/dev/null) || ECR_URL="" - if [ -n "${ECR_URL}" ]; then - echo "🟒 Resolved ECR URL from SSM (/github-runner/${INSTANCE_ID}/ecr-cache-url): ${ECR_URL}" - else - echo "πŸ”΅ SSM parameter not found for instance ${INSTANCE_ID}" - fi - else - echo "πŸ”΅ Not running on EC2 or IMDS unavailable, skipping SSM lookup" + set -euo pipefail + ecr_url="${INPUT_ECR_URL:-${ECR_CACHE_URL:-}}" + if [ -z "${ecr_url}" ]; then + token=$(curl -sf -X PUT http://169.254.169.254/latest/api/token \ + -H "X-aws-ec2-metadata-token-ttl-seconds: 300") || true + instance=$(curl -sf -H "X-aws-ec2-metadata-token: ${token}" \ + http://169.254.169.254/latest/meta-data/instance-id) || true + region=$(curl -sf -H "X-aws-ec2-metadata-token: ${token}" \ + http://169.254.169.254/latest/meta-data/placement/region) || true + if [ -n "${instance}" ]; then + ecr_url=$(aws ssm get-parameter --name "/github-runner/${instance}/ecr-cache-url" \ + --region "${region}" --query Parameter.Value --output text 2>/dev/null) || ecr_url="" fi fi - - if [ -n "${ECR_URL}" ]; then - echo "ECR_URL=${ECR_URL}" >> "$GITHUB_ENV" - echo "available=true" >> "$GITHUB_OUTPUT" - else - echo "🟠 ECR URL cannot be resolved. Building locally without ECR cache." + if [ -z "${ecr_url}" ]; then + echo "🟠 No ECR URL on this runner; building in the local Docker store instead" + exit 0 fi - ##### 3: Setup ECR authentication ##### - - # Validates the ECR URL, derives ECR image tags, and logs into ECR. - # DOCKER_CONFIG (with credsStore disabled) is already set by step 1. - - - name: Setup ECR authentication - if: steps.resolve-ecr.outputs.available == 'true' - shell: bash - run: | - REGISTRY=$(echo "${ECR_URL}" | cut -d'/' -f1) - AWS_REGION=$(echo "${REGISTRY}" | sed 's/.*\.dkr\.ecr\.\(.*\)\.amazonaws\.com/\1/') - - if [ "${AWS_REGION}" = "${REGISTRY}" ]; then - echo "πŸ”΄ Invalid ECR URL - cannot extract AWS region: ${ECR_URL}" - echo "πŸ”΄ Expected format: .dkr.ecr..amazonaws.com/" + registry="${ecr_url%%/*}" + region=$(sed -n 's/.*\.dkr\.ecr\.\(.*\)\.amazonaws\.com$/\1/p' <<< "${registry}") + if [ -z "${region}" ]; then + echo "::error::Not an ECR URL: ${ecr_url} (expected .dkr.ecr..amazonaws.com/)" exit 1 fi - - ECR_TAG=$(echo "${{ inputs.image-tag }}" | tr ':/' '--') - ECR_IMAGE="${ECR_URL}:${ECR_TAG}" - CACHE_IMAGE="${ECR_URL}:${{ inputs.cache-tag }}" - - echo "ECR_IMAGE=${ECR_IMAGE}" >> "$GITHUB_ENV" - echo "CACHE_IMAGE=${CACHE_IMAGE}" >> "$GITHUB_ENV" - - echo "πŸ”΅ Logging into ECR registry..." - aws ecr get-login-password --region "${AWS_REGION}" | \ - docker login --username AWS --password-stdin "${REGISTRY}" - - ##### 4: Check if exact image exists in ECR ##### - - # Lightweight manifest check - fetches only the image manifest (~KB), - # not the actual layers. If the exact per-commit image already exists - # in ECR, sets output `hit: true` to skip all subsequent build/push steps. - - - name: Check exact image in ECR - id: pull-exact - if: steps.resolve-ecr.outputs.available == 'true' + aws ecr get-login-password --region "${region}" | docker login --username AWS --password-stdin "${registry}" + { + echo "available=true" + echo "url=${ecr_url}" + echo "image=${ecr_url}:$(tr ':/' '--' <<< "${IMAGE_TAG}")" + echo "cache=${ecr_url}:${CACHE_TAG}" + } >> "$GITHUB_OUTPUT" + + - name: Check commit tag in ECR + id: exact + if: steps.ecr.outputs.available == 'true' shell: bash + env: + ECR_IMAGE: ${{ steps.ecr.outputs.image }} run: | - echo "πŸ”΅ Checking if commit-tagged image exists in ECR >> ${ECR_IMAGE}" - if docker manifest inspect "${ECR_IMAGE}" >/dev/null 2>&1; then - echo "🟒 Commit-tagged image found in ECR, skipping build!" + if docker buildx imagetools inspect "${ECR_IMAGE}" >/dev/null 2>&1; then + echo "🟒 ${ECR_IMAGE} already exists" echo "hit=true" >> "$GITHUB_OUTPUT" - else - echo "🟠 Image ${ECR_IMAGE} not found in ECR, will try deps-cache strategy..." fi - # Pull the image when the manifest check succeeded but the image is not - # available locally (test jobs need it for `docker run`). Build jobs - # that only push to ECR will already have the image or don't need it. - - name: Pull exact image from ECR - if: steps.pull-exact.outputs.hit == 'true' - shell: bash - run: | - if docker image inspect "${{ inputs.image-tag }}" >/dev/null 2>&1; then - echo "🟒 Image already available locally, skipping pull" - else - echo "πŸ”΅ Pulling ${ECR_IMAGE} from ECR..." - docker pull "${ECR_IMAGE}" - docker tag "${ECR_IMAGE}" "${{ inputs.image-tag }}" - echo "🟒 Image pulled and tagged as ${{ inputs.image-tag }}" - fi - - ##### 5: Check deps cache ##### - - # Hashes installation-relevant files + the base image digest to produce a stable - # deps- ECR tag. If the image exists in ECR, the build job succeeds - # immediately and test jobs pull the deps image with a source volume mount. - - # Edit DEPS_FILES or DEPS_MANIFEST_PATTERN when install - # inputs change (new packages, new manifests, etc.). - - name: Compute deps hash id: deps-hash - if: steps.resolve-ecr.outputs.available == 'true' && steps.pull-exact.outputs.hit != 'true' + if: steps.ecr.outputs.available == 'true' && steps.exact.outputs.hit != 'true' uses: ./.github/actions/_lib/compute-deps-hash with: dockerfile-path: ${{ inputs.dockerfile-path }} @@ -214,40 +128,120 @@ runs: isaacsim-version: ${{ inputs.isaacsim-version }} platform: ${{ inputs.platform }} + # The deps image is only ever published by the push below, after the verify target passed, so + # aliasing it serves an image that was verified when it was built. - name: Check deps cache - id: deps-cache - if: steps.resolve-ecr.outputs.available == 'true' && steps.pull-exact.outputs.hit != 'true' + id: deps + if: steps.ecr.outputs.available == 'true' && steps.exact.outputs.hit != 'true' shell: bash + env: + ECR_IMAGE: ${{ steps.ecr.outputs.image }} + DEPS_IMAGE: ${{ steps.ecr.outputs.url }}:deps-${{ steps.deps-hash.outputs.hash }} run: | - DEPS_HASH="${{ steps.deps-hash.outputs.hash }}" - DEPS_ECR_IMAGE="${ECR_URL}:deps-${DEPS_HASH}" - echo "πŸ”΅ Deps hash: ${DEPS_HASH}" - echo "πŸ”΅ Checking if deps image ${DEPS_ECR_IMAGE} exists in ECR..." - - # Lightweight manifest check - fetches only the image manifest (~KB), - # not the actual layers, so this completes in seconds. - if docker manifest inspect "${DEPS_ECR_IMAGE}" >/dev/null 2>&1; then - echo "🟒 Deps cache HIT!!! Image exists in ECR: ${DEPS_ECR_IMAGE}" - # Create a commit-tagged alias pointing to the same manifest (registry-side, - # no layer download). Test jobs will pull this tag normally. - echo "πŸ”΅ Tagging as commit image ${ECR_IMAGE}..." - docker buildx imagetools create -t "${ECR_IMAGE}" "${DEPS_ECR_IMAGE}" - echo "🟒 Tagged ${ECR_IMAGE} >> ${DEPS_ECR_IMAGE}" - echo "deps-cache-hit=true" >> "$GITHUB_OUTPUT" + set -euo pipefail + echo "image=${DEPS_IMAGE}" >> "$GITHUB_OUTPUT" + if docker buildx imagetools inspect "${DEPS_IMAGE}" >/dev/null 2>&1; then + echo "🟒 Deps cache hit: aliasing ${ECR_IMAGE} -> ${DEPS_IMAGE}" + docker buildx imagetools create -t "${ECR_IMAGE}" "${DEPS_IMAGE}" else - echo "🟠 Deps cache MISS 😿😿😿 (${DEPS_HASH}). Will build now. 🐒🐒🐒" - echo "publish-image=${DEPS_ECR_IMAGE}" >> "$GITHUB_OUTPUT" + echo "🟠 Deps cache miss: building ${DEPS_IMAGE}" + echo "miss=true" >> "$GITHUB_OUTPUT" fi - ##### 6: Full build (delegated to docker-build) ##### + # Explicit even where they equal the Dockerfile defaults: older release branches declare them without one. + # Dockerfile.kitless builds from ubuntu, so the Isaac Sim arguments only feed its deps hash. + - name: Compose build arguments + id: args + if: steps.deps.outputs.miss == 'true' + shell: bash + env: + DOCKERFILE: ${{ inputs.dockerfile-path }} + BASE_IMAGE: ${{ inputs.isaacsim-base-image }} + BASE_VERSION: ${{ inputs.isaacsim-version }} + run: | + home=/root + if [ "${DOCKERFILE}" = docker/Dockerfile.kitless ]; then home=/home/isaaclab; fi + { + echo "build-args<> "$GITHUB_OUTPUT" + + # Removed by the last step instead of the action's post-job cleanup, which would look for + # the builder in the temp DOCKER_CONFIG this action deletes and leak its container. + - name: Set up BuildKit + id: buildx + if: steps.deps.outputs.miss == 'true' + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + with: + driver: docker-container + cleanup: false - # Runs when neither the exact image nor the deps cache was available. - # docker-build does the actual buildx invocation; we pass ECR layer-cache - # refs and the ECR-prefixed tag so the push steps below have something to - # push. + - name: Verify image + if: steps.deps.outputs.miss == 'true' && inputs.verify-target != '' + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 + env: + DOCKER_BUILD_SUMMARY: 'false' + DOCKER_BUILD_RECORD_UPLOAD: 'false' + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ${{ inputs.dockerfile-path }} + platforms: ${{ inputs.platform }} + target: ${{ inputs.verify-target }} + build-args: ${{ steps.args.outputs.build-args }} + provenance: false + cache-from: type=registry,ref=${{ steps.ecr.outputs.cache }} + outputs: type=cacheonly + + # BuildKit pushes the layers itself: no `docker load` of a multi-GB tarball (about 9 minutes) + # and no second push. zstd, forced onto the Isaac Sim base layers too, decompresses faster than + # gzip on every pull; the cache reuses the image's blobs instead of uploading its own. + # Compression is not part of the deps hash: after changing it, change the hash too (e.g. by + # editing the Dockerfile), or deps-cache hits keep serving images with the old layers. + - name: Build and push + if: steps.deps.outputs.miss == 'true' + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 + env: + DOCKER_BUILD_SUMMARY: 'false' + DOCKER_BUILD_RECORD_UPLOAD: 'false' + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ${{ inputs.dockerfile-path }} + platforms: ${{ inputs.platform }} + build-args: ${{ steps.args.outputs.build-args }} + provenance: false + tags: | + ${{ steps.ecr.outputs.image }} + ${{ steps.deps.outputs.image }} + cache-from: type=registry,ref=${{ steps.ecr.outputs.cache }} + cache-to: type=registry,ref=${{ steps.ecr.outputs.cache }},mode=max,image-manifest=true,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true + outputs: type=image,push=true,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true + + - name: Pull image + if: steps.ecr.outputs.available == 'true' && inputs.pull == 'true' + shell: bash + env: + IMAGE_TAG: ${{ inputs.image-tag }} + ECR_IMAGE: ${{ steps.ecr.outputs.image }} + run: | + set -euo pipefail + if docker image inspect "${IMAGE_TAG}" >/dev/null 2>&1; then + echo "🟒 ${IMAGE_TAG} is already in the local Docker store" + exit 0 + fi + start=${SECONDS} + docker pull "${ECR_IMAGE}" + docker tag "${ECR_IMAGE}" "${IMAGE_TAG}" + echo "πŸ”΅ Pulled ${IMAGE_TAG} in $((SECONDS - start)) s" | tee -a "$GITHUB_STEP_SUMMARY" - - name: Full build - if: steps.pull-exact.outputs.hit != 'true' && steps.deps-cache.outputs.deps-cache-hit != 'true' + - name: Build locally + if: steps.ecr.outputs.available != 'true' uses: ./.github/actions/docker-build with: image-tag: ${{ inputs.image-tag }} @@ -255,95 +249,17 @@ runs: isaacsim-version: ${{ inputs.isaacsim-version }} dockerfile-path: ${{ inputs.dockerfile-path }} platform: ${{ inputs.platform }} - cache-from: ${{ steps.resolve-ecr.outputs.available == 'true' && format('type=registry,ref={0}', env.CACHE_IMAGE) || '' }} - cache-to: ${{ steps.resolve-ecr.outputs.available == 'true' && format('type=registry,ref={0},mode=max', env.CACHE_IMAGE) || '' }} - deps-hash: ${{ steps.deps-hash.outputs.hash }} - - # Assert against the image while it is only local: the push steps below publish under both - # the commit tag and the deps tag, and a deps-cache hit later serves that image without - # rebuilding it, so anything published unverified stays unverified. - - name: Verify freshly built image - if: > - inputs.verify-test-path != '' && - steps.pull-exact.outputs.hit != 'true' && - steps.deps-cache.outputs.deps-cache-hit != 'true' - shell: bash - env: - IMAGE_TAG: ${{ inputs.image-tag }} - TEST_PATH: ${{ inputs.verify-test-path }} - run: | - set -euo pipefail - uv run --no-project --with pytest \ - python -m pytest -q "${TEST_PATH}" + verify-target: ${{ inputs.verify-target }} - - name: Tag built image with ECR-prefixed name - if: > - steps.resolve-ecr.outputs.available == 'true' && - steps.pull-exact.outputs.hit != 'true' && - steps.deps-cache.outputs.deps-cache-hit != 'true' - shell: bash - run: | - docker tag "${{ inputs.image-tag }}" "${ECR_IMAGE}" - echo "🟒 Tagged ${ECR_IMAGE}" - - ##### 7: Push to ECR ##### - - # Pushes the per-commit ECR image after a successful full build. - # Skipped if the image was pulled in (4). - - - name: Push to ECR - if: > - steps.resolve-ecr.outputs.available == 'true' && - steps.pull-exact.outputs.hit != 'true' && - steps.deps-cache.outputs.deps-cache-hit != 'true' - shell: bash - run: | - echo "πŸ”΅ Pushing ${ECR_IMAGE} to ECR..." - docker push "${ECR_IMAGE}" - echo "🟒 Pushed ${ECR_IMAGE}" - - ##### 8: Push deps tag ##### - - # Tags the freshly built image as deps- so future runs with identical - # install inputs hit the fast path (step 5) instead of doing a full build. - - - name: Push deps tag - if: steps.deps-cache.outputs.publish-image != '' + - name: Remove BuildKit builder and docker credentials + if: always() shell: bash env: - DEPS_ECR_IMAGE: ${{ steps.deps-cache.outputs.publish-image }} - run: | - echo "πŸ”΅ Pushing deps image for future cache hits: ${DEPS_ECR_IMAGE}" - docker tag "${{ inputs.image-tag }}" "${DEPS_ECR_IMAGE}" - docker push "${DEPS_ECR_IMAGE}" - - ##### 8b: Pull deps-cached image for same-job use ##### - - # On a deps-cache hit step 5 only aliases the commit tag registry-side. - # Jobs that docker-run the image in later steps opt in here, while the - # temporary docker config (and its ECR login) still exists. - - - name: Pull deps-cached image - if: > - steps.deps-cache.outputs.deps-cache-hit == 'true' && - inputs.pull-on-deps-hit == 'true' - shell: bash + BUILDER: ${{ steps.buildx.outputs.name }} run: | - if docker image inspect "${{ inputs.image-tag }}" >/dev/null 2>&1; then - echo "🟒 Image already available locally, skipping pull" - else - echo "πŸ”΅ Pulling ${ECR_IMAGE} from ECR..." - docker pull "${ECR_IMAGE}" - docker tag "${ECR_IMAGE}" "${{ inputs.image-tag }}" - echo "🟒 Image pulled and tagged as ${{ inputs.image-tag }}" + if [ -n "${BUILDER}" ]; then + docker buildx rm "${BUILDER}" || true fi - - ##### 9: Cleanup docker config ##### - - - name: Cleanup docker config - if: always() - shell: bash - run: | - if [ -n "${DOCKER_CONFIG}" ] && [ -d "${DOCKER_CONFIG}" ]; then + if [ -n "${DOCKER_CONFIG:-}" ] && [ "${DOCKER_CONFIG}" = "${SETUP_DOCKER_CONFIG_OWNED:-}" ]; then rm -rf "${DOCKER_CONFIG}" fi diff --git a/.github/actions/multi-gpu/multi_gpu_shard_runner.sh b/.github/actions/multi-gpu/multi_gpu_shard_runner.sh index 899511e4b943..e2447de6bf8b 100755 --- a/.github/actions/multi-gpu/multi_gpu_shard_runner.sh +++ b/.github/actions/multi-gpu/multi_gpu_shard_runner.sh @@ -30,8 +30,7 @@ # 5. Waits on every shard before aggregating exit codes β€” a fast failure doesn't # tear down still-running siblings # -# The pytest deps (pytest, junitparser et al.) are baked into the image by -# .github/actions/docker-build, so this script no longer installs them. +# The pytest deps (pytest, junitparser et al.) come with the image's ``test`` extra. set +e # keep going on errors; per-shard exit codes are aggregated at the end cd /workspace/isaaclab diff --git a/.github/actions/ovrtx-shader-cache/action.yml b/.github/actions/ovrtx-shader-cache/action.yml index e679517c8c04..de0610013451 100644 --- a/.github/actions/ovrtx-shader-cache/action.yml +++ b/.github/actions/ovrtx-shader-cache/action.yml @@ -71,7 +71,7 @@ runs: - name: Restore OVRTX kit shader cache if: inputs.mode == 'restore' && inputs.trees != 'kitless' id: restore-kit - uses: actions/cache/restore@v4 + uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: ${{ steps.compute.outputs.kit-dir }} key: ${{ steps.compute.outputs.kit-key }} @@ -80,7 +80,7 @@ runs: - name: Restore OVRTX kitless shader cache if: inputs.mode == 'restore' && inputs.trees != 'kit' id: restore-kitless - uses: actions/cache/restore@v4 + uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: ${{ steps.compute.outputs.kitless-dir }} key: ${{ steps.compute.outputs.kitless-key }} @@ -124,7 +124,7 @@ runs: && steps.growth.outputs.kit-files != '' && steps.growth.outputs.kit-files != '0' && steps.growth.outputs.kit-changed == 'true' - uses: actions/cache/save@v4 + uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: ${{ steps.compute.outputs.kit-dir }} key: ${{ steps.compute.outputs.kit-key }} @@ -135,7 +135,7 @@ runs: && steps.growth.outputs.kitless-files != '' && steps.growth.outputs.kitless-files != '0' && steps.growth.outputs.kitless-changed == 'true' - uses: actions/cache/save@v4 + uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: ${{ steps.compute.outputs.kitless-dir }} key: ${{ steps.compute.outputs.kitless-key }} diff --git a/.github/actions/resolve-ov-pins/action.yml b/.github/actions/resolve-ov-pins/action.yml index cbae6b6df477..db52267bf6c5 100644 --- a/.github/actions/resolve-ov-pins/action.yml +++ b/.github/actions/resolve-ov-pins/action.yml @@ -5,11 +5,8 @@ name: 'Resolve OV runtime pins' description: > - Reads the OVRTX / OVPhysX version specifiers from [tool.isaaclab.versions] in - the repository's pyproject.toml. CI installs these packages through a generic - pip-package input, so this keeps the installed versions bound to the single - source of truth instead of hardcoding ranges in the workflow. - NOTE: The calling job must check out the code before using this action. + Reads the OVRTX and OVPhysX requirement specifiers from [tool.isaaclab.versions] in pyproject.toml, so the + workflows install the versions pinned there. The calling job checks out the code first. outputs: ovrtx: @@ -22,20 +19,18 @@ outputs: runs: using: composite steps: - - name: Set up Python - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 + - name: Set up uv + uses: astral-sh/setup-uv@2a39bcff78b189a5800d31cfcf0205c7a3e8381e # v10.4.1 with: - python-version: "3.12" + enable-cache: false - name: Resolve pins from pyproject id: resolve shell: bash run: | set -euo pipefail - # Capture first, write second: a missing/renamed key (or a moved section) must - # fail the step with a clear error, never leave $GITHUB_OUTPUT with a partial or - # empty value that would silently reintroduce an unconstrained ``pip install ovrtx``. - pins="$(python3 <<'PY' + # Capture first: a missing key must fail here, not leave an empty pin that installs any ovrtx. + pins="$(uv run --no-project --python 3.12 python - <<'PY' import sys import tomllib @@ -43,8 +38,7 @@ runs: vals = tomllib.load(f).get("tool", {}).get("isaaclab", {}).get("versions", {}) def spec(pkg: str) -> str: - # Mirror pyproject's convention: exact versions map to ``pkg==x.y.z``, - # range specs (">=...", "<...") map to ``pkg>=...``. + # An exact version ("1.2.3") or a range (">=1.2,<2"). if not vals.get(pkg): sys.exit(f"[tool.isaaclab.versions] is missing a value for required key '{pkg}'") value = vals[pkg] diff --git a/.github/actions/run-package-tests/action.yml b/.github/actions/run-package-tests/action.yml index 1a3a30619921..99f3f4bd719b 100644 --- a/.github/actions/run-package-tests/action.yml +++ b/.github/actions/run-package-tests/action.yml @@ -5,9 +5,8 @@ name: 'Run Package Tests' description: > - Pulls the Docker image from ECR, runs pytest inside the container, uploads - results as an artifact, and fails fork PRs on test failures. - NOTE: The calling job must check out the code before using this action. + Pulls the CI image, runs the selected tests in it with tools/conftest.py, uploads the results, and fails + the job when a test failed. The calling job checks out the code first. inputs: image-tag: @@ -28,7 +27,9 @@ inputs: default: 'cache-base' required: false ci-marker: - description: 'Optional pytest -m marker expression applied to every test file (e.g. arm_ci)' + description: >- + pytest -m expression applied to every test file: a tier of TIER_MARKERS in tools/_selection.py, or e.g. "arm_ci". + Files none of whose tests can match are not started at all (see tools/_selection.py). default: '' required: false platform: @@ -56,9 +57,8 @@ inputs: required: false test-jobs: description: >- - Number of test-file slots tools/conftest.py runs at once. Each file still runs in - its own pytest process; files listed in tools/test_settings.py PYTEST_WORKERS split - across several slots with pytest-xdist. Empty or 1 runs files one by one. + Number of test-file slots tools/conftest.py runs at once (see tools/test_settings.py for files that + take several slots). Empty or 1 runs files one by one. default: '' required: false shard-index: @@ -69,14 +69,6 @@ inputs: description: 'Total number of shards' default: '' required: false - curobo-only: - description: 'Run only cuRobo and SkillGen tests' - default: 'false' - required: false - quarantined-only: - description: 'Run only quarantined tests' - default: 'false' - required: false include-files: description: 'Comma-separated list of specific test files to include' default: '' @@ -143,6 +135,12 @@ inputs: description: 'Visualizer slice used when standalone-script-scope is set; default launches without --viz' default: 'default' required: false + allow-empty-selection: + description: >- + 'true' lets the run select zero tests (e.g. a package with no tests in the nightly tier). Otherwise + tools/conftest.py fails a run that tested nothing, so a stale filter or -k expression cannot go green. + default: 'false' + required: false standalone-script-runtime-group: description: 'Run Kit-dependent or non-Kit standalone script cases' default: '' @@ -164,45 +162,27 @@ outputs: runs: using: composite steps: - # Display some details on AWS instance we're running on - - name: AWS Instance Info - shell: bash - run: | - # get instance ID for debugging purposes (if running on EC2) - IMDS_TOKEN=$(curl -sf -X PUT "http://169.254.169.254/latest/api/token" \ - -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") || true - if [ -n "$IMDS_TOKEN" ]; then - INSTANCE_ID=$(curl -sf -H "X-aws-ec2-metadata-token: ${IMDS_TOKEN}" \ - "http://169.254.169.254/latest/meta-data/instance-id") || true - INSTANCE_REGION=$(curl -sf -H "X-aws-ec2-metadata-token: ${IMDS_TOKEN}" \ - "http://169.254.169.254/latest/meta-data/placement/region") || true - INSTANCE_TYPE=$(curl -sf -H "X-aws-ec2-metadata-token: ${IMDS_TOKEN}" \ - "http://169.254.169.254/latest/meta-data/instance-type") || true - echo "βšͺ Instance ID: ${INSTANCE_ID:-Not running on EC2}" - echo "βšͺ Instance Region: ${INSTANCE_REGION:-Not running on EC2}" - echo "βšͺ Instance Type: ${INSTANCE_TYPE:-Not running on EC2}" - echo "βšͺ Connect: https://${INSTANCE_REGION}.console.aws.amazon.com/ec2-instance-connect/ssh/home?region=${INSTANCE_REGION}&connType=standard&instanceId=${INSTANCE_ID}&osUser=ubuntu&sshPort=22&addressFamily=ipv4" - else - echo "🟠 Could not obtain IMDS token, probably not running on EC2" - fi - - - name: Prepare Docker disk space + # A reused runner keeps earlier images, so a pull only fetches the layers that changed. Prune + # only when the disk is nearly full: an age-based prune deletes a still-current deps image, + # which keeps its original build date, and forces a full re-pull. A stopped container pins + # this job's image, which a runner without ECR (the ARM Spark) has just built locally. + - name: Free Docker disk space if needed shell: bash env: - CONTAINER_NAME: ${{ inputs.container-name }} - ISAACSIM_BASE_IMAGE: ${{ inputs.isaacsim-base-image }} - ISAACSIM_VERSION: ${{ inputs.isaacsim-version }} + IMAGE_TAG: ${{ inputs.image-tag }} run: | - bash .github/actions/run-package-tests/cleanup_docker_storage.sh \ - "${ISAACSIM_BASE_IMAGE}:${ISAACSIM_VERSION}" \ - "isaacsim-pin-${CONTAINER_NAME}-${{ github.run_id }}-${{ github.run_attempt }}-pre" \ - "pre-test-cleanup" \ - "true" - - - name: Record pull start time - id: pull-start - shell: bash - run: echo "time=$(date +%s)" >> "$GITHUB_OUTPUT" + root="$(docker info --format '{{.DockerRootDir}}')" + used=$(df --output=pcent "${root}" | tail -n1 | tr -dc 0-9) + echo "Docker storage is ${used}% full" + if [ "${used}" -ge 80 ]; then + docker container prune --force + pin=$(docker create --pull=never "${IMAGE_TAG}" true 2>/dev/null || true) + docker image prune --all --force + docker builder prune --all --force + docker volume prune --force + [ -z "${pin}" ] || docker rm "${pin}" >/dev/null + df -h "${root}" + fi - name: Pull image from ECR uses: ./.github/actions/ecr-build-push-pull @@ -213,19 +193,7 @@ runs: dockerfile-path: ${{ inputs.dockerfile-path }} cache-tag: ${{ inputs.cache-tag }} platform: ${{ inputs.platform }} - - - name: Report pull duration - if: always() - shell: bash - run: | - start_time="${{ steps.pull-start.outputs.time }}" - if [ -z "$start_time" ]; then - echo "🟠 Could not calculate pull duration (start time not recorded)" >> "$GITHUB_STEP_SUMMARY" - exit 0 - fi - elapsed=$(( $(date +%s) - start_time )) - printf "πŸ”΅ Image pull took %dm %ds\n" $((elapsed/60)) $((elapsed%60)) - echo "πŸ”΅ Docker Image Pulled in ${elapsed}s" >> "$GITHUB_STEP_SUMMARY" + pull: 'true' - name: Resolve Warp cache key if: inputs.warp-cache != '' @@ -238,7 +206,7 @@ runs: - name: Restore Warp kernel cache if: inputs.warp-cache != '' id: warp-cache-restore - uses: actions/cache/restore@v4 + uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: ${{ steps.warp-cache-key.outputs.host-dir }} key: ${{ steps.warp-cache-key.outputs.key }} @@ -252,7 +220,7 @@ runs: MATCHED_KEY: ${{ steps.warp-cache-restore.outputs.cache-matched-key }} COLLECTION: ${{ steps.warp-cache-key.outputs.collection }} CACHE_MODE: ${{ inputs.warp-cache }} - run: | + run: | # zizmor: ignore[github-env] -- writes cache bookkeeping, never event data set -euo pipefail mkdir -p "$HOST_DIR" if [ ! -w "$HOST_DIR" ]; then @@ -359,8 +327,6 @@ runs: test-jobs: ${{ inputs.test-jobs }} shard-index: ${{ inputs.shard-index }} shard-count: ${{ inputs.shard-count }} - curobo-only: ${{ inputs.curobo-only }} - quarantined-only: ${{ inputs.quarantined-only }} include-files: ${{ inputs.include-files }} test-node-ids-file: ${{ inputs.test-node-ids-file }} test-node-ids-key: ${{ inputs.test-node-ids-key }} @@ -376,20 +342,21 @@ runs: standalone-script-scope: ${{ inputs.standalone-script-scope }} standalone-script-visualizer: ${{ inputs.standalone-script-visualizer }} standalone-script-runtime-group: ${{ inputs.standalone-script-runtime-group }} + allow-empty-selection: ${{ inputs.allow-empty-selection }} + # run-tests records failures in the report rather than its exit code. - name: Check Test Results if: always() shell: bash env: RESULT_FILE: "${{ inputs.result-file != '' && inputs.result-file || format('{0}-report.xml', github.job) }}" run: | - if [ -f "reports/$RESULT_FILE" ]; then - if grep -qE 'failures="[1-9][0-9]*"' "reports/$RESULT_FILE" || grep -qE 'errors="[1-9][0-9]*"' "reports/$RESULT_FILE"; then - echo "Tests failed for PR from fork. The test report is in the logs. Failing the job." - exit 1 - fi - else - echo "No test results file found. This might indicate test execution failed." + if [ ! -f "reports/$RESULT_FILE" ]; then + echo "::error::No test report: the test run did not finish." + exit 1 + fi + if grep -qE '(failures|errors)="[1-9][0-9]*"' "reports/$RESULT_FILE"; then + echo "::error::Tests failed; see the test summary and the report artifact." exit 1 fi @@ -457,7 +424,7 @@ runs: # mid-write on is never published. - name: Save Warp kernel cache if: '!cancelled() && inputs.warp-cache == ''save'' && steps.warp-cache-growth.outputs.empty != ''true'' && steps.warp-cache-growth.outputs.changed == ''true''' - uses: actions/cache/save@v4 + uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: ${{ steps.warp-cache-key.outputs.host-dir }} key: ${{ steps.warp-cache-key.outputs.key }} @@ -487,29 +454,6 @@ runs: - name: Cleanup wheelhouse artifacts if: always() && steps.extract-wheelhouse.outputs.wheelhouse_host_dir != '' shell: bash - run: rm -rf "${{ steps.extract-wheelhouse.outputs.wheelhouse_host_dir }}" - - - name: Kill container on cancellation - if: cancelled() - shell: bash - env: - CONTAINER_NAME: ${{ inputs.container-name }} - run: | - CONTAINER="${CONTAINER_NAME}-${{ github.run_id }}-${{ github.run_attempt }}" - echo "🟠 Workflow cancelled, force-killing container ${CONTAINER}..." - docker kill "${CONTAINER}" 2>/dev/null || true - docker rm -f "${CONTAINER}" 2>/dev/null || true - - - name: Cleanup old Docker images - if: always() - shell: bash env: - CONTAINER_NAME: ${{ inputs.container-name }} - ISAACSIM_BASE_IMAGE: ${{ inputs.isaacsim-base-image }} - ISAACSIM_VERSION: ${{ inputs.isaacsim-version }} - run: | - bash .github/actions/run-package-tests/cleanup_docker_storage.sh \ - "${ISAACSIM_BASE_IMAGE}:${ISAACSIM_VERSION}" \ - "isaacsim-pin-${CONTAINER_NAME}-${{ github.run_id }}-${{ github.run_attempt }}-post" \ - "post-job-cleanup" \ - "false" + WHEELHOUSE_HOST_DIR: ${{ steps.extract-wheelhouse.outputs.wheelhouse_host_dir }} + run: rm -rf "${WHEELHOUSE_HOST_DIR}" diff --git a/.github/actions/run-package-tests/cleanup_docker_storage.sh b/.github/actions/run-package-tests/cleanup_docker_storage.sh deleted file mode 100755 index c9ce5dc7822c..000000000000 --- a/.github/actions/run-package-tests/cleanup_docker_storage.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). -# All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause - -set -u - -ISAACSIM_IMAGE="${1:-}" -ISAACSIM_IMAGE_PIN_CONTAINER="${2:-isaacsim-pin-run-package-tests}" -CLEANUP_CONTEXT="${3:-docker-cleanup}" -FAIL_IF_STILL_HIGH="${4:-false}" - -DOCKER_STORAGE_PATH="${DOCKER_STORAGE_PATH:-/var/lib/docker}" -DOCKER_CLEANUP_THRESHOLD_PERCENT="${DOCKER_CLEANUP_THRESHOLD_PERCENT:-85}" -DOCKER_AGGRESSIVE_PRUNE_UNTIL="${DOCKER_AGGRESSIVE_PRUNE_UNTIL:-24h}" -DOCKER_CONSERVATIVE_PRUNE_UNTIL="${DOCKER_CONSERVATIVE_PRUNE_UNTIL:-72h}" - -get_docker_storage_usage_percent() { - df -P "${DOCKER_STORAGE_PATH}" 2>/dev/null | awk 'NR == 2 { gsub("%", "", $5); print $5 }' -} - -resolve_docker_storage_path() { - local docker_root_dir - docker_root_dir="$(docker info --format '{{.DockerRootDir}}' 2>/dev/null || true)" - if [ -n "${docker_root_dir}" ]; then - DOCKER_STORAGE_PATH="${docker_root_dir}" - echo "[${CLEANUP_CONTEXT}] Using Docker root from docker info: ${DOCKER_STORAGE_PATH}" - return 0 - fi - - echo "[${CLEANUP_CONTEXT}] Could not determine Docker storage path from ${DOCKER_STORAGE_PATH} or docker info." >&2 - return 1 -} - -print_docker_storage_usage() { - echo "[${CLEANUP_CONTEXT}] Docker storage usage:" - df -h "${DOCKER_STORAGE_PATH}" || true - docker system df || true -} - -pin_isaacsim_image_if_present() { - if [ -z "${ISAACSIM_IMAGE}" ]; then - echo "[${CLEANUP_CONTEXT}] No IsaacSim base image provided; skipping image pin." - return - fi - - if docker image inspect "${ISAACSIM_IMAGE}" >/dev/null 2>&1; then - echo "[${CLEANUP_CONTEXT}] Pinning IsaacSim base image: ${ISAACSIM_IMAGE}" - docker create --name "${ISAACSIM_IMAGE_PIN_CONTAINER}" "${ISAACSIM_IMAGE}" true >/dev/null 2>&1 || true - else - echo "[${CLEANUP_CONTEXT}] IsaacSim base image is not present locally; skipping image pin." - fi -} - -remove_isaacsim_image_pin() { - docker rm "${ISAACSIM_IMAGE_PIN_CONTAINER}" >/dev/null 2>&1 || true -} - -run_volume_cleanup() { - # Anonymous volumes left behind by test containers are referenced by nothing - # once the container is gone, and no image or builder prune reclaims them, so - # they accumulate for the life of the runner. A stopped container still counts - # as a reference, so this runs after container pruning to also catch the - # volumes that prune releases. - echo "[${CLEANUP_CONTEXT}] Removing Docker volumes no container is using." - docker volume prune -f || true -} - -run_conservative_cleanup() { - echo "[${CLEANUP_CONTEXT}] Running conservative Docker cleanup." - echo "[${CLEANUP_CONTEXT}] Removing Docker images older than ${DOCKER_CONSERVATIVE_PRUNE_UNTIL}." - docker image prune -a -f --filter "until=${DOCKER_CONSERVATIVE_PRUNE_UNTIL}" || true -} - -run_aggressive_cleanup() { - echo "[${CLEANUP_CONTEXT}] Running aggressive Docker cleanup." - echo "[${CLEANUP_CONTEXT}] Removing stopped Docker containers." - docker container prune -f --filter "until=${DOCKER_AGGRESSIVE_PRUNE_UNTIL}" || true - - echo "[${CLEANUP_CONTEXT}] Removing unused Docker builder cache older than ${DOCKER_AGGRESSIVE_PRUNE_UNTIL}." - docker builder prune -a -f --filter "until=${DOCKER_AGGRESSIVE_PRUNE_UNTIL}" || true - - echo "[${CLEANUP_CONTEXT}] Removing Docker images older than ${DOCKER_AGGRESSIVE_PRUNE_UNTIL}." - docker image prune -a -f --filter "until=${DOCKER_AGGRESSIVE_PRUNE_UNTIL}" || true -} - -main() { - echo "[${CLEANUP_CONTEXT}] Checking Docker storage before cleanup." - - local usage_percent - usage_percent="$(get_docker_storage_usage_percent)" - if [ -z "${usage_percent}" ]; then - resolve_docker_storage_path || true - usage_percent="$(get_docker_storage_usage_percent)" - fi - - print_docker_storage_usage - - if [ -z "${usage_percent}" ]; then - echo "[${CLEANUP_CONTEXT}] Could not determine Docker storage usage; running conservative cleanup." - pin_isaacsim_image_if_present - trap remove_isaacsim_image_pin EXIT - run_conservative_cleanup - run_volume_cleanup - print_docker_storage_usage - if [ "${FAIL_IF_STILL_HIGH}" = "true" ]; then - echo "::error::Could not determine Docker storage usage after cleanup. The self-hosted runner needs a measurable Docker storage path before tests can run." >&2 - return 1 - fi - return 0 - fi - - pin_isaacsim_image_if_present - trap remove_isaacsim_image_pin EXIT - - if [ "${usage_percent}" -ge "${DOCKER_CLEANUP_THRESHOLD_PERCENT}" ]; then - echo "[${CLEANUP_CONTEXT}] Docker storage is at ${usage_percent}%, meeting the ${DOCKER_CLEANUP_THRESHOLD_PERCENT}% threshold." - run_aggressive_cleanup - else - echo "[${CLEANUP_CONTEXT}] Docker storage is at ${usage_percent}%, below the ${DOCKER_CLEANUP_THRESHOLD_PERCENT}% threshold." - run_conservative_cleanup - fi - - run_volume_cleanup - - echo "[${CLEANUP_CONTEXT}] Docker storage after cleanup." - print_docker_storage_usage - - local final_usage_percent - final_usage_percent="$(get_docker_storage_usage_percent)" - if [ "${FAIL_IF_STILL_HIGH}" = "true" ] \ - && [ -n "${final_usage_percent}" ] \ - && [ "${final_usage_percent}" -ge "${DOCKER_CLEANUP_THRESHOLD_PERCENT}" ]; then - echo "::error::Docker storage remains at ${final_usage_percent}% after cleanup. The self-hosted runner needs more free Docker storage before tests can run." >&2 - return 1 - fi -} - -main "$@" diff --git a/.github/actions/run-package-tests/test_cleanup_docker_storage.py b/.github/actions/run-package-tests/test_cleanup_docker_storage.py deleted file mode 100644 index 737376867b76..000000000000 --- a/.github/actions/run-package-tests/test_cleanup_docker_storage.py +++ /dev/null @@ -1,223 +0,0 @@ -# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). -# All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause - -"""Tests for CI Docker storage cleanup helpers.""" - -from __future__ import annotations - -import os -import subprocess -from pathlib import Path - -_ACTION_DIR = Path(__file__).resolve().parent -_REPO_ROOT = _ACTION_DIR.parents[2] -_ACTION_PATH = _ACTION_DIR / "action.yml" -_SCRIPT_PATH = _ACTION_DIR / "cleanup_docker_storage.sh" - - -def _write_fake_df( - bin_dir: Path, first_usage: int, final_usage: int, failed_path: str | None = None, fallback_path: str | None = None -) -> None: - count_file = bin_dir / "df-count" - count_file.write_text("0", encoding="utf-8") - script = bin_dir / "df" - script.write_text( - f"""#!/usr/bin/env bash -set -euo pipefail - -path="${{2:-}}" -if [ -n "{failed_path or ""}" ] && [ "$path" = "{failed_path or ""}" ]; then - exit 1 -fi -if [ -n "{fallback_path or ""}" ] && [ "$path" = "{fallback_path or ""}" ]; then - : -elif [ -n "{fallback_path or ""}" ]; then - exit 1 -fi - -if [ "${{1:-}}" = "-P" ]; then - count=$(cat "{count_file}") - if [ "$count" -eq 0 ]; then - usage="{first_usage}" - else - usage="{final_usage}" - fi - echo "$((count + 1))" > "{count_file}" - echo "Filesystem 1024-blocks Used Available Capacity Mounted on" - echo "/dev/test 100 90 10 ${{usage}}% /var/lib/docker" -else - echo "Filesystem Size Used Avail Use% Mounted on" - echo "/dev/test 100G 90G 10G {first_usage}% /var/lib/docker" -fi -""", - encoding="utf-8", - ) - script.chmod(0o755) - - -def _write_fake_docker(bin_dir: Path, docker_root_dir: str = "/var/lib/docker") -> Path: - log_path = bin_dir / "docker.log" - script = bin_dir / "docker" - script.write_text( - f"""#!/usr/bin/env bash -set -euo pipefail - -printf '%s\\n' "$*" >> "{log_path}" -if [ "${{1:-}}" = "info" ] && [ "${{2:-}}" = "--format" ]; then - if [ -z "{docker_root_dir}" ]; then - exit 1 - fi - echo "{docker_root_dir}" - exit 0 -fi -if [ "${{1:-}}" = "image" ] && [ "${{2:-}}" = "inspect" ]; then - exit 0 -fi -exit 0 -""", - encoding="utf-8", - ) - script.chmod(0o755) - return log_path - - -def _run_cleanup( - tmp_path: Path, - first_usage: int, - final_usage: int, - failed_path: str | None = None, - docker_root_dir: str = "/var/lib/docker", -) -> subprocess.CompletedProcess[str]: - bin_dir = tmp_path / "bin" - bin_dir.mkdir() - _write_fake_df(bin_dir, first_usage, final_usage, failed_path=failed_path, fallback_path=docker_root_dir) - _write_fake_docker(bin_dir, docker_root_dir=docker_root_dir) - - env = os.environ.copy() - env["PATH"] = f"{bin_dir}{os.pathsep}{env['PATH']}" - env["DOCKER_STORAGE_PATH"] = "/var/lib/docker" - env["DOCKER_CLEANUP_THRESHOLD_PERCENT"] = "85" - - return subprocess.run( - [ - "bash", - str(_SCRIPT_PATH), - "nvcr.io/nvidian/isaac-sim:latest-develop", - "isaacsim-pin-test", - "test-cleanup", - "true", - ], - cwd=_REPO_ROOT, - env=env, - check=False, - capture_output=True, - text=True, - ) - - -def test_cleanup_uses_aggressive_pruning_when_docker_storage_exceeds_threshold(tmp_path: Path): - result = _run_cleanup(tmp_path, first_usage=91, final_usage=70) - - assert result.returncode == 0, result.stderr - docker_log = (tmp_path / "bin" / "docker.log").read_text(encoding="utf-8") - assert "container prune -f --filter until=24h" in docker_log - assert "builder prune -a -f --filter until=24h" in docker_log - assert "image prune -a -f --filter until=24h" in docker_log - - -def test_cleanup_keeps_conservative_image_pruning_below_threshold(tmp_path: Path): - result = _run_cleanup(tmp_path, first_usage=70, final_usage=70) - - assert result.returncode == 0, result.stderr - docker_log = (tmp_path / "bin" / "docker.log").read_text(encoding="utf-8") - assert "image prune -a -f --filter until=72h" in docker_log - assert "builder prune" not in docker_log - - -def test_cleanup_prunes_unused_volumes_above_threshold(tmp_path: Path): - result = _run_cleanup(tmp_path, first_usage=91, final_usage=70) - - assert result.returncode == 0, result.stderr - docker_log = (tmp_path / "bin" / "docker.log").read_text(encoding="utf-8") - assert "volume prune -f" in docker_log - - -def test_cleanup_prunes_unused_volumes_below_threshold(tmp_path: Path): - result = _run_cleanup(tmp_path, first_usage=70, final_usage=70) - - assert result.returncode == 0, result.stderr - docker_log = (tmp_path / "bin" / "docker.log").read_text(encoding="utf-8") - assert "volume prune -f" in docker_log - - -def test_cleanup_prunes_unused_volumes_after_stopped_containers_are_removed(tmp_path: Path): - result = _run_cleanup(tmp_path, first_usage=91, final_usage=70) - - assert result.returncode == 0, result.stderr - docker_calls = (tmp_path / "bin" / "docker.log").read_text(encoding="utf-8").splitlines() - assert docker_calls.index("container prune -f --filter until=24h") < docker_calls.index("volume prune -f") - volume_prune_position = result.stdout.index("Removing Docker volumes no container is using") - final_check_position = result.stdout.index("Docker storage after cleanup") - assert volume_prune_position < final_check_position - - -def test_cleanup_prunes_unused_volumes_when_usage_cannot_be_measured(tmp_path: Path): - result = _run_cleanup( - tmp_path, - first_usage=91, - final_usage=89, - failed_path="/var/lib/docker", - docker_root_dir="", - ) - - assert result.returncode == 1 - assert "Could not determine Docker storage usage after cleanup" in result.stderr - docker_log = (tmp_path / "bin" / "docker.log").read_text(encoding="utf-8") - assert "volume prune -f" in docker_log - - -def test_cleanup_fails_early_when_aggressive_pruning_cannot_recover_space(tmp_path: Path): - result = _run_cleanup(tmp_path, first_usage=91, final_usage=89) - - assert result.returncode == 1 - assert "Docker storage remains at 89%" in result.stderr - - -def test_cleanup_uses_docker_root_dir_when_default_storage_path_is_unavailable(tmp_path: Path): - result = _run_cleanup( - tmp_path, - first_usage=91, - final_usage=89, - failed_path="/var/lib/docker", - docker_root_dir="/mnt/docker-root", - ) - - assert result.returncode == 1 - assert "Using Docker root from docker info: /mnt/docker-root" in result.stdout - assert "Docker storage remains at 89%" in result.stderr - - -def test_cleanup_fails_early_when_docker_storage_usage_cannot_be_measured(tmp_path: Path): - result = _run_cleanup( - tmp_path, - first_usage=91, - final_usage=89, - failed_path="/var/lib/docker", - docker_root_dir="", - ) - - assert result.returncode == 1 - assert "Could not determine Docker storage usage after cleanup" in result.stderr - - -def test_run_package_tests_prepares_docker_space_before_image_pull(): - action_text = _ACTION_PATH.read_text(encoding="utf-8") - - cleanup_index = action_text.index("name: Prepare Docker disk space") - pull_start_index = action_text.index("name: Record pull start time") - pull_index = action_text.index("name: Pull image from ECR") - - assert cleanup_index < pull_start_index < pull_index - assert "cleanup_docker_storage.sh" in action_text diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index 0168793f40c3..a391f0b3f228 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -55,14 +55,6 @@ inputs: across several slots with pytest-xdist. Empty or 1 runs files one by one. default: '' required: false - curobo-only: - description: 'Run only cuRobo and SkillGen tests (requires the cuRobo Docker image)' - default: 'false' - required: false - quarantined-only: - description: 'Run only tests listed in QUARANTINED_TESTS (skipped in normal jobs)' - default: 'false' - required: false include-files: description: 'Comma-separated list of specific test file paths to include (e.g., source/pkg/test/test_a.py,source/pkg/test/test_b.py)' default: '' @@ -84,9 +76,8 @@ inputs: default: '' required: false volume-mount-source: - description: 'Host path to bind-mount at /workspace/isaaclab (for deps-cache-hit mode)' - default: '' - required: false + description: 'Host checkout bind-mounted at /workspace/isaaclab; the tests run this source, not the image copy' + required: true extra-pip-packages: description: 'Space-separated pip packages to install inside the Docker container before pytest starts' default: '' @@ -113,7 +104,7 @@ inputs: default: '' required: false ci-marker: - description: 'CI_MARKER value forwarded to the container (read by tools/conftest.py to select test files by pytest marker)' + description: 'pytest -m expression (CI_MARKER) for tools/conftest.py, e.g. "not nightly" or "arm_ci"' default: '' required: false standalone-script-scope: @@ -124,6 +115,12 @@ inputs: description: 'Visualizer slice used when standalone-script-scope is set; default launches without --viz' default: 'default' required: false + allow-empty-selection: + description: >- + 'true' lets the run select zero tests (e.g. a package with no tests in the nightly tier). Otherwise + tools/conftest.py fails a run that tested nothing, so a stale filter or -k expression cannot go green. + default: 'false' + required: false standalone-script-runtime-group: description: 'Run Kit-dependent or non-Kit standalone script cases' default: '' @@ -140,7 +137,6 @@ runs: shell: bash env: CONTAINER_NAME: ${{ inputs.container-name }} - CUROBO_ONLY: ${{ inputs.curobo-only }} EXCLUDE_PATTERN: ${{ inputs.exclude-pattern }} EXTRA_PIP_PACKAGES: ${{ inputs.extra-pip-packages }} EXTRA_UV_PACKAGES: ${{ inputs.extra-uv-packages }} @@ -149,11 +145,11 @@ runs: INCLUDE_FILES: ${{ inputs.include-files }} OVRTX_SHADER_CACHE_HOST_DIR: ${{ inputs.ovrtx-shader-cache-host-dir }} PYTEST_OPTIONS: ${{ inputs.pytest-options }} - QUARANTINED_ONLY: ${{ inputs.quarantined-only }} REPORTS_DIR: ${{ inputs.reports-dir }} RESULT_FILE: ${{ inputs.result-file }} SHARD_COUNT: ${{ inputs.shard-count }} SHARD_INDEX: ${{ inputs.shard-index }} + ALLOW_EMPTY_SELECTION: ${{ inputs.allow-empty-selection }} STANDALONE_SCRIPT_RUNTIME_GROUP: ${{ inputs.standalone-script-runtime-group }} STANDALONE_SCRIPT_SCOPE: ${{ inputs.standalone-script-scope }} STANDALONE_SCRIPT_VISUALIZER: ${{ inputs.standalone-script-visualizer }} @@ -167,8 +163,7 @@ runs: WARP_CACHE_HOST_DIR: ${{ inputs.warp-cache-host-dir }} WHEELHOUSE_HOST_DIR: ${{ inputs.wheelhouse-host-dir }} WHEELHOUSE_PACKAGES: ${{ inputs.wheelhouse-packages }} - run: | - bash .github/actions/run-tests/run_tests.sh "$TEST_PATH" "$RESULT_FILE" "$CONTAINER_NAME" "$IMAGE_TAG" "$REPORTS_DIR" "$PYTEST_OPTIONS" "$FILTER_PATTERN" "$EXCLUDE_PATTERN" "$CUROBO_ONLY" "$INCLUDE_FILES" "$QUARANTINED_ONLY" "$SHARD_INDEX" "$SHARD_COUNT" "$VOLUME_MOUNT_SOURCE" "$EXTRA_PIP_PACKAGES" "$TEST_NODE_IDS_FILE" "$TEST_NODE_IDS_KEY" "$WHEELHOUSE_HOST_DIR" "$WHEELHOUSE_PACKAGES" "$TEST_K_EXPR_INPUT" "$CI_MARKER_INPUT" "$STANDALONE_SCRIPT_SCOPE" "$STANDALONE_SCRIPT_VISUALIZER" "$STANDALONE_SCRIPT_RUNTIME_GROUP" "$WARP_CACHE_HOST_DIR" "$EXTRA_UV_PACKAGES" "$OVRTX_SHADER_CACHE_HOST_DIR" "$TEST_JOBS_INPUT" + run: bash .github/actions/run-tests/run_tests.sh - name: Kill container on cancellation if: cancelled() shell: bash @@ -177,7 +172,7 @@ runs: run: | echo "::warning::Job cancelled - force-killing container" docker kill "$CONTAINER_NAME" 2>/dev/null || true - docker rm -f "$CONTAINER_NAME" 2>/dev/null || true + docker rm -fv "$CONTAINER_NAME" 2>/dev/null || true - name: Write job summary if: always() @@ -223,46 +218,20 @@ runs: echo "::warning::junit_summary.py failed to parse $report - test results may be missing from the summary" fi - - name: Upload comparison images - if: always() - id : upload-comparison-images - uses: actions/upload-artifact@v7 - with: - name: comparison-images-${{ inputs.container-name }} - path: ${{ inputs.reports-dir }}/comparison-images/ - if-no-files-found: ignore - retention-days: 7 - - # Renderer logs are quoted into the reports only as a bounded tail; the full log per test is here. - - name: Upload OVRTX renderer logs - if: always() - id: upload-ovrtx-logs - uses: actions/upload-artifact@v7 - with: - name: ovrtx-logs-${{ inputs.container-name }} - path: ${{ inputs.reports-dir }}/ovrtx-logs/ - if-no-files-found: ignore - retention-days: 7 - compression-level: 9 - - # The reports carry the dump truncated to 10 000 chars; the whole thing per test file is here. - - name: Upload hang stack dumps - if: always() - id: upload-hang-dumps - uses: actions/upload-artifact@v7 - with: - name: hang-dumps-${{ inputs.container-name }} - path: ${{ inputs.reports-dir }}/hang-dumps/ - if-no-files-found: ignore - retention-days: 7 - - - name: Upload JUnit XML report + # One artifact: the JUnit report plus whatever diagnostics the run left (rendering comparison images, full + # OVRTX renderer logs and hang stack dumps, which the report only quotes truncated). + - name: Upload test results if: always() - id: upload-junit-report - uses: actions/upload-artifact@v7 + id: upload-results + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: junit-${{ inputs.container-name }} - path: ${{ inputs.reports-dir }}/${{ inputs.result-file }} + name: test-results-${{ inputs.container-name }} + path: | + ${{ inputs.reports-dir }}/${{ inputs.result-file }} + ${{ inputs.reports-dir }}/test-durations.json + ${{ inputs.reports-dir }}/comparison-images/ + ${{ inputs.reports-dir }}/ovrtx-logs/ + ${{ inputs.reports-dir }}/hang-dumps/ if-no-files-found: ignore retention-days: 7 @@ -271,8 +240,8 @@ runs: uses: ./.github/actions/upload-omni-github-test-results with: junit-file: ${{ inputs.reports-dir }}/${{ inputs.result-file }} - junit-log-url: ${{ steps.upload-junit-report.outputs.artifact-url }} - comparison-images-url: ${{ steps.upload-comparison-images.outputs.artifact-url }} + junit-log-url: ${{ steps.upload-results.outputs.artifact-url }} + comparison-images-url: ${{ steps.upload-results.outputs.artifact-url }} artifact-prefix: pytest-results-${{ github.job }}-${{ inputs.container-name }} test-type: ${{ inputs.omni-github-test-type }} @@ -284,4 +253,4 @@ runs: run: | echo "πŸ”΅ Cleaning up Docker container..." docker kill "$CONTAINER_NAME" 2>/dev/null || true - docker rm -f "$CONTAINER_NAME" 2>/dev/null || true + docker rm -fv "$CONTAINER_NAME" 2>/dev/null || true diff --git a/.github/actions/run-tests/run_tests.sh b/.github/actions/run-tests/run_tests.sh index 906ca817db5f..d3641c9725ff 100755 --- a/.github/actions/run-tests/run_tests.sh +++ b/.github/actions/run-tests/run_tests.sh @@ -4,41 +4,37 @@ # # SPDX-License-Identifier: BSD-3-Clause # -# Body of the 'Run Tests in Docker Container' step. Kept in a file because a -# composite action's run: block is capped at 21000 characters (counted as -# chars + lines, i.e. CRLF), and this function alone far exceeds that. -# Positional arguments are passed through from action.yml. +# Body of the 'Run Tests in Docker Container' step, kept in a file because a composite action's run: block is +# capped at 21000 characters. Every input arrives as an environment variable set by action.yml. # Function to run tests in Docker container run_tests() { - local test_path="$1" - local result_file="$2" - local container_name="$3" - local image_tag="$4" - local reports_dir="$5" - local pytest_options="$6" - local filter_pattern="$7" - local exclude_pattern="$8" - local curobo_only="$9" - local include_files="${10}" - local quarantined_only="${11}" - local shard_index="${12}" - local shard_count="${13}" - local volume_mount_source="${14}" - local extra_pip_packages="${15}" - local test_node_ids_file="${16}" - local test_node_ids_key="${17}" - local wheelhouse_host_dir="${18}" - local wheelhouse_packages="${19}" - local test_k_expr="${20}" - local ci_marker="${21}" - local standalone_script_scope="${22}" - local standalone_script_visualizer="${23}" - local standalone_script_runtime_group="${24}" - local warp_cache_host_dir="${25}" - local extra_uv_packages="${26}" - local ovrtx_shader_cache_host_dir="${27}" - local test_jobs="${28}" + local test_path="$TEST_PATH" + local result_file="$RESULT_FILE" + local container_name="$CONTAINER_NAME" + local image_tag="$IMAGE_TAG" + local reports_dir="$REPORTS_DIR" + local pytest_options="${PYTEST_OPTIONS:-}" + local filter_pattern="${FILTER_PATTERN:-}" + local exclude_pattern="${EXCLUDE_PATTERN:-}" + local include_files="${INCLUDE_FILES:-}" + local shard_index="${SHARD_INDEX:-}" + local shard_count="${SHARD_COUNT:-}" + local volume_mount_source="$VOLUME_MOUNT_SOURCE" + local extra_pip_packages="${EXTRA_PIP_PACKAGES:-}" + local test_node_ids_file="${TEST_NODE_IDS_FILE:-}" + local test_node_ids_key="${TEST_NODE_IDS_KEY:-}" + local wheelhouse_host_dir="${WHEELHOUSE_HOST_DIR:-}" + local wheelhouse_packages="${WHEELHOUSE_PACKAGES:-}" + local test_k_expr="${TEST_K_EXPR_INPUT:-}" + local ci_marker="${CI_MARKER_INPUT:-}" + local standalone_script_scope="${STANDALONE_SCRIPT_SCOPE:-}" + local standalone_script_visualizer="${STANDALONE_SCRIPT_VISUALIZER:-}" + local standalone_script_runtime_group="${STANDALONE_SCRIPT_RUNTIME_GROUP:-}" + local warp_cache_host_dir="${WARP_CACHE_HOST_DIR:-}" + local extra_uv_packages="${EXTRA_UV_PACKAGES:-}" + local ovrtx_shader_cache_host_dir="${OVRTX_SHADER_CACHE_HOST_DIR:-}" + local test_jobs="${TEST_JOBS_INPUT:-}" local logs_pid="" local wait_pid="" local docker_wait_file="/tmp/.docker_exit_${container_name}" @@ -50,7 +46,7 @@ run_tests() { # shellcheck disable=SC2064 trap "echo '::warning::Cancellation signal - killing container ${container_name}'; \ docker kill '${container_name}' 2>/dev/null || true; \ - docker rm -f '${container_name}' 2>/dev/null || true; \ + docker rm -fv '${container_name}' 2>/dev/null || true; \ rm -f '${docker_wait_file}'; \ if [ -n \"\$docker_runtime_dir\" ]; then rm -rf \"\$docker_runtime_dir\" 2>/dev/null || true; fi; \ if [ -n \"\$logs_pid\" ]; then kill \"\$logs_pid\" 2>/dev/null || true; fi; \ @@ -80,9 +76,6 @@ run_tests() { if [ -n "$exclude_pattern" ]; then echo "With exclude pattern: $exclude_pattern" fi - if [ "$curobo_only" = "true" ]; then - echo "cuRobo-only mode enabled: running only cuRobo and SkillGen tests" - fi if [ -n "$include_files" ]; then echo "Include files: $include_files" fi @@ -105,11 +98,16 @@ run_tests() { export TEST_NODE_IDS_KEY="$test_node_ids_key" fi + if [ -z "$volume_mount_source" ]; then + echo "::error::volume-mount-source is required: tests run against the bind-mounted checkout" + return 1 + fi + # Create reports directory mkdir -p "$reports_dir" # Clean up any existing container - docker rm -f "$container_name" 2>/dev/null || true + docker rm -fv "$container_name" 2>/dev/null || true # Build Docker environment variables local -a docker_env_args=( @@ -124,16 +122,6 @@ run_tests() { -e "TEST_RESULT_FILE=$result_file" ) - if [ "$curobo_only" = "true" ]; then - docker_env_args+=(-e "TEST_CUROBO_ONLY=true") - echo "Setting TEST_CUROBO_ONLY=true" - fi - - if [ "$quarantined_only" = "true" ]; then - docker_env_args+=(-e "TEST_QUARANTINED_ONLY=true") - echo "Setting TEST_QUARANTINED_ONLY=true" - fi - if [ -n "$include_files" ]; then # conftest.py splits on commas and strips whitespace, so compact form works fine. include_files_compact="${include_files// /}" @@ -205,6 +193,11 @@ run_tests() { echo "Setting CI_MARKER=$ci_marker" fi + if [ "${ALLOW_EMPTY_SELECTION:-false}" = "true" ]; then + docker_env_args+=(-e "TEST_ALLOW_EMPTY_SELECTION=1") + echo "Allowing this run to select zero tests" + fi + # Set by the multi-GPU smoke steps: fail rather than skip on a runner with too few GPUs. [ -z "${ISAACLAB_TEST_REQUIRE_MULTI_GPU:-}" ] || docker_env_args+=(-e ISAACLAB_TEST_REQUIRE_MULTI_GPU) # Set by the kitless legacy rendering job: fail rather than skip when OptiX is not importable. @@ -477,84 +470,30 @@ run_tests() { fi echo "::group::Copy results" - # Copy test results with error handling. - # When volume-mounted, test output lands on the host filesystem directly - # (docker cp cannot see bind-mounted paths after the container stops). - echo "πŸ”΅ Attempting to copy test results..." - if [ -n "$volume_mount_source" ] && [ -f "${volume_mount_source}/tests/$result_file" ]; then - cp "${volume_mount_source}/tests/$result_file" "$reports_dir/$result_file" - echo "🟒 Test results copied from volume mount to $reports_dir/$result_file" - elif cp_err=$(docker cp $container_name:/workspace/isaaclab/tests/$result_file "$reports_dir/$result_file" 2>&1); then - echo "🟒 Test results copied successfully to $reports_dir/$result_file" + # The checkout is bind-mounted, so everything the run wrote under tests/ is already on the host. + local host_tests="${volume_mount_source}/tests" + if [ -f "${host_tests}/${result_file}" ]; then + cp "${host_tests}/${result_file}" "$reports_dir/$result_file" else - echo "πŸ”΄ Failed to copy specific result file: $cp_err" - echo "πŸ”΄ Trying to copy all test results..." - if cp_err=$(docker cp $container_name:/workspace/isaaclab/tests/ "$reports_dir/" 2>&1); then - echo "🟒 All test results copied successfully to $reports_dir/" - # Look for any XML files and use the first one found - if [ -f "$reports_dir/full_report.xml" ]; then - mv "$reports_dir/full_report.xml" "$reports_dir/$result_file" - echo "🟒 Found and renamed full_report.xml to $result_file" - elif ls "$reports_dir"/test-reports-*.xml 1>/dev/null 2>&1; then - # Combine individual test reports if no full report exists. - # Extract each block intact to produce valid JUnit XML. - echo "πŸ”΅ Combining individual test reports..." - echo '' > "$reports_dir/$result_file" - echo '' >> "$reports_dir/$result_file" - for xml_file in "$reports_dir"/test-reports-*.xml; do - if [ -f "$xml_file" ]; then - echo " Processing: $xml_file" - # Copy everything between and (inclusive) - sed -n '//p' "$xml_file" >> "$reports_dir/$result_file" || echo "🟠 Warning: failed to extract testsuite from $xml_file" - fi - done - echo '' >> "$reports_dir/$result_file" - echo "🟒 Combined individual test reports into $result_file" - else - echo "πŸ”΄ No test result files found, creating fallback" - echo "Container may have failed to generate any results" > "$reports_dir/$result_file" - fi - else - echo "πŸ”΄ Failed to copy any test results, creating fallback" - echo "Container may have failed to generate results" > "$reports_dir/$result_file" - fi - fi - - # Copy comparison images (saved by source/isaaclab_tasks/test/test_rendering_*.py). - local img_dir="$reports_dir/comparison-images" - if [ -n "$volume_mount_source" ] && [ -d "${volume_mount_source}/tests/comparison-images" ]; then - cp -r "${volume_mount_source}/tests/comparison-images" "$img_dir" - echo "🟒 Comparison images copied to $img_dir" - elif docker cp "$container_name:/workspace/isaaclab/tests/comparison-images" "$img_dir" 2>/dev/null; then - echo "🟒 Comparison images copied from container to $img_dir" + echo "πŸ”΄ No test report at ${host_tests}/${result_file}; writing a failing placeholder" + echo "The container exited without writing a report" > "$reports_dir/$result_file" fi - - # Copy per-test OVRTX renderer logs (saved by tools/ovrtx_log.py). The reports quote a bounded tail - # of these; the full logs are only here. - local ovrtx_dir="$reports_dir/ovrtx-logs" - if [ -n "$volume_mount_source" ] && [ -d "${volume_mount_source}/tests/ovrtx-logs" ]; then - cp -r "${volume_mount_source}/tests/ovrtx-logs" "$ovrtx_dir" - echo "🟒 OVRTX renderer logs copied to $ovrtx_dir" - elif docker cp "$container_name:/workspace/isaaclab/tests/ovrtx-logs" "$ovrtx_dir" 2>/dev/null; then - echo "🟒 OVRTX renderer logs copied from container to $ovrtx_dir" - fi - - # Copy per-file thread stack dumps (written by tools/hang_dump.py when the runner kills a hung test). - # The reports carry these truncated to 10 000 chars; the whole dump is only here. Absent unless - # something hung, which is the normal case. - local hang_dir="$reports_dir/hang-dumps" - if [ -n "$volume_mount_source" ] && [ -d "${volume_mount_source}/tests/hang-dumps" ]; then - cp -r "${volume_mount_source}/tests/hang-dumps" "$hang_dir" - echo "🟒 Hang stack dumps copied to $hang_dir" - elif docker cp "$container_name:/workspace/isaaclab/tests/hang-dumps" "$hang_dir" 2>/dev/null; then - echo "🟒 Hang stack dumps copied from container to $hang_dir" + # Per-file timings, for tools/update_test_durations.py. + if [ -f "${host_tests}/test-durations.json" ]; then + cp "${host_tests}/test-durations.json" "$reports_dir/test-durations.json" fi + # Rendering comparison images, per-test OVRTX renderer logs and hang stack dumps: absent unless used. + for artifact_dir in comparison-images ovrtx-logs hang-dumps; do + if [ -d "${host_tests}/${artifact_dir}" ]; then + cp -r "${host_tests}/${artifact_dir}" "$reports_dir/${artifact_dir}" + fi + done echo "::endgroup::" echo "::group::Cleanup" # Clean up container echo "πŸ”΅ Cleaning up Docker container..." - docker rm $container_name 2>/dev/null || echo "🟠 Container cleanup failed, but continuing..." + docker rm -v "$container_name" 2>/dev/null || echo "🟠 Container cleanup failed, but continuing..." if [ -n "$docker_runtime_dir" ]; then rm -rf "$docker_runtime_dir" || echo "🟠 Docker runtime storage cleanup failed, but continuing..." fi @@ -563,6 +502,4 @@ run_tests() { return $DOCKER_EXIT } -# Call the function with provided parameters - -run_tests "$@" +run_tests diff --git a/.github/actions/upload-omni-github-test-results/action.yml b/.github/actions/upload-omni-github-test-results/action.yml index d74ceb2186b4..ed61c053fc80 100644 --- a/.github/actions/upload-omni-github-test-results/action.yml +++ b/.github/actions/upload-omni-github-test-results/action.yml @@ -113,7 +113,7 @@ runs: - name: Upload omni-github test results if: always() && steps.convert.outputs.upload == 'true' - uses: actions/upload-artifact@v7 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: ${{ inputs.artifact-prefix }}--v1-${{ github.repository_id }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ job.check_run_id }} path: ${{ steps.convert.outputs.artifact_dir }} diff --git a/.github/actions/upload-omni-github-test-results/test_junit_to_omni_github_results.py b/.github/actions/upload-omni-github-test-results/test_junit_to_omni_github_results.py index 4e94efe97fd2..d6b93e7337cd 100644 --- a/.github/actions/upload-omni-github-test-results/test_junit_to_omni_github_results.py +++ b/.github/actions/upload-omni-github-test-results/test_junit_to_omni_github_results.py @@ -12,6 +12,10 @@ from pathlib import Path from types import ModuleType +import pytest + +pytestmark = pytest.mark.pr + _MODULE_PATH = Path(__file__).with_name("junit_to_omni_github_results.py") _RESULT_PATH = "_testoutput/test_results.json" @@ -121,8 +125,22 @@ def test_convert_junit_marks_xfail_as_unreliable(tmp_path: Path) -> None: assert "skip_reason" not in row -def test_convert_junit_marks_crashes_and_timeouts(tmp_path: Path) -> None: - """Converted rows should surface crash and timeout messages.""" +_JUNIT_LOG_URL = "https://github.com/isaac-sim/IsaacLab/actions/runs/123/artifacts/456" +_COMPARISON_IMAGES_URL = "https://github.com/isaac-sim/IsaacLab/actions/runs/123/artifacts/789" + + +@pytest.mark.parametrize( + ("junit_log_url", "comparison_images_url", "log_paths"), + [ + ("", "", []), + (_JUNIT_LOG_URL, _COMPARISON_IMAGES_URL, [_JUNIT_LOG_URL, _COMPARISON_IMAGES_URL]), + ], + ids=["no-artifacts", "junit-and-comparison-artifacts"], +) +def test_convert_junit_marks_crashes_and_timeouts( + tmp_path: Path, junit_log_url: str, comparison_images_url: str, log_paths: list[str] +) -> None: + """Converted rows should surface crash and timeout messages and link uploaded artifacts.""" converter = _load_converter_module() junit_file = tmp_path / "report.xml" output_dir = tmp_path / "out" @@ -145,8 +163,8 @@ def test_convert_junit_marks_crashes_and_timeouts(tmp_path: Path) -> None: app_platform="linux-x86_64", app_config="test-job", group_name="Docker + Tests / environments", - junit_log_url="", - comparison_images_url="", + junit_log_url=junit_log_url, + comparison_images_url=comparison_images_url, retries=0, ) @@ -156,7 +174,7 @@ def test_convert_junit_marks_crashes_and_timeouts(tmp_path: Path) -> None: "crash": True, "duration": 0.0, "group_id": "Docker + Tests / environments", - "log_paths": [], + "log_paths": log_paths, "message": "Process killed by signal 15 after timeout", "passed": False, "retries": 0, @@ -168,44 +186,6 @@ def test_convert_junit_marks_crashes_and_timeouts(tmp_path: Path) -> None: ] -def test_convert_junit_adds_log_paths_for_junit_and_comparison_artifacts(tmp_path: Path) -> None: - """Converted rows should point at the uploaded JUnit and comparison image artifacts.""" - converter = _load_converter_module() - reports_dir = tmp_path - output_dir = tmp_path / "out" - junit_file = reports_dir / "report.xml" - junit_log_url = "https://github.com/isaac-sim/IsaacLab/actions/runs/123/artifacts/456" - comparison_images_url = "https://github.com/isaac-sim/IsaacLab/actions/runs/123/artifacts/789" - - junit_file.write_text( - """ - - - -""", - encoding="utf-8", - ) - - converter.convert_junit( - junit_file=junit_file, - output_dir=output_dir, - test_tool_id="pytest", - test_type="rendering-correctness", - app_platform="linux-x86_64", - app_config="test-job", - group_name="Docker + Tests / rendering", - junit_log_url=junit_log_url, - comparison_images_url=comparison_images_url, - retries=0, - ) - - rows = _load_rows(output_dir) - assert rows[0]["log_paths"] == [ - junit_log_url, - comparison_images_url, - ] - - def test_convert_junit_appends_markers_to_test_type_with_separator(tmp_path: Path) -> None: """Recorded intent markers should append to the base test_type with comma separators.""" converter = _load_converter_module() diff --git a/.github/scripts/runner_health.sh b/.github/scripts/runner_health.sh deleted file mode 100755 index 177a2c4b32cb..000000000000 --- a/.github/scripts/runner_health.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). -# All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause - -# Print a short memory and storage summary of the CI host. Usage: runner_health.sh