Skip to content

Add build-rejson composite action - #10

Merged
kei-nan merged 1 commit into
mainfrom
jk-build-rejson
Oct 4, 2026
Merged

kei-nan merged 1 commit into
mainfrom
jk-build-rejson

Conversation

@kei-nan

@kei-nan kei-nan commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Purpose

A shared, cached RedisJSON build for flow tests that load RedisJSON as a side module. Today RediSearch has its own .github/actions/build-rejson, and a repo that vendors RediSearch as a submodule keeps a near-copy of it. This action is the union of the two, so both can drop their local copy and keep the same behaviour.

On a cache hit, rejson.so is restored. On a miss, it is built through RediSearch's own tests/deps/setup_rejson.sh (the script the flow tests source) and then saved. Every step is inline, so the action is container-safe and doesn't depend on github.action_path.

Inputs / outputs

Input Default Notes
rejson-branch master Branch, tag or 40-char SHA. It is resolved to a SHA, and the build uses that SHA so the binary matches the key.
san "" Sanitizer ("" or address). Passed as SAN.
cov "0" 1 = coverage build. Passed as COV.
cache_platform_id required Opaque id of the binary-compatible platform (container image or runner env).
redisearch-root . RediSearch checkout root, relative to $GITHUB_WORKSPACE or absolute. It must contain .rust-nightly and tests/deps/setup_rejson.sh.
toolchain-enable "" Optional script, sourced before computing the key and before building (e.g. a devtoolset enable script).
export-rejson-path true When true, writes REJSON_PATH to $GITHUB_ENV.
Output
rejson-path Absolute path of $GITHUB_WORKSPACE/bin/rejson.so (built or restored).
cache-hit 'true' when restored from cache.

Cache key

rejson-<RedisJSON SHA>-<platform id>-<runner.arch>-san_<san|none>-cov_<cov>-cc_<hash>-rust_<.rust-nightly>

cc_<hash> is the first 12 hex digits of a SHA-256. It covers the first line of ${CC:-cc} --version plus the values of CFLAGS, CXXFLAGS, LDFLAGS, RUSTFLAGS and CARGO_ENCODED_RUSTFLAGS. It is computed in the same login shell as the build, after toolchain-enable has been sourced. The hashed material is printed to the log.

setup_rejson.sh runs make with the inherited environment, so the compiler and any job-level flags shape the binary. Hashing them means an entry is never shared across compilers or flags. The other components are the same as the RediSearch original.

Differences from the RediSearch original

  • redisearch-root input replaces the hardcoded $GITHUB_WORKSPACE for .rust-nightly and setup_rejson.sh. This is required for reuse; the default . keeps current behaviour.
  • toolchain-enable input lets jobs that switch compilers via an enable script key and build with the compiler their tests use.
  • cc_ key component, as above.
  • Key step uses bash -leo pipefail (as the build step already did), so the compiler and flags it sees match the build.
  • Build step drops set -u, because typical toolchain enable scripts read unset variables. The shell still runs with -eo pipefail.
  • rejson-path / cache-hit outputs are added. The REJSON_PATH export stays, as the default, behind export-rejson-path.
  • rejson-branch is optional and defaults to master, the same default as setup_rejson.sh. Existing callers always pass it.
  • Hashing falls back to shasum -a 256 where sha256sum is missing (macOS runners).
  • actions/cache/{restore,save} stay on the same SHA pin (v5.1.0).

Differences from the submodule-consumer copy

  • san/cov inputs and the REJSON_PATH export are restored. Defaults are empty, 0 and true. Pass export-rejson-path: 'false' to keep output-only behaviour.
  • actions/cache is pinned by SHA (v5.1.0) instead of the @v6 tag, per this repo's third-party pinning rule.
  • The key gains san_none-cov_0 and the flags hash, so expect one cold miss per platform after migrating.

Migration

RediSearch is a one-line swap in task-build-rejson.yml and task-test.yml, after which .github/actions/build-rejson/ can be deleted:

uses: redislabsdev/redisearch-ci-common/.github/actions/build-rejson@v1

The inputs are unchanged. Expect one cold miss per platform/flavour, because of the added cc_ component.

Submodule consumers:

- id: rejson
  uses: redislabsdev/redisearch-ci-common/.github/actions/build-rejson@v1
  with:
    cache_platform_id: ...
    redisearch-root: deps/RediSearch
    toolchain-enable: ${{ env.<ENABLE_SCRIPT_VAR> }}
    export-rejson-path: 'false'
# later: env: REJSON_PATH: ${{ steps.rejson.outputs.rejson-path }}

If a job selects its compiler through CC rather than an enable script, set CC in the env: of the uses: step so it is applied to both the key and the build.

Validation

actionlint 1.7.7 and the strict duplicate-key YAML check pass locally. Shellcheck of the extracted run: scripts shows only the expected dynamic-source notes. The key script was smoke-tested locally, and it produces a different key when RUSTFLAGS changes.

🤖 Generated with Claude Code


Note

Low Risk
CI-only shared action and documentation; no runtime product or auth/data-path changes.

Overview
Adds a shared build-rejson composite action so RediSearch-family repos can build or restore a cached rejson.so for flow tests instead of duplicating local actions.

The action resolves a RedisJSON ref to a SHA, restores rejson.so from GitHub Actions cache on a hit, or on a miss runs RediSearch’s tests/deps/setup_rejson.sh (via configurable redisearch-root) and saves the binary. Cache keys include RedisJSON SHA, platform id, arch, sanitizer/coverage, pinned .rust-nightly, and a hash of the active C compiler plus CFLAGS/RUSTFLAGS (with optional toolchain-enable). It outputs rejson-path and cache-hit, and by default exports REJSON_PATH for later steps. Steps are fully inline for container jobs.

README documents the new utility in the shared CI table.

Reviewed by Cursor Bugbot for commit b5a6995. Bugbot is set up for automated code reviews on this repo. Configure here.

Shared, cached RedisJSON build for RediSearch-family flow tests, unifying
the per-repo copies. The RediSearch checkout root is an input so repos
that vendor RediSearch as a submodule can use it, an optional toolchain
script is sourced before keying and building, and the cache key also
covers the C compiler and job-level build flags so entries are never
shared across toolchains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b5a6995. Configure here.

Comment thread .github/actions/build-rejson/action.yml Resolved
@kei-nan
kei-nan merged commit 81adf75 into main Oct 4, 2026
2 checks passed
@kei-nan
kei-nan deleted the jk-build-rejson branch October 5, 2026 15:33
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