From 8ece598d7e2187e19784b2424c04dd10d5cbf5a9 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Tue, 27 Feb 2024 13:48:49 +1100 Subject: [PATCH] chore(ci): setup test pipeline Signed-off-by: JP-Ellis --- .github/workflows/test.yml | 57 +++++++++++++++++++++++++++++++++++++ pypacter-api/pyproject.toml | 2 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..21735f9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,57 @@ +name: test + +on: + push: + branches: + - main + pull_request: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + PYTHONUNBUFFERED: "1" + FORCE_COLOR: "1" + HATCH_VERBOSE: "1" + +jobs: + test: + name: > + ${{ matrix.directory == '.' && 'Core' || matrix.directory == 'pypacter-api' && 'API' || 'CLI' }} + Python ${{ matrix.python-version }} + on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + directory: [".", "pypacter-api", "pypacter-cli"] + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Hatch + run: pip install --upgrade hatch + + - name: Run lints + working-directory: ${{ matrix.directory}} + run: | + hatch run format --check + hatch run lint + hatch run typecheck + + - name: Run tests + working-directory: ${{ matrix.directory}} + run: | + hatch run test diff --git a/pypacter-api/pyproject.toml b/pypacter-api/pyproject.toml index a9f9203..9447cfd 100644 --- a/pypacter-api/pyproject.toml +++ b/pypacter-api/pyproject.toml @@ -97,7 +97,7 @@ pre-install-commands = [ # The update is necessary as we are not using editable installs lint = "ruff check --show-source --show-fixes {args} src tests" typecheck = "mypy src tests {args}" -format = "ruff format src tests docs {args}" +format = "ruff format src tests {args}" test = "pytest tests/ {args}" all = ["format", "lint", "typecheck", "test"]