From 6a240ace87d6f5dafe7b969e3a8d82630198387a Mon Sep 17 00:00:00 2001 From: Yuma Endo Date: Sun, 22 Mar 2026 22:49:10 +0900 Subject: [PATCH 1/2] feat: trigger ingot rebuild on infrastructure changes Add scripts/**, schema/**, and platforms.toml to push trigger paths. When these files change, all existing build-type molds are rebuilt to ensure published ingots reflect the latest infrastructure. Changes to detect-build-targets: - Diff all files (not just molds/) to detect INFRA_CHANGED - INFRA_CHANGED: include all existing molds for rebuild - Mold-only changes: existing source-change detection (unchanged) - Both: deduplicated union of infra + mold targets - workflow_dispatch: unchanged (explicit mold_path) Design rationale: - scripts/ changes affect build/validation logic for all molds - schema/ changes affect mold interpretation - platforms.toml changes affect platform matrix - .github/workflows/ excluded (affects how builds run, not what is built) --- .github/workflows/ingot-cast.yml | 124 ++++++++++++++++++++++--------- 1 file changed, 87 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ingot-cast.yml b/.github/workflows/ingot-cast.yml index 5f9c91a..a10813e 100644 --- a/.github/workflows/ingot-cast.yml +++ b/.github/workflows/ingot-cast.yml @@ -3,7 +3,11 @@ name: Ingot Cast on: push: branches: [main] - paths: ['molds/**'] + paths: + - 'molds/**' + - 'scripts/**' + - 'schema/**' + - 'platforms.toml' workflow_dispatch: inputs: mold_path: @@ -71,26 +75,64 @@ jobs: # Guard against null SHA on initial push NULL_SHA="0000000000000000000000000000000000000000" if [[ "$BEFORE_SHA" == "$NULL_SHA" ]]; then - CHANGED_FILES=$(git ls-tree -r --name-only HEAD -- molds/) + ALL_CHANGED_FILES=$(git ls-tree -r --name-only HEAD) else - CHANGED_FILES=$(git diff --name-only "${BEFORE_SHA}..${CURRENT_SHA}" -- molds/ || true) + ALL_CHANGED_FILES=$(git diff --name-only "${BEFORE_SHA}..${CURRENT_SHA}" || true) fi - if [[ -z "$CHANGED_FILES" ]]; then - echo "No mold changes detected" + if [[ -z "$ALL_CHANGED_FILES" ]]; then + echo "No changes detected" no_targets exit 0 fi - # Extract unique mold directories (molds/{family}/{version}) - MOLD_DIRS=$(echo "$CHANGED_FILES" \ - | sed 's|^\(molds/[^/]*/[^/]*\)/.*|\1|; s|^\(molds/[^/]*/[^/]*\)$|\1|' \ - | sort -u) + # Check for infrastructure changes that affect all molds. + # When build scripts, schema, or platform definitions change, + # all existing build-type molds must be rebuilt to ensure + # published ingots reflect the latest infrastructure. + # Workflow files (.github/workflows/) are excluded — they + # affect how builds run, not what is built. Same rationale + # as pr-validation.yml. + INFRA_CHANGED=$(echo "$ALL_CHANGED_FILES" | grep -E '^(schema/|scripts/|platforms\.toml$)' || true) - # Write source-change-detection script to a temp file - CHECK_SCRIPT=$(mktemp) - trap 'rm -f "$CHECK_SCRIPT"' EXIT - cat > "$CHECK_SCRIPT" << 'CHECKEOF' + # Extract mold-specific changes + MOLD_CHANGED_FILES=$(echo "$ALL_CHANGED_FILES" | grep '^molds/' || true) + + if [[ -z "$INFRA_CHANGED" ]] && [[ -z "$MOLD_CHANGED_FILES" ]]; then + echo "No relevant changes detected (no mold or infrastructure changes)" + no_targets + exit 0 + fi + + CHANGED_MOLDS=() + + # --- Infrastructure change: include ALL existing build-type molds --- + if [[ -n "$INFRA_CHANGED" ]]; then + echo "Infrastructure change detected:" + echo "$INFRA_CHANGED" | while IFS= read -r f; do echo " - $f"; done + echo "All existing molds will be evaluated for rebuild." + + ALL_MOLD_DIRS=$(find molds -name "mold.toml" -not -path "*/\.*" 2>/dev/null \ + | sed 's|/mold\.toml$||' | sort -u || true) + while IFS= read -r mold_dir; do + [[ -z "$mold_dir" ]] && continue + CHANGED_MOLDS+=("$mold_dir") + done <<< "$ALL_MOLD_DIRS" + fi + + # --- Mold-specific changes: add individually changed molds --- + if [[ -n "$MOLD_CHANGED_FILES" ]]; then + MOLD_DIRS=$(echo "$MOLD_CHANGED_FILES" \ + | sed 's|^\(molds/[^/]*/[^/]*\)/.*|\1|; s|^\(molds/[^/]*/[^/]*\)$|\1|' \ + | sort -u) + + # Source-change detection: skip metadata-only changes. + # Only applies when INFRA_CHANGED is empty (infra changes + # rebuild all molds regardless of their individual changes). + if [[ -z "$INFRA_CHANGED" ]]; then + CHECK_SCRIPT=$(mktemp) + trap 'rm -f "$CHECK_SCRIPT"' EXIT + cat > "$CHECK_SCRIPT" << 'CHECKEOF' import tomllib, subprocess, sys, os mold_dir = os.environ['MOLD_DIR_VAR'] @@ -116,37 +158,45 @@ jobs: print('false') CHECKEOF - # Filter to molds with source/patches changes only - CHANGED_MOLDS=() - while IFS= read -r mold_dir; do - [[ -z "$mold_dir" ]] && continue - [[ ! -f "${mold_dir}/mold.toml" ]] && continue + while IFS= read -r mold_dir; do + [[ -z "$mold_dir" ]] && continue + [[ ! -f "${mold_dir}/mold.toml" ]] && continue - NEEDS_BUILD=false + NEEDS_BUILD=false - # Check if patches/ changed - if echo "$CHANGED_FILES" | grep -q "^${mold_dir}/patches/"; then - NEEDS_BUILD=true - fi - - # Check if mold.toml changed and source/test sections differ - if echo "$CHANGED_FILES" | grep -q "^${mold_dir}/mold.toml$"; then - if [[ "$BEFORE_SHA" == "$NULL_SHA" ]]; then - NEEDS_BUILD=true - else - SOURCE_CHANGED=$(MOLD_DIR_VAR="$mold_dir" BEFORE_SHA_VAR="$BEFORE_SHA" python3 "$CHECK_SCRIPT") - if [[ "$SOURCE_CHANGED" == "true" ]]; then + if echo "$MOLD_CHANGED_FILES" | grep -q "^${mold_dir}/patches/"; then NEEDS_BUILD=true fi - fi - fi - if [[ "$NEEDS_BUILD" == "true" ]]; then - CHANGED_MOLDS+=("$mold_dir") + if echo "$MOLD_CHANGED_FILES" | grep -q "^${mold_dir}/mold.toml$"; then + if [[ "$BEFORE_SHA" == "$NULL_SHA" ]]; then + NEEDS_BUILD=true + else + SOURCE_CHANGED=$(MOLD_DIR_VAR="$mold_dir" BEFORE_SHA_VAR="$BEFORE_SHA" python3 "$CHECK_SCRIPT") + if [[ "$SOURCE_CHANGED" == "true" ]]; then + NEEDS_BUILD=true + fi + fi + fi + + if [[ "$NEEDS_BUILD" == "true" ]]; then + CHANGED_MOLDS+=("$mold_dir") + else + echo "Skipping ${mold_dir}: no source/patches changes" + fi + done <<< "$MOLD_DIRS" else - echo "Skipping ${mold_dir}: no source/patches changes" + # INFRA_CHANGED is set — all molds already included above. + # Individual mold changes are redundant (union is handled + # by dedup below). + : fi - done <<< "$MOLD_DIRS" + fi + + # Deduplicate (infra + individual mold changes may overlap) + if [[ ${#CHANGED_MOLDS[@]} -gt 0 ]]; then + mapfile -t CHANGED_MOLDS < <(printf '%s\n' "${CHANGED_MOLDS[@]}" | sort -u) + fi fi if [[ ${#CHANGED_MOLDS[@]} -eq 0 ]]; then From 5cb4c8708171eeb866fccf207a9b6245c69e360f Mon Sep 17 00:00:00 2001 From: Yuma Endo Date: Sun, 22 Mar 2026 22:53:31 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20clarify=20comment=20=E2=80=94=20all?= =?UTF-8?q?=20molds=20included,=20not=20just=20build-type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build-type filtering happens in Step 2 (source type classification), not during the infrastructure change mold collection. --- .github/workflows/ingot-cast.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ingot-cast.yml b/.github/workflows/ingot-cast.yml index a10813e..8a0a19f 100644 --- a/.github/workflows/ingot-cast.yml +++ b/.github/workflows/ingot-cast.yml @@ -106,7 +106,8 @@ jobs: CHANGED_MOLDS=() - # --- Infrastructure change: include ALL existing build-type molds --- + # --- Infrastructure change: include ALL existing molds --- + # (fetch vs build filtering happens in Step 2 below) if [[ -n "$INFRA_CHANGED" ]]; then echo "Infrastructure change detected:" echo "$INFRA_CHANGED" | while IFS= read -r f; do echo " - $f"; done