-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: custom cargo config to reduce build time #2104
Changes from all commits
4a2c4c4
f9d854b
89c9597
8764554
fa520f2
dc6c571
2e6f40a
8be9f74
fbe2594
94f4549
d6917de
f4e45da
46c4531
ec150d1
cf7e392
03edc72
f3422b0
3560657
700339b
5dbcbd7
5a9f755
9b4e017
07caf38
1572a28
5a1289d
13ffc7a
accfc35
2742a4b
9d3a5a5
aac9852
9f5c97a
a32913c
40e7713
f525219
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[alias] | ||
b = "build" | ||
c = "check" | ||
d = "doc" | ||
t = "test" | ||
r = "run" | ||
|
||
[build] | ||
incremental = true | ||
# might be helpful but we don't enforce sccache installation atm | ||
# https://github.com/mozilla/sccache | ||
# rustc-wrapper = "sccache" | ||
|
||
# For details checkout https://jondot.medium.com/8-steps-for-troubleshooting-your-rust-build-times-2ffc965fd13e | ||
[target.x86_64-unknown-linux-gnu] | ||
# clang has been listed as prerequisite in the doc | ||
linker = "clang" | ||
# enable avx2 by default since it's avaiable on almost all x86_64 CPUs | ||
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Ctarget-feature=+avx2,+fma", "-Zshare-generics=y"] | ||
|
||
[target.x86_64-apple-darwin] | ||
# zld might help here | ||
# brew install michaeleisel/zld/zld | ||
# "-Clink-arg=-fuse-ld=zld" | ||
# For details checkout https://jondot.medium.com/8-steps-for-troubleshooting-your-rust-build-times-2ffc965fd13e | ||
rustflags = ["-Ctarget-feature=+avx2,+fma", "-Zshare-generics=y"] | ||
|
||
[net] | ||
git-fetch-with-cli = true | ||
retry = 5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
name: Rust | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
|
@@ -14,140 +15,112 @@ env: | |
CI: 1 | ||
CARGO_INCREMENTAL: 1 | ||
CACHE_TIMEOUT_MINUTES: 5 | ||
RUSTFLAGS: -Ctarget-feature=+avx2,+fma | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: buildjet-8vcpu-ubuntu-2004 | ||
timeout-minutes: 30 | ||
env: | ||
RUSTFLAGS: "-Ctarget-feature=+avx2,+fma -D warnings" | ||
steps: | ||
- name: Install Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y build-essential clang ocl-icd-opencl-dev | ||
- name: Checkout Sources | ||
uses: actions/checkout@v3 | ||
- name: Setup sccache | ||
uses: hanabi1224/sccache-action@v1.2.0 | ||
with: | ||
release-name: v0.3.0 | ||
cache-key: ${{ runner.os }}-sccache-test-${{ hashFiles('rust-toolchain.toml') }} | ||
cache-update: ${{ github.event_name != 'pull_request' }} | ||
- name: Apt Dependencies | ||
run: sudo make install-deps | ||
- name: install nextest | ||
uses: taiki-e/install-action@nextest | ||
- name: Rust Cache | ||
uses: Swatinem/rust-cache@v2 | ||
timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} | ||
continue-on-error: true | ||
- name: Cargo Check | ||
run: cargo check | ||
- name: Make Test-All | ||
run: make test-all | ||
|
||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Apt Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y build-essential clang ocl-icd-opencl-dev | ||
- name: Checkout Sources | ||
uses: actions/checkout@v3 | ||
- name: Rust Cache | ||
uses: Swatinem/rust-cache@v2 | ||
timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} | ||
continue-on-error: true | ||
- name: Install taplo (TOML linter) | ||
run: cargo install taplo-cli --locked | ||
- name: Run Linters | ||
run: make lint | ||
|
||
audit: | ||
name: Audit | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Sources | ||
uses: actions/checkout@v3 | ||
- name: Rust Cache | ||
uses: Swatinem/rust-cache@v2 | ||
timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} | ||
continue-on-error: true | ||
- name: Install Audit | ||
run: cargo install cargo-audit --locked | ||
- name: Run Audit | ||
run: make audit | ||
|
||
unused_dependencies: | ||
name: Unused dependencies | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Sources | ||
uses: actions/checkout@v3 | ||
- name: Rust Cache | ||
uses: Swatinem/rust-cache@v2 | ||
timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} | ||
continue-on-error: true | ||
- name: Install udeps | ||
run: cargo install cargo-udeps --locked | ||
- name: Run udeps | ||
run: make udeps | ||
- run: make test-all | ||
env: | ||
CC: "sccache clang" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if it wouldn't clash with some other steps, but would adding those envs as global for the entire workflow be fine? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
CXX: "sccache clang++" | ||
|
||
spellcheck: | ||
name: Spellcheck | ||
lint-all: | ||
name: All lint checks (lint audit spellcheck udeps) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Sources | ||
uses: actions/checkout@v3 | ||
- name: Rust Cache | ||
uses: Swatinem/rust-cache@v2 | ||
timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} | ||
- name: Apt Dependencies | ||
run: sudo make install-deps | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
key: ${{ runner.os }}-lints-cargo-bin-${{ hashFiles('rust-toolchain.toml') }} | ||
- run: make install-lint-tools | ||
continue-on-error: true | ||
- name: Install spellcheck | ||
run: cargo install cargo-spellcheck --locked | ||
- name: Run Spellcheck | ||
run: make spellcheck | ||
- name: Setup sccache | ||
uses: hanabi1224/sccache-action@v1.2.0 | ||
with: | ||
release-name: v0.3.0 | ||
cache-key: ${{ runner.os }}-sccache-lints-${{ hashFiles('rust-toolchain.toml') }} | ||
cache-update: ${{ github.event_name != 'pull_request' }} | ||
- run: make lint-all | ||
env: | ||
CC: "sccache clang" | ||
CXX: "sccache clang++" | ||
|
||
build: | ||
name: Build | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
#rv: [1.58.1, stable, beta, nightly] | ||
rv: [nightly] | ||
steps: | ||
- name: Install Dependencies | ||
if: startsWith(matrix.os, 'Ubuntu') | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y build-essential clang ocl-icd-opencl-dev | ||
- name: Checkout Sources | ||
uses: actions/checkout@v3 | ||
- name: Rust Cache | ||
uses: Swatinem/rust-cache@v2 | ||
timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} | ||
continue-on-error: true | ||
- name: Cargo Build | ||
run: cargo build --profile dev | ||
- name: Setup sccache | ||
uses: hanabi1224/sccache-action@v1.2.0 | ||
with: | ||
# hard code release-name for macos, it always get rate limited when calling github api | ||
release-name: v0.3.0 | ||
cache-key: ${{ runner.os }}-sccache-${{ hashFiles('rust-toolchain.toml') }} | ||
cache-update: ${{ github.event_name != 'pull_request' }} | ||
- name: Install Apt Dependencies | ||
if: startsWith(matrix.os, 'Ubuntu') | ||
run: | | ||
lscpu # the job may run on different CPUs, list cpu here for analysing build time | ||
sudo make install-deps | ||
- name: Cargo Check | ||
run: cargo check --timings | ||
env: | ||
CC: "sccache clang" | ||
CXX: "sccache clang++" | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: build-timings | ||
path: | | ||
target/cargo-timings/* | ||
if-no-files-found: error | ||
|
||
calibnet-check: | ||
name: Calibnet sync check | ||
if: ${{ false }} | ||
runs-on: buildjet-8vcpu-ubuntu-2004 | ||
timeout-minutes: 30 | ||
steps: | ||
- name: Install Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y build-essential clang ocl-icd-opencl-dev | ||
- name: Checkout Sources | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
- name: Rust Cache | ||
uses: Swatinem/rust-cache@v2 | ||
timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} | ||
continue-on-error: true | ||
- name: Apt Dependencies | ||
run: sudo make install-deps | ||
- name: Setup sccache | ||
uses: hanabi1224/sccache-action@v1.2.0 | ||
with: | ||
release-name: v0.3.0 | ||
cache-key: ${{ runner.os }}-sccache-calibnet-check-${{ hashFiles('rust-toolchain.toml') }} | ||
cache-update: ${{ github.event_name != 'pull_request' }} | ||
- name: build and install binaries | ||
run: make install | ||
env: | ||
CC: "sccache clang" | ||
CXX: "sccache clang++" | ||
- name: download snapshot | ||
run: forest-cli --chain calibnet chain fetch -s /tmp/snapshots/ | ||
- name: import snapshot and run Forest | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be great to include a comment on why are we using a fork
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Basically we need the
cache-update
to only save the cache on 1.main
branch, 2. cache not found. The original action repo looks like unmaintained so we keep using the fork