Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit d265c76

Browse files
author
Antonio Calvín García
authored
Revert "Update Pr: Make contract caches shared (#1071)" (#1116)
This reverts commit 8a11259.
1 parent 8a11259 commit d265c76

File tree

84 files changed

+1081
-17878
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1081
-17878
lines changed

.gitattributes

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

.github/workflows/rust-tests.yml

Lines changed: 182 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -9,169 +9,240 @@ on:
99

1010
env:
1111
CARGO_TERM_COLOR: always
12-
RUST_TOOLCHAIN: '1.72.1'
12+
RUST_TOOLCHAIN: 1.70.0
13+
CAIRO_PROGRAMS_PATH: |
14+
cairo_programs/**/*.casm
15+
cairo_programs/**/*.sierra
16+
cairo_programs/**/*.json
17+
starknet_programs/**/*.casm
18+
starknet_programs/**/*.sierra
19+
starknet_programs/**/*.json
20+
!starknet_programs/raw_contract_classes/*
1321
1422
jobs:
15-
build:
16-
name: Build with release profile
17-
runs-on: ubuntu-latest
23+
build-programs:
24+
strategy:
25+
matrix:
26+
program-target: [
27+
compile-cairo,
28+
compile-starknet,
29+
compile-cairo-1-casm,
30+
compile-cairo-1-sierra,
31+
compile-cairo-2-casm,
32+
compile-cairo-2-sierra,
33+
]
34+
name: Build Cairo programs
35+
runs-on: ubuntu-22.04
1836
steps:
1937
- name: Checkout
2038
uses: actions/checkout@v3
21-
- name: Install Rust $RUST_TOOLCHAIN
22-
uses: dtolnay/rust-toolchain@master
2339
with:
24-
toolchain: $RUST_TOOLCHAIN
25-
components: rustfmt, clippy
40+
fetch-depth: 0
41+
42+
- name: Fetch from cache
43+
uses: actions/cache@v3
44+
id: cache-programs
45+
with:
46+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
47+
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
48+
restore-keys: ${{ matrix.program-target }}-cache-
49+
50+
# This is not pretty, but we need `make` to see the compiled programs are
51+
# actually newer than the sources, otherwise it will try to rebuild them
52+
- name: Restore timestamps
53+
uses: chetan/git-restore-mtime-action@v1
54+
2655
- name: Python3 Build
56+
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
2757
uses: actions/setup-python@v4
2858
with:
2959
python-version: '3.9'
3060
cache: 'pip'
61+
62+
- name: Install deps
63+
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
64+
run: make deps
65+
66+
- name: Build programs
67+
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
68+
run: make -j ${{ matrix.program-target }}
69+
70+
# NOTE: used to reduce the amount of cache steps we need in later jobs
71+
# TODO: remove this cache once the workflow finishes
72+
merge-caches:
73+
name: Merge Cairo programs cache
74+
runs-on: ubuntu-22.04
75+
needs: build-programs
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v3
79+
80+
- name: Fetch from cache (compile-cairo)
81+
uses: actions/cache/restore@v3
82+
id: cache-programs
83+
with:
84+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
85+
key: compile-cairo-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
86+
fail-on-cache-miss: true
87+
88+
- name: Fetch from cache (compile-starknet)
89+
uses: actions/cache/restore@v3
90+
with:
91+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
92+
key: compile-starknet-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
93+
fail-on-cache-miss: true
94+
95+
- name: Fetch from cache (compile-cairo-1-casm)
96+
uses: actions/cache/restore@v3
97+
with:
98+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
99+
key: compile-cairo-1-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
100+
fail-on-cache-miss: true
101+
102+
- name: Fetch from cache (compile-cairo-1-sierra)
103+
uses: actions/cache/restore@v3
104+
with:
105+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
106+
key: compile-cairo-1-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
107+
fail-on-cache-miss: true
108+
109+
- name: Fetch from cache (compile-cairo-2-casm)
110+
uses: actions/cache/restore@v3
111+
with:
112+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
113+
key: compile-cairo-2-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
114+
fail-on-cache-miss: true
115+
116+
- name: Fetch from cache (compile-cairo-2-sierra)
117+
uses: actions/cache/restore@v3
118+
with:
119+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
120+
key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
121+
fail-on-cache-miss: true
122+
123+
- name: Fetch from cache (compile-cairo-2-sierra)
124+
uses: actions/cache/restore@v3
125+
with:
126+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
127+
key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
128+
fail-on-cache-miss: true
129+
130+
- name: Merge caches
131+
uses: actions/cache/save@v3
132+
with:
133+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
134+
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
135+
136+
build:
137+
name: Build with release profile
138+
needs: merge-caches
139+
runs-on: ubuntu-22.04
140+
steps:
141+
- name: Install Rust
142+
uses: dtolnay/rust-toolchain@stable
143+
with:
144+
toolchain: ${{ env.RUST_TOOLCHAIN }}
145+
components: rustfmt, clippy
31146
- uses: Swatinem/rust-cache@v2
32147
with:
33148
cache-on-failure: true
149+
- name: Checkout
150+
uses: actions/checkout@v3
151+
- name: Fetch programs
152+
uses: actions/cache/restore@v3
153+
with:
154+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
155+
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
156+
fail-on-cache-miss: true
34157

35-
- name: Install deps
36-
run: make deps
37158
- name: Build
38-
run: make build
159+
run: cargo build --release --workspace
39160

40161
lint:
41162
name: Lint with fmt and clippy
42-
runs-on: ubuntu-latest
43-
env:
44-
MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/
45-
TABLEGEN_170_PREFIX: /usr/lib/llvm-17/
163+
needs: merge-caches
164+
runs-on: ubuntu-22.04
46165
steps:
47-
- name: Checkout
48-
uses: actions/checkout@v3
49-
- name: Install Rust $RUST_TOOLCHAIN
50-
uses: dtolnay/rust-toolchain@master
51-
with:
52-
toolchain: $RUST_TOOLCHAIN
53-
components: rustfmt, clippy
54-
- name: Python3 Build
55-
uses: actions/setup-python@v4
166+
- name: Install Rust
167+
uses: dtolnay/rust-toolchain@stable
56168
with:
57-
python-version: '3.9'
58-
cache: 'pip'
169+
toolchain: ${{ env.RUST_TOOLCHAIN }}
170+
components: rustfmt, clippy
59171
- uses: Swatinem/rust-cache@v2
60172
with:
61173
cache-on-failure: true
62-
- name: check and free hdd space left
63-
run: |
64-
echo "Listing 20 largest packages"
65-
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20
66-
df -h
67-
sudo apt-get update
68-
sudo apt-get remove -y '^llvm-.*'
69-
sudo apt-get remove -y 'php.*'
70-
sudo apt-get remove -y '^dotnet-.*'
71-
sudo apt-get remove -y '^temurin-.*'
72-
sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel
73-
sudo apt-get autoremove -y
74-
sudo apt-get clean
75-
df -h
76-
echo "Removing large directories"
77-
# deleting 15GB
78-
sudo rm -rf /usr/share/dotnet/
79-
sudo rm -rf /usr/local/lib/android
80-
df -h
81-
- name: add llvm deb repository
82-
uses: myci-actions/add-deb-repo@10
83-
with:
84-
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main
85-
repo-name: llvm-repo
86-
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
87-
- name: Install LLVM
88-
run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools
89-
- name: Install deps
90-
run: make deps
174+
- name: Checkout
175+
uses: actions/checkout@v3
176+
- name: Fetch programs
177+
uses: actions/cache/restore@v3
178+
with:
179+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
180+
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
181+
fail-on-cache-miss: true
182+
91183
- name: Format
92184
run: cargo fmt --all -- --check
93185
- name: Run clippy
94-
run: make clippy
186+
run: cargo clippy --workspace --all-targets -- -D warnings
95187

96188
tests:
97189
env:
98190
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
99-
MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/
100-
TABLEGEN_170_PREFIX: /usr/lib/llvm-17/
101191
strategy:
102192
fail-fast: false
103193
matrix:
104-
target: [ test-cairo-1, test-cairo-2, test-doctests, test-cairo-native ]
194+
target: [ test-cairo-1, test-cairo-2, test-doctests ]
105195
name: Run tests
106-
runs-on: ubuntu-latest
196+
needs: merge-caches
197+
runs-on: ubuntu-22.04
107198
steps:
108-
- name: Checkout
109-
uses: actions/checkout@v3
110-
- name: Install Rust $RUST_TOOLCHAIN
111-
uses: dtolnay/rust-toolchain@master
112-
with:
113-
toolchain: $RUST_TOOLCHAIN
114-
components: rustfmt, clippy
115-
- name: Python3 Build
116-
uses: actions/setup-python@v4
199+
- name: Install Rust
200+
uses: dtolnay/rust-toolchain@stable
117201
with:
118-
python-version: '3.9'
119-
cache: 'pip'
202+
toolchain: ${{ env.RUST_TOOLCHAIN }}
203+
components: rustfmt, clippy
120204
- uses: Swatinem/rust-cache@v2
121205
with:
122206
cache-on-failure: true
207+
- name: Checkout
208+
uses: actions/checkout@v3
123209

124-
- name: Install deps
125-
run: make deps
126-
210+
- name: Fetch programs
211+
uses: actions/cache/restore@v3
212+
with:
213+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
214+
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
215+
fail-on-cache-miss: true
216+
127217
- name: Install testing tools
128218
# TODO: remove `if` when nextest adds doctests support
129219
if: ${{ matrix.target != 'test-doctests' }}
130220
uses: taiki-e/install-action@v2
131221
with:
132222
133223

134-
- name: check and free hdd space left
135-
run: |
136-
echo "Listing 20 largest packages"
137-
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20
138-
df -h
139-
sudo apt-get update
140-
sudo apt-get remove -y '^llvm-.*'
141-
sudo apt-get remove -y 'php.*'
142-
sudo apt-get remove -y '^dotnet-.*'
143-
sudo apt-get remove -y '^temurin-.*'
144-
sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel
145-
sudo apt-get autoremove -y
146-
sudo apt-get clean
147-
df -h
148-
echo "Removing large directories"
149-
# deleting 15GB
150-
sudo rm -rf /usr/share/dotnet/
151-
sudo rm -rf /usr/local/lib/android
152-
df -h
153-
- name: add llvm deb repository
154-
uses: myci-actions/add-deb-repo@10
155-
with:
156-
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main
157-
repo-name: llvm-repo
158-
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
159-
- name: Install LLVM
160-
run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools
161224
- name: Run tests (${{ matrix.target }})
162225
run: make ${{ matrix.target }}
163226

164227
coverage:
228+
needs: merge-caches
165229
name: Generate and upload coverage report
166-
runs-on: ubuntu-latest
230+
runs-on: ubuntu-22.04
167231
steps:
168232
- name: Checkout
169233
uses: actions/checkout@v3
234+
- name: Install Rust
235+
uses: dtolnay/rust-toolchain@nightly
236+
with:
237+
toolchain: ${{ env.RUST_TOOLCHAIN }}
238+
239+
- name: Set nightly as default
240+
run: rustup default nightly
170241

171-
- name: Install Rust nightly
172-
uses: dtolnay/rust-toolchain@master
242+
- name: Install testing tools
243+
uses: taiki-e/install-action@v2
173244
with:
174-
toolchain: nightly
245+
tool: [email protected],cargo-llvm-cov
175246

176247
- uses: Swatinem/rust-cache@v2
177248
with:
@@ -184,17 +255,13 @@ jobs:
184255
path: lcov.info
185256
key: coverage-cache-${{ github.sha }}
186257

187-
- name: Python3 Build
188-
uses: actions/setup-python@v4
189-
with:
190-
python-version: '3.9'
191-
cache: 'pip'
192-
- uses: Swatinem/rust-cache@v2
258+
- name: Fetch programs
259+
if: steps.restore-report.outputs.cache-hit != 'true'
260+
uses: actions/cache/restore@v3
193261
with:
194-
cache-on-failure: true
195-
196-
- name: Install deps
197-
run: make deps
262+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
263+
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
264+
fail-on-cache-miss: true
198265

199266
- name: Generate coverage report
200267
if: steps.restore-report.outputs.cache-hit != 'true'

0 commit comments

Comments
 (0)