Skip to content

Commit 33be31f

Browse files
committed
feat: enhance test workflow to run fast tests on pull requests and full tests on main branch
1 parent d915035 commit 33be31f

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

.github/workflows/run-tests-on-push.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
name: Run Tests (On Push)
1+
name: Run Tests
22
on:
33
push:
4+
# Run all tests on main, fast tests on other branches
45

56
env:
67
LOG_CONFIG: test
@@ -50,7 +51,12 @@ jobs:
5051
- run: pip install --upgrade pip
5152
- run: pip install poetry
5253
- run: poetry install --with dev
53-
- run: poetry run pytest tests/
54+
- name: Run fast tests on non-main branches
55+
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
56+
run: poetry run pytest tests/ -m "not network and not slow"
57+
- name: Run full tests on main
58+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
59+
run: poetry run pytest tests/
5460

5561
run-tests-3_11:
5662
runs-on: ubuntu-latest
@@ -66,7 +72,12 @@ jobs:
6672
- run: pip install --upgrade pip
6773
- run: pip install poetry
6874
- run: poetry install --with dev --extras server
69-
- run: poetry run pytest tests/ --show-capture=stdout --cov=src
75+
- name: Run fast tests on non-main branches
76+
if: github.ref != 'refs/heads/main'
77+
run: poetry run pytest tests/ -m "not network and not slow" --show-capture=stdout
78+
- name: Run all tests with coverage on main branch
79+
if: github.ref == 'refs/heads/main'
80+
run: poetry run pytest tests/ --show-capture=stdout --cov=src
7081

7182
run-tests-3_12-core-dependencies:
7283
runs-on: ubuntu-latest
@@ -80,7 +91,12 @@ jobs:
8091
- run: pip install --upgrade pip
8192
- run: pip install poetry
8293
- run: poetry install --with dev
83-
- run: poetry run pytest tests/
94+
- name: Run fast tests on non-main branches
95+
if: github.ref != 'refs/heads/main'
96+
run: poetry run pytest tests/ -m "not network and not slow"
97+
- name: Run all tests on main branch
98+
if: github.ref == 'refs/heads/main'
99+
run: poetry run pytest tests/
84100

85101
run-tests-3_12:
86102
runs-on: ubuntu-latest
@@ -96,4 +112,9 @@ jobs:
96112
- run: pip install --upgrade pip
97113
- run: pip install poetry
98114
- run: poetry install --with dev --extras server
99-
- run: poetry run pytest tests/ --show-capture=stdout --cov=src
115+
- name: Run fast tests on non-main branches
116+
if: github.ref != 'refs/heads/main'
117+
run: poetry run pytest tests/ -m "not network and not slow" --show-capture=stdout
118+
- name: Run all tests with coverage on main branch
119+
if: github.ref == 'refs/heads/main'
120+
run: poetry run pytest tests/ --show-capture=stdout --cov=src

0 commit comments

Comments
 (0)