Add rye and ruff, and local dependency for CI and development #589
Workflow file for this run
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
name: CI | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '**' | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
jobs: | |
lint: | |
if: github.event.pull_request.draft != true | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install the latest version of rye | |
uses: eifinger/setup-rye@v2 | |
- run: make install | |
- run: make lint | |
- run: npm install | |
- uses: pre-commit/action@v3.0.1 | |
with: | |
extra_args: --all-files | |
env: | |
SKIP: no-commit-to-branch | |
docs-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
# note: PPPR_TOKEN is not available on PRs sourced from forks, but the necessary | |
# dependencies are also listed in docs.txt :) | |
- name: install | |
run: | | |
pip install --upgrade pip | |
pip install --extra-index-url https://pydantic:${PPPR_TOKEN}@pppr.pydantic.dev/simple/ mkdocs-material mkdocstrings-python | |
pip install -r requirements/docs.txt | |
# note -- we can use these in the future when mkdocstrings-typescript and griffe-typedoc beocome publicly available | |
# pip install --extra-index-url https://pydantic:${PPPR_TOKEN}@pppr.pydantic.dev/simple/ mkdocs-material mkdocstrings-python griffe-typedoc mkdocstrings-typescript | |
# npm install | |
# npm install -g typedoc | |
env: | |
PPPR_TOKEN: ${{ secrets.PPPR_TOKEN }} | |
- name: build site | |
run: mkdocs build --strict | |
test: | |
name: test ${{ matrix.python-version }} on ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-13, macos-latest] | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
exclude: | |
# Python 3.8 and 3.9 are not available on macOS 14 | |
- os: macos-13 | |
python-version: '3.10' | |
- os: macos-13 | |
python-version: '3.11' | |
- os: macos-13 | |
python-version: '3.12' | |
- os: macos-latest | |
python-version: '3.8' | |
- os: macos-latest | |
python-version: '3.9' | |
if: github.event.pull_request.draft != true | |
runs-on: ${{ matrix.os }} | |
env: | |
PYTHON: ${{ matrix.python-version }} | |
OS: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install the latest version of rye | |
uses: eifinger/setup-rye@v2 | |
- name: Pin python-version ${{ matrix.python-version }} | |
run: rye pin ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: make install | |
- name: Run test, with generating coverage on FastUI source | |
run: make testcov | |
- name: Run cov report generator | |
run: make testcov-report | |
- name: Run type check on FastUI source | |
run: make typecheck | |
# ci on demo for 3.11 and 3.12, these ops are intentionally omitted, reason is that it's using 3.11 and 3.12 syntax | |
- if: matrix.python-version == '3.11' || matrix.python-version == '3.12' | |
run: make lint-demo | |
- if: matrix.python-version == '3.11' || matrix.python-version == '3.12' | |
run: make typecheck-demo | |
- if: matrix.python-version == '3.11' || matrix.python-version == '3.12' | |
run: make test-demo | |
- name: Run XML coverage report generator | |
run: make testcov-xml | |
- name: Upload coverage report from XML | |
uses: codecov/codecov-action@v4 | |
with: | |
file: ./src/python-fastui/coverage.xml | |
env_vars: PYTHON,OS | |
npm-build: | |
if: github.event.pull_request.draft != true | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- run: npm install | |
- run: npm run build | |
- run: tree src | |
check: # This job does nothing and is only used for the branch protection | |
if: github.event.pull_request.draft != true | |
needs: [lint, test, npm-build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@release/v1 | |
id: all-green | |
with: | |
jobs: ${{ toJSON(needs) }} | |
release: | |
needs: [check] | |
if: "success() && startsWith(github.ref, 'refs/tags/') && github.event.pull_request.draft != true" | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- run: pip install -U build | |
- id: check-version | |
uses: samuelcolvin/check-python-version@v4.1 | |
with: | |
version_file_path: 'src/python-fastui/fastui/__init__.py' | |
- run: python -m build --outdir dist src/python-fastui | |
- run: ls -lh dist | |
- uses: pypa/gh-action-pypi-publish@release/v1 |