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

ci: Speed up pip install by caching deps install output #1885

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 21 additions & 3 deletions .github/workflows/build_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,30 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- if: ${{ runner.os == 'Windows' }}
# This is needed so that restoring cache on Windows is fast.
# See until https://github.com/actions/cache/issues/752 is resolved.
name: Use GNU tar
shell: cmd
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('Pipfile.lock') }}
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-pip-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
- name: Install dependencies
run: pip install wheel && pip install .[dev]
# Only if the cache misses
# Based on https://github.com/pypa/pip/issues/8049#issuecomment-633845028
# read_requirements.py should be removed once
# https://github.com/pypa/pip/issues/11440 is resolved.
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install toml
python tests/read_requirements.py > requirements.txt
pip install -r requirements.txt
- name: Install Mesa
run: pip install --no-deps .
- name: Test with pytest
run: pytest --cov=mesa tests/ --cov-report=xml
- if: matrix.os == 'ubuntu'
Expand Down
8 changes: 8 additions & 0 deletions tests/read_requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import toml

# This file reads the pyproject.toml and prints out the
# dependencies and dev dependencies.
# It is located in tests/ folder so as not to pollute the root repo.
c = toml.load("pyproject.toml")
print("\n".join(c["project"]["dependencies"]))
print("\n".join(c["project"]["optional-dependencies"]["dev"]))