Skip to content

Commit e13a638

Browse files
AnomalRoilazixus
andauthored
Starting to use sccache in GHA (#191)
Co-authored-by: Robin Müller <[email protected]>
1 parent 277d824 commit e13a638

File tree

14 files changed

+210
-164
lines changed

14 files changed

+210
-164
lines changed

.github/actions/rust-test-action/action.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/check-rust-bindings.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on:
33
push:
44
branches: [ main ]
55
pull_request:
6+
paths:
7+
- 'modules/*-solidity/**'
68
workflow_dispatch:
79

810
jobs:
@@ -51,4 +53,5 @@ jobs:
5153

5254
# 4. Actually check the bindings against the generated code
5355
- name: Check the bindings match
54-
run: ./generate-bindings.sh
56+
run: ./generate-bindings.sh
57+

.github/workflows/rust-build-and-tests.yml

Lines changed: 60 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,85 +10,83 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
env:
13+
SCCACHE_CACHE_SIZE: "10G"
14+
SCCACHE_GCS_BUCKET: "randamu-gha-cache-bucket"
15+
SCCACHE_GCS_KEY_PATH: /tmp/gcp-secret.json
16+
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GCP_SCCACHE_SERVICE_ACCOUNT }}
17+
SCCACHE_GCS_KEY_PREFIX: sccache_dcipher
18+
SCCACHE_GCS_RW_MODE: READ_WRITE
1319
CARGO_TERM_COLOR: always
1420

21+
1522
jobs:
16-
rust-build-and-tests:
17-
name: Build and test rust crates
23+
rust-tests:
24+
name: Test rust crates
1825
runs-on: ["randamu-self-hosted-default"]
26+
env:
27+
RUSTC_WRAPPER: "sccache"
1928
steps:
29+
- name: setup secrets for sccache
30+
run: echo $GOOGLE_APPLICATION_CREDENTIALS > $SCCACHE_GCS_KEY_PATH
31+
- name: Install sccache
32+
uses: mozilla-actions/[email protected]
33+
34+
# Pull cargo nextest binaries
35+
- uses: taiki-e/install-action@v2
36+
with:
37+
tool: nextest
38+
2039
- name: Checkout code
2140
uses: actions/checkout@v5
2241
with:
2342
submodules: 'recursive'
2443

25-
- name: Cache npm blocklock-solidity
26-
uses: actions/cache@v3
27-
with:
28-
path: modules/blocklock-solidity/node_modules
29-
key: ${{ runner.os }}-npm-blocklock-solidity-${{ hashFiles('blocklock-solidity/package-lock.json') }}
30-
restore-keys: |
31-
${{ runner.os }}-npm-blocklock-solidity-
44+
- name: Run all tests
45+
run: cargo nextest run --target-dir './target' --no-tests warn --profile ci
46+
shell: bash
47+
env:
48+
TESTNETS_PRIVATE_KEY: ${{ secrets.TESTNETS_PRIVATE_KEY }}
49+
POLYGON_RPC_URL: ${{ secrets.POLYGON_RPC_URL }}
50+
BASE_SEPOLIA_RPC_URL: ${{ secrets.BASE_SEPOLIA_RPC_URL }}
51+
AVALANCHE_FUJI_RPC_URL: ${{ secrets.AVALANCHE_FUJI_RPC_URL }}
3252

33-
- name: Cache npm randomness-solidity
34-
uses: actions/cache@v3
35-
with:
36-
path: modules/randomness-solidity/node_modules
37-
key: ${{ runner.os }}-npm-randomness-solidity-${{ hashFiles('randomness-solidity/package-lock.json') }}
38-
restore-keys: |
39-
${{ runner.os }}-npm-randomness-solidity-
53+
rust-clippy:
54+
name: Run clippy
55+
runs-on: ["randamu-self-hosted-default"]
56+
env:
57+
RUSTC_WRAPPER: "sccache"
58+
RUSTFLAGS: -Dwarnings
59+
RUSTDOCFLAGS: -Dwarnings
60+
steps:
61+
- name: setup secrets for sccache
62+
run: echo $GOOGLE_APPLICATION_CREDENTIALS > $SCCACHE_GCS_KEY_PATH
63+
- name: Install sccache
64+
uses: mozilla-actions/[email protected]
4065

41-
- name: Cache Solidity blocklock-solidity
42-
uses: actions/cache@v3
66+
# Pull cargo nextest binaries
67+
- uses: taiki-e/install-action@v2
4368
with:
44-
path: modules/blocklock-solidity/out
45-
key: ${{ runner.os }}-sol-blocklock-solidity-${{ hashFiles('blocklock-solidity/src/**/*.sol', 'blocklock-solidity/lib/**/*.sol') }}
46-
restore-keys: |
47-
${{ runner.os }}-sol-blocklock-solidity-
69+
tool: hack
4870

49-
- name: Cache Solidity randomness-solidity
50-
uses: actions/cache@v3
71+
- name: Checkout code
72+
uses: actions/checkout@v5
5173
with:
52-
path: modules/randomness-solidity/out
53-
key: ${{ runner.os }}-sol-randomness-solidity-${{ hashFiles('randomness-solidity/src/**/*.sol', 'randomness-solidity/lib/**/*.sol') }}
54-
restore-keys: |
55-
${{ runner.os }}-sol-randomness-solidity-
56-
57-
# 1. Compile blocklock-solidity
58-
- name: blocklock-solidity - Install dependencies
59-
working-directory: ./modules/blocklock-solidity
60-
run: npm ci
61-
62-
- name: blocklock-solidity - Build Solidity contracts
63-
working-directory: ./modules/blocklock-solidity
64-
run: npm run build:forge
74+
submodules: 'recursive'
6575

66-
# 2. Compile randomness-solidity
67-
- name: randomness-solidity - Install dependencies
68-
working-directory: ./modules/randomness-solidity
69-
run: npm ci
76+
- name: Check formatting
77+
run: cargo fmt --check
78+
shell: bash
7079

71-
- name: randomness-solidity - Build Solidity contracts
72-
working-directory: ./modules/randomness-solidity
73-
run: npm run build:forge
80+
- name: clippy check (all features)
81+
run: cargo clippy --workspace --all-features --all-targets --lib --bins --tests --benches --examples
7482

75-
# 3. Compile onlyswaps-solidity
76-
- name: onlyswaps-solidity - Install dependencies
77-
working-directory: ./modules/onlyswaps-solidity
78-
run: npm ci
83+
- name: clippy check (no features)
84+
run: cargo clippy --workspace --no-default-features --all-targets --lib --bins --tests --benches --examples
7985

80-
- name: onlyswaps-solidity - Build Solidity contracts
81-
working-directory: ./modules/onlyswaps-solidity
82-
run: npm run build
86+
- name: clippy check (default features)
87+
run: cargo clippy --workspace --all-targets --lib --bins --tests --benches --examples
8388

84-
# 4. Build and test workspace packages
85-
- name: Lint & Test Rust Workspace
86-
uses: ./.github/actions/rust-test-action
87-
env:
88-
TESTNETS_PRIVATE_KEY: ${{ secrets.TESTNETS_PRIVATE_KEY }}
89-
POLYGON_RPC_URL: ${{ secrets.POLYGON_RPC_URL }}
90-
BASE_SEPOLIA_RPC_URL: ${{ secrets.BASE_SEPOLIA_RPC_URL }}
91-
AVALANCHE_FUJI_RPC_URL: ${{ secrets.AVALANCHE_FUJI_RPC_URL }}
92-
with:
93-
working-directory: .
94-
extra-cache-key: 'dcipher'
89+
- name: clippy for each only on main
90+
if: github.ref == 'refs/heads/main'
91+
run: cargo hack clippy --workspace --exclude generated --each-feature --all-targets --target-dir './target'
92+
shell: bash

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ The repository is organized into:
2828

2929
### Binaries (`bin/`)
3030

31-
| Binary | Purpose | Documentation |
32-
|-----------------------|--------------------------------------------------------------------------------------------------------|----------------------------------------------|
33-
| `adkg-cli` | CLI for running and testing Asynchronous Distributed Key Generation ceremonies | [README](./bin/adkg-cli/README.md) |
34-
| `blocklock-agent` | Agent for the Blocklock protocol (time-lock / conditional decryption) | |
35-
| `dsigner` | Threshold signing daemon, allowing operators to separate condition evaluation and signing for security | [README](./bin/dsigner/README.md) |
36-
| `gen-keys` | Utility for key generation (testing / setup) | [README](./bin/gen-keys/README.md) |
37-
| `monitoring` | An agent that listens/polls dcipher-related information and ships it to prometheus | [README](./bin/monitoring/README.md) |
38-
| `onlyswaps-solver` | An agent for providing token liquidity on chains that support onlyswaps to make yield. | [README](./bin/onlyswaps-solver/README.md) |
39-
| `onlyswaps-state-api` | API for caching and serving state related to ONLYSwaps | |
40-
| `onlyswaps-verifier` | A dcipher protocol implementation called ONLYSwaps for enabling cross-chain token swaps | [README](./bin/onlyswaps-verifier/README.md) |
41-
| `randomness-agent` | A dcipher protocol implementation for providing verifiable randomness on-chain | | |
31+
| Binary | Purpose | Documentation |
32+
|-----------------------|--------------------------------------------------------------------------------------------------------|-----------------------------------------------|
33+
| `adkg-cli` | CLI for running and testing Asynchronous Distributed Key Generation ceremonies | [README](./bin/adkg-cli/README.md) |
34+
| `blocklock-agent` | Agent for the Blocklock protocol (time-lock / conditional decryption) | |
35+
| `dsigner` | Threshold signing daemon, allowing operators to separate condition evaluation and signing for security | [README](./bin/dsigner/README.md) |
36+
| `gen-keys` | Utility for key generation (testing / setup) | [README](./bin/gen-keys/README.md) |
37+
| `monitoring` | An agent that listens/polls dcipher-related information and ships it to prometheus | [README](./bin/monitoring/README.md) |
38+
| `onlyswaps-smoketest` | A continuous monitoring and testing tool for only swaps. | [README](./bin/onlyswaps-smoketest/README.md) |
39+
| `onlyswaps-solver` | An agent for providing token liquidity on chains that support onlyswaps to make yield. | [README](./bin/onlyswaps-solver/README.md) |
40+
| `onlyswaps-state-api` | API for caching and serving state related to ONLYSwaps | |
41+
| `onlyswaps-verifier` | A dcipher protocol implementation called ONLYSwaps for enabling cross-chain token swaps | [README](./bin/onlyswaps-verifier/README.md) |
42+
| `randomness-agent` | A dcipher protocol implementation for providing request-based verifiable randomness on-chain | |
4243

4344
---
4445

bin/adkg-cli/Dockerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@ WORKDIR /app
55

66
FROM chef AS planner
77
COPY . .
8-
RUN cargo chef prepare --recipe-path recipe.json
8+
RUN cargo chef prepare --recipe-path recipe.json --bin adkg-cli
99

1010
FROM chef AS builder
1111
COPY --from=planner /app/recipe.json recipe.json
1212
# Build dependencies - this is the caching Docker layer!
13-
RUN cargo chef cook --release --recipe-path recipe.json
13+
RUN cargo chef cook --release --recipe-path recipe.json --bin adkg-cli
14+
# Copy local dependencies
15+
COPY Cargo.toml Cargo.lock ./
16+
COPY bin/adkg-cli/ ./bin/adkg-cli
17+
COPY crates/adkg ./crates/adkg
18+
COPY crates/config ./crates/config
19+
COPY crates/network ./crates/network
20+
COPY crates/utils ./crates/utils
1421
# Build application
15-
COPY . .
16-
RUN cargo build --release -p adkg-cli
17-
RUN strip target/release/adkg-cli
22+
RUN cargo build --release -p adkg-cli --bin adkg-cli
1823

1924
# We do not need the Rust toolchain to run the binary!
2025
FROM debian:bookworm-slim AS runtime

bin/blocklock-agent/Dockerfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,24 @@ WORKDIR /app
66

77
FROM chef AS planner
88
COPY . .
9-
RUN cargo chef prepare --recipe-path recipe.json
9+
RUN cargo chef prepare --recipe-path recipe.json --bin blocklock-agent
1010

1111
FROM chef AS builder
1212
COPY --from=planner /app/recipe.json recipe.json
13-
1413
# Build dependencies - this is the caching Docker layer!
1514
RUN cargo chef cook --release --recipe-path recipe.json
16-
1715
# Build application
18-
COPY . .
16+
COPY Cargo.toml Cargo.lock ./
17+
18+
COPY bin/blocklock-agent/ ./bin/blocklock-agent
19+
COPY crates/dcipher-agents ./crates/dcipher-agents
20+
COPY crates/generated ./crates/generated
21+
COPY crates/utils ./crates/utils
22+
COPY crates/config ./crates/config
23+
COPY crates/network ./crates/network
24+
COPY crates/signer ./crates/signer
25+
COPY crates/superalloy ./crates/superalloy
26+
1927
RUN cargo build --release -p blocklock-agent --example blocklock
2028

2129
# We do not need the Rust toolchain to run the binary!

bin/dsigner/examples/dsigner_grpc/Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,33 @@
22

33
# Base image for rust
44
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
5-
RUN apt-get update && apt-get install -y protobuf-compiler
6-
5+
RUN apt-get update \
6+
&& apt-get install -y protobuf-compiler \
7+
&& rm -rf /var/lib/apt/lists/*
78
WORKDIR /app
89

910
FROM chef AS planner
1011
COPY . .
12+
# chef prepare --bin sadly doesn't support binaries of kind "example"
1113
RUN cargo chef prepare --recipe-path recipe.json
1214

1315
FROM chef AS builder
1416
COPY --from=planner /app/recipe.json recipe.json
1517

1618
# Build dependencies - this is the caching Docker layer!
19+
# --bin sadly doesn't support binaries of kind "example"
1720
RUN cargo chef cook --release --recipe-path recipe.json
1821

1922
# Build application
20-
COPY . .
23+
COPY Cargo.toml Cargo.lock ./
24+
25+
COPY bin/dsigner/ ./bin/dsigner
26+
COPY crates/network ./crates/network
27+
COPY crates/signer ./crates/signer
28+
COPY crates/superalloy ./crates/superalloy
29+
COPY crates/utils ./crates/utils
30+
COPY modules/dcipher-proto ./modules/dcipher-proto
31+
2132
RUN cargo build --release --example dsigner_grpc --all-features
2233

2334
# We do not need the Rust toolchain to run the binary!

bin/dsigner/examples/dsigner_legacy_http/Dockerfile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,27 @@ WORKDIR /app
88

99
FROM chef AS planner
1010
COPY . .
11+
# chef prepare --bin sadly doesn't support binaries of kind "example"
1112
RUN cargo chef prepare --recipe-path recipe.json
1213

1314
FROM chef AS builder
1415
COPY --from=planner /app/recipe.json recipe.json
1516

1617
# Build dependencies - this is the caching Docker layer!
18+
# --bin sadly doesn't support binaries of kind "example"
1719
RUN cargo chef cook --release --recipe-path recipe.json
1820

1921
# Build application
20-
COPY . .
22+
COPY Cargo.toml Cargo.lock ./
23+
24+
COPY bin/dsigner/ ./bin/dsigner
25+
COPY crates/config ./crates/config
26+
COPY crates/network ./crates/network
27+
COPY crates/signer ./crates/signer
28+
COPY crates/superalloy ./crates/superalloy
29+
COPY crates/utils ./crates/utils
30+
COPY modules/dcipher-proto ./modules/dcipher-proto
31+
2132
RUN cargo build --release --example dsigner_legacy_http --all-features
2233

2334
# We do not need the Rust toolchain to run the binary!

0 commit comments

Comments
 (0)