Skip to content
196 changes: 172 additions & 24 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ parameters:
default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:1f387a77be889f65a2a25986a5c5eccc88cec23fabe6aeaf351790751145c81e"
ubuntu-2404-docker-image:
type: string
# ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404-6
default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:c0412c53e59ce0c96bde4c08e7332ea12e4cadba9bbac829621947897fa21272"
# ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404-7
default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:e52bd8fbb38908f203c6866e39562548faf26e5b7a5174f9860b44aae2b8f0cd"
ubuntu-2404-arm-docker-image:
type: string
# ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404.arm-2
default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:27b03c1c4688e5d69b10e0539460346a3dee3b10b0e04fb406b9707c6f0dd95e"
# ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404.arm-3
default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:1e6dbf9a9173f2645449281a1e11918a95ca6dc04e59aa9d70824cffc44697ed"
ubuntu-2404-clang-docker-image:
type: string
# ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404.clang-7
default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:7466ed23590cf14e60da884894723bcdab064742f017dcfcce015999b4f9143b"
# ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404.clang-8
default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:e283c8ec6a59c76565c89b856d8019af2fa5beb96f27d3064fc4dda42bf3524d"
ubuntu-clang-ossfuzz-docker-image:
type: string
# ghcr.io/argotorg/solidity-buildpack-deps:ubuntu.clang.ossfuzz-12
default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:c7088af5082bf764244a6251ecf3dd29d280d2cd2cd071f011f7f32e0326f426"
# ghcr.io/argotorg/solidity-buildpack-deps:ubuntu.clang.ossfuzz-13
default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:2acb5d6f254ece25a96096f26960b5fe114eb86ceca92312cd20d59c096bf6e4"
emscripten-docker-image:
type: string
# NOTE: Please remember to update the `scripts/build_emscripten.sh` whenever the hash of this image changes.
# ghcr.io/argotorg/solidity-buildpack-deps:emscripten-21
default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:fc53d68a4680ffa7d5f70164e13a903478964f15bcc07434d74833a05f4fbc19"
# ghcr.io/argotorg/solidity-buildpack-deps:emscripten-22
default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:b9c953144d82cca5553f65626bc43b8af456dbc8966f8732ff9522f33ca8d722"
evm-version:
type: string
default: osaka
Expand Down Expand Up @@ -75,6 +75,55 @@ commands:
event: release
condition: on_success

ensure_ccache_key:
description: "Fail fast when CCACHE_KEY is missing."
steps:
- run:
name: Check CCACHE_KEY
command: |
if [ -z "${CCACHE_KEY:-}" ]; then
echo "CCACHE_KEY is not set. Please set it in CircleCI environment settings."
exit 1
fi

restore_ccache_if_allowed:
description: "Restore ccache unless on a tag or a skipped branch."
parameters:
# TODO: remove the line below
# Before merging this PR we need to use an alternative develop branch to test the functionality, `ci-ccache`
skip_branches_regex:
description: "Regex of branches that should skip restoring the cache."
type: string
default: "^(ci-ccache|breaking)$"
steps:
# Tags always skip ccache. Selected branches intentionally start from scratch.
- when:
condition:
and:
- equal: ["", << pipeline.git.tag >>]
- not:
matches:
pattern: "<< parameters.skip_branches_regex >>"
value: << pipeline.git.branch >>
steps:
- restore_cache:
keys:
# Reuse cache produced on ci-ccache (prefix match; restores the most recent).
- v1-{{ .Environment.CCACHE_KEY }}-ccache-{{ .Environment.CIRCLE_JOB }}-ci-ccache-

save_ccache_if_develop:
description: "Save a fresh ccache only on the ci-ccache branch."
steps:
# On `ci-ccache` we always generate a fresh cache by never restoring and by saving under a unique key.
- when:
condition:
equal: ["ci-ccache", << pipeline.git.branch >>]
steps:
- save_cache:
key: v1-{{ .Environment.CCACHE_KEY }}-ccache-{{ .Environment.CIRCLE_JOB }}-ci-ccache-{{ .Revision }}
paths:
- ~/.ccache

prepare_bytecode_report:
description: "Generate bytecode report and upload it as an artifact."
parameters:
Expand Down Expand Up @@ -208,15 +257,61 @@ commands:

run_build:
steps:
- run:
name: Build
command: scripts/ci/build.sh
- when:
condition:
equal: ["", << pipeline.git.tag >>]
steps:
- ensure_ccache_key
- restore_ccache_if_allowed
# WARNING! If you edit anything between here and save_cache, remember to bump the CCACHE_KEY version in CircleCI environment settings
- when:
condition:
and:
- equal: ["", << pipeline.git.tag >>]
steps:
- run:
name: Build (ccache)
command: CCACHE_ENABLED=${CCACHE_ENABLED:-1} scripts/ci/build.sh
- when:
condition:
or:
- not:
equal: ["", << pipeline.git.tag >>]
steps:
- run:
name: Build (no ccache)
command: scripts/ci/build.sh

- save_ccache_if_develop

run_build_ossfuzz:
steps:
- run:
name: Build_ossfuzz
command: scripts/ci/build_ossfuzz.sh
- when:
condition:
equal: ["", << pipeline.git.tag >>]
steps:
- ensure_ccache_key
- restore_ccache_if_allowed
# WARNING! If you edit anything between here and save_cache, remember to bump the CCACHE_KEY version in CircleCI environment settings
- when:
condition:
and:
- equal: ["", << pipeline.git.tag >>]
steps:
- run:
name: Build_ossfuzz (ccache)
command: CCACHE_ENABLED=${CCACHE_ENABLED:-1} scripts/ci/build_ossfuzz.sh
- when:
condition:
or:
- not:
equal: ["", << pipeline.git.tag >>]
steps:
- run:
name: Build_ossfuzz (no ccache)
command: scripts/ci/build_ossfuzz.sh

- save_ccache_if_develop

run_proofs:
steps:
Expand Down Expand Up @@ -1197,7 +1292,7 @@ jobs:
- run:
name: Install build dependencies
command: |
pacman --noconfirm -Syu --noprogressbar --needed base-devel boost cmake git openssh tar
pacman --noconfirm -Syu --noprogressbar --needed base-devel boost cmake ccache git openssh tar
- checkout
- run_build
- store_artifacts_solc
Expand Down Expand Up @@ -1257,10 +1352,33 @@ jobs:
MAKEFLAGS: -j 10
steps:
- checkout
- run:
name: Build
command: |
scripts/ci/build_emscripten.sh
- when:
condition:
equal: ["", << pipeline.git.tag >>]
steps:
- ensure_ccache_key
- restore_ccache_if_allowed
# WARNING! If you edit anything between here and save_cache, remember to bump the CCACHE_KEY version in CircleCI environment settings
- when:
condition:
and:
- equal: ["", << pipeline.git.tag >>]
steps:
- run:
name: Build (ccache)
command: CCACHE_ENABLED=${CCACHE_ENABLED:-1} scripts/ci/build_emscripten.sh
- when:
condition:
or:
- not:
equal: ["", << pipeline.git.tag >>]
steps:
- run:
name: Build (no ccache)
command: |
scripts/ci/build_emscripten.sh

- save_ccache_if_develop
- store_artifacts:
path: upload/soljson.js
destination: soljson.js
Expand Down Expand Up @@ -1737,9 +1855,39 @@ jobs:
key: dependencies-win-{{ arch }}-{{ checksum "scripts/install_deps.ps1" }}
paths:
- .\deps
- run:
name: "Building solidity"
command: scripts/ci/build_win.sh
- when:
condition:
equal: ["", << pipeline.git.tag >>]
steps:
- ensure_ccache_key
- restore_ccache_if_allowed
# WARNING! If you edit anything between here and save_cache, remember to bump the CCACHE_KEY version in CircleCI environment settings
- when:
condition:
and:
- equal: ["", << pipeline.git.tag >>]
steps:
- run:
name: "Building solidity (ccache)"
command: CCACHE_ENABLED=${CCACHE_ENABLED:-1} scripts/ci/build_win.sh
- when:
condition:
or:
- not:
equal: ["", << pipeline.git.tag >>]
steps:
- run:
name: "Building solidity (no ccache)"
command: scripts/ci/build_win.sh
# On `ci-ccache` we always generate a fresh cache by never restoring and by saving under a unique key.
- when:
condition:
equal: ["ci-ccache", << pipeline.git.branch >>]
steps:
- save_cache:
key: v1-{{ .Environment.CCACHE_KEY }}-ccache-{{ .Environment.CIRCLE_JOB }}-ci-ccache
paths:
- ~/.ccache
- run:
name: "Run solc.exe to make sure build was successful."
command: .\build\solc\Release\solc.exe --version
Expand Down
1 change: 1 addition & 0 deletions .circleci/osx_install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ then
brew update
brew upgrade
brew install cmake
brew install ccache
brew install wget
brew install coreutils
brew install diffutils
Expand Down
18 changes: 17 additions & 1 deletion scripts/ci/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -ex

ROOTDIR="$(dirname "$0")/../.."
ROOTDIR="$(realpath "$(dirname "$0")/../..")"
Copy link
Member

Choose a reason for hiding this comment

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

Why is this change necessary?

Copy link
Member Author

@marcocastignoli marcocastignoli Jan 12, 2026

Choose a reason for hiding this comment

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

Because of CCACHE_BASEDIR,it needs to be an absolute path to keep ccache hash paths consistent across runs. it's probably not needed but it's cleaner imo

# shellcheck source=scripts/common.sh
source "${ROOTDIR}/scripts/common.sh"

Expand All @@ -16,7 +16,23 @@ cd build

[[ -n $COVERAGE && -z $CIRCLE_TAG ]] && CMAKE_OPTIONS="$CMAKE_OPTIONS -DCOVERAGE=ON"

if [[ "${CCACHE_ENABLED:-}" == "1" ]]; then
export CCACHE_DIR="$HOME/.ccache"
export CCACHE_BASEDIR="$ROOTDIR"
export CCACHE_NOHASHDIR=1
CMAKE_OPTIONS="${CMAKE_OPTIONS:-} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
mkdir -p "$CCACHE_DIR"
fi

# shellcheck disable=SC2086
cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" $CMAKE_OPTIONS

if [[ "${CCACHE_ENABLED:-}" == "1" ]]; then
ccache -z
fi

cmake --build .

if [[ "${CCACHE_ENABLED:-}" == "1" ]]; then
ccache -s
fi
12 changes: 12 additions & 0 deletions scripts/ci/build_emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ function build() {
# TODO: This can be removed if and when all usages of `move()` in our codebase use the `std::` qualifier.
CMAKE_CXX_FLAGS="-Wno-unqualified-std-cast-call"

if [[ "${CCACHE_ENABLED:-}" == "1" ]]; then
export CCACHE_DIR="$HOME/.ccache"
CCACHE_BASEDIR="$(pwd)"
export CCACHE_BASEDIR
export CCACHE_NOHASHDIR=1
mkdir -p "$CCACHE_DIR"
ccache -z
fi

mkdir -p "$build_dir"
cd "$build_dir"
emcmake cmake \
Expand All @@ -64,6 +73,9 @@ function build() {
-DTESTS=0 \
..
make soljson
if [[ "${CCACHE_ENABLED:-}" == "1" ]]; then
ccache -s
fi

cd ..
mkdir -p upload
Expand Down
19 changes: 17 additions & 2 deletions scripts/ci/build_ossfuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,24 @@ function generate_protobuf_bindings
function build_fuzzers
{
cd "${BUILDDIR}"
cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" -DCCACHE=OFF \
-DCMAKE_TOOLCHAIN_FILE="${ROOTDIR}"/cmake/toolchains/libfuzzer.cmake
if [[ "${CCACHE_ENABLED:-}" == "1" ]]; then
export CCACHE_DIR="$HOME/.ccache"
export CCACHE_BASEDIR="$ROOTDIR"
export CCACHE_NOHASHDIR=1
CMAKE_OPTIONS="${CMAKE_OPTIONS:-} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
mkdir -p "$CCACHE_DIR"
fi
# shellcheck disable=SC2086
cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" \
-DCMAKE_TOOLCHAIN_FILE="${ROOTDIR}"/cmake/toolchains/libfuzzer.cmake \
$CMAKE_OPTIONS
if [[ "${CCACHE_ENABLED:-}" == "1" ]]; then
ccache -z
fi
make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j 4
if [[ "${CCACHE_ENABLED:-}" == "1" ]]; then
ccache -s
fi
}

generate_protobuf_bindings
Expand Down
Loading