From 3c26c92612de820f022174a4aece9d2025cfcdb5 Mon Sep 17 00:00:00 2001 From: Sepand Haghighi Date: Fri, 24 May 2024 07:30:55 +0330 Subject: [PATCH] CLI error message (#48) * fix : minor edit in play_cli function * fix : codecov section updated * fix : fast-fail disabled * fix : function_test.py updated * fix : error_test.py updated * fix : sys.exit(0) removed from play_cli function * doc : CHANGELOG.md updated * fix : minor bug in tests fixed * fix : minor edit in codecov.yml * fix : codecov.yml bug fixed * fix : macOS version changed from 11 to 13 --- .github/workflows/linux_test.yml | 6 ++++-- .github/workflows/macOS_test.yml | 8 +++++--- .github/workflows/windows_test.yml | 6 ++++-- CHANGELOG.md | 1 + codecov.yml | 2 +- nava/functions.py | 5 +++-- test/error_test.py | 3 +++ test/function_test.py | 1 + 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/linux_test.yml b/.github/workflows/linux_test.yml index 7071aca..dfb74ff 100644 --- a/.github/workflows/linux_test.yml +++ b/.github/workflows/linux_test.yml @@ -13,6 +13,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ubuntu-20.04] python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0, 3.11.0, 3.12.0] @@ -54,9 +55,10 @@ jobs: sudo python -m pydocstyle -v --match-dir=nava if: matrix.python-version == env.TEST_PYTHON_VERSION - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: - fail_ci_if_error: false + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} if: matrix.python-version == env.TEST_PYTHON_VERSION - name: Version check run: | diff --git a/.github/workflows/macOS_test.yml b/.github/workflows/macOS_test.yml index 15e6f84..ffb7021 100644 --- a/.github/workflows/macOS_test.yml +++ b/.github/workflows/macOS_test.yml @@ -13,8 +13,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - os: [macOS-12, macOS-11] + os: [macOS-12, macOS-13] python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0, 3.11.0, 3.12.0] steps: - uses: actions/checkout@v2 @@ -44,7 +45,8 @@ jobs: python -m pydocstyle -v --match-dir=nava if: matrix.python-version == env.TEST_PYTHON_VERSION - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: - fail_ci_if_error: false + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} if: matrix.python-version == env.TEST_PYTHON_VERSION diff --git a/.github/workflows/windows_test.yml b/.github/workflows/windows_test.yml index a12a0ee..4ad911a 100644 --- a/.github/workflows/windows_test.yml +++ b/.github/workflows/windows_test.yml @@ -13,6 +13,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [windows-2022, windows-2019] python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0, 3.11.0, 3.12.0] @@ -59,7 +60,8 @@ jobs: python -m pydocstyle -v --match-dir=nava if: matrix.python-version == env.TEST_PYTHON_VERSION - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: - fail_ci_if_error: false + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} if: matrix.python-version == env.TEST_PYTHON_VERSION diff --git a/CHANGELOG.md b/CHANGELOG.md index a863a98..66a5f78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - `main` function updated - OSs local checklist added to pull request template +- Test system modified - `README.md` modified ## [0.5] - 2024-04-03 ### Changed diff --git a/codecov.yml b/codecov.yml index 3fd943a..7b4274c 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,6 +1,6 @@ codecov: require_ci_to_pass: yes -notify: + notify: after_n_builds: 3 wait_for_ci: yes diff --git a/nava/functions.py b/nava/functions.py index a571e9e..beffc90 100644 --- a/nava/functions.py +++ b/nava/functions.py @@ -292,6 +292,7 @@ def play_cli(sound_path, loop=False): play(sound_path) if not loop: break - except KeyboardInterrupt: + except NavaBaseError as e: + print("Error: {0}".format(e)) + finally: stop_all() - sys.exit(0) diff --git a/test/error_test.py b/test/error_test.py index 3b68bee..ed69740 100644 --- a/test/error_test.py +++ b/test/error_test.py @@ -18,4 +18,7 @@ Traceback (most recent call last): ... nava.errors.NavaBaseError: `loop` can not be set True when `async_mode` is False. +>>> import nava +>>> nava.functions.play_cli("test2.wav") +Error: Given sound file doesn't exist. """ diff --git a/test/function_test.py b/test/function_test.py index 6f50cf5..bc1b747 100644 --- a/test/function_test.py +++ b/test/function_test.py @@ -27,6 +27,7 @@ True >>> nava.params._play_threads_counter == 44 True +>>> nava.functions.play_cli(os.path.join("others", "test.wav")) >>> nava.functions.nava_help() A Python library for playing sound everywhere natively and securely.