Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use matrix for Python versions #120

Merged
merged 1 commit into from
Jun 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ jobs:
source .venv/bin/activate
pip install --upgrade pip
pip install -r test/requirements.txt
.venv/bin/pytest --pastebin=failed --no-flaky-report -sr fE || true
sudo .venv/bin/pytest --pastebin=failed --no-flaky-report -sr fE || true
.venv/bin/pytest --pastebin=failed --no-flaky-report -sr fE -n auto || true
sudo .venv/bin/pytest --pastebin=failed --no-flaky-report -sr fE -n auto || true
deactivate

- name: Generate Cobertura report
Expand Down
95 changes: 63 additions & 32 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ concurrency:
jobs:
tests-linux:
runs-on: ubuntu-latest

strategy:
fail-fast: false
name: Tests on Linux
matrix:
python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]

env:
AUSTIN_TESTS_PYTHON_VERSIONS: ${{ matrix.python-version }}

name: Tests on Linux with Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2

Expand All @@ -22,9 +29,22 @@ jobs:
sudo apt-get -y install \
valgrind \
gdb \
python2.7 \
python3.{5..11} \
python3.10-full
python${{ matrix.python-version }} \
python3.10{,-full}

# Using these actions lead to Python binaries that cause SIGSEGV during
# C unit tests. See
# https://github.com/actions/setup-python/issues/442.

# - name: Install Python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}

# - name: Install Python 3.10
# uses: actions/setup-python@v4
# with:
# python-version: "3.10"

- name: Compile Austin
run: |
Expand All @@ -39,42 +59,59 @@ jobs:
source .venv/bin/activate
pip install --upgrade pip
pip install -r test/requirements.txt
.venv/bin/pytest --pastebin=failed --no-flaky-report -sr a -n auto
sudo .venv/bin/pytest --pastebin=failed --no-flaky-report -sr a -n auto
sudo -E .venv/bin/pytest --pastebin=failed --no-flaky-report -sr a
.venv/bin/pytest --pastebin=failed --no-flaky-report -sr a
deactivate

tests-osx:
runs-on: macos-latest

strategy:
fail-fast: false
name: Tests on macOS
matrix:
python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]

env:
AUSTIN_TESTS_PYTHON_VERSIONS: ${{ matrix.python-version }}

name: Tests on macOS with Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- name: Compile Austin
run: gcc -Wall -O3 -g src/*.c -o src/austin

- name: Install test dependencies
run: |
brew update
brew install [email protected]
brew install [email protected]
brew install [email protected]
brew install [email protected]
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}-dev

- name: Install Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Run tests
run: |
$(brew --prefix)/opt/[email protected]/bin/python3 -m venv .venv
python3.10 -m pip install --upgrade pip
python3.10 -m pip install -r test/requirements.txt
python${{ matrix.python-version }} -m venv .venv \
|| (python${{ matrix.python-version }} -m pip install virtualenv && python${{ matrix.python-version }} -m virtualenv .venv)
source .venv/bin/activate
pip install --upgrade pip
pip install -r test/requirements.txt
sudo .venv/bin/pytest --ignore=test/cunit --pastebin=failed --no-flaky-report -sr a -n auto
sudo -E pytest --ignore=test/cunit --pastebin=failed --no-flaky-report -sr a
deactivate

tests-win:
runs-on: windows-latest

strategy:
fail-fast: false
name: Tests on Windows
matrix:
python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]

env:
AUSTIN_TESTS_PYTHON_VERSIONS: ${{ matrix.python-version }}

name: Tests on Windows with Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2

Expand All @@ -83,27 +120,21 @@ jobs:
gcc.exe -O3 -g -o src/austin.exe src/*.c -lpsapi -lntdll -Wall
src\austin.exe --help

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}-dev

- uses: actions/setup-python@v2
name: Setup Python
name: Install Python 3.10
with:
python-version: '3.10'

- name: Install test dependencies
run: |
choco install python --no-progress -y --version=2.7.11
choco install python --no-progress -y --version=3.5.4
choco install python --no-progress -y --version=3.6.8
choco install python --no-progress -y --version=3.7.9
choco install python --no-progress -y --version=3.8.10
choco install python --no-progress -y --version=3.9.10
choco install python --no-progress -y --version=3.11.0-b3 --pre
refreshenv

- name: Run tests
run: |
py -3.10 -m venv venv
venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r test/requirements.txt
python -m pytest --ignore=test\cunit --pastebin=failed --no-flaky-report -sr a -n auto
python -m pytest --ignore=test\cunit --pastebin=failed --no-flaky-report -sr a
deactivate
18 changes: 16 additions & 2 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import os
import platform

PY3_LATEST = 11

try:
REQUESTED_PYTHON_VERSIONS = [
tuple(int(_) for _ in v.split("."))
for v in os.getenv("AUSTIN_TESTS_PYTHON_VERSIONS", "").split(",")
]
except Exception:
REQUESTED_PYTHON_VERSIONS = None


match platform.system():
case "Darwin":
PYTHON_VERSIONS = [(3, _) for _ in range(7, PY3_LATEST + 1)]
PYTHON_VERSIONS = REQUESTED_PYTHON_VERSIONS or [
(3, _) for _ in range(7, PY3_LATEST + 1)
]
case _:
PYTHON_VERSIONS = [(2, 7)] + [(3, _) for _ in range(5, PY3_LATEST + 1)]
PYTHON_VERSIONS = REQUESTED_PYTHON_VERSIONS or [(2, 7)] + [
(3, _) for _ in range(5, PY3_LATEST + 1)
]
9 changes: 7 additions & 2 deletions test/test_attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@


def allpythons():
# Attach tests fail on Windows for Python < 3.7
return _allpythons(min=(3, 7) if platform.system() == "Windows" else None)
# Attach tests fail on Windows for Python < 3.7 and on MacOS for Python < 3
match platform.system():
case "Windows":
return _allpythons(min=(3, 7))
case "Darwin":
return _allpythons(min=(3,))
return _allpythons()


@flaky(max_runs=6)
Expand Down
29 changes: 26 additions & 3 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ def python(version: str) -> list[str]:
match platform.system():
case "Windows":
py = ["py", f"-{version}"]
case "Darwin":
py = [f"{BREW_PREFIX}/opt/python@{version}/bin/python3"]
case "Linux":
case "Darwin" | "Linux":
py = [f"python{version}"]
case _:
raise RuntimeError(f"Unsupported platform: {platform.system()}")
Expand All @@ -83,9 +81,34 @@ def gdb(cmds: list[str], *args: tuple[str]) -> str:
).decode()


def apport_unpack(report: Path, target_dir: Path):
return check_output(
["apport-unpack", str(report), str(target_dir)],
stderr=STDOUT,
).decode()


def bt(binary: Path) -> str:
if Path("core").is_file():
return gdb(["bt full", "q"], str(binary), "core")

# On Ubuntu, apport puts crashes in /var/crash
crash_dir = Path("/var/crash")
if crash_dir.is_dir():
crashes = list(crash_dir.glob("*.crash"))
if crashes:
# Take the last one
crash = crashes[-1]
target_dir = Path(crash.stem)
apport_unpack(crash, target_dir)

result = gdb(["bt full", "q"], str(binary), target_dir / "CoreDump")

crash.unlink()
target_dir.rmdir()

return result

return "No core dump available."


Expand Down