Skip to content

Commit

Permalink
👷 Use uv in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo committed Oct 12, 2024
1 parent b672b20 commit e6575c3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/smokeshow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
permissions:
statuses: write

env:
UV_SYSTEM_PYTHON: 1

jobs:
smokeshow:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
Expand All @@ -17,16 +20,21 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.9'

- run: pip install smokeshow

- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.15"
enable-cache: true
cache-dependency-glob: |
requirements**.txt
pyproject.toml
- run: uv pip install -r requirements-github-actions.txt
- uses: actions/download-artifact@v4
with:
name: coverage-html
path: htmlcov
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

- run: smokeshow upload htmlcov
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
Expand Down
35 changes: 21 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ on:
# # cron every week on monday
# - cron: "0 1 * * 1"

env:
UV_SYSTEM_PYTHON: 1

jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -34,20 +37,22 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.15"
enable-cache: true
cache-dependency-glob: |
requirements**.txt
pyproject.toml
# Allow debugging with tmate
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
with:
limit-access-to-actor: true
- uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-v01
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-tests.txt
run: uv pip install -r requirements-tests.txt
# - name: Lint
# # Do not run on Python 3.7 as mypy behaves differently
# if: matrix.python-version != '3.7'
Expand All @@ -69,28 +74,30 @@ jobs:
needs:
- test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.15"
enable-cache: true
cache-dependency-glob: |
requirements**.txt
pyproject.toml
- name: Get coverage files
uses: actions/download-artifact@v4
with:
pattern: coverage-*
path: coverage
merge-multiple: true

- run: pip install coverage[toml]

- run: uv pip install -r requirements-tests.txt
- run: ls -la coverage
- run: coverage combine coverage
- run: coverage report
- run: coverage html --title "Coverage for ${{ github.sha }}"

- name: Store coverage HTML
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions requirements-github-actions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
smokeshow

0 comments on commit e6575c3

Please sign in to comment.