Skip to content

Commit 6df54ac

Browse files
committed
.github/workflows: Add Action to run unit tests
- Runs on PRs and on push to main branch - Badge on README displaying results
1 parent 497f5a7 commit 6df54ac

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

.github/workflows/unit-tests.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'src/**/*.py'
8+
- 'tests/**/*.py'
9+
- 'pyproject.toml'
10+
- '.github/workflows/unit-tests.yml'
11+
pull_request:
12+
branches: [ main ]
13+
paths:
14+
- 'src/**/*.py'
15+
- 'tests/**/*.py'
16+
- 'pyproject.toml'
17+
- '.github/workflows/unit-tests.yml'
18+
19+
jobs:
20+
unit-tests:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
matrix:
24+
python-version: ['3.12']
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v4
31+
32+
- name: Set up Python ${{ matrix.python-version }}
33+
run: uv python install ${{ matrix.python-version }}
34+
35+
- name: Install dependencies
36+
run: |
37+
uv sync --all-groups
38+
39+
- name: Run unit tests
40+
run: |
41+
uv run pytest tests/unit/ -m "unit" -v --tb=short
42+
43+
- name: Run unit tests with coverage
44+
run: |
45+
uv run pytest tests/unit/ -m "unit" --cov=src/amp --cov-report=xml --cov-report=term-missing
46+
47+
- name: Upload coverage reports
48+
uses: codecov/codecov-action@v4
49+
if: always()
50+
with:
51+
file: ./coverage.xml
52+
flags: unittests
53+
name: codecov-umbrella
54+
fail_ci_if_error: false

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Python Amp Client
22

3+
[![Unit tests status](https://github.com/edgeandnode/amp-python/actions/workflows/unit-tests.yml/badge.svg?event=push)](https://github.com/edgeandnode/amp-python/actions/workflows/unit-tests.yml)
4+
[![Formatting status](https://github.com/edgeandnode/amp-python/actions/workflows/ruff.yml/badge.svg?event=push)](https://github.com/edgeandnode/amp-python/actions/workflows/ruff.yml)
5+
6+
7+
## Overview
8+
39
Client for issuing queries to an Amp server and working with the returned data.
410

511
## Installation

0 commit comments

Comments
 (0)