Run integration tests in GitHub Actions
ADD
.github/workflows/integration.yml
+name: Downstream
+
+on:
+ pull_request:
+ paths:
+ - "src/urllib3/_version.py"
+
+jobs:
+ integration:
+ strategy:
+ fail-fast: false
+ matrix:
+ downstream: [botocore, requests]
+ runs-on: ubuntu-18.04
+
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v2
+
+ - name: Set Up Python - ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.9
+
+ - name: Install Dependencies
+ run: python -m pip install --upgrade nox
+ - name: Run downstream tests
+ run: nox -s downstream_${{ matrix.downstream }}

DELETE
ci/downstream/botocore.sh
-#!/bin/bash
-
-set -exo pipefail
-
-case "${1}" in
- install)
- git clone --depth 1 https://github.com/boto/botocore
- cd botocore
- git rev-parse HEAD
- python scripts/ci/install
- ;;
- run)
- cd botocore
- python scripts/ci/run-tests
- ;;
- *)
- exit 1
- ;;
-esac

DELETE
ci/downstream/requests-requirements.txt
-pytest-mock
-pysocks
-httpbin
-
-# psf/requests#5049
-pytest<4.1
-
-# psf/requests#5004
-pytest-httpbin==0.3.0

DELETE
ci/downstream/requests.sh
-#!/bin/bash
-
-set -exo pipefail
-
-case "${1}" in
- install)
- git clone --depth 1 https://github.com/psf/requests
- cd requests
- git rev-parse HEAD
- python -m pip install -r ${TRAVIS_BUILD_DIR}/ci/downstream/requests-requirements.txt
- python -m pip install .
- ;;
- run)
- cd requests
- pytest tests/
- ;;
- *)
- exit 1
- ;;
-esac

ADD
ci/requests.patch
+diff --git a/tests/test_requests.py b/tests/test_requests.py
+index 8f3914ee..aa47f2eb 100644
+--- a/tests/test_requests.py
++++ b/tests/test_requests.py
+@@ -851,6 +851,7 @@ class TestRequests:
+ headers={str('Content-Type'): 'application/octet-stream'},
+ data='\xff') # compat.str is unicode.
+
++ @pytest.mark.skip(reason="fails upstream")
+ def test_pyopenssl_redirect(self, httpbin_secure, httpbin_ca_bundle):
+ requests.get(httpbin_secure('status', '301'), verify=httpbin_ca_bundle)
+

DELETE
ci/run.sh
-#!/bin/bash
-
-set -exo pipefail
-
-if [ -n "${NOX_SESSION}" ]; then
- nox -s "${NOX_SESSION}" --error-on-missing-interpreters
-else
- downstream_script="${TRAVIS_BUILD_DIR}/ci/downstream/${DOWNSTREAM}.sh"
- if [ ! -x "$downstream_script" ]; then
- exit 1
- fi
- $downstream_script install
- python -m pip install .
- $downstream_script run
-fi

MODIFY
noxfile.py
noxfile.py
@@ -78,6 +78,50 @@ def test_brotlipy(session):
tests_impl(session, extras="socks,secure")
+def git_clone(session, git_url):
+ session.run("git", "clone", "--depth", "1", git_url, external=True)
+
+
+@nox.session()
+def downstream_botocore(session):
+ root = os.getcwd()
+ tmp_dir = session.create_tmp()
+
+ session.cd(tmp_dir)
+ git_clone(session, "https://github.com/boto/botocore")
+ session.chdir("botocore")
+ session.run("git", "rev-parse", "HEAD", external=True)
+ session.run("python", "scripts/ci/install")
+
+ session.cd(root)
+ session.install(".", silent=False)
+ session.cd(f"{tmp_dir}/botocore")
+
+ session.run("python", "-c", "import urllib3; print(urllib3.__version__)")
+ session.run("python", "scripts/ci/run-tests")
+
+
+@nox.session()
+def downstream_requests(session):
+ root = os.getcwd()
+ tmp_dir = session.create_tmp()
+
+ session.cd(tmp_dir)
+ git_clone(session, "https://github.com/psf/requests")
+ session.chdir("requests")
+ session.run("git", "apply", f"{root}/ci/requests.patch", external=True)
+ session.run("git", "rev-parse", "HEAD", external=True)
+ session.install(".[socks]", silent=False)
+ session.install("-r", "requirements-dev.txt", silent=False)
+
+ session.cd(root)
+ session.install(".", silent=False)
+ session.cd(f"{tmp_dir}/requests")
+
+ session.run("python", "-c", "import urllib3; print(urllib3.__version__)")
+ session.run("pytest", "tests")
+
+
@nox.session()
def format(session):
"""Run code formatters."""

Run integration tests in GitHub Actions