Skip to content

Fail if poetry.lock has fallen out of sync with pyproject.toml #2

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

Merged
merged 1 commit into from
Mar 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ runs:
path: ${{ steps.poetry-venvs.outputs.dir }}
key: poetry-venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Check that the poetry lockfile is up to date
# This is rather hacky. We look for the warning message in poetry's
# output. We really want to use `poetry lock --check`, but that is only
# available in poetry 1.2.
# https://github.com/python-poetry/poetry/issues/1406
run: >-
poetry export --without-hashes | (! grep "The lock file is not up to date") ||
(echo pyproject.toml was updated without running \`poetry lock --no-update\`. && false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you were feeling particularly fancy, you could make this set an error annotation on poetry.lock: see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message

(But I don't think we need to be fancy)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, I didn't know you could do that with GHA. I'll leave the fanciness alone for now.

shell: bash

- name: Install dependencies
if: "${{ steps.poetry-venv-cache.outputs.cache-hit != 'true' }}"
run: poetry install --no-interaction --no-root
Expand Down