Skip to content

Commit

Permalink
Use caching in Github Actions Workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed May 23, 2023
1 parent 51f0bf6 commit 0bc9eec
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
19 changes: 18 additions & 1 deletion .github/actions/setup-python-env/action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
name: Setup Python env
name: Setup Python Environment
description: Install Python & Hatch

runs:
using: "composite"

steps:
- name: Set Linux Release Environment Variable
shell: bash
run: echo "LINUX_RELEASE=$(lsb_release -rs)" >> $GITHUB_ENV
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.9"

# Cache the dependencies installed by Hatch so that we don't need to reinstall them on every run.
- uses: actions/cache@v3
with:
path: |
${{ env.pythonLocation }}
# Save Hatch environments.
~/.local/share/hatch
# Save the package cache for Hatch.
~/.cache/hatch
# Save pre-commit environments.
~/.cache/pre-commit
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ env.LINUX_RELEASE }}-000

- name: Install Hatch
shell: bash
run: pip3 install hatch
3 changes: 2 additions & 1 deletion .github/workflows/ci-pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-python-env
- name: Setup Python Environment
uses: ./.github/actions/setup-python-env
- name: Run Pre-commit Hooks
run: hatch run pre-commit:pre-commit run --show-diff-on-failure --color=always --all-files
3 changes: 2 additions & 1 deletion .github/workflows/ci-pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-python-env
- name: Setup Python Environment
uses: ./.github/actions/setup-python-env
- name: Run Python Tests
run: hatch run pytest:pytest tests

0 comments on commit 0bc9eec

Please sign in to comment.