diff --git a/.github/actions/setup-python-env/action.yml b/.github/actions/setup-python-env/action.yml index eb0cac0b..ec9ff7a5 100644 --- a/.github/actions/setup-python-env/action.yml +++ b/.github/actions/setup-python-env/action.yml @@ -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 diff --git a/.github/workflows/ci-pre-commit.yaml b/.github/workflows/ci-pre-commit.yaml index ed43500b..fc5495bc 100644 --- a/.github/workflows/ci-pre-commit.yaml +++ b/.github/workflows/ci-pre-commit.yaml @@ -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 diff --git a/.github/workflows/ci-pytest.yaml b/.github/workflows/ci-pytest.yaml index 9a22463b..aad55228 100644 --- a/.github/workflows/ci-pytest.yaml +++ b/.github/workflows/ci-pytest.yaml @@ -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