update workflows #413
This file contains 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: | |
branches: | |
- main | |
paths: | |
- ytmusicapi/** | |
- tests/** | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- name: Setup Python | |
uses: actions/setup-python@master | |
with: | |
python-version: 3.x | |
- name: Setup PDM | |
uses: pdm-project/setup-pdm@v3 | |
- name: create-json | |
uses: jsdaniell/[email protected] | |
with: | |
name: "oauth.json" | |
dir: "tests/" | |
json: ${{ secrets.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 -o tests/test.mp3 https://www.kozco.com/tech/piano2-CoolEdit.mp3 | |
cat <<< "$HEADERS_AUTH" > tests/browser.json | |
cat <<< "$TEST_CFG" > tests/test.cfg | |
(echo "===== tests attempt: 1 ====" && pdm run pytest) || \ | |
(echo "===== tests attempt: 2 ====" && pdm run pytest) | |
pdm run pytest | |
pdm run coverage xml | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
file: coverage.xml | |
flags: unittests | |
fail_ci_if_error: true |