diff --git a/.github/workflows/cpu_tests.yaml b/.github/workflows/cpu_tests.yaml index b11b49c..14fc8db 100644 --- a/.github/workflows/cpu_tests.yaml +++ b/.github/workflows/cpu_tests.yaml @@ -7,7 +7,7 @@ on: jobs: do-the-job: - name: Do the job on the runner + name: Do the job on the cpu runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -17,8 +17,6 @@ jobs: - {os: ubuntu-latest, architecture: x64, python-version: '3.11'} - {os: macos-latest, architecture: arm64, python-version: '3.10'} - {os: macos-latest, architecture: arm64, python-version: '3.11'} - env: - RUN_GPU_TESTS: false steps: - name: Hello World run: echo 'Hello World!' diff --git a/.github/workflows/gpu_tests.yaml b/.github/workflows/gpu_tests.yaml index 2e68e35..186f29a 100644 --- a/.github/workflows/gpu_tests.yaml +++ b/.github/workflows/gpu_tests.yaml @@ -36,8 +36,6 @@ jobs: name: Run GPU Tests on the runner needs: start-runner # required to start the main job when the runner is ready runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner - env: - RUN_GPU_TESTS: true steps: - name: Hello World run: echo 'Hello World!' diff --git a/test_math_operations.py b/test_math_operations.py index c37129f..07eaa18 100644 --- a/test_math_operations.py +++ b/test_math_operations.py @@ -1,5 +1,5 @@ import pytest -import os +import torch from math_operations import basic_math_operation def test_add(): @@ -12,19 +12,21 @@ def test_subtract(): assert basic_math_operation(2, 5, 'subtract') == -3 assert basic_math_operation(0, 0, 'subtract') == 0 -if os.getenv("RUN_GPU_TESTS") == "true": - def test_multiply(): - assert basic_math_operation(2, 3, 'multiply') == 6 - assert basic_math_operation(-2, 3, 'multiply') == -6 - assert basic_math_operation(0, 5, 'multiply') == 0 +@pytest.mark.skipif(not torch.cuda.is_available(), reason="GPU is not available") +def test_multiply(): + assert basic_math_operation(2, 3, 'multiply') == 6 + assert basic_math_operation(-2, 3, 'multiply') == -6 + assert basic_math_operation(0, 5, 'multiply') == 0 - def test_divide(): - assert basic_math_operation(6, 3, 'divide') == 2 - assert basic_math_operation(7, 2, 'divide') == 3.5 +@pytest.mark.skipif(not torch.cuda.is_available(), reason="GPU is not available") +def test_divide(): + assert basic_math_operation(6, 3, 'divide') == 2 + assert basic_math_operation(7, 2, 'divide') == 3.5 - with pytest.raises(ValueError): - basic_math_operation(6, 0, 'divide') + with pytest.raises(ValueError): + basic_math_operation(6, 0, 'divide') - def test_invalid_operation(): - with pytest.raises(ValueError): - basic_math_operation(2, 3, 'modulus') +@pytest.mark.skipif(not torch.cuda.is_available(), reason="GPU is not available") +def test_invalid_operation(): + with pytest.raises(ValueError): + basic_math_operation(2, 3, 'modulus')