tests: unittest for bump in uv project #95
This file contains 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
# This workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: ci | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10", 3.11, 3.12, 3.13] | |
steps: | |
- name: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
allow-prereleases: true | |
- uses: actions/cache@v4 | |
id: cache | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('**/pdm.lock') }} | |
- name: Prepare tools | |
run: | | |
python -m pip install --upgrade pip pdm poetry | |
poetry config virtualenvs.create false | |
poetry self add poetry-plugin-version | |
poetry self add poetry-dynamic-versioning | |
pdm config --global venv.with_pip true | |
git config --global user.email "waketzheng@gmail.com" | |
git config --global user.name "Waket Zheng" | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: Install requirements/Check code style and Type Hint | |
run: make check | |
- name: Test with pytest | |
run: | | |
pdm run coverage run -m pytest | |
pdm run python -c "import os;from pathlib import Path;pp=list(Path().glob('.coverage.*'));pp and os.system('pdm run coverage combine .coverage*')" | |
- name: Upload Coverage | |
run: | | |
pip3 install --upgrade coveralls | |
coveralls --service=github | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COVERALLS_FLAG_NAME: ${{ matrix.python-version }} | |
COVERALLS_PARALLEL: true | |
coveralls: | |
name: Indicate completion to coveralls.io | |
needs: test | |
runs-on: ubuntu-latest | |
container: python:3-slim | |
steps: | |
- name: Finished | |
run: | | |
pip3 install --upgrade coveralls | |
coveralls --service=github --finish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |