Skip to content

Commit

Permalink
fix: skip installing poetry if the cache hits (#527)
Browse files Browse the repository at this point in the history
* fix: skip installing poetry if the cache hits

* fix: apply cache fix to static also

* fix: use poetry run not .venv

* fix: add env info

* fix: tell poetry to use the right python

* fix: add poetry env use to test workflows also

* fix: add cached poetry to path

* fix: try again

* fix: windows already using bash

* fix: skip poetry use on windows
  • Loading branch information
tconbeer authored Apr 17, 2024
1 parent 4ceb9f6 commit 4cfe86d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ jobs:
python-version: "3.10"

- name: Load cached Poetry installation
id: cached-poetry
id: cached-poetry-install
uses: actions/cache@v4
with:
path: ~/.local
key: ${{ runner.os }}-poetry-171 # increment to reset cache

- name: Install Poetry
if: steps.cached-poetry-install.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.7.1
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ jobs:
python-version: "3.10"

- name: Load cached Poetry installation
id: cached-poetry
id: cached-poetry-install
uses: actions/cache@v4
with:
path: ~/.local
key: ${{ runner.os }}-poetry-171 # increment to reset cache

- name: Install Poetry
if: steps.cached-poetry-install.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.7.1
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ jobs:
python-version: "3.8"

- name: Load cached Poetry installation
id: cached-poetry
id: cached-poetry-install
uses: actions/cache@v4
with:
path: ~/.local
key: ${{ runner.os }}-poetry-171 # increment to reset cache

- name: Add cached Poetry to PATH
if: steps.cached-poetry-install.outputs.cache-hit == 'true'
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install Poetry
if: steps.cached-poetry-install.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.7.1
Expand All @@ -49,11 +54,13 @@ jobs:

- name: Install python dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --sync --no-interaction --without dev
run: |
poetry env use ${{ steps.setup-python.outputs.python-version }}
poetry install --sync --no-interaction --without dev
poetry env info
- name: Run analysis
run: |
source .venv/bin/activate
black . --check
ruff check .
mypy
poetry run black . --check
poetry run ruff check .
poetry run mypy
23 changes: 18 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
persist-credentials: false

- name: Set up Python 3.10
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.10"
Expand All @@ -38,16 +39,22 @@ jobs:
id: cached-poetry-install
uses: actions/cache@v4
with:
path: ~/.local
path: ~\.local
key: ${{ runner.os }}-poetry-171

- name: Add cached Poetry to PATH
if: steps.cached-poetry-install.outputs.cache-hit == 'true'
run: echo "$HOME\.local\bin" >> $GITHUB_PATH

- name: Install Poetry
if: steps.cached-poetry-install.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.7.1

- name: Install python dependencies
run: poetry install --sync --no-interaction --only main,test
run: |
poetry install --sync --no-interaction --only main,test
- name: Run tests
run: poetry run pytest -m "not online" -m "not flaky_windows" --snapshot-warn-unused
Expand Down Expand Up @@ -97,6 +104,10 @@ jobs:
path: ~/.local
key: ${{ runner.os }}-poetry-171

- name: Add cached Poetry to PATH
if: steps.cached-poetry-install.outputs.cache-hit == 'true'
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install Poetry
if: steps.cached-poetry-install.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
Expand All @@ -112,11 +123,13 @@ jobs:

- name: Install python dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --sync --no-interaction --only main,test
run: |
poetry env use ${{ steps.setup-python.outputs.python-version }}
poetry install --sync --no-interaction --only main,test
- name: Run tests
run: |
source .venv/bin/activate
pytest -m "not online"
poetry run pytest -m "not online"
- name: Store snapshot report on failure
uses: actions/upload-artifact@v4
Expand Down

0 comments on commit 4cfe86d

Please sign in to comment.