Skip to content

Commit 975f378

Browse files
committed
ci: attempt to speed up ci by agressive cache reuse
1 parent 83edd84 commit 975f378

File tree

9 files changed

+54
-26
lines changed

9 files changed

+54
-26
lines changed

.github/actions/setup-build-env/action.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ runs:
2424
repo-token: ${{ inputs.github_token }}
2525

2626
- name: Install Rust
27-
shell: "bash"
28-
run: rustup toolchain install ${{ inputs.rust_toolchain_release }} --profile default
27+
uses: dtolnay/rust-toolchain@master
28+
with:
29+
toolchain: ${{ inputs.rust_toolchain_release }}
2930

3031
- name: Install system deps (libudev, LLVM/Clang)
3132
if: runner.os == 'Linux'
@@ -41,7 +42,7 @@ runs:
4142
shared-key: ${{ inputs.build_cache_key_name }}
4243
workspaces: |
4344
magicblock-validator -> target
44-
magicblock-validator/test-integration -> target
45+
magicblock-validator/test-integration -> test-integration/target
4546
cache-targets: true
4647
cache-all-crates: true
4748
cache-on-failure: true

.github/actions/setup-solana/action.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ description: 'Install Solana Test Validator and ensure it works'
44
runs:
55
using: "composite"
66
steps:
7+
- name: Cache Solana toolchain
8+
uses: actions/cache@v3
9+
with:
10+
path: ~/.local/share/solana
11+
key: solana-v2.2.20-${{ runner.os }}
12+
713
- name: Install Solana Test Validator
814
shell: "bash"
915
run: |
10-
sh -c "$(curl -sSfL https://release.anza.xyz/v2.2.20/install)"
16+
if [ ! -f ~/.local/share/solana/install/active_release/bin/solana-test-validator ]; then
17+
sh -c "$(curl -sSfL https://release.anza.xyz/v2.2.20/install)"
18+
fi
1119
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
1220
1321
- name: Ensure Solana Test Validator is Installed

.github/workflows/ci-fmt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
- uses: ./magicblock-validator/.github/actions/setup-build-env
2323
with:
24-
build_cache_key_name: "magicblock-validator-ci-fmt-v001"
24+
build_cache_key_name: "magicblock-validator-ci-fmt-${{ hashFiles('magicblock-validator/Cargo.lock', 'magicblock-validator/test-integration/Cargo.lock') }}-v001"
2525
rust_toolchain_release: "nightly"
2626
github_access_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
2727
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
- uses: ./magicblock-validator/.github/actions/setup-build-env
2424
with:
25-
build_cache_key_name: "magicblock-validator-ci-lint-v002"
25+
build_cache_key_name: "magicblock-validator-${{ hashFiles('magicblock-validator/Cargo.lock', 'magicblock-validator/test-integration/Cargo.lock') }}-v001"
2626
rust_toolchain_release: "1.91.1"
2727
github_access_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
2828
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci-test-integration.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
- uses: ./magicblock-validator/.github/actions/setup-build-env
2525
with:
26-
build_cache_key_name: "magicblock-validator-ci-test-integration-${{ github.ref_name }}-${{ hashFiles('magicblock-validator/Cargo.lock') }}"
26+
build_cache_key_name: "magicblock-validator-${{ hashFiles('magicblock-validator/Cargo.lock', 'magicblock-validator/test-integration/Cargo.lock') }}-v001"
2727
rust_toolchain_release: "1.91.1"
2828
github_access_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
2929
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -37,6 +37,23 @@ jobs:
3737
shell: bash
3838
working-directory: magicblock-validator
3939

40+
- name: Build test-runner binary
41+
run: cargo build --package test-runner --bin run-tests --locked
42+
shell: bash
43+
working-directory: magicblock-validator
44+
45+
- name: Pre-build all test binaries
46+
run: cargo build --tests --locked
47+
shell: bash
48+
working-directory: magicblock-validator/test-integration
49+
50+
- name: Upload test-runner binary
51+
uses: actions/upload-artifact@v3
52+
with:
53+
name: test-runner-binary
54+
path: magicblock-validator/test-integration/target/debug/run-tests
55+
retention-days: 1
56+
4057
run_integration_tests:
4158
needs: build
4259
runs-on: ubuntu-latest-m
@@ -64,13 +81,23 @@ jobs:
6481

6582
- uses: ./magicblock-validator/.github/actions/setup-build-env
6683
with:
67-
build_cache_key_name: "magicblock-validator-ci-test-integration-${{ github.ref_name }}-${{ hashFiles('magicblock-validator/Cargo.lock') }}"
68-
rust_toolchain_release: "1.84.1"
84+
build_cache_key_name: "magicblock-validator-${{ hashFiles('magicblock-validator/Cargo.lock', 'magicblock-validator/test-integration/Cargo.lock') }}-v001"
85+
rust_toolchain_release: "1.91.1"
6986
github_access_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
7087
github_token: ${{ secrets.GITHUB_TOKEN }}
7188

7289
- uses: ./magicblock-validator/.github/actions/setup-solana
7390

91+
- name: Download test-runner binary
92+
uses: actions/download-artifact@v3
93+
with:
94+
name: test-runner-binary
95+
path: magicblock-validator/test-integration/target/debug/
96+
97+
- name: Make test-runner binary executable
98+
run: chmod +x magicblock-validator/test-integration/target/debug/run-tests
99+
shell: bash
100+
74101
- name: Run integration tests - ${{ matrix.batch_tests }}
75102
run: |
76103
sudo prlimit --pid $$ --nofile=1048576:1048576
@@ -81,3 +108,4 @@ jobs:
81108
working-directory: magicblock-validator
82109
env:
83110
RUN_TESTS: ${{ matrix.batch_tests }}
111+
TEST_RUNNER_BIN: ${{ github.workspace }}/magicblock-validator/test-integration/target/debug/run-tests

.github/workflows/ci-test-unit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
- uses: ./magicblock-validator/.github/actions/setup-build-env
2424
with:
25-
build_cache_key_name: "magicblock-validator-ci-test-unit-v000"
25+
build_cache_key_name: "magicblock-validator-${{ hashFiles('magicblock-validator/Cargo.lock', 'magicblock-validator/test-integration/Cargo.lock') }}-v001"
2626
rust_toolchain_release: "1.91.1"
2727
github_access_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
2828
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish-packages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
- uses: ./magicblock-validator/.github/actions/setup-build-env
6565
with:
6666
build_cache_key_name: "magicblock-validator-ci-publish-v000"
67-
rust_toolchain_release: "1.85.0"
67+
rust_toolchain_release: "1.91.1"
6868
github_access_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
6969
github_token: ${{ secrets.GITHUB_TOKEN }}
7070

test-integration/test-runner/bin/run_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,8 @@ fn run_test(
783783
"RUST_LOG",
784784
std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string()),
785785
)
786-
.arg("test");
786+
.arg("test")
787+
.arg("--locked");
787788
if let Some(package) = config.package {
788789
cmd.arg("-p").arg(package);
789790
}

test-integration/test-tools/src/validator.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,14 @@ pub fn start_magic_block_validator_with_config(
3333

3434
let port = rpc_port_from_config(config_path);
3535

36-
// First build so that the validator can start fast
37-
let mut command = process::Command::new("cargo");
36+
// Start validator directly from the pre-built binary
37+
// (already compiled in CI build step or by local `cargo build`)
38+
let validator_bin = root_dir.join("target/debug/magicblock-validator");
39+
let mut command = process::Command::new(&validator_bin);
3840
let keypair_base58 = loaded_chain_accounts.validator_authority_base58();
39-
command.arg("build");
40-
let build_res = command.current_dir(root_dir.clone()).output();
41-
42-
if build_res.is_ok_and(|output| !output.status.success()) {
43-
eprintln!("Failed to build validator");
44-
return None;
45-
}
46-
47-
// Start validator via `cargo run -- <path to config>`
48-
let mut command = process::Command::new("cargo");
49-
command.arg("run");
5041
let rust_log_style =
5142
std::env::var("RUST_LOG_STYLE").unwrap_or(log_suffix.to_string());
5243
command
53-
.arg("--")
5444
.arg(config_path)
5545
.env("RUST_LOG_STYLE", rust_log_style)
5646
.env("MBV_VALIDATOR__KEYPAIR", keypair_base58.clone())

0 commit comments

Comments
 (0)