Skip to content

Install dependencies, build SMACK, and format once in CI - #845

Open
shaobo-he wants to merge 7 commits into
developfrom
simplify-ci
Open

Install dependencies, build SMACK, and format once in CI#845
shaobo-he wants to merge 7 commits into
developfrom
simplify-ci

Conversation

@shaobo-he

@shaobo-he shaobo-he commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

The regression matrix has 28 entries, but dependency installation, source
compilation, and formatting are properties of the revision rather than of an
individual test folder. This PR moves each of those operations out of the
matrix so the shards run only their assigned regression tests.

Workflow

  1. prepare CI dependency image computes an exact recipe hash over
    .github/ci/Dockerfile, bin/build.sh, and bin/versions.
    • If that GHCR image exists, the warm lookup finishes in seconds.
    • If it does not exist, one serialized producer installs Ubuntu packages,
      LLVM, .NET, Boost, Python, Rust, Z3, Boogie, and Corral and publishes the
      image only after a successful build.
    • There are no fallback tags or prefix restores, so a changed recipe cannot
      silently select stale tools.
  2. build SMACK checks out the requested revision in that image, compiles it
    once, and uploads a one-day tar artifact of its install tree. The tar archive
    preserves executable permissions.
  3. All 28 regression shards use the same dependency image and install artifact,
    set BUILD_SMACK=0, and run only their selected tests.
  4. Formatting runs once in an independent job.

Fork pull requests can reuse an existing exact dependency image. If a fork
changes the image recipe, CI fails with an explicit request for a maintainer to
publish that trusted image; untrusted pull-request code is never given package
write access.

Per workflow run

Work Before After
Formatting passes 28 1
Dev-tool installations 28 1
OS/language/solver dependency installations 28 0 warm / 1 after a recipe change
SMACK compilations 28 1
Matrix jobs that only test 0 28

The GitHub-hosted runner stops and deletes every job container during cleanup,
then decommissions the VM and its local image layers. The content-addressed GHCR
dependency image is retained deliberately: deleting that registry version after
each run would force a rebuild on every run and would prevent fork PRs from
reusing the trusted image.

Other CI corrections retained

  • Run Docker Hub publication only on trusted push events after formatting,
    build, and regressions pass.
  • Publish main as stable and develop as latest.
  • Avoid duplicate feature-branch push and pull_request runs.
  • Make DEPS_DIR overridable so the container can keep solver tools under
    /opt/smack-deps without changing local defaults.

Verification

shaobo-he and others added 6 commits August 18, 2026 23:27
The regression matrix has 28 entries, and every one of them re-ran the
identical clang-format/flake8 pass and installed the dev dependencies from
scratch to do it. Each job also invoked bin/build.sh twice, the second call
re-running the whole apt phase for nothing, and installed a Rust nightly
toolchain even for the 17 pure C/LLVM folders.

Workflow changes:

* Hoist formatting into a single `check-format` job. bin/build.sh stays the
  single source of truth for how the tools are installed -- it pins
  clang-format to LLVM_SHORT_VERSION from bin/versions -- but every phase
  except INSTALL_DEV_DEPENDENCIES is switched off, so the job installs no
  LLVM/dotnet/Boost packages, downloads no solvers and compiles nothing.
  It is deliberately not a `needs:` of check-regressions: a skipped job
  reports as success to branch protection, so gating the matrix on it would
  turn a formatting error into 28 green-looking skipped checks.

* Collapse each matrix job's two bin/build.sh calls into one.

* Derive INSTALL_RUST from the matrix entry, so only the folders that
  actually reach rustc install the nightly toolchain (10 of 28).

* Cache smack-deps on bin/versions + bin/build.sh, so Z3, Boogie and Corral
  are downloaded once per version bump instead of 28 times per run.
  restore/save are split rather than using actions/cache so that only a job
  which ran green can publish an entry: bin/build.sh guards its installs
  with `[ ! -d ]`, so a job that died on a failed download would otherwise
  cache an empty tree that every later job would accept as a complete
  install. No restore-keys, for the same reason.

* Restrict `push` to the branches that publish an image and add a
  concurrency group. A push to a branch with an open pull request used to
  fire the entire workflow a second time. Push runs key the group on
  github.run_id so two merges landing close together on develop both run and
  both publish.

* Docker job: replace the disabled ::set-output syntax with $GITHUB_OUTPUT,
  and gate the job on a push to this repository -- Docker Hub secrets are
  not available to forks, so a fork PR used to earn a guaranteed red X after
  ~25 minutes of green regressions. Map main to :stable; master no longer
  exists after the rename, which is why :stable stopped being published even
  though docs/installation.md advertises it.

* Add job timeouts and a read-only default permissions block.

bin/build.sh changes:

* Make DEPS_DIR overridable, so CI can place smack-deps inside
  GITHUB_WORKSPACE for actions/cache. Identical to today's value when unset.

* Remove the hardcoded `GITHUB_ACTIONS = true -> exit 0` escape hatch. It
  existed only so the old workflow could lint between two build.sh calls,
  and it is a trap: any future job setting INSTALL_DEV_DEPENDENCIES=1
  alongside BUILD_SMACK/TEST_SMACK would exit before the tests and report
  green.

* Drop `cargo install rustfilt`. rustfilt appears exactly once in the whole
  repository, on the line being removed; nothing invokes it. It is also a
  from-source compile and the only unpinned item in the Rust install.

* Give the exit status a defined value when TEST_SMACK=0. With `set -e`
  active, `res=$?` was only ever reached with $? == 0, and with TEST_SMACK=0
  `res` was unset entirely.

The 28 matrix strings are byte-identical, so every existing status check
name is preserved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@shaobo-he shaobo-he changed the title Install dependencies and check formatting only once in CI Install dependencies, build SMACK, and format once in CI Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant