From d431d5453bdbcdd2469d396478adb3a4b1986fa5 Mon Sep 17 00:00:00 2001 From: Yixing Lao Date: Sun, 26 Apr 2026 19:24:03 +0800 Subject: [PATCH] ci(workflows): add ci workflow with linting and unit testing (#18) --- .github/workflows/ci.yml | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3af3b40 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,77 @@ +name: CI + +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + types: [opened, reopened, synchronize] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.10" + + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + version: "0.11.7" + enable-cache: true + + - name: Install dependencies + run: uv sync --extra dev --locked --python 3.10 + + - name: Run pre-commit + run: uv run pre-commit run --all-files + + unit-test: + name: Unit test (${{ matrix.os }}, Python ${{ matrix.python-version }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + python-version: "3.10" + - os: ubuntu-latest + python-version: "3.11" + - os: ubuntu-latest + python-version: "3.12" + - os: ubuntu-latest + python-version: "3.13" + - os: macos-latest + python-version: "3.13" + + steps: + - uses: actions/checkout@v6 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + version: "0.11.7" + enable-cache: true + + - name: Install dependencies + run: uv sync --locked --python ${{ matrix.python-version }} + + - name: Run unit tests + run: uv run python -m unittest discover -s tests -v