Skip to content

Cicd combined

Cicd combined #6

Workflow file for this run

# SPDX-License-Identifier: Apache-2.0
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
pre-commit:
name: Pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
# Run the exact same hooks as the local pre-commit stage (ruff, toml/yaml
# validity, link/import validation, SPDX headers, whitespace/EOF, uv-lock,
# nbstripout, ...) so CI and pre-commit can never drift. `uv` must be on
# PATH for the uv-lock hook.
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Cache pre-commit hook environments
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit hooks
run: uvx pre-commit run --all-files --show-diff-on-failure --color=always
test-cpu:
name: CPU Tests (Python ${{ matrix.python-version }})
needs: pre-commit
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- run: uv sync --frozen --group dev --extra hf --extra compose
- name: Run CPU tests
run: |
# Exclude tests that download/compose real models (requires_model),
# need CUDA (gpu), hit the network / take long (slow), or are the
# expensive code-theory suite (deep). Those run on the GPU cluster,
# not on GitHub-hosted runners, which lack the RAM/disk/time.
# tests/composer/ is also excluded here: even filtered, its suite is
# heavy enough that GitHub-hosted runners get killed mid-run. It runs
# on the GPU cluster instead.
uv run pytest tests/unit/ tests/hf/ \
-m "not requires_model and not gpu and not slow and not deep" \
-v -s --tb=short -x \
--cov=granite_switch --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
fail_ci_if_error: false