Repository navigation
fix: adapt tests and parsing to YT server changes #1106
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Code coverage | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - ytmusicapi/** | |
| - tests/** | |
| pull_request_target: | |
| paths: | |
| - ytmusicapi/** | |
| - tests/** | |
| permissions: {} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| # For pull_request_target events, requires maintainer approval via the | |
| # 'coverage' environment before the job runs and secrets are exposed. | |
| # Configure in Settings → Environments → coverage → Required reviewers. | |
| # Enable "Prevent administrators from bypassing configured protection rules" | |
| # to enforce this for admins too. | |
| environment: ${{ github.event_name != 'push' && 'coverage' || '' }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| persist-credentials: false | |
| fetch-depth: 1 | |
| # v7 blocks fork PR checkouts on pull_request_target by default. | |
| # Safe here because the 'coverage' environment gate requires maintainer approval | |
| # before this job runs and secrets are exposed (see environment: field above). | |
| allow-unsafe-pr-checkout: true | |
| - name: Setup Python | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: "3.10" | |
| - name: Setup PDM | |
| uses: pdm-project/setup-pdm@94a823180e06fcde4ad29308721954a521c96ed0 # v4.4 | |
| - name: Write OAuth credentials | |
| env: | |
| OAUTH_JSON: ${{ secrets.OAUTH_JSON }} | |
| run: printf '%s\n' "$OAUTH_JSON" > tests/oauth.json | |
| - name: Install dependencies | |
| run: pdm install | |
| - name: Generate coverage report | |
| env: | |
| HEADERS_AUTH: ${{ secrets.HEADERS_AUTH }} | |
| TEST_CFG: ${{ secrets.TEST_CFG }} | |
| run: | | |
| curl -fsSL -o tests/test.mp3 https://www.kozco.com/tech/piano2-CoolEdit.mp3 | |
| cat <<< "$HEADERS_AUTH" > tests/browser.json | |
| cat <<< "$TEST_CFG" > tests/test.cfg | |
| pdm run pytest --junitxml=test-results.xml | |
| pdm run coverage xml | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 | |
| if: ${{ !cancelled() }} | |
| with: | |
| flags: unittests | |
| fail_ci_if_error: true | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload test results to Codecov | |
| if: ${{ !cancelled() }} | |
| uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1.2.1 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: test-results.xml |