Skip to content

Commit 48b504f

Browse files
authored
fix(ci): calculate parallel jobs based on infrastructure needs (#1475)
1 parent 2ade49a commit 48b504f

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

.github/workflows/run-e2e-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
strategy:
2222
matrix:
2323
# Maintenance: disabled until we discover concurrency lock issue with multiple versions and tmp
24-
# version: ["3.7", "3.8", "3.9"]
25-
version: ["3.7"]
24+
version: ["3.7", "3.8", "3.9"]
25+
# version: ["3.7"]
2626
steps:
2727
- name: "Checkout"
2828
uses: actions/checkout@v3

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ unit-test:
3535
poetry run pytest tests/unit
3636

3737
e2e-test:
38-
poetry run pytest -rP -n auto --dist loadfile -o log_cli=true tests/e2e
38+
python parallel_run_e2e.py
3939

4040
coverage-html:
4141
poetry run pytest -m "not perf" --ignore tests/e2e --cov=aws_lambda_powertools --cov-report=html

parallel_run_e2e.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
""" Calculate how many parallel workers are needed to complete E2E infrastructure jobs across available CPU Cores """
2+
import subprocess
3+
from pathlib import Path
4+
5+
6+
def main():
7+
features = Path("tests/e2e").rglob("infrastructure.py")
8+
workers = len(list(features)) - 1
9+
10+
command = f"poetry run pytest -n {workers} --dist loadfile -o log_cli=true tests/e2e"
11+
print(f"Running E2E tests with: {command}")
12+
subprocess.run(command.split(), shell=False)
13+
14+
15+
if __name__ == "__main__":
16+
main()

tox.ini

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[tox]
2+
envlist = py37,py38,py39
3+
4+
[testenv]
5+
deps =
6+
filelock
7+
pytest-xdist
8+
pydantic
9+
email-validator
10+
11+
commands = python parallel_run_e2e.py
12+
13+
; If you ever encounter another parallel lock across interpreters
14+
; pip install tox tox-poetry
15+
; tox -p --parallel-live

0 commit comments

Comments
 (0)