From 9072b98a18cd7ae3b553ddee85ebe683e7d9e7c4 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 19 Oct 2021 13:08:53 +0300 Subject: [PATCH 1/4] Rename master to main, use 3.10 final, add workflow_dispatch --- .github/workflows/deploy.yml | 15 ++++++++------- .github/workflows/labels.yml | 7 +++++-- .github/workflows/lint.yml | 2 +- .github/workflows/release-drafter.yml | 7 ++++--- .github/workflows/test.yml | 12 ++++++------ README.md | 8 ++++---- RELEASING.md | 14 +++++++------- tox.ini | 13 +++++++------ 8 files changed, 42 insertions(+), 36 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1f65cb8..9b4297e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,14 +3,15 @@ name: Deploy on: push: branches: - - master + - main release: types: - published + workflow_dispatch: jobs: - build: - if: github.repository == 'pylast/pylast' + deploy: + if: github.repository_owner == 'pylast' runs-on: ubuntu-20.04 steps: @@ -29,18 +30,18 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: "3.10" - name: Install dependencies run: | python -m pip install -U pip - python -m pip install -U setuptools twine wheel + python -m pip install -U build twine wheel - name: Build package run: | python setup.py --version - python setup.py sdist --format=gztar bdist_wheel - twine check dist/* + python -m build + twine check --strict dist/* - name: Publish package to PyPI if: github.event.action == 'published' diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index e84c13e..c22c0d0 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -1,12 +1,15 @@ name: Sync labels + on: push: branches: - - master + - main paths: - .github/labels.yml + workflow_dispatch: + jobs: - build: + sync: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f092b74..bfe362b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,6 @@ name: Lint -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] jobs: lint: diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index f1d92f9..a806a43 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -4,14 +4,15 @@ on: push: # branches to consider in the event; optional, defaults to all branches: - - master + - main + workflow_dispatch: jobs: update_release_draft: - if: github.repository == 'pylast/pylast' + if: github.repository_owner == 'hugovk' runs-on: ubuntu-latest steps: - # Drafts your next release notes as pull requests are merged into "master" + # Drafts your next release notes as pull requests are merged into "main" - uses: release-drafter/release-drafter@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e8b978a..7bda29d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,17 +1,17 @@ name: Test -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] env: FORCE_COLOR: 1 jobs: - build: + test: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10-dev", "pypy3"] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "pypy3"] os: [ubuntu-20.04] include: # Include new variables for Codecov @@ -35,10 +35,10 @@ jobs: with: path: ${{ steps.pip-cache.outputs.dir }} key: - ${{ matrix.os }}-${{ matrix.python-version }}-v3-${{ + ${{ matrix.os }}-${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }} restore-keys: | - ${{ matrix.os }}-${{ matrix.python-version }}-v3- + ${{ matrix.os }}-${{ matrix.python-version }}-v1- - name: Install dependencies run: | @@ -56,7 +56,7 @@ jobs: PYLAST_USERNAME: ${{ secrets.PYLAST_USERNAME }} - name: Upload coverage - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v2 with: flags: ${{ matrix.codecov-flag }} name: ${{ matrix.os }} Python ${{ matrix.python-version }} diff --git a/README.md b/README.md index b297c74..3c62148 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ pyLast [![Supported Python versions](https://img.shields.io/pypi/pyversions/pylast.svg)](https://pypi.org/project/pylast/) [![PyPI downloads](https://img.shields.io/pypi/dm/pylast.svg)](https://pypistats.org/packages/pylast) [![Test](https://github.com/pylast/pylast/workflows/Test/badge.svg)](https://github.com/pylast/pylast/actions) -[![Coverage (Codecov)](https://codecov.io/gh/pylast/pylast/branch/master/graph/badge.svg)](https://codecov.io/gh/pylast/pylast) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![Coverage (Codecov)](https://codecov.io/gh/pylast/pylast/branch/main/graph/badge.svg)](https://codecov.io/gh/pylast/pylast) +[![Code style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![DOI](https://zenodo.org/badge/7803088.svg)](https://zenodo.org/badge/latestdoi/7803088) A Python interface to [Last.fm](https://www.last.fm/) and other API-compatible websites @@ -98,12 +98,12 @@ track.add_tags(("awesome", "favorite")) More examples in hugovk/lastfm-tools and -[tests/](https://github.com/pylast/pylast/tree/master/tests). +[tests/](https://github.com/pylast/pylast/tree/main/tests). Testing ------- -The [tests/](https://github.com/pylast/pylast/tree/master/tests) directory contains +The [tests/](https://github.com/pylast/pylast/tree/main/tests) directory contains integration and unit tests with Last.fm, and plenty of code examples. For integration tests you need a test account at Last.fm that will become cluttered with diff --git a/RELEASING.md b/RELEASING.md index 8181754..452bca6 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,21 +1,21 @@ # Release Checklist -* [ ] Get master to the appropriate code release state. +- [ ] Get `main` to the appropriate code release state. [GitHub Actions](https://github.com/pylast/pylast/actions) should be running cleanly for - all merges to master. + all merges to `main`. [![Test](https://github.com/pylast/pylast/workflows/Test/badge.svg)](https://github.com/pylast/pylast/actions) -* [ ] Edit release draft, adjust text if needed: +- [ ] Edit release draft, adjust text if needed: https://github.com/pylast/pylast/releases -* [ ] Check next tag is correct, amend if needed +- [ ] Check next tag is correct, amend if needed -* [ ] Publish release +- [ ] Publish release -* [ ] Check the tagged [GitHub Actions build](https://github.com/pylast/pylast/actions?query=workflow%3ADeploy) +- [ ] Check the tagged [GitHub Actions build](https://github.com/pylast/pylast/actions?query=workflow%3ADeploy) has deployed to [PyPI](https://pypi.org/project/pylast/#history) -* [ ] Check installation: +- [ ] Check installation: ```bash pip3 uninstall -y pylast && pip3 install -U pylast && python3 -c "import pylast; print(pylast.__version__)" diff --git a/tox.ini b/tox.ini index c19e202..0cdfe53 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,6 @@ [tox] envlist = + lint py{py3, 310, 39, 38, 37, 36} [testenv] @@ -13,12 +14,6 @@ extras = commands = pytest -v -s -W all --cov pylast --cov tests --cov-report term-missing --random-order {posargs} -[testenv:venv] -deps = - ipdb -commands = - {posargs} - [testenv:lint] passenv = PRE_COMMIT_COLOR @@ -27,3 +22,9 @@ deps = pre-commit commands = pre-commit run --all-files --show-diff-on-failure + +[testenv:venv] +deps = + ipdb +commands = + {posargs} From e5b9f2aa1965572b0723f1d95b8ceef6be03f60b Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 19 Oct 2021 13:11:21 +0300 Subject: [PATCH 2/4] Add colour to tests --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 0cdfe53..c04ab95 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ envlist = [testenv] passenv = + FORCE_COLOR PYLAST_API_KEY PYLAST_API_SECRET PYLAST_PASSWORD_HASH From c41f831d82c02166e887e32a63a5e19330b50ed5 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 19 Oct 2021 13:17:20 +0300 Subject: [PATCH 3/4] Fix test --- tests/test_artist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_artist.py b/tests/test_artist.py index 4e8d694..a911882 100755 --- a/tests/test_artist.py +++ b/tests/test_artist.py @@ -22,7 +22,7 @@ class TestPyLastArtist(TestPyLastWithLastFm): def test_artist_is_hashable(self): # Arrange - test_artist = self.network.get_artist("Test Artist") + test_artist = self.network.get_artist("Radiohead") artist = test_artist.get_similar(limit=2)[0].item assert isinstance(artist, pylast.Artist) From 05b4ad8c629a60a13cf183deca0acadb98004ac3 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 19 Oct 2021 13:57:47 +0300 Subject: [PATCH 4/4] Disable the flaky write tests --- tests/test_pylast.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index 26f799c..c7cd7b3 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -3,7 +3,6 @@ Integration (not unit) tests for pylast.py """ import os -import sys import time import pytest @@ -11,7 +10,7 @@ from flaky import flaky import pylast -WRITE_TEST = sys.version_info[:2] == (3, 9) +WRITE_TEST = False def load_secrets(): # pragma: no cover