-
Notifications
You must be signed in to change notification settings - Fork 251
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
ci: modernize based on poetry #717
Draft
neersighted
wants to merge
13
commits into
python-poetry:main
Choose a base branch
from
neersighted:ci_update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8c6aed5
tests: add FixtureFactory fixture
neersighted 02969e1
tests/masonry/builders: enable parallelism
neersighted 2764247
github: remove issue template
neersighted b7e1940
gitignore: cleanup and simplify
neersighted 79994ca
pyproject: sync ruff config from poetry
neersighted fdf1d50
ci: normalize workflow names
neersighted d09a478
tests: add missing fixture
neersighted 5047182
tests: add github-actions-annotate-failures
neersighted 1a41415
tests: run in parallel with xdist (and randomize order)
neersighted f10c230
tests: disable the legacy tmpdir fixture
neersighted cd734e6
ci: add composite actions from poetry
neersighted a9f44b7
ci/tests: modernize based on poetry
neersighted 7539d83
ci/tests: skip downstream tests on pypy
neersighted File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Bootstrap Poetry | ||
description: Configure the environment with the specified Python and Poetry version. | ||
|
||
inputs: | ||
python-version: | ||
description: Desired node-semver compatible Python version expression (or 'default') | ||
default: 'default' | ||
python-latest: | ||
description: Use an uncached Python if a newer match is available | ||
default: 'false' | ||
python-prereleases: | ||
description: Allow usage of pre-release Python versions | ||
default: 'false' | ||
poetry-spec: | ||
description: pip-compatible installation specification to use for Poetry | ||
default: 'poetry' | ||
|
||
outputs: | ||
python-path: | ||
description: Path to the installed Python interpreter | ||
value: ${{ steps.setup-python.outputs.python-path }} | ||
python-version: | ||
description: Version of the installed Python interpreter | ||
value: ${{ steps.setup-python.outputs.python-version }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5 | ||
id: setup-python | ||
if: inputs.python-version != 'default' | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
check-latest: ${{ inputs.python-latest == 'true' }} | ||
allow-prereleases: ${{ inputs.python-prereleases == 'true' }} | ||
update-environment: false | ||
|
||
- run: pipx install ${{ inputs.python-version != 'default' && format('--python "{0}"', steps.setup-python.outputs.python-path) || '' }} '${{ inputs.poetry-spec }}' | ||
shell: bash | ||
|
||
# Enable handling long path names (+260 char) on the Windows platform | ||
# https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation | ||
- run: git config --system core.longpaths true | ||
if: runner.os == 'Windows' | ||
shell: pwsh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Poetry Install | ||
description: Run `poetry install` with optional artifact and metadata caching | ||
|
||
inputs: | ||
args: | ||
description: Arguments for `poetry install` | ||
cache: | ||
description: Enable transparent Poetry artifact and metadata caching | ||
default: 'true' | ||
path: | ||
description: Path to Poetry project | ||
default: '.' | ||
|
||
outputs: | ||
cache-hit: | ||
description: Whether an exact cache hit occured | ||
value: ${{ steps.cache.outputs.cache-hit }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- run: printf 'cache-dir=%s\n' "$(poetry config cache-dir)" >> $GITHUB_OUTPUT | ||
id: poetry-config | ||
shell: bash | ||
|
||
# Bust the cache every 24 hours to prevent it from expanding over time. | ||
- run: printf 'date=%s\n' "$(date -I)" >> $GITHUB_OUTPUT | ||
id: get-date | ||
if: inputs.cache == 'true' | ||
shell: bash | ||
|
||
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4 | ||
id: cache | ||
if: inputs.cache == 'true' | ||
with: | ||
path: | | ||
${{ steps.poetry-config.outputs.cache-dir }}/artifacts | ||
${{ steps.poetry-config.outputs.cache-dir }}/cache | ||
key: poetry-${{ steps.get-date.outputs.date }}-${{ runner.os }}-${{ hashFiles(format('{0}/pyproject.toml', inputs.path), format('{0}/poetry.lock', inputs.path)) }} | ||
# The cache is cross-platform, and other platforms are used to seed cache misses. | ||
restore-keys: | | ||
poetry-${{ steps.get-date.outputs.date }}-${{ runner.os }}- | ||
poetry-${{ steps.get-date.outputs.date }}- | ||
enableCrossOsArchive: true | ||
|
||
- run: poetry install ${{ inputs.args }} | ||
working-directory: ${{ inputs.path }} | ||
shell: bash | ||
|
||
- run: poetry env info | ||
working-directory: ${{ inputs.path }} | ||
shell: bash | ||
|
||
- run: poetry show | ||
working-directory: ${{ inputs.path }} | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Reusable workflow consumed by tests.yaml; used to share a single matrix across jobs. | ||
on: | ||
workflow_call: | ||
inputs: | ||
runner: | ||
required: true | ||
type: string | ||
python-version: | ||
required: true | ||
type: string | ||
run-mypy: | ||
required: true | ||
type: boolean | ||
run-pytest: | ||
required: true | ||
type: boolean | ||
run-pytest-poetry: | ||
required: true | ||
type: boolean | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
mypy: | ||
name: mypy | ||
runs-on: ${{ inputs.runner }} | ||
if: inputs.run-mypy | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
|
||
- uses: ./.github/actions/bootstrap-poetry | ||
id: bootstrap-poetry | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- uses: ./.github/actions/poetry-install | ||
|
||
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4 | ||
with: | ||
path: .mypy_cache | ||
key: mypy-${{ runner.os }}-py${{ steps.bootstrap-poetry.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'poetry.lock') }} | ||
restore-keys: | | ||
mypy-${{ runner.os }}-py${{ steps.bootstrap-poetry.outputs.python-version }}- | ||
mypy-${{ runner.os }}- | ||
|
||
- run: poetry run mypy | ||
|
||
pytest: | ||
name: pytest | ||
runs-on: ${{ inputs.runner }} | ||
if: inputs.run-pytest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
|
||
- uses: ./.github/actions/bootstrap-poetry | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- uses: ./.github/actions/poetry-install | ||
with: | ||
args: --with github-actions | ||
|
||
- run: poetry run pytest --integration -v | ||
|
||
- run: git diff --exit-code --stat HEAD | ||
|
||
pytest-poetry: | ||
name: pytest (Poetry) | ||
runs-on: ${{ inputs.runner }} | ||
# FIXME: make Poetry tests pass with PyPy | ||
if: inputs.run-pytest-poetry && !startsWith(inputs.python-version, 'pypy') | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
with: | ||
path: poetry-core | ||
|
||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
with: | ||
path: poetry | ||
repository: python-poetry/poetry | ||
|
||
- uses: ./poetry-core/.github/actions/bootstrap-poetry | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- uses: ./poetry-core/.github/actions/poetry-install | ||
with: | ||
path: ./poetry | ||
|
||
- run: poetry add ../poetry-core | ||
working-directory: ./poetry | ||
|
||
- run: poetry run pytest -v | ||
working-directory: ./poetry |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: Tests | ||
|
||
on: | ||
merge_group: | ||
pull_request: | ||
push: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
env: | ||
PYTHONWARNDEFAULTENCODING: 'true' | ||
|
||
jobs: | ||
changes: | ||
name: Detect changed files | ||
runs-on: ubuntu-latest | ||
outputs: | ||
project: ${{ steps.changes.outputs.project }} | ||
src: ${{ steps.changes.outputs.src }} | ||
tests: ${{ steps.changes.outputs.tests }} | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
|
||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3 | ||
id: changes | ||
with: | ||
filters: | | ||
workflow: &workflow | ||
- '.github/actions/**' | ||
- '.github/workflows/tests.yaml' | ||
- '.github/workflows/.tests-matrix.yaml' | ||
project: &project | ||
- *workflow | ||
- 'poetry.lock' | ||
- 'pyproject.toml' | ||
src: | ||
- *project | ||
- 'src/**/*.py' | ||
tests: | ||
- *project | ||
- 'src/**/*.py' | ||
- 'tests/**' | ||
|
||
lockfile: | ||
name: Check poetry.lock | ||
runs-on: ubuntu-latest | ||
if: needs.changes.outputs.project == 'true' | ||
needs: changes | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
|
||
- uses: ./.github/actions/bootstrap-poetry | ||
|
||
- run: poetry check --lock | ||
|
||
tests-matrix: | ||
# Use this matrix with multiple jobs defined in a reusable workflow: | ||
uses: ./.github/workflows/.tests-matrix.yaml | ||
name: ${{ matrix.os.name }} (Python ${{ matrix.python-version }}) | ||
if: '!failure() && !cancelled()' | ||
needs: | ||
- lockfile | ||
- changes | ||
with: | ||
runner: ${{ matrix.os.image }} | ||
python-version: ${{ matrix.python-version }} | ||
run-mypy: ${{ needs.changes.outputs.src == 'true' }} | ||
run-pytest: ${{ needs.changes.outputs.tests == 'true' }} | ||
run-pytest-poetry: ${{ needs.changes.outputs.src == 'true' }} | ||
secrets: inherit | ||
strategy: | ||
matrix: | ||
os: | ||
- name: Ubuntu | ||
image: ubuntu-22.04 | ||
- name: macOS | ||
image: macos-13 | ||
- name: Windows | ||
image: windows-2022 | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
include: | ||
- os: {name: Ubuntu, image: ubuntu-22.04} | ||
python-version: pypy3.9 | ||
- os: {name: Ubuntu, image: ubuntu-22.04} | ||
python-version: pypy3.10 | ||
fail-fast: false | ||
|
||
status: | ||
name: Status | ||
runs-on: ubuntu-latest | ||
if: '!cancelled()' | ||
needs: | ||
- lockfile | ||
- tests-matrix | ||
steps: | ||
- run: ${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && 'false' || 'true' }} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See python-poetry/poetry#9317