Skip to content
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: Speed up runs #393

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
60 changes: 45 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,59 @@ jobs:
run: uv run slotscheck -m advanced_alchemy.config -m advanced_alchemy.repository -m advanced_alchemy.service -m advanced_alchemy.extensions -m advanced_alchemy.base -m advanced_alchemy.types -m advanced_alchemy.operations

test:
name: "test (${{ matrix.python-version }}"
name: "${{ matrix.python-version }} [${{ matrix.pytest-select }}]"
strategy:
fail-fast: true
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
pytest-select:
- "not oracle and not pg"
- "pg"
- "oracle"
uses: ./.github/workflows/test.yml
with:
coverage: ${{ matrix.python-version == '3.13' }}
coverage: ${{ matrix.python-version == '3.13'}}
python-version: ${{ matrix.python-version }}
pytest-select: ${{ matrix.pytest-select }}
process_coverage:
name: merge-coverage-files
runs-on: ubuntu-latest
needs: test
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Set up Python
run: uv python install 3.13

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: coverage
pattern: coverage-xml*
merge-multiple: true

- name: Combine coverage files
run: |
uv venv
uv pip install coverage covdefaults
uv run python -m coverage combine coverage/
uv run python -m coverage xml -i

- name: Fix coverage file name
run: sed -i "s/home\/runner\/work\/advanced-alchemy\/advanced-alchemy/github\/workspace/g" coverage.xml

- name: Upload fixed coverage file
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
sonar:
needs:
- test
- validate
- process_coverage
if: github.event.pull_request.head.repo.fork == false && github.repository_owner == 'litestar-org'
runs-on: ubuntu-latest
steps:
Expand All @@ -125,8 +165,7 @@ jobs:

codecov:
needs:
- test
- validate
- process_coverage
runs-on: ubuntu-latest
permissions:
security-events: write
Expand All @@ -143,15 +182,6 @@ jobs:
path: coverage.xml
merge-multiple: true

# - name: Combine coverage files
# run: |
# python -Im pip install coverage covdefaults
# python -Im coverage combine
# python -Im coverage xml -i

# - name: Fix coverage file name
# run: sed -i "s/home\/runner\/work\/advanced-alchemy\/advanced-alchemy/github\/workspace/g" coverage.xml

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ on:
required: false
type: number
default: 60
pytest-select:
required: true
type: string

jobs:
test:
Expand Down Expand Up @@ -61,14 +64,25 @@ jobs:

- name: Test
if: ${{ !inputs.coverage }}
run: uv run pytest --dist "loadgroup" -m "" tests -n 2
run: uv run pytest --dist "loadgroup" -m "" -k "${{ inputs.pytest-select }}" tests -n 2

- name: Test with coverage
if: ${{ inputs.coverage }}
run: uv run pytest tests --dist "loadgroup" -m "" --cov=advanced_alchemy --cov-report=xml -n 2
run: uv run pytest tests --dist "loadgroup" -m "" --cov=advanced_alchemy -k "${{ inputs.pytest-select }}" --cov-report=xml -n 2

- uses: rlespinasse/[email protected]
id: slugify-value
if: ${{ inputs.coverage }}
with:
key: pytest_select_slug
value: ${{ inputs.pytest-select }}

- name: Rename coverage file
if: ${{ inputs.coverage }}
run: mv coverage.xml coverage-${{ steps.slugify-value.outputs.slug }}.xml

- uses: actions/upload-artifact@v4
if: ${{ inputs.coverage }}
with:
name: coverage-xml
path: coverage.xml
name: coverage-xml-${{ steps.slugify-value.outputs.slug }}
path: coverage-${{ steps.slugify-value.outputs.slug }}.xml
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
- id: unasyncd
additional_dependencies: ["ruff"]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.9.9"
rev: "v0.9.10"
hooks:
# Run the linter.
- id: ruff
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ dev = [
{ include-group = "spanner" },
{ include-group = "cockroachdb" },
{ include-group = "postgres" },
"pytest-cdist>=0.3.1",
]
doc = [
"auto-pytabs[sphinx]>=0.5.0",
Expand Down
62 changes: 38 additions & 24 deletions uv.lock

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

Loading