Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI workflow for GitHub Actions #1012

Merged
merged 6 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: CI

on:
pull_request:
atugushev marked this conversation as resolved.
Show resolved Hide resolved
push:
branches:
atugushev marked this conversation as resolved.
Show resolved Hide resolved
- master

jobs:
qa:
atugushev marked this conversation as resolved.
Show resolved Hide resolved
name: QA
atugushev marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
strategy:
matrix:
toxenv:
- checkqa
- readme
webknjaz marked this conversation as resolved.
Show resolved Hide resolved
steps:
atugushev marked this conversation as resolved.
Show resolved Hide resolved
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
atugushev marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/setup-python@v2
atugushev marked this conversation as resolved.
Show resolved Hide resolved
- 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') }}
atugushev marked this conversation as resolved.
Show resolved Hide resolved
- name: Install tox
run: pip install tox
- name: Test ${{ matrix.toxenv }}
atugushev marked this conversation as resolved.
Show resolved Hide resolved
run: tox -e ${{ matrix.toxenv }}
atugushev marked this conversation as resolved.
Show resolved Hide resolved

cpython:
name: Test
atugushev marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os:
- Ubuntu
- Windows
python-version:
- 2.7
- 3.5
- 3.6
- 3.7
- 3.8
atugushev marked this conversation as resolved.
Show resolved Hide resolved
pip-version:
- "20.0"
- "latest"
atugushev marked this conversation as resolved.
Show resolved Hide resolved
steps:
atugushev marked this conversation as resolved.
Show resolved Hide resolved
- 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 }}
atugushev marked this conversation as resolved.
Show resolved Hide resolved

pypy:
atugushev marked this conversation as resolved.
Show resolved Hide resolved
name: Test
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os:
- Ubuntu
# TODO uncomment after test_realistic_complex_sub_dependencies being fixed
# - Windpws
atugushev marked this conversation as resolved.
Show resolved Hide resolved
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 }}
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))


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