diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..6e9cf5706 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,52 @@ +name: CI + +on: + pull_request: + push: + branches: + - master + tags: + schedule: + # Run everyday at 03:53 UTC + - cron: 53 3 * * * + +jobs: + test: + name: ${{ matrix.os }} / ${{ matrix.python-version }} / ${{ matrix.pip-version }} + runs-on: ${{ matrix.os }}-latest + strategy: + matrix: + os: + - Ubuntu + - Windows + - MacOS + python-version: + - 3.8 + - 2.7 + - 3.5 + - 3.6 + - 3.7 + pip-version: + - "latest" + - "20.0" + env: + PY_COLORS: 1 + TOXENV: pip${{ matrix.pip-version }}-coverage + TOX_PARALLEL_NO_SPINNER: 1 + steps: + - uses: actions/checkout@master + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install tox + run: pip install tox + - name: Prepare test environment + run: tox --notest -p auto --parallel-live + - name: Test pip ${{ matrix.pip-version }} + run: tox + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1.0.6 + with: + file: ./coverage.xml + name: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pip-version }} diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index e38ee58d4..c1d391860 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -1,28 +1,73 @@ -name: cron +name: Cron on: schedule: - # Run every day at 00:00 UTC - - cron: 0 0 * * * + # Run every day at 00:00 UTC + - cron: 0 0 * * * jobs: - test: + master: + name: ${{ matrix.os }} / ${{ matrix.python-version }} / ${{ matrix.pip-version }} runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [2.7, 3.5, 3.6, 3.7, 3.8] - env: - - TOXENV: pipmaster - os: [ubuntu-latest, windows-latest] + os: + - Ubuntu + - Windows + - MacOS + python-version: + - 3.8 + - 2.7 + - 3.5 + - 3.6 + - 3.7 + pip-version: + - master + env: + PY_COLORS: 1 + TOXENV: pip${{ matrix.pip-version }} + TOX_PARALLEL_NO_SPINNER: 1 + steps: + - uses: actions/checkout@master + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install tox + run: pip install tox + - name: Prepare test environment + run: tox --notest -p auto --parallel-live + - name: Test pip ${{ matrix.pip-version }} + run: tox + pypy: + name: ${{ matrix.os }} / ${{ matrix.python-version }} / ${{ matrix.pip-version }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - Ubuntu + - MacOS + # TODO: fix test_realistic_complex_sub_dependencies test on Windows + # - Windows + python-version: + - pypy3 + - pypy2 + pip-version: + - latest + env: + PY_COLORS: 1 + TOXENV: pip${{ matrix.pip-version }} + TOX_PARALLEL_NO_SPINNER: 1 steps: - uses: actions/checkout@master - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install tox run: pip install tox - - name: Test with tox ${{ matrix.env.TOXENV }} + - name: Prepare test environment + run: tox --notest -p auto --parallel-live + - name: Test pip ${{ matrix.pip-version }} run: tox - env: ${{ matrix.env }} diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml new file mode 100644 index 000000000..2c5d6f5c5 --- /dev/null +++ b/.github/workflows/qa.yml @@ -0,0 +1,43 @@ +name: QA + +on: + pull_request: + push: + branches: + - master + tags: + +jobs: + qa: + name: ${{ matrix.toxenv }} + runs-on: ubuntu-latest + strategy: + matrix: + toxenv: + - checkqa + - readme + python-version: + - "3.x" + env: + PY_COLORS: 1 + TOXENV: ${{ matrix.toxenv }} + TOX_PARALLEL_NO_SPINNER: 1 + steps: + - uses: actions/checkout@master + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Prepare cache key + id: cache-key + run: echo "::set-output name=sha-256::$(python -VV | sha256sum | cut -d' ' -f1)" + - uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ steps.cache-key.outputs.sha-256 }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Install tox + run: pip install tox + - name: Prepare test environment + run: tox --notest -p auto --parallel-live + - name: Test ${{ matrix.toxenv }} + run: tox diff --git a/tests/conftest.py b/tests/conftest.py index e14199d7d..206bf94ca 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,6 +15,7 @@ from pip._vendor.pkg_resources import Requirement from .constants import MINIMAL_WHEELS_PATH +from .utils import looks_like_ci from piptools.cache import DependencyCache from piptools.exceptions import NoCandidateFound @@ -106,7 +107,7 @@ def requires(self): def pytest_collection_modifyitems(config, items): for item in items: # Mark network tests as flaky - if item.get_closest_marker("network") and "CI" in os.environ: + if item.get_closest_marker("network") and looks_like_ci(): item.add_marker(pytest.mark.flaky(reruns=3, reruns_delay=2)) diff --git a/tests/utils.py b/tests/utils.py index a8780f313..ac44b3653 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,3 +1,4 @@ +import os import subprocess @@ -11,3 +12,11 @@ def invoke(command): status = error.returncode return status, output + + +# NOTE: keep in sync with "passenv" in tox.ini +CI_VARIABLES = {"CI", "GITHUB_ACTIONS"} + + +def looks_like_ci(): + return bool(set(os.environ.keys()) & CI_VARIABLES) diff --git a/tox.ini b/tox.ini index 76656d021..503a0f997 100644 --- a/tox.ini +++ b/tox.ini @@ -20,12 +20,12 @@ setenv = pip20.0: PIP==20.0 pip20.1: PIP==20.1 - coverage: PYTEST_ADDOPTS=--strict --doctest-modules --cov --cov-report=term-missing {env:PYTEST_ADDOPTS:} + coverage: PYTEST_ADDOPTS=--strict --doctest-modules --cov --cov-report=term-missing --cov-report=xml {env:PYTEST_ADDOPTS:} commands_pre = piplatest: python -m pip install -U pip pip --version commands = pytest {posargs} -passenv = CI +passenv = CI GITHUB_ACTIONS pip_pre=True [testenv:checkqa]