Skip to content

Commit

Permalink
Remove circular dependency on export plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Sep 17, 2023
1 parent 9e1dd3c commit 346236b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
shell: bash
steps:
- uses: actions/checkout@v3
with:
path: poetry

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down Expand Up @@ -82,6 +84,7 @@ jobs:

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
working-directory: ./poetry
run: |
# `timeout` is not available on macOS, so we define a custom function.
[ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
Expand All @@ -90,15 +93,19 @@ jobs:
timeout 10s poetry run pip --version || rm -rf .venv
- name: Check lock file
working-directory: ./poetry
run: poetry check --lock

- name: Install dependencies
working-directory: ./poetry
run: poetry install --with github-actions

- name: Run mypy
working-directory: ./poetry
run: poetry run mypy

- name: Run pytest
working-directory: ./poetry
env:
POETRY_TEST_INTEGRATION_GIT_USERNAME: ${GITHUB_ACTOR}
POETRY_TEST_INTEGRATION_GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -107,7 +114,9 @@ jobs:
- name: Get Plugin Version (poetry-plugin-export)
id: poetry-plugin-export-version
run: |
echo version=$(poetry show poetry-plugin-export | grep version | cut -d : -f 2 | xargs) >> $GITHUB_OUTPUT
PLUGIN_VERSION=$(curl -s https://pypi.org/pypi/poetry-plugin-export/json | python -c 'import json, sys ; print(json.load(sys.stdin)["info"]["version"])')
echo "Found version ${PLUGIN_VERSION}"
echo version=${PLUGIN_VERSION} >> $GITHUB_OUTPUT
- name: Checkout Plugin Source (poetry-plugin-export)
uses: actions/checkout@v3
Expand All @@ -116,11 +125,26 @@ jobs:
repository: python-poetry/poetry-plugin-export
ref: refs/tags/${{ steps.poetry-plugin-export-version.outputs.version }}

- name: Update poetry version (poetry-plugin-export)
working-directory: poetry-plugin-export
run: |
poetry add --lock --dev ../poetry
git diff
- name: Install (poetry-plugin-export)
working-directory: ./poetry-plugin-export
run: poetry install

- name: Run pytest (poetry-plugin-export)
working-directory: ./poetry-plugin-export
run: poetry run -C .. pytest -v
run: poetry run python -m pytest -p no:sugar -q tests/

- name: Check for clean working tree
working-directory: ./poetry
run: git diff --exit-code --stat HEAD

- name: Check for clean working tree (poetry-plugin-export)
working-directory: ./poetry-plugin-export
run: |
git checkout -- pyproject.toml poetry.lock
git diff --exit-code --stat HEAD
git -C poetry-plugin-export diff --exit-code --stat HEAD
9 changes: 0 additions & 9 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@
pass_filenames: false
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$

- id: poetry-export
name: poetry-export
description: run poetry export to sync lock file with requirements.txt
entry: poetry export
language: python
pass_filenames: false
files: ^(.*/)?poetry\.lock$
args: ["-f", "requirements.txt", "-o", "requirements.txt"]

- id: poetry-install
name: poetry-install
description: run poetry install to install dependencies from the lock file
Expand Down
2 changes: 2 additions & 0 deletions docs/pre-commit-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ The `poetry-export` hook calls the `poetry export` command
to sync your `requirements.txt` file with your current dependencies.

{{% note %}}
This hook is provided by the [Export Poetry Plugin](https://github.com/python-poetry/poetry-plugin-export).

It is recommended to run the [`poetry-lock`](#poetry-lock) hook prior to this one.
{{% /note %}}

Expand Down
17 changes: 1 addition & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Changelog = "https://python-poetry.org/history/"
python = "^3.8"

poetry-core = "1.7.0"
poetry-plugin-export = "^1.5.0"
build = "^1.0.3"
cachecontrol = { version = "^0.13.0", extras = ["filecache"] }
cleo = "^2.0.0"
Expand Down

0 comments on commit 346236b

Please sign in to comment.