Skip to content

Commit 3edc404

Browse files
committed
ci(tests): Add poetry caching from libvcs
1 parent e47af11 commit 3edc404

File tree

1 file changed

+49
-11
lines changed

1 file changed

+49
-11
lines changed

.github/workflows/tests.yml

+49-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,49 @@ jobs:
1212
tmux-version: [ '2.6', '2.7', '2.8', '3.0', 'master' ]
1313
steps:
1414
- uses: actions/checkout@v1
15-
- name: Cache tmux build ${{ matrix.tmux-version }}
15+
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
21+
- name: Get full Python version
22+
id: full-python-version
23+
shell: bash
24+
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
25+
26+
- name: Install poetry
27+
run: |
28+
curl -O -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
29+
python get-poetry.py -y
30+
echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH"
31+
rm get-poetry.py
32+
33+
- name: Get poetry cache paths from config
34+
run: |
35+
echo ::set-env name=poetry_cache_dir::$(poetry config --list | sed -n 's/.*cache-dir = //p' | sed -e 's/^"//' -e 's/"$//')
36+
echo ::set-env name=poetry_virtualenvs_path::$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^"//' -e 's/"$//')
37+
38+
- name: Configure poetry
39+
shell: bash
40+
run: poetry config virtualenvs.in-project true
41+
42+
- name: Set up poetry cache
43+
uses: actions/cache@v2
44+
id: cache
45+
with:
46+
path: |
47+
.venv
48+
{{ env.poetry_cache_dir }}
49+
{{ env.poetry_virtualenvs_path }}
50+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
51+
52+
- name: Ensure cache is healthy
53+
if: steps.cache.outputs.cache-hit == 'true'
54+
shell: bash
55+
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
56+
57+
- name: Setup tmux build cache for tmux ${{ matrix.tmux-version }}
1658
id: tmux-build-cache
1759
uses: actions/cache@v1
1860
with:
@@ -33,18 +75,14 @@ jobs:
3375
export PATH=$HOME/tmux-builds/tmux-${{ matrix.tmux-version }}/bin:$PATH
3476
cd ~
3577
tmux -V
36-
- name: Configure git
37-
run: |
38-
git config --global user.name 'travis-ci'
39-
git config --global user.email '[email protected]'
40-
- name: Set up Python ${{ matrix.python-version }}
41-
uses: actions/setup-python@v1
42-
with:
43-
python-version: ${{ matrix.python-version }}
78+
79+
- name: Upgrade pip
80+
shell: bash
81+
run: poetry run python -m pip install pip -U
82+
4483
- name: Install python dependencies
4584
run: |
46-
python -m pip install --upgrade poetry
47-
poetry install
85+
poetry install -E "test coverage lint"
4886
- name: Lint with flake8
4987
run: |
5088
poetry run flake8

0 commit comments

Comments
 (0)