Skip to content

Commit 8f9a1af

Browse files
authored
Merge pull request #1611 from o1-labs/dw/build-use-rust-env-var
CI: Centralize version management, including Rust (stable and nightly) and OCaml
2 parents 1185530 + d094461 commit 8f9a1af

File tree

7 files changed

+135
-39
lines changed

7 files changed

+135
-39
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Load Versions
2+
description: Load version numbers from centralized config file
3+
4+
outputs:
5+
rust-stable:
6+
description: "Rust stable version"
7+
value: ${{ steps.load.outputs.rust-stable }}
8+
rust-nightly:
9+
description: "Rust nightly version"
10+
value: ${{ steps.load.outputs.rust-nightly }}
11+
ocaml-version:
12+
description: "OCaml version"
13+
value: ${{ steps.load.outputs.ocaml-version }}
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Load version configuration
19+
id: load
20+
shell: bash
21+
run: |
22+
VERSIONS_FILE="${{ github.action_path }}/../../config/versions.yaml"
23+
24+
# Read versions from YAML file using yq
25+
RUST_STABLE=$(yq eval '.rust.stable' "$VERSIONS_FILE")
26+
RUST_NIGHTLY=$(yq eval '.rust.nightly' "$VERSIONS_FILE")
27+
OCAML_VERSION=$(yq eval '.ocaml.version' "$VERSIONS_FILE")
28+
29+
# Set outputs
30+
echo "rust-stable=$RUST_STABLE" >> $GITHUB_OUTPUT
31+
echo "rust-nightly=$RUST_NIGHTLY" >> $GITHUB_OUTPUT
32+
echo "ocaml-version=$OCAML_VERSION" >> $GITHUB_OUTPUT
33+
34+
# Also set as environment variables for convenience
35+
echo "RUST_STABLE_VERSION=$RUST_STABLE" >> $GITHUB_ENV
36+
echo "RUST_NIGHTLY_VERSION=$RUST_NIGHTLY" >> $GITHUB_ENV
37+
echo "OCAML_VERSION=$OCAML_VERSION" >> $GITHUB_ENV
38+
39+
echo "Loaded versions:"
40+
echo " Rust stable: $RUST_STABLE"
41+
echo " Rust nightly: $RUST_NIGHTLY"
42+
echo " OCaml: $OCAML_VERSION"

.github/config/versions.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Centralized version definitions for CI workflows
2+
#
3+
# This file serves as the single source of truth for all version numbers
4+
# used across GitHub Actions workflows.
5+
#
6+
# When updating versions here, also update:
7+
# - rust-toolchain.toml (for rust.stable)
8+
# - Makefile (for rust.nightly as NIGHTLY_RUST_VERSION)
9+
# - website/scripts/setup/install-rust.sh
10+
# - website/docs/developers/getting-started.mdx
11+
12+
rust:
13+
stable: "1.84"
14+
nightly: "nightly"
15+
16+
ocaml:
17+
version: "4.14.2"

.github/workflows/build-reusable.yaml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ on:
77
required: true
88
type: string
99
description: "Operating system to build on"
10-
ocaml_version:
11-
required: false
12-
type: string
13-
default: "4.14.2"
14-
description: "OCaml version to use"
1510
cache-prefix:
1611
required: false
1712
type: string
@@ -45,18 +40,21 @@ jobs:
4540
- name: Git checkout
4641
uses: actions/checkout@v5
4742

43+
- name: Load versions
44+
uses: ./.github/actions/load-versions
45+
4846
- name: Setup build dependencies
4947
uses: ./.github/actions/setup-build-deps
5048

5149
- name: Use shared OCaml setting up steps
5250
uses: ./.github/actions/setup-ocaml
5351
with:
54-
ocaml_version: ${{ inputs.ocaml_version }}
52+
ocaml_version: ${{ env.OCAML_VERSION }}
5553

5654
- name: Setup Rust
5755
uses: ./.github/actions/setup-rust
5856
with:
59-
toolchain: 1.84
57+
toolchain: ${{ env.RUST_STABLE_VERSION }}
6058
cache-prefix: build-${{ inputs.os }}-${{ inputs.cache-prefix }}v0
6159

6260
- name: Release build
@@ -88,18 +86,21 @@ jobs:
8886
- name: Git checkout
8987
uses: actions/checkout@v5
9088

89+
- name: Load versions
90+
uses: ./.github/actions/load-versions
91+
9192
- name: Setup build dependencies
9293
uses: ./.github/actions/setup-build-deps
9394

9495
- name: Use shared OCaml setting up steps
9596
uses: ./.github/actions/setup-ocaml
9697
with:
97-
ocaml_version: ${{ inputs.ocaml_version }}
98+
ocaml_version: ${{ env.OCAML_VERSION }}
9899

99100
- name: Setup Rust
100101
uses: ./.github/actions/setup-rust
101102
with:
102-
toolchain: 1.84
103+
toolchain: ${{ env.RUST_STABLE_VERSION }}
103104
cache-prefix: build-tests-${{ inputs.os }}-${{ inputs.cache-prefix }}v0
104105

105106
- name: Build tests
@@ -114,18 +115,21 @@ jobs:
114115
- name: Git checkout
115116
uses: actions/checkout@v5
116117

118+
- name: Load versions
119+
uses: ./.github/actions/load-versions
120+
117121
- name: Setup build dependencies
118122
uses: ./.github/actions/setup-build-deps
119123

120124
- name: Use shared OCaml setting up steps
121125
uses: ./.github/actions/setup-ocaml
122126
with:
123-
ocaml_version: ${{ inputs.ocaml_version }}
127+
ocaml_version: ${{ env.OCAML_VERSION }}
124128

125129
- name: Setup Rust
126130
uses: ./.github/actions/setup-rust
127131
with:
128-
toolchain: 1.84
132+
toolchain: ${{ env.RUST_STABLE_VERSION }}
129133
cache-prefix: build-tests-webrtc-${{ inputs.os }}-${{ inputs.cache-prefix }}v0
130134

131135
- name: Build tests
@@ -141,18 +145,21 @@ jobs:
141145
- name: Git checkout
142146
uses: actions/checkout@v5
143147

148+
- name: Load versions
149+
uses: ./.github/actions/load-versions
150+
144151
- name: Setup build dependencies
145152
uses: ./.github/actions/setup-build-deps
146153

147154
- name: Use shared OCaml setting up steps
148155
uses: ./.github/actions/setup-ocaml
149156
with:
150-
ocaml_version: ${{ inputs.ocaml_version }}
157+
ocaml_version: ${{ env.OCAML_VERSION }}
151158

152159
- name: Setup Rust
153160
uses: ./.github/actions/setup-rust
154161
with:
155-
toolchain: 1.84
162+
toolchain: ${{ env.RUST_STABLE_VERSION }}
156163
cache-prefix: build-${{ inputs.os }}-${{ inputs.cache-prefix }}v0
157164

158165
- name: Build benchmarks
@@ -166,13 +173,16 @@ jobs:
166173
- name: Git checkout
167174
uses: actions/checkout@v5
168175

176+
- name: Load versions
177+
uses: ./.github/actions/load-versions
178+
169179
- name: Setup build dependencies
170180
uses: ./.github/actions/setup-build-deps
171181

172182
- name: Use shared OCaml setting up steps
173183
uses: ./.github/actions/setup-ocaml
174184
with:
175-
ocaml_version: ${{ inputs.ocaml_version }}
185+
ocaml_version: ${{ env.OCAML_VERSION }}
176186

177187
- name: Setup WebAssembly environment
178188
uses: ./.github/actions/setup-wasm

.github/workflows/doc-commands.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,27 @@ concurrency:
2222
jobs:
2323
test-doc-commands:
2424
runs-on: ubuntu-22.04
25-
strategy:
26-
matrix:
27-
ocaml_version: [4.14.2]
2825
steps:
2926
- name: Git checkout
3027
uses: actions/checkout@v5
3128

29+
- name: Load versions
30+
uses: ./.github/actions/load-versions
31+
3232
- name: Setup build dependencies
3333
uses: ./.github/actions/setup-build-deps
3434

3535
- name: Setup Rust
3636
uses: ./.github/actions/setup-rust
3737
with:
3838
components: rustfmt
39-
toolchain: 1.84
39+
toolchain: ${{ env.RUST_STABLE_VERSION }}
4040
cache-prefix: test-doc-commands-v0
4141

4242
- name: Use shared OCaml setting up steps
4343
uses: ./.github/actions/setup-ocaml
4444
with:
45-
ocaml_version: ${{ matrix.ocaml_version }}
45+
ocaml_version: ${{ env.OCAML_VERSION }}
4646

4747
- name: Download circuits files
4848
uses: ./.github/actions/setup-circuits

.github/workflows/lint.yaml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,59 @@ on:
88
jobs:
99
lint:
1010
timeout-minutes: 10
11-
name: Lint - ${{ matrix.os }} - Rust ${{ matrix.toolchain }}
11+
name: Lint - ${{ matrix.os }}
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
ocaml_version: [4.14.2]
1615
os: [ubuntu-24.04]
17-
toolchain: [1.84]
1816
steps:
1917
- uses: actions/checkout@v5
18+
19+
- name: Load versions
20+
uses: ./.github/actions/load-versions
21+
2022
- name: Setup build dependencies
2123
uses: ./.github/actions/setup-build-deps
2224
- name: Use shared OCaml setting up steps
2325
uses: ./.github/actions/setup-ocaml
2426
with:
25-
ocaml_version: ${{ matrix.ocaml_version }}
27+
ocaml_version: ${{ env.OCAML_VERSION }}
2628
- name: Setup Rust
2729
uses: ./.github/actions/setup-rust
2830
with:
29-
toolchain: ${{ matrix.toolchain }}
31+
toolchain: ${{ env.RUST_STABLE_VERSION }}
3032
components: clippy, rustfmt
31-
cache-prefix: lint-${{ matrix.toolchain }}-v0
33+
cache-prefix: lint-${{ env.RUST_STABLE_VERSION }}-v0
3234
- name: Run make check
3335
run: make check
3436
- name: Run make lint
3537
run: make lint
3638

3739
lint-tx-fuzzing:
3840
timeout-minutes: 10
39-
name: Lint transaction Fuzzing - ${{ matrix.os }} - Rust ${{ matrix.toolchain }}
41+
name: Lint transaction Fuzzing - ${{ matrix.os }}
4042
runs-on: ${{ matrix.os }}
4143
strategy:
4244
matrix:
4345
os: [ubuntu-24.04]
44-
# This should be in line with the verison in:
45-
# - Makefile
46-
# - ./github/workflows/docs.yaml
47-
# - ./github/workflows/fmt.yaml
48-
# - ./github/workflows/lint.yaml
49-
toolchain: [nightly]
50-
ocaml_version: [4.14.2]
5146
steps:
5247
- uses: actions/checkout@v5
48+
49+
- name: Load versions
50+
uses: ./.github/actions/load-versions
51+
5352
- name: Setup build dependencies
5453
uses: ./.github/actions/setup-build-deps
5554
- name: Use shared OCaml setting up steps
5655
uses: ./.github/actions/setup-ocaml
5756
with:
58-
ocaml_version: ${{ matrix.ocaml_version }}
57+
ocaml_version: ${{ env.OCAML_VERSION }}
5958
- name: Setup Rust
6059
uses: ./.github/actions/setup-rust
6160
with:
62-
toolchain: ${{ matrix.toolchain }}
61+
toolchain: ${{ env.RUST_NIGHTLY_VERSION }}
6362
components: clippy, rustfmt
64-
cache-prefix: lint-tx-fuzzing-${{ matrix.toolchain }}-v0
63+
cache-prefix: lint-tx-fuzzing-${{ env.RUST_NIGHTLY_VERSION }}-v0
6564
- name: Run transaction Fuzzing check
6665
run: make check-tx-fuzzing
6766

0 commit comments

Comments
 (0)