Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip installing poetry if the cache hits #527

Merged
merged 10 commits into from
Apr 17, 2024
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