dev: switch to uv and update ci #737
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
| name: CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: ["main", "dev-*"] | |
| pull_request: | |
| release: | |
| types: [published] | |
| jobs: | |
| test: | |
| name: "Test" | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # Checks based on python versions --- | |
| python-version: ["3.9", "3.10"] | |
| requirements: [""] | |
| include: | |
| - name: "pydantic v1" | |
| requirements: "pydantic<2.0.0" | |
| python-version: "3.10" | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python ${{ matrix.python-version }} | |
| run: uv python install ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| # include requirements if specified | |
| if [ -n "$REQUIREMENTS" ]; then | |
| uv sync --group dev | |
| uv pip install $REQUIREMENTS | |
| else | |
| uv sync --group dev | |
| fi | |
| env: | |
| REQUIREMENTS: ${{ matrix.requirements }} | |
| - name: Run tests | |
| run: | | |
| uv run pytest --cov | |
| - name: Upload results to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| pre-commit: | |
| name: "pre-commit checks" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python 3.10 | |
| run: uv python install 3.10 | |
| - name: Install dependencies | |
| run: uv sync --group dev | |
| - uses: pre-commit/[email protected] | |
| release-pypi: | |
| name: "Release to pypi" | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' | |
| needs: [test] | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - uses: actions/setup-python@v2 | |
| with: | |
| python-version: "3.10" | |
| - name: "Build Package" | |
| run: | | |
| python -m pip install build wheel | |
| python -m build --sdist --wheel | |
| - name: "Deploy to Test PyPI" | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| build-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python 3.10 | |
| run: uv python install 3.10 | |
| - name: Install dependencies | |
| run: | | |
| uv sync --group dev | |
| # TODO: temporary installs for examples | |
| # once quartodoc is stable we should move into their own libraries | |
| uv pip install shiny shinylive | |
| uv pip install --no-deps dascore==0.0.8 | |
| - uses: quarto-dev/quarto-actions/setup@v2 | |
| - name: Test building starter template | |
| run: | | |
| make test-overview-template | |
| - name: Build docs | |
| run: | | |
| make docs-build | |
| # push to netlify ------------------------------------------------------- | |
| # set release name ---- | |
| - name: Configure pull release name | |
| if: ${{github.event_name == 'pull_request'}} | |
| run: | | |
| echo "RELEASE_NAME=pr-${PR_NUMBER}" >> $GITHUB_ENV | |
| env: | |
| PR_NUMBER: ${{ github.event.number }} | |
| - name: Configure branch release name | |
| if: ${{github.event_name != 'pull_request'}} | |
| run: | | |
| # use branch name, but replace slashes. E.g. feat/a -> feat-a | |
| echo "RELEASE_NAME=${GITHUB_REF_NAME/\//-}" >> $GITHUB_ENV | |
| # deploy ---- | |
| - name: Create Github Deployment | |
| uses: bobheadxi/[email protected] | |
| id: deployment | |
| with: | |
| step: start | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| env: ${{ env.RELEASE_NAME }} | |
| ref: ${{ github.head_ref }} | |
| transient: true | |
| logs: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| - name: Netlify docs preview | |
| run: | | |
| npm install -g netlify-cli | |
| # push main branch to production, others to preview -- | |
| if [ "${ALIAS}" == "main" ]; then | |
| netlify deploy --dir=docs/_build --alias="main" | |
| else | |
| netlify deploy --dir=docs/_build --alias="${ALIAS}" | |
| fi | |
| env: | |
| NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| ALIAS: ${{ steps.deployment.outputs.env }} | |
| - name: Update Github Deployment | |
| uses: bobheadxi/[email protected] | |
| if: ${{ always() }} | |
| with: | |
| step: finish | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| status: ${{ job.status }} | |
| deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
| env_url: "https://${{ steps.deployment.outputs.env }}--quartodoc.netlify.app" | |
| logs: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| - uses: peaceiris/actions-gh-pages@v3 | |
| if: github.event_name == 'release' | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: docs/_build |