Skip to content

Commit 4c52d23

Browse files
committed
separate workflow for migration tests, fix test on ci
1 parent b293fa7 commit 4c52d23

File tree

4 files changed

+158
-118
lines changed

4 files changed

+158
-118
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Rust CI - Long Test (Reusable)
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
test_name:
7+
description: 'Name of the test (e.g., E2E Withdrawal Tests)'
8+
required: true
9+
type: string
10+
monitored_paths:
11+
description: 'JSON array of paths to monitor for changes'
12+
required: true
13+
type: string
14+
test_filter:
15+
description: 'Nextest filter expression (e.g., test(e2e_tee_withdrawal))'
16+
required: true
17+
type: string
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}-${{ inputs.test_name }}
21+
cancel-in-progress: true
22+
23+
env:
24+
CARGO_TERM_COLOR: always
25+
# Make sure CI fails on all warnings, including Clippy lints
26+
RUSTFLAGS: "-Dwarnings"
27+
# Use a shared cache key for all jobs in the same PR/run. Note the usage of `../Cargo.lock` in invocations
28+
# below to check for any changed deps
29+
CACHE_KEY: "ci-${{ github.head_ref || github.ref_name }}"
30+
# Rust version for consistency across jobs
31+
RUST_VERSION: "1.88.0"
32+
# GitHub Container Registry
33+
GITHUB_REGISTRY: ghcr.io
34+
35+
jobs:
36+
e2e-test:
37+
if: github.event.pull_request.draft == false
38+
name: ${{ inputs.test_name }}
39+
runs-on: shared-large-02
40+
timeout-minutes: 60
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0 # Required for full diff detection
46+
submodules: recursive
47+
48+
- name: Determine whether to run tests
49+
id: diff
50+
run: |
51+
echo "Fetching base ref..."
52+
git fetch origin ${{ github.base_ref }}
53+
54+
echo "Collecting changed files..."
55+
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
56+
echo "$CHANGED_FILES"
57+
58+
echo "Checking for matches against relevant paths..."
59+
PATHS='${{ inputs.monitored_paths }}'
60+
61+
run_tests=false
62+
for path in $(echo "$PATHS" | jq -r '.[]'); do
63+
if echo "$CHANGED_FILES" | grep -q "^$path"; then
64+
echo "Match found: $path"
65+
run_tests=true
66+
break
67+
fi
68+
done
69+
70+
echo "run_tests=$run_tests" >> "$GITHUB_OUTPUT"
71+
72+
- name: Skip notice
73+
if: steps.diff.outputs.run_tests == 'false'
74+
run: echo "No relevant files changed — skipping ${{ inputs.test_name }}"
75+
76+
# All remaining steps are conditional on whether the related files were modified
77+
78+
- name: Install Rust toolchain
79+
if: steps.diff.outputs.run_tests == 'true'
80+
uses: dtolnay/rust-toolchain@stable
81+
with:
82+
toolchain: ${{ env.RUST_VERSION }}
83+
components: "cargo, rustc, clippy, llvm-tools, rustc-dev"
84+
85+
- name: Cache dependencies
86+
if: steps.diff.outputs.run_tests == 'true'
87+
uses: Swatinem/rust-cache@v2
88+
with:
89+
shared-key: ${{ env.CACHE_KEY }}-${{ hashFiles('**/Cargo.toml') }}
90+
save-if: "false"
91+
92+
- name: Install Foundry
93+
if: steps.diff.outputs.run_tests == 'true'
94+
uses: foundry-rs/foundry-toolchain@v1
95+
with:
96+
version: v1.3.5
97+
98+
- name: Pre-download docker test docker images
99+
if: steps.diff.outputs.run_tests == 'true'
100+
run: |
101+
docker pull ghcr.io/syndicateprotocol/generate_batch
102+
docker pull valkey/valkey:latest
103+
104+
- name: Install nextest
105+
if: steps.diff.outputs.run_tests == 'true'
106+
uses: taiki-e/install-action@nextest
107+
108+
- name: Run ${{ inputs.test_name }}
109+
if: steps.diff.outputs.run_tests == 'true'
110+
run: |
111+
# sets debug logs for all syndicate services and info for everything else
112+
RUST_LOG="common=debug,shared=debug,synd_batch_sequencer=debug,synd_block_builder=debug,synd_chain_ingestor=debug,synd_maestro=debug,synd_mchain=debug,synd_slotter=debug,synd_tee_attestation_zk_proofs_aws_nitro=debug,synd_tee_attestation_zk_proofs_sp1_script=debug,synd_tee_attestation_zk_proofs_submitter=debug,synd_translator=debug,test_framework=debug,test_utils=debug,info" \
113+
RUST_LOG_DISABLE_JSON="true" \
114+
RUST_LOG_DISABLE_TELEMETRY="true" \
115+
cargo build && cargo nextest run -p test-framework -E '${{ inputs.test_filter }}' --test-threads=1
116+
117+
# Needs to be the last job step
118+
- name: Notify Slack on Failure
119+
# Only notify for workflow_run failures on main branch (not PRs)
120+
if: failure() && github.ref_name == 'main'
121+
uses: rtCamp/action-slack-notify@v2
122+
env:
123+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
124+
SLACK_COLOR: "danger"
125+
SLACK_MESSAGE: ":x: `${{github.workflow}}` (${{ inputs.test_name }}) failed on `main` branch. View failure information here: <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow>"
126+
SLACK_TITLE: "`${{github.workflow}}` (${{ inputs.test_name }}) failed on `main` branch. Notify the author of the latest PR merged to `main`"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Rust CI - Migration
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review] # the first 3 are the defaults if you dont specify `types`
6+
branches:
7+
- main
8+
- staging
9+
workflow_run:
10+
workflows: ["Publish Service Images"] # Run on `main` pushes only AFTER `publish-images` workflow completes successfully
11+
types:
12+
- completed
13+
branches:
14+
- main
15+
- staging
16+
17+
jobs:
18+
migration-tests:
19+
uses: ./.github/workflows/rust-ci-long-test.yml
20+
with:
21+
test_name: "E2E Migration Tests"
22+
monitored_paths: '["synd-migration-cli/", "synd-mchain/", "test-framework/tests/e2e/e2e_tests_migration.rs", "shared/"]'
23+
test_filter: "test(e2e_migration)"
24+
secrets: inherit
Lines changed: 7 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: Rust CI - Withdrawals
2-
# TODO ENG-2223: Add migration tests
32

43
on:
54
pull_request:
@@ -15,120 +14,11 @@ on:
1514
- main
1615
- staging
1716

18-
concurrency:
19-
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
20-
cancel-in-progress: true
21-
22-
env:
23-
CARGO_TERM_COLOR: always
24-
# Make sure CI fails on all warnings, including Clippy lints
25-
RUSTFLAGS: "-Dwarnings"
26-
# Use a shared cache key for all jobs in the same PR/run. Note the usage of `../Cargo.lock` in invocations
27-
# below to check for any changed deps
28-
CACHE_KEY: "ci-${{ github.head_ref || github.ref_name }}"
29-
# Rust version for consistency across jobs
30-
RUST_VERSION: "1.88.0"
31-
# GitHub Container Registry
32-
GITHUB_REGISTRY: ghcr.io
33-
3417
jobs:
35-
e2e-withdrawals:
36-
if: github.event.pull_request.draft == false
37-
name: E2E Withdrawal Tests
38-
runs-on: shared-large-02
39-
timeout-minutes: 60
40-
41-
steps:
42-
- uses: actions/checkout@v4
43-
with:
44-
fetch-depth: 0 # Required for full diff detection
45-
submodules: recursive
46-
47-
- name: Determine whether to run Withdrawals & Migration tests
48-
id: diff
49-
run: |
50-
echo "Fetching base ref..."
51-
git fetch origin ${{ github.base_ref }}
52-
53-
echo "Collecting changed files..."
54-
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
55-
echo "$CHANGED_FILES"
56-
57-
echo "Checking for matches against relevant paths..."
58-
PATHS=(
59-
"synd-withdrawals/"
60-
"synd-contracts/src/withdrawal/"
61-
"test-framework/tests/e2e/e2e_tests_withdrawals.rs"
62-
"synd-migration-cli/"
63-
"synd-mchain"
64-
"test-framework/tests/e2e/e2e_tests_migration.rs"
65-
"shared/"
66-
)
67-
68-
run_tests=false
69-
for path in "${PATHS[@]}"; do
70-
if echo "$CHANGED_FILES" | grep -q "^$path"; then
71-
echo "Match found: $path"
72-
run_tests=true
73-
break
74-
fi
75-
done
76-
77-
echo "run_tests=$run_tests" >> "$GITHUB_OUTPUT"
78-
79-
- name: Skip notice
80-
if: steps.diff.outputs.run_tests == 'false'
81-
run: echo "No relevant files changed — skipping E2E withdrawal & migration tests."
82-
83-
# All remaining steps are conditional on whether the withdrawals related files were modified
84-
85-
- name: Install Rust toolchain
86-
if: steps.diff.outputs.run_tests == 'true'
87-
uses: dtolnay/rust-toolchain@stable
88-
with:
89-
toolchain: ${{ env.RUST_VERSION }}
90-
components: "cargo, rustc, clippy, llvm-tools, rustc-dev"
91-
92-
- name: Cache dependencies
93-
if: steps.diff.outputs.run_tests == 'true'
94-
uses: Swatinem/rust-cache@v2
95-
with:
96-
shared-key: ${{ env.CACHE_KEY }}-${{ hashFiles('**/Cargo.toml') }}
97-
save-if: "false"
98-
99-
- name: Install Foundry
100-
if: steps.diff.outputs.run_tests == 'true'
101-
uses: foundry-rs/foundry-toolchain@v1
102-
with:
103-
version: v1.3.5
104-
105-
- name: Pre-download docker test docker images
106-
if: steps.diff.outputs.run_tests == 'true'
107-
run: |
108-
docker pull ghcr.io/syndicateprotocol/generate_batch
109-
docker pull valkey/valkey:latest
110-
111-
- name: Install nextest
112-
if: steps.diff.outputs.run_tests == 'true'
113-
uses: taiki-e/install-action@nextest
114-
115-
# TODO ENG-2223: Enable CI migration tests
116-
- name: Run E2E withdrawal & migration tests
117-
if: steps.diff.outputs.run_tests == 'true'
118-
run: |
119-
# sets debug logs for all syndicate services and info for everything else
120-
RUST_LOG="common=debug,shared=debug,synd_batch_sequencer=debug,synd_block_builder=debug,synd_chain_ingestor=debug,synd_maestro=debug,synd_mchain=debug,synd_slotter=debug,synd_tee_attestation_zk_proofs_aws_nitro=debug,synd_tee_attestation_zk_proofs_sp1_script=debug,synd_tee_attestation_zk_proofs_submitter=debug,synd_translator=debug,test_framework=debug,test_utils=debug,info" \
121-
RUST_LOG_DISABLE_JSON="true" \
122-
RUST_LOG_DISABLE_TELEMETRY="true" \
123-
cargo build && cargo nextest run -p test-framework -E 'test(e2e_tee_withdrawal)' --test-threads=1
124-
125-
# Needs to be the last job step
126-
- name: Notify Slack on Failure
127-
# Only notify for workflow_run failures on main branch (not PRs)
128-
if: failure() && github.ref_name == 'main'
129-
uses: rtCamp/action-slack-notify@v2
130-
env:
131-
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
132-
SLACK_COLOR: "danger"
133-
SLACK_MESSAGE: ":x: `${{github.workflow}}` failed on `main` branch. View failure information here: <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow>"
134-
SLACK_TITLE: "`${{github.workflow}}` failed on `main` branch. Notify the author of the latest PR merged to `main`"
18+
withdrawal-tests:
19+
uses: ./.github/workflows/rust-ci-long-test.yml
20+
with:
21+
test_name: "E2E Withdrawal Tests"
22+
monitored_paths: '["synd-withdrawals/", "synd-contracts/src/withdrawal/", "test-framework/tests/e2e/e2e_tests_withdrawals.rs", "shared/"]'
23+
test_filter: "test(e2e_tee_withdrawal)"
24+
secrets: inherit

test-framework/tests/e2e/e2e_tests_migration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ async fn e2e_migration() -> Result<()> {
352352
{
353353
Ok(data) => {
354354
res = data;
355-
true
355+
res.0.batch_count == 2
356356
}
357357
Err(e) => {
358358
eprintln!("error when trying to get migration data: {e}");

0 commit comments

Comments
 (0)