From 93380664d1181c22fe9a55c041e43c2a90231e65 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Mon, 15 Sep 2025 22:46:49 +0200 Subject: [PATCH 01/11] 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 4e91423b6431302681cc3f19d6d9d7be0f4ae758 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 18 Sep 2025 20:42:25 +0200 Subject: [PATCH 02/11] fix: make some bad tests --- app/test_calculator.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/test_calculator.py b/app/test_calculator.py index d811fe7..28783ed 100644 --- a/app/test_calculator.py +++ b/app/test_calculator.py @@ -1,10 +1,18 @@ import random +import time from .calculator import Calculator def test_flaky(): assert random.random() <= 0.8 +def test_slow(): + time.sleep(random.random() * 10) + assert True is True + +def test_fail(): + assert True is False + def test_add(): assert Calculator.add(1, 2) == 3.0 assert Calculator.add(1.0, 2.0) == 3.0 From 746f4e6ee1efd0ecdb42e8009927b21b4f7d43f5 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 18 Sep 2025 20:44:53 +0200 Subject: [PATCH 03/11] fix: py11 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b67c5e..1616586 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,10 +8,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Set up Python 3.10 + - name: Set up Python 3.11 uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Install dependencies run: pip install -r requirements.txt - name: Run tests and collect coverage From 3f85f4f903787f2768b019e16ae7d238c78f1ed6 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 18 Sep 2025 20:46:18 +0200 Subject: [PATCH 04/11] fix: fetch-depth --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1616586..6c7a8ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,9 @@ jobs: id-token: write steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 + with: + fetch-depth: 0 - name: Set up Python 3.11 uses: actions/setup-python@v4 with: From 278322bd634aebd3fb85d4fea5aa402a273c743a Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 18 Sep 2025 20:49:13 +0200 Subject: [PATCH 05/11] fix: use the action --- .github/workflows/ci.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c7a8ce..11be441 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,6 @@ name: Workflow for Codecov example-python +permissions: + id-token: write on: [push, pull_request] jobs: run: @@ -20,8 +22,4 @@ jobs: 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 - env: - PREVENT_TOKEN: ${{ secrets.PREVENT_TOKEN }} + uses: getsentry/prevent-action@latest From ee9ecaef26bad2810f08952ead79eb1563573c49 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 18 Sep 2025 20:49:46 +0200 Subject: [PATCH 06/11] fix: use v0 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11be441..2e7d26b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,4 +22,4 @@ jobs: run: pytest --cov app --junitxml=junit.xml -o junit_family=legacy - name: Upload test results to Codecov if: ${{ !cancelled() }} - uses: getsentry/prevent-action@latest + uses: getsentry/prevent-action@v0 From 206281afde5268984e1650dec64481191dc09270 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 18 Sep 2025 20:52:53 +0200 Subject: [PATCH 07/11] fix: use v4 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e7d26b..74b9535 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: id-token: write steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python 3.11 From 16e067df17f216b09a0e7a6fe76e3c6e9288ca7f Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 18 Sep 2025 22:39:37 +0200 Subject: [PATCH 08/11] fix: now now --- app/test_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test_calculator.py b/app/test_calculator.py index 28783ed..ace704c 100644 --- a/app/test_calculator.py +++ b/app/test_calculator.py @@ -7,7 +7,7 @@ def test_flaky(): assert random.random() <= 0.8 def test_slow(): - time.sleep(random.random() * 10) + time.sleep(random.random() * 12) assert True is True def test_fail(): From 2e898e8b7b313b3f1d11f93d46f6fbdfc509fe06 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 18 Sep 2025 23:19:45 +0200 Subject: [PATCH 09/11] fix: joey --- app/test_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test_calculator.py b/app/test_calculator.py index ace704c..5904391 100644 --- a/app/test_calculator.py +++ b/app/test_calculator.py @@ -7,7 +7,7 @@ def test_flaky(): assert random.random() <= 0.8 def test_slow(): - time.sleep(random.random() * 12) + time.sleep(random.random() * 11) assert True is True def test_fail(): From 0ed6cec405bb6d3a3a492b089ce706a57561cf16 Mon Sep 17 00:00:00 2001 From: joseph-sentry Date: Thu, 18 Sep 2025 19:05:39 -0400 Subject: [PATCH 10/11] joey do it --- app/test_calculator.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/test_calculator.py b/app/test_calculator.py index 5904391..bbd306b 100644 --- a/app/test_calculator.py +++ b/app/test_calculator.py @@ -1,18 +1,22 @@ import random import time + from .calculator import Calculator def test_flaky(): assert random.random() <= 0.8 + def test_slow(): - time.sleep(random.random() * 11) + time.sleep(random.random() * 10) assert True is True + def test_fail(): assert True is False + def test_add(): assert Calculator.add(1, 2) == 3.0 assert Calculator.add(1.0, 2.0) == 3.0 @@ -20,6 +24,7 @@ def test_add(): assert Calculator.add(2.0, 0) == 2.0 assert Calculator.add(-4, 2.0) == -2.0 + def test_subtract(): assert Calculator.subtract(1, 2) == -1.0 assert Calculator.subtract(2, 1) == 1.0 @@ -28,6 +33,7 @@ def test_subtract(): assert Calculator.subtract(2.0, 0.0) == 2.0 assert Calculator.subtract(-4, 2.0) == -6.0 + def test_multiply(): assert Calculator.multiply(1, 2) == 2.0 assert Calculator.multiply(1.0, 2.0) == 2.0 @@ -35,6 +41,7 @@ def test_multiply(): assert Calculator.multiply(2.0, 0.0) == 0.0 assert Calculator.multiply(-4, 2.0) == -8.0 + def test_divide(): # assert Calculator.divide(1, 2) == 0.5 assert Calculator.divide(1.0, 2.0) == 0.5 From a4667e98a3cf514ee4cd6f447654b877ab2a5379 Mon Sep 17 00:00:00 2001 From: joseph-sentry Date: Thu, 18 Sep 2025 19:15:14 -0400 Subject: [PATCH 11/11] joey do it --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74b9535..823d8e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python 3.11 uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: "3.11" - name: Install dependencies run: pip install -r requirements.txt - name: Run tests and collect coverage @@ -23,3 +23,5 @@ jobs: - name: Upload test results to Codecov if: ${{ !cancelled() }} uses: getsentry/prevent-action@v0 + with: + token: ${{ secrets.PREVENT_TOKEN }}