-
Notifications
You must be signed in to change notification settings - Fork 4
👷 Add setup to run tests on CI #6
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
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b9cc0e7
🔨 Add tests and lint scripts
tiangolo d69cb04
👷 Add CI for tests
tiangolo a4bdf88
👷 Add CI for Smokeshow
tiangolo 71688f4
➕ Include Smokeshow in development dependencies
tiangolo 2253b9b
🔧 Tweak smokeshow config
tiangolo 0c2f90c
👷 Add CI for test-redistribute
tiangolo b6b11a0
👷 Tweak CI for tests
tiangolo 7904e9c
🔨 Tweak script
tiangolo 3b23888
🎨 Format
tiangolo 90f8aae
🔧 Include test files in source distribution
tiangolo 15863db
👷 Update tests for redistribution
tiangolo 4ae1f98
🔧 Tweak config
tiangolo bd66ed1
🐛 Debug with tmate
tiangolo 51bc3ad
🔧 Tweak coverage config and Python version
tiangolo 5f2223f
👷 Run tmate only on debug
tiangolo 936f2bc
➖ Remove uv.lock as it's now installed with pip
tiangolo 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 contains hidden or 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,62 @@ | ||
| name: Smokeshow | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: | ||
| - Test | ||
| types: | ||
| - completed | ||
|
|
||
| permissions: | ||
| statuses: write | ||
|
|
||
| env: | ||
| UV_SYSTEM_PYTHON: 1 | ||
|
|
||
| jobs: | ||
| smokeshow: | ||
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Dump GitHub context | ||
| env: | ||
| GITHUB_CONTEXT: ${{ toJson(github) }} | ||
| run: echo "$GITHUB_CONTEXT" | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.9' | ||
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| version: "0.4.15" | ||
| enable-cache: true | ||
| cache-dependency-glob: | | ||
| requirements**.txt | ||
| pyproject.toml | ||
| - run: uv pip install -r requirements-tests.txt | ||
| - uses: actions/download-artifact@v5 | ||
| with: | ||
| name: coverage-html | ||
| path: htmlcov | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| # Try 5 times to upload coverage to smokeshow | ||
| - name: Upload coverage to Smokeshow | ||
| run: | | ||
| for i in 1 2 3 4 5; do | ||
| if smokeshow upload htmlcov; then | ||
| echo "Smokeshow upload success!" | ||
| break | ||
| fi | ||
| echo "Smokeshow upload error, sleep 1 sec and try again." | ||
| sleep 1 | ||
| done | ||
| env: | ||
| SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage} | ||
| SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 100 | ||
| SMOKESHOW_GITHUB_CONTEXT: coverage | ||
| SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} | ||
| SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }} |
This file contains hidden or 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,59 @@ | ||
| name: Test Redistribute | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| types: | ||
| - opened | ||
| - synchronize | ||
|
|
||
| env: | ||
| UV_SYSTEM_PYTHON: 1 | ||
|
|
||
| jobs: | ||
| test-redistribute: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Dump GitHub context | ||
| env: | ||
| GITHUB_CONTEXT: ${{ toJson(github) }} | ||
| run: echo "$GITHUB_CONTEXT" | ||
| - uses: actions/checkout@v5 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.10" | ||
| - name: Install build dependencies | ||
| run: pip install build | ||
| - name: Build source distribution | ||
| run: python -m build --sdist | ||
| - name: Decompress source distribution | ||
| run: | | ||
| cd dist | ||
| tar xvf annotated_doc*.tar.gz | ||
| - name: Install test dependencies | ||
| run: | | ||
| cd dist/annotated_doc*/ | ||
| pip install -r requirements-tests.txt | ||
| - name: Run source distribution tests | ||
| run: | | ||
| cd dist/annotated_doc*/ | ||
| bash scripts/test.sh | ||
| - name: Build wheel distribution | ||
| run: | | ||
| cd dist | ||
| pip wheel --no-deps annotated_doc*.tar.gz | ||
|
|
||
| # https://github.com/marketplace/actions/alls-green#why | ||
| test-redistribute-alls-green: # This job does nothing and is only used for the branch protection | ||
| if: always() | ||
| needs: | ||
| - test-redistribute | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Decide whether the needed jobs succeeded or failed | ||
| uses: re-actors/alls-green@release/v1 | ||
| with: | ||
| jobs: ${{ toJSON(needs) }} |
This file contains hidden or 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,140 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| types: | ||
| - opened | ||
| - synchronize | ||
| workflow_dispatch: | ||
| inputs: | ||
| debug_enabled: | ||
| description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' | ||
| required: false | ||
| default: 'false' | ||
| schedule: | ||
| # cron every week on monday | ||
| - cron: "0 0 * * 1" | ||
|
|
||
| env: | ||
| UV_SYSTEM_PYTHON: 1 | ||
|
|
||
| jobs: | ||
| test: | ||
| strategy: | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
| - windows-latest | ||
| - macos-latest | ||
| python-version: | ||
| - "3.14" | ||
| include: | ||
| - os: macos-latest | ||
| python-version: "3.8" | ||
| - os: windows-latest | ||
| python-version: "3.9" | ||
| - os: ubuntu-latest | ||
| python-version: "3.10" | ||
| - os: macos-latest | ||
| python-version: "3.11" | ||
| - os: windows-latest | ||
| python-version: "3.12" | ||
| - os: ubuntu-latest | ||
| python-version: "3.13" | ||
| - os: macos-latest | ||
| python-version: "3.13" | ||
| fail-fast: false | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| 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 | ||
| - name: Install Dependencies | ||
| run: uv pip install -r requirements-tests.txt | ||
| - name: Lint | ||
| run: bash scripts/lint.sh | ||
| - run: mkdir coverage | ||
| - name: Test | ||
| run: bash scripts/test.sh | ||
| env: | ||
| COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} | ||
| CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} | ||
| - name: Store coverage files | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: coverage-${{ runner.os }}-${{ matrix.python-version }} | ||
| path: coverage | ||
| include-hidden-files: true | ||
|
|
||
| coverage-combine: | ||
| needs: | ||
| - test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.13' | ||
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| version: "0.4.15" | ||
| enable-cache: true | ||
| cache-dependency-glob: | | ||
| requirements**.txt | ||
| pyproject.toml | ||
| - name: Get coverage files | ||
| uses: actions/download-artifact@v5 | ||
| with: | ||
| pattern: coverage-* | ||
| path: coverage | ||
| merge-multiple: true | ||
| # 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 | ||
| - name: Install Dependencies | ||
| 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: | ||
| name: coverage-html | ||
| path: htmlcov | ||
| include-hidden-files: true | ||
|
|
||
| # https://github.com/marketplace/actions/alls-green#why | ||
| alls-green: # This job does nothing and is only used for the branch protection | ||
| if: always() | ||
| needs: | ||
| - coverage-combine | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Decide whether the needed jobs succeeded or failed | ||
| uses: re-actors/alls-green@release/v1 | ||
| with: | ||
| jobs: ${{ toJSON(needs) }} |
This file contains hidden or 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
This file contains hidden or 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,7 @@ | ||
| -e . | ||
|
|
||
| pytest >=8.3.5 | ||
| coverage[toml] >=7.6.1 | ||
| mypy ==1.14.1 | ||
| ruff ==0.14.1 | ||
| smokeshow >=0.5.0 |
This file contains hidden or 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,8 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
| set -x | ||
|
|
||
| coverage combine | ||
| coverage report | ||
| coverage html |
This file contains hidden or 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,5 @@ | ||
| #!/usr/bin/env bash | ||
| set -x | ||
|
|
||
| ruff check src tests scripts --fix | ||
| ruff format src tests scripts |
This file contains hidden or 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,8 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
| set -x | ||
|
|
||
| mypy src | ||
| ruff check src tests scripts | ||
| ruff format src tests --check |
This file contains hidden or 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,7 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
| set -x | ||
|
|
||
| bash scripts/test.sh ${@} | ||
| bash scripts/coverage.sh |
This file contains hidden or 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,6 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
| set -x | ||
|
|
||
| coverage run -m pytest tests ${@} |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.