From cd357dd124859e7dfe2c60400961f61067185912 Mon Sep 17 00:00:00 2001 From: HarryZhou <2373256746@qq.com> Date: Tue, 5 May 2026 01:02:40 +0800 Subject: [PATCH 1/3] ci: add runtime sentinel check for cfd_externals cache prefix match actions/cache reports cache-hit=false on prefix match (key is shorter than stored entry), but the content IS restored. The build step would then run and fail on git submodule clone conflict. Fix: check if libcgns.a exists at runtime before building. Also rm -rf the submodule dir before git submodule update to prevent clone conflict if the directory exists but is incomplete. Also: update AGENTS.md gh policy with explicit list of write operations requiring user authorization. --- .github/workflows/ci.yml | 7 +++++++ AGENTS.md | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb936826..6c16f716 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -227,9 +227,16 @@ jobs: - name: Build cfd_externals if: steps.cache-cfd-ext.outputs.cache-hit != 'true' run: | + # Double-check: skip if install already restored via prefix match + if [ -f external/cfd_externals/install/lib/libcgns.a ]; then + echo "cfd_externals install present (cache prefix match), skipping build" + exit 0 + fi + rm -rf external/cfd_externals git submodule update --init --recursive --depth=1 cd external/cfd_externals CC=mpicc CXX=mpicxx python3 cfd_externals_build.py + CC=mpicc CXX=mpicxx python3 cfd_externals_build.py # ------------------------------------------------------------------ # 6. Python venv diff --git a/AGENTS.md b/AGENTS.md index 261e8a33..173d13ad 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -333,8 +333,19 @@ Key concepts agents should know: **Read-only by default.** You may use `gh` freely for read operations (viewing issues, PRs, checks, releases, diffs, comments). **Do NOT use `gh` for any write operation** (creating/closing issues, creating/merging PRs, posting -comments, approving reviews, creating releases, editing labels, etc.) **unless -the user explicitly requests that specific write action.** One-time explicit -permission does not carry over to other write actions — ask each time. +comments, approving reviews, creating releases, editing labels, deleting +caches, etc.) **unless the user explicitly requests that specific write +action.** One-time explicit permission does not carry over to other write +actions — ask each time. + +**Operations requiring explicit user authorization (non-exhaustive):** +- `gh pr create/merge/close/edit` +- `gh issue create/close/edit` +- `gh pr comment` / `gh issue comment` +- `gh pr review` +- `gh release create/delete` +- `gh cache delete` +- `gh api` with non-GET methods (POST, PUT, PATCH, DELETE) +- `git push --force` / `git push --force-with-lease` **Draft PR by default** You must use --draft on new prs. From 460d44f08f1952c9b120d7a1853e44d515d7ba0b Mon Sep 17 00:00:00 2001 From: HarryZhou <2373256746@qq.com> Date: Tue, 5 May 2026 01:06:47 +0800 Subject: [PATCH 2/3] ci: always save caches (restore/save split for externals + venv) Switch header-only, cfd_externals, and Python venv from actions/cache (combined restore+save, skips save on hit) to actions/cache/restore + actions/cache/save with if:always(). This ensures caches are saved with the correct key even after a prefix-match restore (where cache-hit is false but content is already present). --- .github/workflows/ci.yml | 46 ++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c16f716..51ef1881 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,9 +188,9 @@ jobs: # ------------------------------------------------------------------ # 4. Header-only externals (Eigen, Boost, CGAL, fmt, pybind11, ...) # ------------------------------------------------------------------ - - name: Cache header-only externals + - name: Restore header-only externals cache id: cache-headeronlys - uses: actions/cache@v4 + uses: actions/cache/restore@v4 with: path: | external/argparse @@ -214,12 +214,32 @@ jobs: curl -L -o external/external_headeronlys.tar.gz "$HEADERONLYS_URL" cd external && tar -xzf external_headeronlys.tar.gz + - name: Save header-only externals cache + if: always() + uses: actions/cache/save@v4 + with: + path: | + external/argparse + external/boost + external/CGAL + external/cppcodec + external/cpptrace + external/doctest + external/eigen + external/exprtk + external/fmt + external/nanoflann + external/nlohmann + external/pybind11 + external/pybind11_json + key: headeronlys-v1 + # ------------------------------------------------------------------ # 5. cfd_externals (zlib, hdf5, cgns, parmetis) # ------------------------------------------------------------------ - - name: Cache cfd_externals install + - name: Restore cfd_externals cache id: cache-cfd-ext - uses: actions/cache@v4 + uses: actions/cache/restore@v4 with: path: external/cfd_externals/install key: cfd-ext-${{ runner.os }}-${{ steps.submod.outputs.cfd_ext_sha }} @@ -236,14 +256,21 @@ jobs: git submodule update --init --recursive --depth=1 cd external/cfd_externals CC=mpicc CXX=mpicxx python3 cfd_externals_build.py + + - name: Save cfd_externals cache + if: always() + uses: actions/cache/save@v4 + with: + path: external/cfd_externals/install + key: cfd-ext-${{ runner.os }}-${{ steps.submod.outputs.cfd_ext_sha }} CC=mpicc CXX=mpicxx python3 cfd_externals_build.py # ------------------------------------------------------------------ # 6. Python venv # ------------------------------------------------------------------ - - name: Cache Python venv + - name: Restore Python venv cache id: cache-venv - uses: actions/cache@v4 + uses: actions/cache/restore@v4 with: path: venv key: venv-ci-${{ runner.os }}-${{ steps.submod.outputs.cfd_ext_sha }}-${{ hashFiles('requirements.txt', 'scripts/install_python_deps.sh') }} @@ -256,6 +283,13 @@ jobs: pip install --upgrade pip PIP=$PWD/venv/bin/pip ./scripts/install_python_deps.sh + - name: Save Python venv cache + if: always() + uses: actions/cache/save@v4 + with: + path: venv + key: venv-ci-${{ runner.os }}-${{ steps.submod.outputs.cfd_ext_sha }}-${{ hashFiles('requirements.txt', 'scripts/install_python_deps.sh') }} + # ------------------------------------------------------------------ # 7. ccache # ------------------------------------------------------------------ From bd26be4e533bb2de7c9fc39e3f1e83bce9ca116f Mon Sep 17 00:00:00 2001 From: HarryZhou <2373256746@qq.com> Date: Tue, 5 May 2026 01:13:25 +0800 Subject: [PATCH 3/3] ci: fix stray line in cfd_externals save step (YAML syntax error) --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51ef1881..6196fc50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -263,7 +263,6 @@ jobs: with: path: external/cfd_externals/install key: cfd-ext-${{ runner.os }}-${{ steps.submod.outputs.cfd_ext_sha }} - CC=mpicc CXX=mpicxx python3 cfd_externals_build.py # ------------------------------------------------------------------ # 6. Python venv