Skip to content

Commit

Permalink
Cached everything.
Browse files Browse the repository at this point in the history
  • Loading branch information
flipbit03 committed Dec 31, 2024
1 parent ee5984b commit b4373f1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
name: Install and cache poetry/pre-commit dependencies
name: Checkout and get (possibly cached) Poetry/Pre-commit virtualenvs

runs:
using: "composite"
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Set up python
- name: Set up Python
id: setup-python
uses: actions/setup-python@v5

- name: Install poetry
- name: Install Poetry
shell: bash
run: |
python -m pip install poetry
python -m pip install -qqq poetry
- name: Load cached poetry virtualenv
- name: Load cached Poetry virtualenv, if available
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('.github/actions/cache_deps/action.yml') }}-${{ steps.setup-python.outputs.python-version }}

- name: Install poetry dependencies, only if cache wasn't found
shell: bash
run: |
poetry install --no-interaction
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('.github/actions/poetry_cached/action.yml') }}-${{ steps.setup-python.outputs.python-version }}

- name: Load cached pre-commit virtualenv
id: cached-pre-commit
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('.github/actions/cache_deps/action.yml') }}-${{ steps.setup-python.outputs.python-version }}
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('.github/actions/poetry_cached/action.yml') }}-${{ steps.setup-python.outputs.python-version }}

- name: Install poetry dependencies, only if cache wasn't found
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
shell: bash
run: |
poetry install --no-interaction
- name: Install pre-commit hooks, only if cache wasn't found
if: steps.cached-pre-commit.outputs.cache-hit != 'true'
shell: bash
run: |
poetry run pre-commit install-hooks
if: steps.cached-pre-commit.outputs.cache-hit != 'true'
6 changes: 2 additions & 4 deletions .github/workflows/lints_and_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3

- name: Get or set cached dependencies
uses: ./.github/actions/cache_deps
- name: Checkout and get (possibly cached) Poetry/Pre-commit virtualenvs
uses: ./.github/actions/poetry_cached

- name: Static type checking with `mypy`
run: |
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ jobs:

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Checkout and get (possibly cached) Poetry/Pre-commit virtualenvs
uses: ./.github/actions/poetry_cached

- name: Set version from GITHUB_REF
run: |
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,8 @@ jobs:
matrix:
python-version: [ "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: |
python -m pip install poetry
poetry install
- name: Checkout and get (possibly cached) Poetry/Pre-commit virtualenvs
uses: ./.github/actions/poetry_cached

- name: Run Tests
run: |
Expand Down

0 comments on commit b4373f1

Please sign in to comment.