Skip to content

Commit 8ff6d23

Browse files
authored
Merge pull request #175 from P403n1x87/ci/data-validation
ci: add data validation workflow
2 parents 4c3e26b + a3dcaa2 commit 8ff6d23

File tree

6 files changed

+414
-41
lines changed

6 files changed

+414
-41
lines changed

.github/workflows/tests.yml

+53
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,56 @@ jobs:
225225
python -m pip install -r test/requirements.txt
226226
python -m pytest --ignore=test\cunit --pastebin=failed --no-flaky-report -sr a
227227
deactivate
228+
229+
validation:
230+
runs-on: ubuntu-20.04
231+
232+
needs: build-linux
233+
234+
strategy:
235+
fail-fast: false
236+
matrix:
237+
python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
238+
239+
env:
240+
AUSTIN_TESTS_PYTHON_VERSIONS: ${{ matrix.python-version }}
241+
242+
name: Data validation with Python ${{ matrix.python-version }}
243+
steps:
244+
- uses: actions/checkout@v2
245+
246+
- name: Install build dependencies
247+
run: |
248+
sudo apt-get -y install libunwind-dev binutils-dev libiberty-dev
249+
250+
- name: Install Python
251+
uses: actions/setup-python@v4
252+
with:
253+
python-version: ${{ matrix.python-version }}-dev
254+
255+
- name: Install Python 3.10
256+
uses: actions/setup-python@v4
257+
with:
258+
python-version: "3.10"
259+
260+
- name: Compile Austin
261+
run: |
262+
autoreconf --install
263+
./configure --enable-debug-symbols true
264+
make
265+
266+
- name: Install runtime dependencies
267+
run: |
268+
python3.10 -m venv .venv
269+
source .venv/bin/activate
270+
pip install --upgrade pip
271+
pip install -r scripts/requirements-val.txt
272+
deactivate
273+
274+
- name: Run data validation
275+
run: |
276+
ulimit -c unlimited
277+
278+
source .venv/bin/activate
279+
python scripts/validation.py --ignore-errors
280+
deactivate

scripts/benchmark.py

+3-39
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@
77
from textwrap import wrap
88
import typing as t
99
from argparse import ArgumentParser
10-
from itertools import product
1110
from math import floor, log
1211
from pathlib import Path
1312

1413
from scipy.stats import ttest_ind
1514

16-
sys.path.insert(0, str(Path(__file__).parent.parent))
15+
from common import download_release
16+
17+
from test.utils import metadata, target
1718

18-
import tarfile
19-
from io import BytesIO
20-
from test.utils import Variant, metadata, target
21-
from urllib.error import HTTPError
22-
from urllib.request import urlopen
2319

2420
VERSIONS = ("3.4.1", "3.5.0", "dev")
2521
SCENARIOS = [
@@ -99,38 +95,6 @@ def get_stats(output: str) -> t.Optional[dict]:
9995
return None
10096

10197

102-
def download_release(version: str, dest: Path, variant_name: str = "austin") -> Variant:
103-
if version == "dev":
104-
return Variant(f"src/{variant_name}")
105-
106-
binary_dest = dest / version
107-
binary = binary_dest / variant_name
108-
109-
if not binary.exists():
110-
prefix = "https://github.com/p403n1x87/austin/releases/download/"
111-
for flavour, v in product({"-gnu", ""}, {"", "v"}):
112-
try:
113-
with urlopen(
114-
f"{prefix}v{version}/{variant_name}-{v}{version}{flavour}-linux-amd64.tar.xz"
115-
) as stream:
116-
buffer = BytesIO(stream.read())
117-
binary_dest.mkdir(parents=True, exist_ok=True)
118-
tar = tarfile.open(fileobj=buffer, mode="r:xz")
119-
tar.extract(variant_name, str(binary_dest))
120-
except HTTPError:
121-
continue
122-
break
123-
else:
124-
raise RuntimeError(f"Could not download Austin version {version}")
125-
126-
variant = Variant(str(binary))
127-
128-
out = variant("-V").stdout
129-
assert f"{variant_name} {version}" in out, (f"{variant_name} {version}", out)
130-
131-
return variant
132-
133-
13498
class Outcome:
13599
def __init__(self, data: list[float]) -> None:
136100
self.data = data

scripts/common.py

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import sys
2+
from itertools import product
3+
from pathlib import Path
4+
5+
sys.path.insert(0, str(Path(__file__).parent.parent))
6+
7+
import tarfile
8+
from io import BytesIO
9+
from test.utils import Variant
10+
from urllib.error import HTTPError
11+
from urllib.request import urlopen
12+
import json
13+
14+
15+
def get_latest_release() -> str:
16+
with urlopen(
17+
"https://api.github.com/repos/p403n1x87/austin/releases/latest"
18+
) as stream:
19+
return json.loads(stream.read().decode("utf-8"))["tag_name"].strip("v")
20+
21+
22+
def download_release(version: str, dest: Path, variant_name: str = "austin") -> Variant:
23+
if version == "dev":
24+
return Variant(f"src/{variant_name}")
25+
26+
binary_dest = dest / version
27+
binary = binary_dest / variant_name
28+
29+
if not binary.exists():
30+
prefix = "https://github.com/p403n1x87/austin/releases/download/"
31+
for flavour, v in product({"-gnu", ""}, {"", "v"}):
32+
try:
33+
with urlopen(
34+
f"{prefix}v{version}/{variant_name}-{v}{version}{flavour}-linux-amd64.tar.xz"
35+
) as stream:
36+
buffer = BytesIO(stream.read())
37+
binary_dest.mkdir(parents=True, exist_ok=True)
38+
tar = tarfile.open(fileobj=buffer, mode="r:xz")
39+
tar.extract(variant_name, str(binary_dest))
40+
except HTTPError:
41+
continue
42+
break
43+
else:
44+
raise RuntimeError(f"Could not download Austin version {version}")
45+
46+
variant = Variant(str(binary))
47+
48+
out = variant("-V").stdout
49+
assert f"{variant_name} {version}" in out, (f"{variant_name} {version}", out)
50+
51+
return variant
52+
53+
54+
def download_latest(dest: Path, variant_name: str = "austin") -> Variant:
55+
return download_release(get_latest_release(), dest, variant_name)
56+
57+
58+
def get_dev(variant_name: str = "austin") -> Variant:
59+
return download_release("dev", None, variant_name)

scripts/requirements-val.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
austin-python~=1.5
2+
numpy
3+
scipy

0 commit comments

Comments
 (0)