Skip to content

Commit 7ad4c17

Browse files
Merge remote-tracking branch 'origin/main' into 239-asap-planner-rs-accept-prometheus-query-log-as-input
2 parents c66f024 + e6d8afd commit 7ad4c17

20 files changed

Lines changed: 1850 additions & 74 deletions

File tree

.github/workflows/correctness.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: Correctness Tests
2+
3+
# Verifies cross-language parity between Python and Rust implementations of
4+
# PromQL pattern matching and sketch serialisation. Ephemeral GitHub Actions
5+
# VMs are well-suited for these deterministic correctness checks.
6+
7+
on:
8+
push:
9+
branches: [ main ]
10+
paths:
11+
- 'asap-common/tests/**'
12+
- 'asap-common/dependencies/**'
13+
- 'asap-common/sketch-core/**'
14+
- '.github/workflows/correctness.yml'
15+
pull_request:
16+
branches: [ main ]
17+
paths:
18+
- 'asap-common/tests/**'
19+
- 'asap-common/dependencies/**'
20+
- 'asap-common/sketch-core/**'
21+
- '.github/workflows/correctness.yml'
22+
workflow_dispatch:
23+
24+
jobs:
25+
# ── 1. Cross-language token matching (Python vs Rust) ──────────────────────
26+
cross-language-token-matching:
27+
name: Cross-language PromQL token matching
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: '3.11'
36+
37+
- name: Install Python dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
if [ -f asap-common/dependencies/py/requirements.txt ]; then
41+
pip install -r asap-common/dependencies/py/requirements.txt
42+
fi
43+
pip install -e asap-common/dependencies/py/promql_utilities/
44+
45+
- name: Install Rust
46+
uses: dtolnay/rust-toolchain@stable
47+
48+
- name: Install protoc
49+
run: |
50+
sudo apt-get update -qq
51+
sudo apt-get install -y protobuf-compiler
52+
53+
- name: Run sccache
54+
uses: mozilla-actions/sccache-action@v0.0.4
55+
56+
- name: Cache cargo
57+
uses: actions/cache@v4
58+
with:
59+
path: |
60+
~/.cargo/registry
61+
~/.cargo/git
62+
target
63+
key: ${{ runner.os }}-cargo-correctness-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
64+
65+
- name: Run master test runner (Python + Rust + comparison)
66+
working-directory: asap-common/tests/compare_matched_tokens
67+
run: python utilities/master_test_runner.py
68+
env:
69+
RUSTC_WRAPPER: sccache
70+
71+
- name: Upload test artefacts
72+
if: always()
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: cross-language-token-results
76+
path: |
77+
asap-common/tests/compare_matched_tokens/python_tests/python_test_results.json
78+
asap-common/tests/compare_matched_tokens/rust_tests/rust_test_results.json
79+
asap-common/tests/compare_matched_tokens/comparison_tests/comparison_report.json
80+
asap-common/tests/compare_matched_tokens/test_summary.json
81+
if-no-files-found: warn
82+
83+
# ── 2. Cross-language serialised pattern comparison ────────────────────────
84+
cross-language-pattern-serialisation:
85+
name: Cross-language pattern serialisation
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v4
89+
90+
- name: Set up Python
91+
uses: actions/setup-python@v5
92+
with:
93+
python-version: '3.11'
94+
95+
- name: Install Python dependencies
96+
run: |
97+
python -m pip install --upgrade pip
98+
if [ -f asap-common/dependencies/py/requirements.txt ]; then
99+
pip install -r asap-common/dependencies/py/requirements.txt
100+
fi
101+
pip install -e asap-common/dependencies/py/promql_utilities/
102+
103+
- name: Install Rust
104+
uses: dtolnay/rust-toolchain@stable
105+
106+
- name: Install protoc
107+
run: |
108+
sudo apt-get update -qq
109+
sudo apt-get install -y protobuf-compiler
110+
111+
- name: Run sccache
112+
uses: mozilla-actions/sccache-action@v0.0.4
113+
114+
- name: Cache cargo
115+
uses: actions/cache@v4
116+
with:
117+
path: |
118+
~/.cargo/registry
119+
~/.cargo/git
120+
target
121+
key: ${{ runner.os }}-cargo-correctness-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
122+
123+
- name: Generate Python patterns
124+
working-directory: asap-common/tests/compare_patterns
125+
run: python python_generate_patterns.py
126+
127+
- name: Build and run Rust pattern generator
128+
working-directory: asap-common/tests/compare_patterns
129+
run: cargo run --release
130+
env:
131+
RUSTC_WRAPPER: sccache
132+
133+
- name: Compare serialised patterns
134+
working-directory: asap-common/tests/compare_patterns
135+
run: python compare_serialized_patterns.py
136+
137+
# ── 3. Rust pattern-matching unit tests ────────────────────────────────────
138+
rust-pattern-matching:
139+
name: Rust pattern matching unit tests
140+
runs-on: ubuntu-latest
141+
steps:
142+
- uses: actions/checkout@v4
143+
144+
- name: Install Rust
145+
uses: dtolnay/rust-toolchain@stable
146+
147+
- name: Install protoc
148+
run: |
149+
sudo apt-get update -qq
150+
sudo apt-get install -y protobuf-compiler
151+
152+
- name: Run sccache
153+
uses: mozilla-actions/sccache-action@v0.0.4
154+
155+
- name: Cache cargo
156+
uses: actions/cache@v4
157+
with:
158+
path: |
159+
~/.cargo/registry
160+
~/.cargo/git
161+
target
162+
key: ${{ runner.os }}-cargo-correctness-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
163+
164+
- name: Run Rust pattern matching tests
165+
working-directory: asap-common/tests/rust_pattern_matching
166+
run: cargo test --release
167+
env:
168+
RUSTC_WRAPPER: sccache

Cargo.lock

Lines changed: 23 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

asap-common/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ dependencies/py/promql_utilities/promql_utilities.egg-info/
88
dependencies/rs/**/target/
99

1010
tests/**/*.json
11+
!tests/**/test_data/*.json
1112
tests/**/target/

asap-common/tests/compare_matched_tokens/rust_tests/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[workspace]
2+
13
[package]
24
name = "promql_cross_lang_tests"
35
version = "0.1.0"

0 commit comments

Comments
 (0)