Skip to content

Commit eae246a

Browse files
ci: run all the integration tests on PR or push
1 parent bc809f2 commit eae246a

File tree

5 files changed

+172
-96
lines changed

5 files changed

+172
-96
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Integration Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch:
7+
description: 'Branch to checkout and test'
8+
required: false
9+
type: string
10+
default: ''
11+
is_nightly:
12+
description: 'Whether this is a nightly run'
13+
required: false
14+
type: boolean
15+
default: false
16+
changes_only:
17+
description: 'Only build tests affected by changes'
18+
required: false
19+
type: boolean
20+
default: false
21+
commit_id:
22+
description: 'Base commit ID for change comparison'
23+
required: false
24+
type: string
25+
default: ''
26+
27+
jobs:
28+
build-integration-tests:
29+
runs-on: namespace-profile-large-ubuntu-24-04-amd64
30+
outputs:
31+
test_binaries: ${{ steps.build.outputs.test_binaries }}
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
# Fetch the entire history.
36+
fetch-depth: 0
37+
ref: ${{ inputs.branch }}
38+
39+
- uses: ./.github/actions/bootstrap
40+
with:
41+
github_token: ${{ secrets.GITHUB_TOKEN }}
42+
43+
# Setup pypy and link to the location expected by .cargo/config.toml.
44+
- uses: actions/setup-python@v5
45+
id: setup-pypy
46+
with:
47+
python-version: "pypy3.9"
48+
cache: "pip"
49+
- run: ln -s '${{ steps.setup-pypy.outputs.python-path }}' /usr/local/bin/pypy3.9
50+
- env:
51+
LD_LIBRARY_PATH: ${{ env.Python3_ROOT_DIR }}/bin
52+
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
53+
- run: pip install -r scripts/requirements.txt
54+
55+
- name: "Build integration tests"
56+
id: build
57+
run: |
58+
CMD="scripts/run_tests.py --command build_integration"
59+
if [[ "${{ inputs.is_nightly }}" == "true" ]]; then
60+
CMD="$CMD --is_nightly"
61+
fi
62+
if [[ "${{ inputs.changes_only }}" == "true" ]]; then
63+
CMD="$CMD --changes_only --include_dependencies"
64+
if [[ -n "${{ inputs.commit_id }}" ]]; then
65+
CMD="$CMD --commit_id ${{ inputs.commit_id }}"
66+
fi
67+
fi
68+
eval $CMD
69+
70+
- name: "Upload integration test binaries"
71+
if: steps.build.outputs.test_binaries
72+
uses: namespace-actions/upload-artifact@v1
73+
with:
74+
name: integration-test-binaries-${{ replace(inputs.branch || github.ref_name, '/', '-') }}
75+
path: ./target/debug
76+
compression-level: 0
77+
78+
run-integration-tests:
79+
needs: build-integration-tests
80+
if: needs.build-integration-tests.outputs.test_binaries
81+
runs-on: namespace-profile-large-ubuntu-24-04-amd64
82+
strategy:
83+
fail-fast: false
84+
matrix:
85+
test_binary: ${{ fromJson(needs.build-integration-tests.outputs.test_binaries) }}
86+
steps:
87+
- uses: actions/checkout@v4
88+
with:
89+
# Fetch the entire history.
90+
fetch-depth: 0
91+
ref: ${{ inputs.branch }}
92+
93+
- uses: ./.github/actions/bootstrap
94+
with:
95+
github_token: ${{ secrets.GITHUB_TOKEN }}
96+
97+
# Setup pypy and link to the location expected by .cargo/config.toml.
98+
- uses: actions/setup-python@v5
99+
id: setup-pypy
100+
with:
101+
python-version: "pypy3.9"
102+
cache: "pip"
103+
- run: ln -s '${{ steps.setup-pypy.outputs.python-path }}' /usr/local/bin/pypy3.9
104+
- env:
105+
LD_LIBRARY_PATH: ${{ env.Python3_ROOT_DIR }}/bin
106+
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
107+
- run: pip install -r scripts/requirements.txt
108+
109+
- name: "Download integration test binaries"
110+
uses: namespace-actions/download-artifact@v1
111+
with:
112+
name: integration-test-binaries-${{ replace(inputs.branch || github.ref_name, '/', '-') }}
113+
path: ./target/debug
114+
115+
- name: "Restore executable permissions"
116+
run: |
117+
chmod +x ./target/debug/apollo_node
118+
chmod +x ./target/debug/${{ matrix.test_binary }}
119+
120+
- name: "Run ${{ matrix.test_binary }}"
121+
run: ./target/debug/${{ matrix.test_binary }}
122+
env:
123+
SEED: 0
124+

.github/workflows/main.yml

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -144,32 +144,10 @@ jobs:
144144
env:
145145
SEED: 0
146146

147-
run-integration-tests:
148-
runs-on: namespace-profile-large-ubuntu-24-04-amd64
149-
steps:
150-
- uses: actions/checkout@v4
151-
with:
152-
# Fetch the entire history.
153-
fetch-depth: 0
154-
- uses: ./.github/actions/bootstrap
155-
with:
156-
github_token: ${{ secrets.GITHUB_TOKEN }}
157-
158-
# Setup pypy and link to the location expected by .cargo/config.toml.
159-
- uses: actions/setup-python@v5
160-
id: setup-pypy
161-
with:
162-
python-version: "pypy3.9"
163-
cache: "pip"
164-
- run: ln -s '${{ steps.setup-pypy.outputs.python-path }}' /usr/local/bin/pypy3.9
165-
- env:
166-
LD_LIBRARY_PATH: ${{ env.Python3_ROOT_DIR }}/bin
167-
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
168-
- run: pip install -r scripts/requirements.txt
169-
170-
- name: "Run integration tests pull request"
171-
if: github.event_name == 'pull_request'
172-
run: |
173-
scripts/run_tests.py --command integration --changes_only --include_dependencies --commit_id ${{ github.event.pull_request.base.sha }}
174-
env:
175-
SEED: 0
147+
integration-tests-pr:
148+
if: github.event_name == 'pull_request'
149+
uses: ./.github/workflows/integration-tests.yml
150+
with:
151+
changes_only: true
152+
commit_id: ${{ github.event.pull_request.base.sha }}
153+
secrets: inherit

.github/workflows/main_nightly.yml

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -89,33 +89,16 @@ jobs:
8989
- name: "Run feature combo on all crates."
9090
run: scripts/run_feature_combos_test.py
9191

92-
run-integration-tests:
93-
runs-on: namespace-profile-large-ubuntu-24-04-amd64
94-
needs: define_branches
95-
strategy:
96-
matrix:
97-
branch: ${{ fromJson(needs.define_branches.outputs.branches) }}
98-
steps:
99-
- uses: actions/checkout@v4
100-
with:
101-
ref: ${{ matrix.branch }}
102-
103-
- uses: ./.github/actions/bootstrap
104-
with:
105-
github_token: ${{ secrets.GITHUB_TOKEN }}
92+
integration-tests-main:
93+
uses: ./.github/workflows/integration-tests.yml
94+
with:
95+
branch: main
96+
is_nightly: true
97+
secrets: inherit
10698

107-
# Setup pypy and link to the location expected by .cargo/config.toml.
108-
- uses: actions/setup-python@v5
109-
id: setup-pypy
110-
with:
111-
python-version: "pypy3.9"
112-
- run: ln -s '${{ steps.setup-pypy.outputs.python-path }}' /usr/local/bin/pypy3.9
113-
- env:
114-
LD_LIBRARY_PATH: ${{ env.Python3_ROOT_DIR }}/bin
115-
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
116-
- run: pip install -r scripts/requirements.txt
117-
- name: "Run integration tests pull request"
118-
run: |
119-
scripts/run_tests.py --command integration --is_nightly
120-
env:
121-
SEED: 0
99+
integration-tests-main-v0-14:
100+
uses: ./.github/workflows/integration-tests.yml
101+
with:
102+
branch: main-v0.14.1
103+
is_nightly: true
104+
secrets: inherit

crates/apollo_integration_tests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Trigger CI integration tests
12
[package]
23
name = "apollo_integration_tests"
34
version.workspace = true

scripts/run_tests.py

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/env python3
22

33
import argparse
4+
import os
45
import subprocess
56
from enum import Enum
67
from typing import List, Optional, Set
@@ -18,22 +19,30 @@
1819

1920
# List of sequencer node integration test binary names. Stored as a list to maintain order.
2021
SEQUENCER_INTEGRATION_TEST_NAMES: List[str] = [
21-
"integration_test_restart_flow",
22-
]
23-
NIGHTLY_ONLY_SEQUENCER_INTEGRATION_TEST_NAMES: List[str] = [
2422
"integration_test_positive_flow",
2523
"integration_test_restart_flow",
2624
"integration_test_revert_flow",
27-
"integration_test_central_and_p2p_sync_flow",
25+
# TODO(shahak): revive this test
26+
# "integration_test_central_and_p2p_sync_flow",
2827
]
2928

3029

30+
def build_cmds(with_cairo_native: bool) -> List[List[str]]:
31+
feature_flag = ["--features", "cairo_native"] if with_cairo_native else []
32+
# Commands to build the node and all the test binaries.
33+
build_cmds = [
34+
["cargo", "build", "--bin", binary_name] + feature_flag
35+
for binary_name in [SEQUENCER_BINARY_NAME] + SEQUENCER_INTEGRATION_TEST_NAMES
36+
]
37+
return build_cmds
38+
39+
3140
# Enum of base commands.
3241
class BaseCommand(Enum):
3342
TEST = "test"
3443
CLIPPY = "clippy"
3544
DOC = "doc"
36-
INTEGRATION = "integration"
45+
BUILD_INTEGRATION = "build_integration"
3746

3847
def cmds(self, crates: Set[str], is_nightly: bool) -> List[List[str]]:
3948
package_args = []
@@ -48,46 +57,27 @@ def cmds(self, crates: Set[str], is_nightly: bool) -> List[List[str]]:
4857
elif self == BaseCommand.DOC:
4958
doc_args = package_args if len(package_args) > 0 else ["--workspace"]
5059
return [["cargo", "doc", "--document-private-items", "--no-deps"] + doc_args]
51-
elif self == BaseCommand.INTEGRATION:
60+
elif self == BaseCommand.BUILD_INTEGRATION:
5261
# Do nothing if integration tests should not be triggered; on nightly, run the tests.
5362
if INTEGRATION_TEST_CRATE_TRIGGERS.isdisjoint(crates) and not is_nightly:
5463
print(f"Skipping sequencer integration tests.")
5564
return []
5665

57-
integration_test_names_to_run = (
58-
NIGHTLY_ONLY_SEQUENCER_INTEGRATION_TEST_NAMES
59-
if is_nightly
60-
else SEQUENCER_INTEGRATION_TEST_NAMES
66+
with_cairo_native = (not CAIRO_NATIVE_CRATE_TRIGGERS.isdisjoint(crates)) or is_nightly
67+
68+
print(
69+
f"Composing sequencer integration test commands, with_cairo_native={with_cairo_native}."
6170
)
6271

63-
print(f"Composing sequencer integration test commands.")
64-
65-
def build_cmds(with_feature: bool) -> List[List[str]]:
66-
feature_flag = (
67-
["--features", "cairo_native"] if (with_feature and is_nightly) else []
68-
)
69-
# Commands to build the node and all the test binaries.
70-
build_cmds = [
71-
["cargo", "build", "--bin", binary_name] + feature_flag
72-
for binary_name in [SEQUENCER_BINARY_NAME] + integration_test_names_to_run
73-
]
74-
return build_cmds
75-
76-
# Commands to run the test binaries.
77-
run_cmds = [
78-
[f"./target/debug/{test_binary_name}"]
79-
for test_binary_name in integration_test_names_to_run
80-
]
81-
82-
cmds_no_feat = build_cmds(with_feature=False) + run_cmds
83-
84-
# Only run cairo_native feature if the blockifier crate is modified, and in nightly.
85-
if CAIRO_NATIVE_CRATE_TRIGGERS.isdisjoint(crates) and not is_nightly:
86-
return cmds_no_feat
87-
88-
print("Composing sequencer integration test commands with cairo_native feature.")
89-
cmds_with_feat = build_cmds(with_feature=True) + run_cmds
90-
return cmds_no_feat + cmds_with_feat
72+
cmds = build_cmds(with_cairo_native=with_cairo_native)
73+
74+
if "GITHUB_OUTPUT" in os.environ:
75+
test_list = str(SEQUENCER_INTEGRATION_TEST_NAMES)
76+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
77+
f.write(f"test_binaries={test_list}\n")
78+
print(f"Wrote test list to GITHUB_OUTPUT: {test_list}")
79+
80+
return cmds
9181

9282
raise NotImplementedError(f"Command {self} not implemented.")
9383

0 commit comments

Comments
 (0)