From 836c72fe19f1f73f8a4c67afa808878f9ecb022e Mon Sep 17 00:00:00 2001 From: Mystic <215104920@qq.com> Date: Mon, 30 Sep 2024 19:03:05 +0800 Subject: [PATCH] ci(py): split lint and test jobs across platforms --- .../.github/workflows/ci.yml | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/template/py/{{cookiecutter.project_slug}}/.github/workflows/ci.yml b/template/py/{{cookiecutter.project_slug}}/.github/workflows/ci.yml index 82de046..5f63186 100644 --- a/template/py/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +++ b/template/py/{{cookiecutter.project_slug}}/.github/workflows/ci.yml @@ -7,43 +7,45 @@ on: pull_request: workflow_dispatch: -{% raw %} jobs: - build-and-test: - name: python-${{ matrix.os }} + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up UV Environment + uses: astral-sh/setup-uv@v3 + with: + version: "latest" + + - name: Format Code + run: uvx ruff format --diff . + + - name: Lint Code + run: uvx ruff check . + build-and-test: + runs-on: {{ "${{ matrix.os }}" }} strategy: matrix: - os: - - ubuntu-latest - - windows-latest - - macos-latest - + os: [ubuntu-latest, macos-latest, windows-latest] fail-fast: false - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - - name: Set up uv - if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }} - run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Set up UV Environment + uses: astral-sh/setup-uv@v3 + with: + version: "latest" - - name: Set up uv - if: ${{ matrix.os == 'windows-latest' }} - run: irm https://astral.sh/uv/install.ps1 | iex - shell: powershell + - name: Synchronize Dependencies + run: uv sync - - name: Format - run: uvx ruff format --diff . - - - name: Lint - run: uvx ruff check . + - name: Build Project + run: uvx hatch build - - name: Build & Test - run: | - uv sync - uvx hatch build - uvx hatch test -{% endraw -%} + - name: Run Tests + run: uvx hatch test