Cache poetry CLI #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CI/CD workflow for the project. | |
name: cicd | |
on: | |
push: | |
env: | |
PYTHON_VERSION: "3.11" | |
POETRY_VERSION: "1.8.2" | |
jobs: | |
# Run our linter on every push to the repository. | |
lint: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: get code | |
uses: actions/checkout@v4 | |
# `poetry` is installed in ~/.local, so we cache it to speed up the action. Without the cache, it usually takes | |
# 15-20 seconds to install poetry. | |
- name: cache poetry cli | |
uses: actions/cache@v4 | |
with: | |
path: ~/.local | |
# Invalidate the cache when this workflow file changes. | |
key: poetry-${{ runner.os }}-${{ env.POETRY_VERSION }}-${{ env.PYTHON_VERSION }} | |
- name: install python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: install poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: ${{ env.POETRY_VERSION }} | |
- name: cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: py-lint-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
py-lint-${{ runner.os }}-${{ env.PYTHON_VERSION }}- | |
- name: lint | |
run: | | |
make lint | |
# Run unit tests on every push to the repository. | |
test: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: get code | |
uses: actions/checkout@v4 | |
# `poetry` is installed in ~/.local, so we cache it to speed up the action. Without the cache, it usually takes | |
# 15-20 seconds to install poetry. | |
- name: cache poetry cli | |
uses: actions/cache@v4 | |
with: | |
path: ~/.local | |
# Invalidate the cache when this workflow file changes. | |
key: poetry-${{ runner.os }}-${{ env.POETRY_VERSION }}-${{ env.PYTHON_VERSION }} | |
- name: install python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: install poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: ${{ env.POETRY_VERSION }} | |
- name: cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: py-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
py-${{ runner.os }}-${{ env.PYTHON_VERSION }}- | |
- name: test | |
run: | | |
make test | |
- name: debug | |
run: | | |
ls ~/.local/ |