Skip to content

Commit 0bf4f75

Browse files
authored
Cache dependency installs in CI (#833)
1 parent 4039b0b commit 0bf4f75

3 files changed

Lines changed: 33 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,34 @@ jobs:
1515
matrix:
1616
os: [ubuntu-latest, macos-latest, windows-latest]
1717
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
18+
include:
19+
- os: ubuntu-latest
20+
venvcmd: . env/bin/activate
21+
- os: macos-latest
22+
venvcmd: . env/bin/activate
23+
- os: windows-latest
24+
venvcmd: env\Scripts\Activate.ps1
1825
steps:
19-
- uses: actions/checkout@v2
20-
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v2
22-
with:
23-
python-version: ${{ matrix.python-version }}
24-
- name: Install dependencies
25-
run: |
26-
pip install --upgrade -r requirements-dev.txt
27-
pip install .
28-
- name: Install pytest-github-actions-annotate-failures plugin
29-
run: pip install pytest-github-actions-annotate-failures
30-
- name: Run tests
31-
run: make ci
32-
- name: Report coverage to Codecov
33-
uses: codecov/codecov-action@v1
26+
- uses: actions/checkout@v2
27+
- uses: actions/cache@v2
28+
id: cache
29+
with:
30+
path: env
31+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements-dev.txt') }}-${{ hashFiles('**/Makefile') }}
32+
restore-keys: |
33+
${{ runner.os }}-pip-
34+
- name: Set up Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@v2
36+
with:
37+
python-version: ${{ matrix.python-version }}
38+
- name: Install dependencies
39+
run: |
40+
python -m venv env
41+
${{ matrix.venvcmd }}
42+
pip install --upgrade -r requirements-dev.txt pytest-github-actions-annotate-failures
43+
- name: Run tests
44+
run: |
45+
${{ matrix.venvcmd }}
46+
make ci
47+
- name: Report coverage to Codecov
48+
uses: codecov/codecov-action@v1

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ endif
1313
virtualenv: ./env/requirements.built
1414

1515
env:
16-
virtualenv env
16+
python -m venv env
1717

1818
./env/requirements.built: env requirements-dev.txt
1919
./env/bin/pip install -r requirements-dev.txt
@@ -48,3 +48,4 @@ test_coverage:
4848

4949
autopep8:
5050
autopep8 --max-line-length=$(MAX_LINE_LENGTH) -i setup.py examples zeroconf
51+

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ autopep8
22
black;implementation_name=="cpython"
33
coveralls
44
coverage
5-
# Version restricted because of https://github.com/PyCQA/pycodestyle/issues/741
5+
# Version restricted because of https://github.com/PyCQA/pycodestyle/issues/741 - is fixed
66
flake8>=3.6.0
77
flake8-import-order
88
ifaddr

0 commit comments

Comments
 (0)