justfile groups in readmes #52
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
| # Workflow to run pre-commit checks and tests against multiple Python versions | |
| # GitHub Action Workflow validator: https://rhysd.github.io/actionlint/ | |
| name: sdk-code-quality | |
| on: | |
| workflow_dispatch: | |
| # To manually trigger the workflow | |
| # https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_dispatch | |
| push: | |
| paths: | |
| # https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet | |
| - sdk/** | |
| branches: | |
| - main | |
| - master | |
| pull_request: | |
| paths: | |
| # https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet | |
| - sdk/** | |
| branches: | |
| - main | |
| - master | |
| types: | |
| # https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request | |
| - ready_for_review | |
| - synchronize | |
| env: | |
| PYTHON_VERSION: "3.13" # pre-commit and pyright don't seem to work well with 3.14 yet | |
| jobs: | |
| # Run pre-commit checks on all files using the project's python version | |
| sdk-pre-commit: | |
| runs-on: ubuntu-latest | |
| env: | |
| UV_LINK_MODE: copy | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # this ubuntu-latest version ships node 18, which was causing issues | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| # https://github.com/marketplace/actions/astral-sh-setup-uv | |
| - name: Install pre-commit | |
| working-directory: ./sdk | |
| run: uv tool install -p ${{ env.PYTHON_VERSION }} pre-commit | |
| - name: Cache pre-commit hooks | |
| id: cache-pre-commit | |
| uses: actions/cache@v4 | |
| # https://github.com/actions/cache/blob/main/examples.md#python---pip | |
| with: | |
| key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | |
| path: ~/.cache/pre-commit/ | |
| - name: Install Python | |
| working-directory: ./sdk | |
| run: uv python install ${{ env.PYTHON_VERSION }} | |
| - name: Install hooks | |
| working-directory: ./sdk | |
| run: uv run -p ${{ env.PYTHON_VERSION }} pre-commit install --install-hooks | |
| - name: Run pre-commit | |
| working-directory: ./sdk | |
| # make sure default_language_version in .pre-commit-config.yaml | |
| # matches the one installed with uv, which is the most recent | |
| # stable python version that meets project requirements. | |
| run: uv run -p ${{ env.PYTHON_VERSION }} pre-commit run --all-files | |
| # Run static analysis with pyright | |
| # - Install the pylance extension for VS Code to have these warnings in the editor | |
| sdk-pyright: | |
| env: | |
| UV_LINK_MODE: copy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Install Python | |
| working-directory: ./sdk | |
| run: uv python install ${{ env.PYTHON_VERSION }} | |
| - name: Install packages | |
| working-directory: ./sdk | |
| run: uv sync -p ${{ env.PYTHON_VERSION }} --frozen --dev | |
| - uses: jakebailey/pyright-action@v2 | |
| # https://github.com/jakebailey/pyright-action#options | |
| with: | |
| pylance-version: latest-release | |
| working-directory: ./sdk | |
| python-path: ./.venv/bin/python | |
| # Run tests against multiple Python versions | |
| sdk-simple-coverage: | |
| runs-on: ${{ matrix.platform }} | |
| env: | |
| UV_LINK_MODE: copy | |
| strategy: | |
| matrix: | |
| # uv will take care of installing other python versions, | |
| # so we don't need a python-version matrix here. | |
| # This is faster, saving some GH action minutes and dev time. | |
| platform: [ubuntu-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install just on ubuntu | |
| if: matrix.platform == 'ubuntu-latest' | |
| working-directory: ./sdk | |
| run: | | |
| npm install -g rust-just | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| # https://github.com/marketplace/actions/astral-sh-setup-uv | |
| - name: Run all tests | |
| working-directory: ./sdk | |
| # the uv commands invoked by just will take care to install compatible | |
| # dependencies for each python version, so we don't need to matrix over | |
| # python versions here. | |
| run: just test-all |