-
-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
105 additions
and
36 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 |
---|---|---|
|
@@ -11,88 +11,127 @@ concurrency: | |
|
||
jobs: | ||
check-manifest: | ||
if: github.event_name != 'schedule' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: pipx run check-manifest | ||
|
||
pre-commit: | ||
if: github.event_name != 'schedule' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
python-version-file: .python-version-default | ||
- uses: pre-commit/[email protected] | ||
|
||
typing: | ||
if: github.event_name != 'schedule' | ||
install-dev: | ||
name: Verify dev env | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
- name: install | ||
python-version-file: .python-version-default | ||
cache: pip | ||
|
||
- name: Install in dev mode & import | ||
run: | | ||
python -m pip install -U pip | ||
python -m pip install -e ".[test]" | ||
python -Im pip install -e .[dev] | ||
python -Ic 'import subliminal; print(subliminal.__version__)' | ||
typing: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: .python-version-default | ||
- name: Install tox-uv | ||
run: python -Im pip install tox-uv | ||
- name: type-check | ||
run: | | ||
mypy --install-types --non-interactive --config-file pyproject.toml subliminal tests | ||
run: python -Im tox run -e mypy | ||
|
||
docs: | ||
if: github.event_name != 'schedule' | ||
name: Build docs and run doctests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
- run: | | ||
python -m venv venv | ||
source ./venv/bin/activate | ||
python -m pip install -e .[docs] | ||
sphinx-build -b html docs/ docs/_build | ||
# Keep in sync with tox/docs and .readthedocs.yaml. | ||
python-version: "3.12" | ||
cache: pip | ||
|
||
- name: Install tox-uv | ||
run: python -Im pip install tox-uv | ||
- name: Build docs | ||
run: python -Im tox run -e docs,changelog | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: docs | ||
path: docs/_build/ | ||
|
||
build-package: | ||
name: Build & verify package | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: hynek/build-and-inspect-python-package@v2 | ||
id: baipp | ||
|
||
outputs: | ||
# Used to define the matrix for tests below. The value is based on | ||
# packaging metadata (trove classifiers). | ||
supported-python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }} | ||
|
||
test: | ||
name: Test | ||
if: github.event_name != 'schedule' | ||
runs-on: ${{ matrix.os }} | ||
needs: build-package | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
exclude: | ||
# macos-latest only work with arm64 | ||
- os: macos-latest | ||
python-version: ["3.8", "3.9"] | ||
# Created by the build-and-inspect-python-package action above. | ||
python-version: ${{ fromJson(needs.build-package.outputs.supported-python-versions) }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' | ||
allow-prereleases: true | ||
- name: Install tox-uv | ||
run: python -Im pip install tox-uv | ||
- name: install | ||
run: python -Im pip install -e .[test] | ||
|
||
- uses: hynek/setup-cached-uv@v2 | ||
|
||
- name: Prepare tox | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -e .[test] | ||
- name: run pytest --cov | ||
echo TOX_PYTHON=py$(echo ${{ matrix.python-version }} | tr -d .) >>$GITHUB_ENV | ||
- run: >- | ||
uvx --with=tox-uv | ||
tox run | ||
-e ${{ env.TOX_PYTHON }}-coverage | ||
env: | ||
COVERAGE_FILE: ".coverage.${{ matrix.os }}.${{ matrix.python-version }}" | ||
# Alternatively you can run coverage with the --parallel flag or add | ||
# `parallel = True` in the coverage config file. | ||
# If using pytest-cov, you can also add the `--cov-append` flag | ||
# directly or through PYTEST_ADD_OPTS. | ||
run: | | ||
pytest --cov --cov-report=xml | ||
- name: Store coverage file | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
|
@@ -107,10 +146,19 @@ jobs: | |
pull-requests: write | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Download pre-built packages | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: Packages | ||
path: dist | ||
- run: tar -xf dist/*.tar.gz --strip-components=1 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: .python-version-default | ||
- uses: hynek/setup-cached-uv@v2 | ||
|
||
- uses: actions/download-artifact@v4 | ||
id: download | ||
- name: Download coverage data | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: coverage-* | ||
merge-multiple: true | ||
|
@@ -128,3 +176,24 @@ jobs: | |
with: | ||
name: python-coverage-comment-action | ||
path: python-coverage-comment-action.txt | ||
|
||
|
||
# Ensure everything required is passing for branch protection. | ||
required-checks-pass: | ||
if: always() | ||
|
||
needs: | ||
- coverage | ||
- docs | ||
- install-dev | ||
- typing | ||
- pre-commit | ||
- check-manifest | ||
|
||
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 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 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 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