Switch root tests to uv #1346
Workflow file for this run
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: Test | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| defaults: | |
| run: | |
| # to fail on error in multiline statements (-e), in pipes (-o pipefail), and on unset variables (-u). | |
| shell: bash -euo pipefail {0} | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python: ["3.10", "3.13"] | |
| os: [ubuntu-latest] | |
| # one that matches "project-name".lower().replace('-', '_'), one that doesn’t: | |
| package-name: [project_name, package_alt] | |
| env: | |
| PROJECT_ROOT: project-name | |
| steps: | |
| # Setup | |
| - uses: actions/checkout@v4 | |
| - name: Set git identity | |
| run: | | |
| git config --global user.name "scverse-bot" | |
| git config --global user.email "108668866+scverse-bot@users.noreply.github.com" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| cache-dependency-glob: "{{cookiecutter.project_name}}/pyproject.toml" | |
| - name: Install Ubuntu system dependencies | |
| if: matrix.os == 'ubuntu-latest' | |
| run: sudo apt-get install pandoc | |
| # Build | |
| - name: Build from template | |
| run: | | |
| uvx --with pre-commit cruft create . --no-input --extra-context '{"package_name": "${{ matrix.package-name }}"}' | |
| # Check | |
| - name: Set up pre-commit cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: pre-commit-3|${{ matrix.python }}|${{ hashFiles(format('{0}/.pre-commit-config.yaml', env.PROJECT_ROOT)) }} | |
| - name: Run pre-commit | |
| run: | | |
| cd "$PROJECT_ROOT" | |
| git add . | |
| uvx pre-commit run --verbose --color=always --show-diff-on-failure --all-files | |
| - name: Install the package and check if it can be imported | |
| run: | | |
| cd "$PROJECT_ROOT" | |
| uv run python -c "import ${{ matrix.package-name }}" | |
| # Docs | |
| - name: Build the documentation | |
| run: | | |
| cd "$PROJECT_ROOT" | |
| uvx hatch run docs:build -W | |
| test-scripts: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set git identity | |
| run: | | |
| git config --global user.name "scverse-bot" | |
| git config --global user.email "108668866+scverse-bot@users.noreply.github.com" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| cache-dependency-glob: pyproject.toml | |
| - name: set git default branch | |
| run: git config --global init.defaultBranch main | |
| - name: Run tests | |
| env: | |
| SCVERSE_BOT_READONLY_GITHUB_TOKEN: ${{ secrets.SCVERSE_BOT_READONLY_GITHUB_TOKEN }} | |
| working-directory: ./scripts | |
| run: uvx hatch test |