From 93380664d1181c22fe9a55c041e43c2a90231e65 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Mon, 15 Sep 2025 22:46:49 +0200 Subject: [PATCH 1/2] fix: add a flaky test --- app/test_calculator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/test_calculator.py b/app/test_calculator.py index f564193..d811fe7 100644 --- a/app/test_calculator.py +++ b/app/test_calculator.py @@ -1,6 +1,10 @@ +import random from .calculator import Calculator +def test_flaky(): + assert random.random() <= 0.8 + def test_add(): assert Calculator.add(1, 2) == 3.0 assert Calculator.add(1.0, 2.0) == 3.0 From 57e2f146b5e4e684ff202a3ecdcf49f2275ecd5e Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 19 Sep 2025 19:12:51 +0200 Subject: [PATCH 2/2] fix: see things e2e --- .github/workflows/ci.yml | 12 +++++------- app/test_calculator.py | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b67c5e..93132b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,19 +7,17 @@ jobs: id-token: write steps: - name: Checkout - uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v4 + uses: actions/checkout@v5 + - name: Set up Python 3.11 + uses: actions/setup-python@v6 with: - python-version: '3.10' + python-version: '3.11' - name: Install dependencies run: pip install -r requirements.txt - name: Run tests and collect coverage run: pytest --cov app --junitxml=junit.xml -o junit_family=legacy - name: Upload test results to Codecov if: ${{ !cancelled() }} - run: | - pip install sentry-prevent-cli - sentry-prevent-cli -v upload --report-type test-results + uses: getsentry/prevent-action@v0 env: PREVENT_TOKEN: ${{ secrets.PREVENT_TOKEN }} diff --git a/app/test_calculator.py b/app/test_calculator.py index d811fe7..6536cbf 100644 --- a/app/test_calculator.py +++ b/app/test_calculator.py @@ -1,10 +1,24 @@ import random +import time + from .calculator import Calculator def test_flaky(): assert random.random() <= 0.8 +def test_fail_1(): + assert True is False + +def test_fail_2(): + assert True is False + +def test_fail_3(): + assert True is False + +def test_slow(): + time.sleep(5) + def test_add(): assert Calculator.add(1, 2) == 3.0 assert Calculator.add(1.0, 2.0) == 3.0