Skip to content

Commit d72ddc0

Browse files
committed
build(tests): Update to latest and greatest caching
1 parent 52a8b81 commit d72ddc0

File tree

1 file changed

+47
-7
lines changed

1 file changed

+47
-7
lines changed

.github/workflows/tests.yml

+47-7
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,56 @@ jobs:
1919
uses: actions/setup-python@v1
2020
with:
2121
python-version: ${{ matrix.python-version }}
22-
- name: Install dependencies
22+
23+
- name: Get full Python version
24+
id: full-python-version
25+
shell: bash
26+
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
27+
28+
- name: Install poetry
2329
run: |
24-
python -m pip install --upgrade poetry
25-
poetry install
26-
- name: Lint with flake8
30+
curl -O -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
31+
python get-poetry.py -y
32+
echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH"
33+
rm get-poetry.py
34+
35+
- name: Get poetry cache paths from config
2736
run: |
28-
poetry run flake8
37+
echo ::set-env name=poetry_cache_dir::$(poetry config --list | sed -n 's/.*cache-dir = //p' | sed -e 's/^"//' -e 's/"$//')
38+
echo ::set-env name=poetry_virtualenvs_path::$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^"//' -e 's/"$//')
39+
40+
- name: Configure poetry
41+
shell: bash
42+
run: poetry config virtualenvs.in-project true
43+
44+
- name: Set up cache
45+
uses: actions/cache@v2
46+
id: cache
47+
with:
48+
path: |
49+
.venv
50+
{{ env.poetry_cache_dir }}
51+
{{ env.poetry_virtualenvs_path }}
52+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
53+
54+
- name: Ensure cache is healthy
55+
if: steps.cache.outputs.cache-hit == 'true'
56+
shell: bash
57+
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
58+
59+
- name: Upgrade pip
60+
shell: bash
61+
run: poetry run python -m pip install pip -U
62+
63+
- name: Install dependencies
64+
run: poetry install -E "docs test coverage lint format"
65+
66+
- name: Lint with flake8
67+
run: poetry run flake8
68+
2969
- name: Test with pytest
30-
run: |
31-
poetry run py.test --cov=./ --cov-report=xml
70+
run: poetry run py.test --cov=./ --cov-report=xml
71+
3272
- uses: codecov/codecov-action@v1
3373
with:
3474
token: ${{ secrets.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)