diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b67c5e..823d8e4 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: @@ -8,18 +10,18 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Set up Python 3.10 + with: + fetch-depth: 0 + - 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 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@v0 + with: + token: ${{ secrets.PREVENT_TOKEN }} diff --git a/app/test_calculator.py b/app/test_calculator.py index f564193..bbd306b 100644 --- a/app/test_calculator.py +++ b/app/test_calculator.py @@ -1,6 +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() * 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 @@ -8,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 @@ -16,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 @@ -23,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