forked from python-poetry/poetry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci/tests: DRY matrix with reusable workflow
- Loading branch information
1 parent
1c6c1d9
commit eb78cdd
Showing
2 changed files
with
125 additions
and
112 deletions.
There are no files selected for viewing
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,111 @@ | ||
# Reusable workflow consumed by tests.yaml; used to share a single matrix across jobs. | ||
name: .tests | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
os-name: | ||
required: true | ||
type: string | ||
os-image: | ||
required: true | ||
type: string | ||
python-version: | ||
required: true | ||
type: string | ||
run-mypy: | ||
required: true | ||
type: boolean | ||
run-pytest: | ||
required: true | ||
type: boolean | ||
run-pytest-export: | ||
required: true | ||
type: boolean | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
mypy: | ||
name: mypy | ||
runs-on: ${{ inputs.os-image }} | ||
if: inputs.run-mypy | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/bootstrap-poetry | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- run: poetry install --sync | ||
|
||
- run: poetry env info | ||
|
||
- run: poetry show | ||
|
||
- uses: actions/cache@v4 | ||
with: | ||
path: .mypy_cache | ||
key: mypy-${{ inputs.os-image }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'poetry.lock') }} | ||
restore-keys: | | ||
mypy-${{ inputs.os-image }}-${{ env.pythonLocation }}- | ||
mypy-${{ inputs.os-image }}- | ||
- run: poetry run mypy | ||
|
||
pytest: | ||
name: pytest | ||
runs-on: ${{ inputs.os-image }} | ||
if: inputs.run-pytest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/bootstrap-poetry | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- run: poetry install --sync --with github-actions | ||
|
||
- run: poetry env info | ||
|
||
- run: poetry show | ||
|
||
- run: poetry run pytest --integration -v | ||
env: | ||
POETRY_TEST_INTEGRATION_GIT_USERNAME: ${{ github.actor }} | ||
POETRY_TEST_INTEGRATION_GIT_PASSWORD: ${{ github.token }} | ||
|
||
- run: git diff --exit-code --stat HEAD | ||
|
||
pytest-export: | ||
name: pytest (poetry-plugin-export) | ||
runs-on: ${{ inputs.os-image }} | ||
if: inputs.run-pytest-export | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/bootstrap-poetry | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- run: poetry install --sync --with github-actions | ||
|
||
- run: poetry env info | ||
|
||
- run: poetry show | ||
|
||
- id: poetry-plugin-export | ||
run: echo version=$(poetry run pip list --format json | jq -r '.[] | select(.name == "poetry-plugin-export").version') >> $GITHUB_OUTPUT | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
path: poetry-plugin-export | ||
repository: python-poetry/poetry-plugin-export | ||
ref: refs/tags/${{ steps.poetry-plugin-export.outputs.version }} | ||
|
||
- run: poetry run -C .. pytest -v | ||
working-directory: ./poetry-plugin-export | ||
|
||
- run: git -C poetry-plugin-export diff --exit-code --stat HEAD |
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