Files
solvecraft/.github/actions/cpp-reference/action.yml
T
bherbruck ead02a9ec1 ci: cut CI wall time (parallel jobs, opt-level 0 difftest glue, time-ordered queue)
- difftest no longer waits for the test job; cpp clippy moves to the clippy job and
  the runner tests to the test job (both 8 vCPU), sharing a composite action that
  clones upstream, enables sccache and installs the C++ reference.
- [profile.difftest.package.difftest] opt-level = 0: the ~300k-line runner crate took
  ~5 of the ~6 build minutes at opt-level 3; solidcore stays at 3. Reports are
  byte-identical.
- difftest --jobs orders its queue by each unit's wall time in the previous run
  (reports/difftest/times.tsv, uploaded with main's reports), so the slowest unit
  starts first and the run ends at the longest unit's time.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0158BfaB2oaoX64fskuKP1bm
2026-10-22 00:55:52 -04:00

78 lines
3.2 KiB
YAML

name: C++ reference
description: >
Clones upstream at the pinned commit, enables sccache and installs the C++ reference
(bin/cpp layout) into $SOLIDCORE_CPP_DIR, so the cpp feature of solidcore-ffi builds.
Expects UPSTREAM_REPO, UPSTREAM_COMMIT and SOLIDCORE_CPP_DIR in the job environment.
runs:
using: composite
steps:
- name: Clone upstream at pinned commit
shell: bash
run: |
git init upstream
git -C upstream remote add origin "$UPSTREAM_REPO"
git -C upstream fetch --depth 1 origin "$UPSTREAM_COMMIT" \
|| git -C upstream fetch origin
git -C upstream checkout --detach "$UPSTREAM_COMMIT"
# sccache caches the ~200 shim objects solidcore-ffi compiles (the cc crate wraps the
# C++ compiler in RUSTC_WRAPPER when it is sccache) and the workspace crates, which
# rust-cache does not keep; both survive across runs in the GitHub Actions cache.
- name: Set up sccache
uses: mozilla-actions/sccache-action@v0.0.11
- name: Enable sccache
shell: bash
run: |
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
# The difftest run is idle for sccache for minutes; without this the server
# exits after 10 idle minutes and the stats printed at the end read zero.
echo "SCCACHE_IDLE_TIMEOUT=0" >> "$GITHUB_ENV"
# The C++ reference (bin/cpp/lib) comes prebuilt from the GitHub Release that
# .github/workflows/cpp-reference.yml publishes for scripts/cpp-ref-key.sh's key.
# When none matches (a PR that changes harness/cpp before it is published), build it
# from source and keep that build in actions/cache under the same key. It lives
# outside cargo's target dir (bin/): rust-cache's post-step cleans bin/.
- name: C++ reference key
id: cppkey
shell: bash
run: echo "key=$(scripts/cpp-ref-key.sh)" >> "$GITHUB_OUTPUT"
- name: Restore C++ reference built from source
uses: actions/cache/restore@v4
with:
path: .cpp
key: cpp-v3-${{ runner.os }}-${{ steps.cppkey.outputs.key }}
- name: Fetch C++ reference (build it when no prebuilt matches)
id: cpp
shell: bash
run: |
cpp=$SOLIDCORE_CPP_DIR
if [ -f "$cpp/lib/libSMLib.a" ] && [ -f "$cpp/lib/libSM_API.a" ] && [ -f "$cpp/ffi.env" ]; then
echo "C++ reference restored from cache"
exit 0
fi
command -v zstd >/dev/null || sudo apt-get install -y zstd
rc=0
scripts/fetch-cpp.sh --no-build || rc=$?
if [ "$rc" = 3 ]; then
sudo apt-get update && sudo apt-get install -y ninja-build cmake g++
harness/cpp/build.sh --no-tests --jobs "$(nproc)"
echo "built=true" >> "$GITHUB_OUTPUT"
elif [ "$rc" != 0 ]; then
exit "$rc"
fi
# Several jobs may build the same key at once; only the first save wins, the
# others log a warning.
- name: Save C++ reference built from source
if: steps.cpp.outputs.built == 'true'
uses: actions/cache/save@v4
continue-on-error: true
with:
path: .cpp
key: cpp-v3-${{ runner.os }}-${{ steps.cppkey.outputs.key }}