From 75596daf316b4a806f18057e2797a15bdf83cf6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20B=C3=A9langer?= Date: Wed, 8 May 2024 15:23:23 -0700 Subject: [PATCH] Restore CI, including Python 2.7 (#492) * Restores CI to a green state to aid in landing other changes. * Python 2.7 is still covered, but only on Ubuntu and excluding PyPy. Changes are made to `requirements.txt` et al to ensure this works. * Runner versions are pinned to avoid automatic breakage, required statuses are updated to match. * Codecov action is updated, token is now explicitly passed. * Fixes an integration test breaking due to backend changes, to be investigated separately. --- .github/workflows/ci.yml | 62 ++++++++++++++++++++----------- .github/workflows/coverage.yml | 12 +++--- .github/workflows/pypiupload.yml | 15 ++++++-- .github/workflows/spec_update.yml | 2 +- requirements.txt | 7 ++-- setup.py | 7 ++-- test/integration/test_dropbox.py | 9 +++-- test/requirements.txt | 2 +- 8 files changed, 74 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ecf98c9..c0d85f3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,18 +10,27 @@ jobs: # https://github.com/actions/python-versions/blob/main/versions-manifest.json strategy: matrix: - os: [macos-latest, windows-latest] - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy-2.7, pypy-3.7] + os: [macos-13, windows-latest] + python-version: [3.5, 3.6, 3.7, 3.8, pypy-3.7] exclude: - os: windows-latest python-version: 3.6 include: - - os: ubuntu-latest + - os: ubuntu-20.04 python-version: 3.7 + - os: ubuntu-20.04 + python-version: 2.7 steps: - uses: actions/checkout@v2 - - name: Setup Python environment - uses: actions/setup-python@v2.2.2 + - if: ${{ matrix.python-version == '2.7' }} + name: Setup Python environment (2.7) + run: | + sudo apt-get install python-is-python2 + curl -sSL https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py + python get-pip.py + - if: ${{ matrix.python-version != '2.7' }} + name: Setup Python environment + uses: actions/setup-python@v3.1.4 with: python-version: ${{ matrix.python-version }} - name: Install Requirements @@ -30,19 +39,19 @@ jobs: pip install flake8 pytest pip install -r requirements.txt pip install -r test/requirements.txt - python setup.py install + python setup.py install --user - name: Run Linter run: | flake8 setup.py dropbox example test - name: Run Unit Tests run: | - pytest test/unit/test_dropbox_unit.py + pytest -v test/unit/test_dropbox_unit.py Docs: - runs-on: macos-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - name: Setup Python environment - uses: actions/setup-python@v2.2.2 + uses: actions/setup-python@v3.1.4 with: python-version: '3.7' - name: Install Requirements @@ -64,18 +73,27 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, windows-latest] - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy-2.7, pypy-3.7] - exclude: - - os: windows-latest - python-version: 3.6 - include: - - os: ubuntu-latest - python-version: 3.7 - steps: + os: [macos-13, windows-latest] + python-version: [3.5, 3.6, 3.7, 3.8, pypy-3.7] + exclude: + - os: windows-latest + python-version: 3.6 + include: + - os: ubuntu-20.04 + python-version: 3.7 + - os: ubuntu-20.04 + python-version: 2.7 + steps: - uses: actions/checkout@v2.3.4 - - name: Setup Python environment - uses: actions/setup-python@v2.2.2 + - if: ${{ matrix.python-version == '2.7' }} + name: Setup Python environment (2.7) + run: | + sudo apt-get install python-is-python2 + curl -sSL https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py + python get-pip.py + - if: ${{ matrix.python-version != '2.7' }} + name: Setup Python environment + uses: actions/setup-python@v3.1.4 with: python-version: ${{ matrix.python-version }} - name: Install Requirements @@ -84,7 +102,7 @@ jobs: pip install flake8 pytest pip install -r requirements.txt pip install -r test/requirements.txt - python setup.py install + python setup.py install --user - name: Run Integration Tests env: LEGACY_USER_DROPBOX_TOKEN: ${{ secrets.LEGACY_USER_DROPBOX_TOKEN }} @@ -101,4 +119,4 @@ jobs: SCOPED_TEAM_REFRESH_TOKEN: ${{ secrets.SCOPED_TEAM_REFRESH_TOKEN }} DROPBOX_SHARED_LINK: ${{ secrets.DROPBOX_SHARED_LINK }} run: | - pytest test/integration/test_dropbox.py \ No newline at end of file + pytest -v test/integration/test_dropbox.py diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 87cf19d1..7cab535b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Setup Python environment - uses: actions/setup-python@v2.2.2 + uses: actions/setup-python@v3.1.4 with: python-version: '3.7' - name: Install Requirements @@ -28,8 +28,9 @@ jobs: coverage run --rcfile=.coveragerc -m pytest test/unit/test_dropbox_unit.py coverage xml - name: Publish Coverage - uses: codecov/codecov-action@v1.3.2 + uses: codecov/codecov-action@v3.1.6 with: + token: ${{ secrets.CODECOV_TOKEN }} flags: unit fail_ci_if_error: true IntegrationCoverage: @@ -37,7 +38,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Setup Python environment - uses: actions/setup-python@v2.2.2 + uses: actions/setup-python@v3.1.4 with: python-version: '3.7' - name: Install Requirements @@ -66,7 +67,8 @@ jobs: coverage run --rcfile=.coveragerc -m pytest test/integration/test_dropbox.py coverage xml - name: Publish Coverage - uses: codecov/codecov-action@v1.3.2 + uses: codecov/codecov-action@v3.1.6 with: + token: ${{ secrets.CODECOV_TOKEN }} flags: integration - fail_ci_if_error: true \ No newline at end of file + fail_ci_if_error: true diff --git a/.github/workflows/pypiupload.yml b/.github/workflows/pypiupload.yml index 3c7f1675..874a32b4 100644 --- a/.github/workflows/pypiupload.yml +++ b/.github/workflows/pypiupload.yml @@ -9,15 +9,22 @@ on: jobs: deploy: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: python-version: [2.7, 3.x] steps: - - uses: actions/checkout@v2 - - name: Setup Python - uses: actions/setup-python@v2.2.2 + - uses: actions/checkout@v2.3.4 + - if: ${{ matrix.python-version == '2.7' }} + name: Setup Python environment (2.7) + run: | + sudo apt-get install python-is-python2 + curl -sSL https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py + python get-pip.py + - if: ${{ matrix.python-version != '2.7' }} + name: Setup Python environment + uses: actions/setup-python@v3.1.4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/spec_update.yml b/.github/workflows/spec_update.yml index f4a60c7c..5010e1a8 100644 --- a/.github/workflows/spec_update.yml +++ b/.github/workflows/spec_update.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Setup Python environment - uses: actions/setup-python@v2.2.2 + uses: actions/setup-python@v3.1.4 with: python-version: 3.7 - name: Get current time diff --git a/requirements.txt b/requirements.txt index 2c55c04b..2b5b9a8e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,12 @@ # Dependencies required for installation (keep in sync with setup.py) -requests >= 2.16.2 +requests<2.30 +urllib3<2 six >= 1.12.0 -stone >= 2 +stone>=2,<3.3.3 # Other dependencies for development ply pytest -pytest-runner +pytest-runner==5.2.0 sphinx twine wheel diff --git a/setup.py b/setup.py index efbd57de..6e748976 100644 --- a/setup.py +++ b/setup.py @@ -25,15 +25,16 @@ version = eval(line.split('=', 1)[1].strip()) # pylint: disable=eval-used install_reqs = [ - 'requests >= 2.16.2', + 'requests<2.30', + 'urllib3<2', 'six >= 1.12.0', - 'stone >= 2', + 'stone>=2,<3.3.3', ] setup_requires = [ # Pin pytest-runner to 5.2.0, since 5.3.0 uses `find_namespaces` directive, not supported in # Python 2.7 - 'pytest-runner == 5.2.0', + 'pytest-runner==5.2.0', ] # WARNING: This imposes limitations on test/requirements.txt such that the diff --git a/test/integration/test_dropbox.py b/test/integration/test_dropbox.py index 5aeb3232..b950cb90 100644 --- a/test/integration/test_dropbox.py +++ b/test/integration/test_dropbox.py @@ -26,7 +26,7 @@ from dropbox.exceptions import ( ApiError, AuthError, - BadInputError, + # BadInputError, PathRootError, ) from dropbox.files import ( @@ -153,9 +153,12 @@ def test_default_oauth2_urls(self): def test_bad_auth(self): # Test malformed token malformed_token_dbx = Dropbox(MALFORMED_TOKEN) - with pytest.raises(BadInputError,) as cm: + # TODO: backend is no longer returning `BadInputError` + # with pytest.raises(BadInputError,) as cm: + # malformed_token_dbx.files_list_folder('') + # assert 'token is malformed' in cm.value.message + with pytest.raises(AuthError,): malformed_token_dbx.files_list_folder('') - assert 'token is malformed' in cm.value.message # Test reasonable-looking invalid token invalid_token_dbx = Dropbox(INVALID_TOKEN) diff --git a/test/requirements.txt b/test/requirements.txt index c6433e33..9f263bd8 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -2,4 +2,4 @@ pytest mock pytest-mock coverage -stone>=2 +stone>=2,<3.3.3