Skip to content

Commit

Permalink
Update Github workflow to use pip caching
Browse files Browse the repository at this point in the history
  • Loading branch information
ebram96 committed Jan 15, 2024
1 parent c5b8981 commit f583cfc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 19 deletions.
27 changes: 27 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Setup'
description: 'Set up Python and install dependencies'
inputs:
python-version:
description: 'Version of Python to set up'
required: true
runs:
using: 'composite'
steps:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Restore Dependencies Cache
uses: actions/cache@v3
with:
path: ~/.cache/pip/
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
35 changes: 16 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@ on:
- synchronize
- closed

# TODO: Use some kind of cache to speed up running.
jobs:
test-main-python:
cache-dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
- uses: ./.github/actions/setup
with:
python-version: "3.12"
python-version: "3.9"

- name: Install Dependencies
run: |
pip install -r requirements.txt
pip install -e .
main:
needs: cache-dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup
with:
python-version: "3.9"

- name: Unit Tests
run: coverage run -m pytest -s tests
Expand All @@ -38,22 +40,17 @@ jobs:
pre-commit run --all-files
test-matrix:
needs: cache-dependencies
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11" ]
python-version: [ "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.version }}

- name: Install Dependencies
run: |
pip install -r requirements.txt
pip install -e .
python-version: ${{ matrix.python-version }}

- name: Run Test Matrix
run: |
Expand Down

0 comments on commit f583cfc

Please sign in to comment.