Cache poetry itself #1170
Workflow file for this run
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
name: Build the package | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Build | |
strategy: | |
matrix: | |
os: [macos-latest, ubuntu-latest, windows-latest] | |
python-version: ["3.9"] | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Setup Python Environment | |
uses: ./.github/actions/setup-environment | |
id: environment | |
- name: Get poetry latest version | |
id: latest-versions | |
shell: bash | |
run: | | |
poetry_version=$(curl -s https://pypi.org/pypi/poetry/json | jq -r .info.version) | |
echo "poetry=$poetry_version" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v4 | |
name: Cache Poetry | |
with: | |
path: ${{ steps.environment.outputs.pip-cache }} | |
key: > | |
${{ format('pip-cache-{0}-{1}-{2}', | |
matrix.os, | |
matrix.python-version, | |
steps.latest-versions.outputs.poetry | |
) }} | |
- name: Install or update Poetry | |
run: pip install poetry==${{ steps.latest-versions.outputs.poetry }} | |
- name: Use local virtual environment | |
run: | | |
poetry config virtualenvs.create true --local | |
poetry config virtualenvs.in-project true --local | |
- uses: actions/cache@v4 | |
name: Cache Poetry dependencies | |
with: | |
path: ./.venv | |
key: deps-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} | |
restore-keys: | | |
deps-${{ matrix.os }}-${{ matrix.python-version }}- | |
- name: Install dependencies with Poetry | |
run: | | |
poetry env use python3 | |
poetry install | |
- name: Check if package builds | |
run: | | |
poetry build |