From fc662cfd6a34c99b7256816dcb91fb4d62fb278f Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 19:59:03 +0000 Subject: [PATCH 01/18] Run non user integration tests --- .github/workflows/pythonapp.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 48c27021..e3b10c17 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -28,3 +28,6 @@ jobs: - name: Run unit tests run: | python -m unittest discover -v tests/unit + - name: Run non user endpoints integration tests + run: | + python -m unittest discover -v tests/integration/non_user From a03815a2779c1176227c28f352dc963fc15cbabc Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 20:03:47 +0000 Subject: [PATCH 02/18] Split into folders --- .github/workflows/pythonapp.yml | 2 +- tests/integration/app_credentials/__init__.py | 0 .../{ => app_credentials}/test_non_user_endpoints.py | 0 tests/integration/user_auth/__init__.py | 0 tests/integration/{ => user_auth}/test_user_endpoints.py | 0 5 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 tests/integration/app_credentials/__init__.py rename tests/integration/{ => app_credentials}/test_non_user_endpoints.py (100%) create mode 100644 tests/integration/user_auth/__init__.py rename tests/integration/{ => user_auth}/test_user_endpoints.py (100%) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index e3b10c17..5289307e 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -30,4 +30,4 @@ jobs: python -m unittest discover -v tests/unit - name: Run non user endpoints integration tests run: | - python -m unittest discover -v tests/integration/non_user + python -m unittest discover -v tests/integration/app_credentials diff --git a/tests/integration/app_credentials/__init__.py b/tests/integration/app_credentials/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/test_non_user_endpoints.py b/tests/integration/app_credentials/test_non_user_endpoints.py similarity index 100% rename from tests/integration/test_non_user_endpoints.py rename to tests/integration/app_credentials/test_non_user_endpoints.py diff --git a/tests/integration/user_auth/__init__.py b/tests/integration/user_auth/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/test_user_endpoints.py b/tests/integration/user_auth/test_user_endpoints.py similarity index 100% rename from tests/integration/test_user_endpoints.py rename to tests/integration/user_auth/test_user_endpoints.py From be875999ed3766710b7ef0f3ba8cfc92c425fd68 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 20:08:23 +0000 Subject: [PATCH 03/18] Add envs via secrets --- .github/workflows/pythonapp.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 5289307e..0da0eeb8 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -9,6 +9,9 @@ jobs: strategy: matrix: python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"] + env: + SPOTIPY_CLIENT_ID: ${{ secrets.SPOTIPY_CLIENT_ID }} + SPOTIPY_CLIENT_SECRET: ${{ secrets.SPOTIPY_CLIENT_SECRET }} steps: - uses: actions/checkout@v2 From f5cf5c26044eb005b386216aafe932ba9841cc68 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 20:20:58 +0000 Subject: [PATCH 04/18] Fix artist_albums() test --- .../app_credentials/test_non_user_endpoints.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/integration/app_credentials/test_non_user_endpoints.py b/tests/integration/app_credentials/test_non_user_endpoints.py index 5628a820..cb7dc0e1 100644 --- a/tests/integration/app_credentials/test_non_user_endpoints.py +++ b/tests/integration/app_credentials/test_non_user_endpoints.py @@ -224,12 +224,13 @@ def test_artist_albums(self): self.assertTrue('items' in results) self.assertTrue(len(results['items']) > 0) - found = False - for album in results['items']: - if album['name'] == 'Hurley': - found = True + def find_album(): + for album in results['items']: + if album['name'] == 'Death to False Metal': + return True + return False - self.assertTrue(found) + self.assertTrue(find_album()) def test_search_timeout(self): client_credentials_manager = SpotifyClientCredentials() From 67c37692a1d54e491195af591c85047c6d86c894 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 20:28:02 +0000 Subject: [PATCH 05/18] Disable flaky test --- .github/workflows/pythonapp.yml | 2 +- .../{app_credentials => non_user_endpoints}/__init__.py | 0 .../test_non_user_endpoints.py => non_user_endpoints/test.py} | 1 + tests/integration/{user_auth => user_endpoints}/__init__.py | 0 .../test_user_endpoints.py => user_endpoints/test.py} | 0 5 files changed, 2 insertions(+), 1 deletion(-) rename tests/integration/{app_credentials => non_user_endpoints}/__init__.py (100%) rename tests/integration/{app_credentials/test_non_user_endpoints.py => non_user_endpoints/test.py} (99%) rename tests/integration/{user_auth => user_endpoints}/__init__.py (100%) rename tests/integration/{user_auth/test_user_endpoints.py => user_endpoints/test.py} (100%) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 0da0eeb8..5eeff15b 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -33,4 +33,4 @@ jobs: python -m unittest discover -v tests/unit - name: Run non user endpoints integration tests run: | - python -m unittest discover -v tests/integration/app_credentials + python -m unittest discover -v tests/integration/non_user_endpoints diff --git a/tests/integration/app_credentials/__init__.py b/tests/integration/non_user_endpoints/__init__.py similarity index 100% rename from tests/integration/app_credentials/__init__.py rename to tests/integration/non_user_endpoints/__init__.py diff --git a/tests/integration/app_credentials/test_non_user_endpoints.py b/tests/integration/non_user_endpoints/test.py similarity index 99% rename from tests/integration/app_credentials/test_non_user_endpoints.py rename to tests/integration/non_user_endpoints/test.py index cb7dc0e1..1222c0b5 100644 --- a/tests/integration/app_credentials/test_non_user_endpoints.py +++ b/tests/integration/non_user_endpoints/test.py @@ -241,6 +241,7 @@ def test_search_timeout(self): self.assertRaises((requests.exceptions.Timeout, requests.exceptions.ConnectionError), lambda: sp.search(q='my*', type='track')) + @unittest.skip("flaky test, need a better method to test retries") def test_max_retries_reached_get(self): spotify_no_retry = Spotify( client_credentials_manager=SpotifyClientCredentials(), diff --git a/tests/integration/user_auth/__init__.py b/tests/integration/user_endpoints/__init__.py similarity index 100% rename from tests/integration/user_auth/__init__.py rename to tests/integration/user_endpoints/__init__.py diff --git a/tests/integration/user_auth/test_user_endpoints.py b/tests/integration/user_endpoints/test.py similarity index 100% rename from tests/integration/user_auth/test_user_endpoints.py rename to tests/integration/user_endpoints/test.py From f8f79a320a0f3bd0b1f60c3208b647922a1c971b Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 20:32:10 +0000 Subject: [PATCH 06/18] cl --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 557325c2..88beb98a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased -// Add your changes here and then delete this line +### Added + +* Integration tests via GHA (non-user endpoints) ## [2.21.0] - 2022-09-26 From a3b52483b9ec44357ab47f5a553296de110f6827 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 19:59:03 +0000 Subject: [PATCH 07/18] Run non user integration tests --- .github/workflows/pythonapp.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index d792c631..a56f11ba 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -30,3 +30,6 @@ jobs: - name: Run unit tests run: | python -m unittest discover -v tests/unit + - name: Run non user endpoints integration tests + run: | + python -m unittest discover -v tests/integration/non_user From 118eb8c277e70826aa92c06eebcf291e2850f5f9 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 20:03:47 +0000 Subject: [PATCH 08/18] Split into folders --- .github/workflows/pythonapp.yml | 2 +- tests/integration/app_credentials/__init__.py | 0 .../{ => app_credentials}/test_non_user_endpoints.py | 0 tests/integration/user_auth/__init__.py | 0 tests/integration/{ => user_auth}/test_user_endpoints.py | 0 5 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 tests/integration/app_credentials/__init__.py rename tests/integration/{ => app_credentials}/test_non_user_endpoints.py (100%) create mode 100644 tests/integration/user_auth/__init__.py rename tests/integration/{ => user_auth}/test_user_endpoints.py (100%) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index a56f11ba..1855b0d3 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -32,4 +32,4 @@ jobs: python -m unittest discover -v tests/unit - name: Run non user endpoints integration tests run: | - python -m unittest discover -v tests/integration/non_user + python -m unittest discover -v tests/integration/app_credentials diff --git a/tests/integration/app_credentials/__init__.py b/tests/integration/app_credentials/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/test_non_user_endpoints.py b/tests/integration/app_credentials/test_non_user_endpoints.py similarity index 100% rename from tests/integration/test_non_user_endpoints.py rename to tests/integration/app_credentials/test_non_user_endpoints.py diff --git a/tests/integration/user_auth/__init__.py b/tests/integration/user_auth/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/test_user_endpoints.py b/tests/integration/user_auth/test_user_endpoints.py similarity index 100% rename from tests/integration/test_user_endpoints.py rename to tests/integration/user_auth/test_user_endpoints.py From 35aacd38c4d9c2e0366a1b7d680a04283b7dcf40 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 20:20:58 +0000 Subject: [PATCH 09/18] Fix artist_albums() test --- .../app_credentials/test_non_user_endpoints.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/integration/app_credentials/test_non_user_endpoints.py b/tests/integration/app_credentials/test_non_user_endpoints.py index 5628a820..cb7dc0e1 100644 --- a/tests/integration/app_credentials/test_non_user_endpoints.py +++ b/tests/integration/app_credentials/test_non_user_endpoints.py @@ -224,12 +224,13 @@ def test_artist_albums(self): self.assertTrue('items' in results) self.assertTrue(len(results['items']) > 0) - found = False - for album in results['items']: - if album['name'] == 'Hurley': - found = True + def find_album(): + for album in results['items']: + if album['name'] == 'Death to False Metal': + return True + return False - self.assertTrue(found) + self.assertTrue(find_album()) def test_search_timeout(self): client_credentials_manager = SpotifyClientCredentials() From b8550c98135e9ad468f7a73b492020ca6ce77851 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 20:28:02 +0000 Subject: [PATCH 10/18] Disable flaky test --- .github/workflows/pythonapp.yml | 2 +- .../{app_credentials => non_user_endpoints}/__init__.py | 0 .../test_non_user_endpoints.py => non_user_endpoints/test.py} | 1 + tests/integration/{user_auth => user_endpoints}/__init__.py | 0 .../test_user_endpoints.py => user_endpoints/test.py} | 0 5 files changed, 2 insertions(+), 1 deletion(-) rename tests/integration/{app_credentials => non_user_endpoints}/__init__.py (100%) rename tests/integration/{app_credentials/test_non_user_endpoints.py => non_user_endpoints/test.py} (99%) rename tests/integration/{user_auth => user_endpoints}/__init__.py (100%) rename tests/integration/{user_auth/test_user_endpoints.py => user_endpoints/test.py} (100%) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 1855b0d3..1ded97e8 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -32,4 +32,4 @@ jobs: python -m unittest discover -v tests/unit - name: Run non user endpoints integration tests run: | - python -m unittest discover -v tests/integration/app_credentials + python -m unittest discover -v tests/integration/non_user_endpoints diff --git a/tests/integration/app_credentials/__init__.py b/tests/integration/non_user_endpoints/__init__.py similarity index 100% rename from tests/integration/app_credentials/__init__.py rename to tests/integration/non_user_endpoints/__init__.py diff --git a/tests/integration/app_credentials/test_non_user_endpoints.py b/tests/integration/non_user_endpoints/test.py similarity index 99% rename from tests/integration/app_credentials/test_non_user_endpoints.py rename to tests/integration/non_user_endpoints/test.py index cb7dc0e1..1222c0b5 100644 --- a/tests/integration/app_credentials/test_non_user_endpoints.py +++ b/tests/integration/non_user_endpoints/test.py @@ -241,6 +241,7 @@ def test_search_timeout(self): self.assertRaises((requests.exceptions.Timeout, requests.exceptions.ConnectionError), lambda: sp.search(q='my*', type='track')) + @unittest.skip("flaky test, need a better method to test retries") def test_max_retries_reached_get(self): spotify_no_retry = Spotify( client_credentials_manager=SpotifyClientCredentials(), diff --git a/tests/integration/user_auth/__init__.py b/tests/integration/user_endpoints/__init__.py similarity index 100% rename from tests/integration/user_auth/__init__.py rename to tests/integration/user_endpoints/__init__.py diff --git a/tests/integration/user_auth/test_user_endpoints.py b/tests/integration/user_endpoints/test.py similarity index 100% rename from tests/integration/user_auth/test_user_endpoints.py rename to tests/integration/user_endpoints/test.py From be6d0dad39f4965e6772ceda82a45c2acccbf49f Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 20:53:49 +0000 Subject: [PATCH 11/18] cl --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2d808df..88beb98a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -* Make test app credentials available in GHA as secrets +* Integration tests via GHA (non-user endpoints) ## [2.21.0] - 2022-09-26 From 176f784fb96522e1b70b62a966e93f0d99e6393e Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 21:08:09 +0000 Subject: [PATCH 12/18] pull_request_target --- .github/workflows/pythonapp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 1ded97e8..463682da 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -1,6 +1,6 @@ name: Tests -on: [push, pull_request] +on: [push, pull_request_target] jobs: build: From 4422f5ec5a6feb9642e4d99f0a014ef9ce278809 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 21:16:11 +0000 Subject: [PATCH 13/18] Separate integration test workflow --- .github/workflows/integration_tests.yml | 25 +++++++++++++++++++++++++ .github/workflows/pythonapp.yml | 3 --- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/integration_tests.yml diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml new file mode 100644 index 00000000..a808c614 --- /dev/null +++ b/.github/workflows/integration_tests.yml @@ -0,0 +1,25 @@ +name: Integration tests + +on: [push, pull_request_target] + +jobs: + build: + + runs-on: ubuntu-latest + env: + SPOTIPY_CLIENT_ID: ${{ secrets.SPOTIPY_CLIENT_ID }} + SPOTIPY_CLIENT_SECRET: ${{ secrets.SPOTIPY_CLIENT_SECRET }} + PYTHON_VERSION: "3.10" + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install .[test] + - name: Run non user endpoints integration tests + run: | + python -m unittest discover -v tests/integration/non_user_endpoints diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index d792c631..48878390 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -9,9 +9,6 @@ jobs: strategy: matrix: python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"] - env: - SPOTIPY_CLIENT_ID: ${{ secrets.SPOTIPY_CLIENT_ID }} - SPOTIPY_CLIENT_SECRET: ${{ secrets.SPOTIPY_CLIENT_SECRET }} steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From 7d59bd983bd27a1ae4c75449977c0195487f5901 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 21:39:59 +0000 Subject: [PATCH 14/18] fix --- .github/workflows/pythonapp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 041ed7e0..8d6c9c08 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -1,6 +1,6 @@ name: Tests -on: [push, pull_request_target] +on: [push, pull_request] jobs: build: From 8a9a0d7f0d5b951fc7b7a957fb6df60698535782 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 21:47:26 +0000 Subject: [PATCH 15/18] fix --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index a808c614..838d28a0 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python ${{ env.PYTHON_VERSION }} uses: actions/setup-python@v1 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ env.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip From 6ac922d76dd6e55d9cb0701403870842d99880bc Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 21:48:25 +0000 Subject: [PATCH 16/18] fix --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 838d28a0..c5450c21 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python ${{ env.PYTHON_VERSION }} uses: actions/setup-python@v1 with: - python-version: ${{ env.python-version }} + python-version: ${{ env.PYTHON_VERSION }} - name: Install dependencies run: | python -m pip install --upgrade pip From 728bdfd108df747050c6ddeef0466462dd742730 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 21:50:24 +0000 Subject: [PATCH 17/18] fix --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index c5450c21..d12a73dd 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -12,7 +12,7 @@ jobs: PYTHON_VERSION: "3.10" steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ env.PYTHON_VERSION }} + - name: Set up Python test uses: actions/setup-python@v1 with: python-version: ${{ env.PYTHON_VERSION }} From 7162e29f70324b94853088092b6b3662f2c66883 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Tue, 1 Nov 2022 21:52:29 +0000 Subject: [PATCH 18/18] fix --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index d12a73dd..c5450c21 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -12,7 +12,7 @@ jobs: PYTHON_VERSION: "3.10" steps: - uses: actions/checkout@v2 - - name: Set up Python test + - name: Set up Python ${{ env.PYTHON_VERSION }} uses: actions/setup-python@v1 with: python-version: ${{ env.PYTHON_VERSION }}