Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
250 changes: 250 additions & 0 deletions .github/workflows/build-zccache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow is based on the `build`, `build-wheels` and `test-wheels` jobs of
# https://github.com/zackees/zccache/blob/1.13.21/.github/workflows/release-auto.yml
# (with its .github/actions/build-target/action.yml) and the `native-pytest` job of
# https://github.com/zackees/zccache/blob/1.13.21/.github/workflows/python-tests.yml
name: Build zccache wheels (riscv64)

on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/zccache.yaml not released yet'
required: false
default: ''
pull_request:
branches: [main]
paths:
- '.github/workflows/build-zccache.yml'
- 'docs/packages/zccache.yaml'
- 'patches/zccache/**'
push:
branches: [main]
paths:
- '.github/workflows/build-zccache.yml'
- 'docs/packages/zccache.yaml'
- 'patches/zccache/**'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read # to fetch code (actions/checkout)

env:
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64

jobs:
setup:
uses: $/.github/workflows/_setup.yml
with:
package: zccache
version: ${{ inputs.version }}

build_wheel:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
name: Build zccache ${{ matrix.version }} py3-none-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 1440

env:
ZCCACHE_VERSION: ${{ matrix.version }}

steps:
- name: Checkout zccache ${{ env.ZCCACHE_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: zackees/zccache
ref: ${{ env.ZCCACHE_VERSION }}
persist-credentials: false

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: python-wheels
persist-credentials: false

- name: Apply patches
run: git apply --verbose python-wheels/patches/zccache/${{ env.ZCCACHE_VERSION }}/*.patch

- name: Write container script
run: |
cat > riscv64-build.sh <<'EOF'
#!/bin/bash
set -e -x

export PATH="/opt/python/cp312-cp312/bin:${PATH}"
TARGET=riscv64gc-unknown-linux-gnu

# Upstream cross-compiles every target from x86_64 through soldr/zig; this builds natively instead.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none
. "${HOME}/.cargo/env"
rustup toolchain install

dnf install -y protobuf-compiler

export PYO3_PYTHON=python
cargo build --release --target "${TARGET}" -p zccache \
--features zccache-bin,fingerprint-bin \
--bin zccache --bin zccache-fp
cargo build --release --target "${TARGET}" -p zccache-cli --features python --lib
cargo build --release --target "${TARGET}" -p zccache-watcher-py --lib
cargo build --release --target "${TARGET}" -p zccache-fingerprint-py --lib

release="target/${TARGET}/release"
staging=dist/linux-riscv64-gnu
mkdir -p "${staging}/python/zccache/fingerprint" "${staging}/python/zccache/watcher"
cp "${release}/zccache" "${release}/zccache-fp" "${staging}/"
cp "${release}/libzccache_cli.so" "${staging}/python/zccache/_native.so"
cp "${release}/libzccache_fingerprint.so" "${staging}/python/zccache/fingerprint/_native.so"
cp "${release}/libzccache_watcher.so" "${staging}/python/zccache/watcher/_native.so"
for f in "${staging}/zccache" "${staging}/zccache-fp" "${staging}"/python/zccache/{,fingerprint/,watcher/}_native.so; do
strip --strip-debug "${f}"
done

now="$(date -u +%s)"
for bin in zccache zccache-fp; do
python ci/stamp_release.py \
--binary "${staging}/${bin}" \
--sha "${ZCCACHE_SHA}" \
--version "${ZCCACHE_VERSION}" \
--triple "${TARGET}" \
--timestamp "${now}"
done

for bin in zccache zccache-fp; do
"${staging}/${bin}" --version | grep -Eq "^${bin} [0-9]"
done
export ZCCACHE_CACHE_DIR="$(mktemp -d)/cache"
"${staging}/zccache" "$(rustup which rustc)" -vV | grep -q '^host: '
"${staging}/zccache" start
"${staging}/zccache" status
"${staging}/zccache" stop

python - <<'PY'
from ci.release_workflow import build_wheel, read_project_meta

build_wheel(*read_project_meta(), "linux-riscv64-gnu", ["manylinux_2_39_riscv64"])
PY
EOF

- name: Build wheel
run: |
podman run -t \
--log-driver=none \
--network=host \
-v "${PWD}":/zccache_src \
--workdir /zccache_src \
-e ZCCACHE_VERSION="${ZCCACHE_VERSION}" \
-e ZCCACHE_SHA="$(git rev-parse HEAD)" \
--pull=newer \
"${MANYLINUX_RISCV64_IMAGE}" \
bash /zccache_src/riscv64-build.sh

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: zccache-${{ env.ZCCACHE_VERSION }}-py3-none-manylinux_riscv64
path: dist/wheels/*.whl
if-no-files-found: error

test_wheel:
name: Test zccache ${{ matrix.version }} ${{ matrix.python }}
needs: [setup, build_wheel]
if: needs.setup.outputs.versions != '[]'
runs-on: ubuntu-24.04-riscv
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
# The pyo3 extensions are abi3, which free-threaded interpreters cannot load.
python: ["cp312", "cp313", "cp314"]

env:
ZCCACHE_VERSION: ${{ matrix.version }}

steps:
- name: Checkout zccache ${{ env.ZCCACHE_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: zackees/zccache
ref: ${{ env.ZCCACHE_VERSION }}
persist-credentials: false

- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: zccache-${{ env.ZCCACHE_VERSION }}-py3-none-manylinux_riscv64
path: dist/wheels

- name: Write container script
run: |
cat > riscv64-test.sh <<'EOF'
#!/bin/bash
set -e -x

export PATH="/opt/python/${PYTHON_TAG}-${PYTHON_TAG}/bin:${PATH}"

python -m pip install --only-binary=:all: /zccache_src/dist/wheels/*.whl pytest

zccache --version
zccache-fp --version
python -c 'import zccache._native, zccache.fingerprint._native, zccache.watcher._native'
python - <<'PY'
import importlib.metadata as md

shipped = {p.name for p in md.files("zccache") if ".dist-info/" in str(p)}
assert "LICENSE" in shipped, sorted(shipped)
PY

python ci/test_exec_cached_wheel.py

export ZCCACHE_CACHE_DIR="$(mktemp -d)/cache"
export ZCCACHE_DAEMON_NAMESPACE=native-python-tests
zccache start
for attempt in $(seq 1 30); do
zccache status && break
sleep 1
done
zccache status
python -m pytest python/tests -q -rs --durations=10
python -m pytest crates/zccache-watcher/python/tests -q -rs --durations=10
python -m pytest crates/zccache-fingerprint/python/tests -q -rs --durations=10
zccache stop
EOF

- name: Test wheel
run: |
podman run -t \
--log-driver=none \
--network=host \
-v "${PWD}":/zccache_src \
--workdir /zccache_src \
-e PYTHON_TAG="${{ matrix.python }}" \
-e PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ \
--pull=newer \
"${MANYLINUX_RISCV64_IMAGE}" \
bash /zccache_src/riscv64-test.sh

publish:
name: Publish zccache ${{ matrix.version }}
needs: [setup, build_wheel, test_wheel]
if: needs.setup.outputs.versions != '[]'
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
secrets:
app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }}
with:
artifact-pattern: zccache-${{ matrix.version }}-*-manylinux_riscv64
6 changes: 6 additions & 0 deletions docs/packages/zccache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package-name: zccache
source-code: https://github.com/zackees/zccache
license: AGPL-3.0-only
versions:
- version: 1.13.21
patched: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
From 813a874854534eb6bbb9be60184312215ccf66bd Mon Sep 17 00:00:00 2001
From: Ludovic Henry <git@ludovic.dev>
Date: Wed, 14 Oct 2026 14:27:20 +0000
Subject: [PATCH] protocol: fall back to prost-build's own protoc lookup on
riscv64

Upstream-Status: Inappropriate [protoc-bin-vendored ships no riscv64 binary; prost_build already defaults to its own PROTOC-env/PATH lookup, so not overriding it on unsupported platforms is the whole fix]

protoc_bin_vendored::protoc_bin_path() returns Err on any host outside
its small set of prebuilt targets (x86, x86_64, aarch64, ppc64le, s390x,
macOS, Windows), and build.rs turned that into a panic before
prost_build ever got a chance to look for a protoc on PATH or via
$PROTOC. Only exporting PROTOC when the vendored lookup succeeds
restores that fallback, which prost-build documents in its "Sourcing
protoc" section.

Signed-off-by: Ludovic Henry <git@ludovic.dev>
---
crates/zccache-protocol/build.rs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/crates/zccache-protocol/build.rs b/crates/zccache-protocol/build.rs
index 7179f40..aba99f4 100644
--- a/crates/zccache-protocol/build.rs
+++ b/crates/zccache-protocol/build.rs
@@ -7,9 +7,11 @@ fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=proto/zccache_v1.proto");

- let protoc = protoc_bin_vendored::protoc_bin_path()
- .expect("vendored protoc is available for zccache wire protobufs");
- std::env::set_var("PROTOC", protoc);
+ // protoc-bin-vendored ships no riscv64 binary; falling through leaves
+ // prost_build's own PROTOC-env/PATH lookup in charge there.
+ if let Ok(protoc) = protoc_bin_vendored::protoc_bin_path() {
+ std::env::set_var("PROTOC", protoc);
+ }

prost_build::Config::new()
.compile_protos(&["proto/zccache_v1.proto"], &["proto"])
--
2.43.0

Loading
Loading