From af97e034a6bbb78f86ea3a306823f1e5ef09aad8 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Thu, 28 Nov 2019 02:10:41 +0700 Subject: [PATCH 1/5] Add CI workflow for GitHub Actions --- .github/workflows/ci.yml | 90 ++++++++++++++++++++++++++++++++++++++++ tests/conftest.py | 3 +- tests/utils.py | 9 ++++ tox.ini | 4 +- 4 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..fd2ab4dc8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,90 @@ +name: CI + +on: + pull_request: + push: + branches: + - master + +jobs: + qa: + name: QA + runs-on: ubuntu-latest + strategy: + matrix: + toxenv: + - checkqa + - readme + steps: + - uses: actions/checkout@master + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + - name: Set PY + run: echo "::set-env name=PY::$(python -VV | sha256sum | cut -d' ' -f1)" + - uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Install tox + run: pip install tox + - name: Test ${{ matrix.toxenv }} + run: tox -e ${{ matrix.toxenv }} + + cpython: + name: Test + runs-on: ${{ matrix.os }}-latest + strategy: + matrix: + os: + - Ubuntu + - Windows + python-version: + - 2.7 + - 3.5 + - 3.6 + - 3.7 + - 3.8 + pip-version: + - "20.0" + - "latest" + 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: Test pip ${{ matrix.pip-version }} + run: tox -e pip${{ matrix.pip-version }}-coverage + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1.0.6 + with: + file: ./coverage.xml + name: ${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.pip-version }} + + pypy: + name: Test + runs-on: ${{ matrix.os }}-latest + strategy: + matrix: + os: + - Ubuntu + # TODO uncomment after test_realistic_complex_sub_dependencies being fixed + # - Windpws + python-version: + - pypy2 + - pypy3 + # Test pypy only with the latest pip version to reduce the number of jobs + pip-version: + - latest + 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: Test pip ${{ matrix.pip-version }} + run: tox -e pip${{ matrix.pip-version }} diff --git a/tests/conftest.py b/tests/conftest.py index 009cb0072..599a19062 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,6 +16,7 @@ from pytest import fixture from .constants import MINIMAL_WHEELS_PATH +from .utils import looks_like_ci from piptools.cache import DependencyCache from piptools.exceptions import NoCandidateFound @@ -107,7 +108,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] From 988dfbcc41f81e28a3fe158dc61fc4b12dea4444 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Sun, 3 May 2020 12:33:56 +0700 Subject: [PATCH 2/5] Address review commends Co-Authored-By: Sviatoslav Sydorenko --- .github/workflows/ci.yml | 79 ++++++++++++---------------------------- .github/workflows/qa.yml | 43 ++++++++++++++++++++++ 2 files changed, 67 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/qa.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd2ab4dc8..b32c6038a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,33 +5,11 @@ on: push: branches: - master + tags: jobs: - qa: - name: QA - runs-on: ubuntu-latest - strategy: - matrix: - toxenv: - - checkqa - - readme - steps: - - uses: actions/checkout@master - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - - name: Set PY - run: echo "::set-env name=PY::$(python -VV | sha256sum | cut -d' ' -f1)" - - uses: actions/cache@v1 - with: - path: ~/.cache/pre-commit - key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} - - name: Install tox - run: pip install tox - - name: Test ${{ matrix.toxenv }} - run: tox -e ${{ matrix.toxenv }} - - cpython: - name: Test + test: + name: ${{ matrix.os }} / ${{ matrix.python-version }} / ${{ matrix.pip-version }} runs-on: ${{ matrix.os }}-latest strategy: matrix: @@ -39,14 +17,29 @@ jobs: - Ubuntu - Windows python-version: + - 3.8 - 2.7 + - pypy3 - 3.5 - 3.6 - 3.7 - - 3.8 + - pypy2 pip-version: - - "20.0" - "latest" + - "20.0" + exclude: + - os: Windows + python-version: pypy2 + - os: Windows + python-version: pypy3 + - pip-version: "20.0" + python-version: pypy2 + - pip-version: "20.0" + python-version: pypy3 + 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 }} @@ -55,36 +48,12 @@ jobs: 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 -e pip${{ matrix.pip-version }}-coverage + run: tox - name: Upload coverage to Codecov uses: codecov/codecov-action@v1.0.6 with: file: ./coverage.xml - name: ${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.pip-version }} - - pypy: - name: Test - runs-on: ${{ matrix.os }}-latest - strategy: - matrix: - os: - - Ubuntu - # TODO uncomment after test_realistic_complex_sub_dependencies being fixed - # - Windpws - python-version: - - pypy2 - - pypy3 - # Test pypy only with the latest pip version to reduce the number of jobs - pip-version: - - latest - 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: Test pip ${{ matrix.pip-version }} - run: tox -e pip${{ matrix.pip-version }} + name: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pip-version }} 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 From 8d39f96af51760ff452064d7022be2d9d028a143 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Sun, 3 May 2020 14:19:45 +0700 Subject: [PATCH 3/5] Comment out the pypy exclusion from the matrix --- .github/workflows/ci.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b32c6038a..971c2d275 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,15 +27,19 @@ jobs: pip-version: - "latest" - "20.0" + # Test pypy only with the latest pip version to reduce the number of jobs exclude: - - os: Windows - python-version: pypy2 - - os: Windows - python-version: pypy3 - pip-version: "20.0" python-version: pypy2 - pip-version: "20.0" python-version: pypy3 + # TODO: fix test_realistic_complex_sub_dependencies test + # and remove Windows exclusion + - os: Windows + python-version: pypy2 + - os: Windows + python-version: pypy3 + env: PY_COLORS: 1 TOXENV: pip${{ matrix.pip-version }}-coverage From 790872fa43ad1c270552577bd613cd03c2a982f0 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Mon, 4 May 2020 23:17:55 +0700 Subject: [PATCH 4/5] Address review comments Co-Authored-By: Sviatoslav Sydorenko --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 971c2d275..4266615c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,9 @@ on: branches: - master tags: + schedule: + # Run everyday at 03:53 UTC + - cron: 53 3 * * * jobs: test: @@ -16,6 +19,7 @@ jobs: os: - Ubuntu - Windows + - MacOS python-version: - 3.8 - 2.7 From d2d946a1c9c36a63573d98607745bd12d20de4e6 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Tue, 5 May 2020 03:33:35 +0700 Subject: [PATCH 5/5] Run pypy test jobs in cron workflow --- .github/workflows/ci.yml | 15 --------- .github/workflows/cron.yml | 67 +++++++++++++++++++++++++++++++------- 2 files changed, 56 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4266615c0..6e9cf5706 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,27 +23,12 @@ jobs: python-version: - 3.8 - 2.7 - - pypy3 - 3.5 - 3.6 - 3.7 - - pypy2 pip-version: - "latest" - "20.0" - # Test pypy only with the latest pip version to reduce the number of jobs - exclude: - - pip-version: "20.0" - python-version: pypy2 - - pip-version: "20.0" - python-version: pypy3 - # TODO: fix test_realistic_complex_sub_dependencies test - # and remove Windows exclusion - - os: Windows - python-version: pypy2 - - os: Windows - python-version: pypy3 - env: PY_COLORS: 1 TOXENV: pip${{ matrix.pip-version }}-coverage 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 }}