Skip to content

Commit d1159bf

Browse files
committed
ci: Speed up pip install by caching
Based on the benchmark, it speeds up by about 2x for the Ubuntu instances. While extracting the cache tarball for the Windows instance could be further sped up. See #12.
1 parent 70b2902 commit d1159bf

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

.github/workflows/build_lint.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,29 @@ jobs:
5050
uses: actions/setup-python@v4
5151
with:
5252
python-version: ${{ matrix.python-version }}
53+
- if: ${{ runner.os == 'Windows' }}
54+
# This is needed so that restoring cache on Windows is fast.
55+
# See until https://github.com/actions/cache/issues/752 is resolved.
56+
name: Use GNU tar
57+
shell: cmd
58+
run: |
59+
echo "Adding GNU tar to PATH"
60+
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
5361
- uses: actions/cache@v3
5462
with:
55-
path: ~/.cache/pip
56-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('Pipfile.lock') }}
63+
path: ${{ env.pythonLocation }}
64+
key: ${{ runner.os }}-pip-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
5765
- name: Install dependencies
58-
run: pip install wheel && pip install .[dev]
66+
# Only if the cache misses
67+
# Based on https://github.com/pypa/pip/issues/8049#issuecomment-633845028
68+
# read_requirements.py should be removed once
69+
# https://github.com/pypa/pip/issues/11440 is resolved.
70+
if: steps.cache.outputs.cache-hit != "true"
71+
run: |
72+
pip install toml
73+
python tests/read_requirements.py | pip install -r /dev/stdin
74+
- name: Install Mesa
75+
run: pip install --no-deps .
5976
- name: Test with pytest
6077
run: pytest --cov=mesa tests/ --cov-report=xml
6178
- if: matrix.os == 'ubuntu'

tests/read_requirements.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import toml
2+
3+
# This file reads the pyproject.toml and prints out the
4+
# dependencies and dev dependencies.
5+
# It is located in tests/ folder so as not to pollute the root repo.
6+
c = toml.load("pyproject.toml")
7+
print("\n".join(c["project"]["dependencies"]))
8+
print("\n".join(c["project"]["optional-dependencies"]["dev"]))

0 commit comments

Comments
 (0)