Skip to content

Commit

Permalink
Add CI workflow for GitHub Actions (#1012)
Browse files Browse the repository at this point in the history
Co-Authored-By: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
  • Loading branch information
atugushev and webknjaz authored May 15, 2020
1 parent ce3da73 commit b1d7369
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 14 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
67 changes: 56 additions & 11 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
@@ -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 }}
43 changes: 43 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))


Expand Down
9 changes: 9 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess


Expand All @@ -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)
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit b1d7369

Please sign in to comment.