Skip to content

Commit 48426f3

Browse files
authored
Merge pull request #126 from SnowEx/codecov
Actions - Switch to use CodeCov to check test coverage
2 parents 05387ce + edb724e commit 48426f3

File tree

5 files changed

+48
-45
lines changed

5 files changed

+48
-45
lines changed

.github/PULL_REQUEST_TEMPLATE.md

-1
This file was deleted.

.github/workflows/ci.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Code Quality
2+
on:
3+
push:
4+
branches: [ master ]
5+
pull_request:
6+
branches: [ master ]
7+
jobs:
8+
run:
9+
runs-on: ubuntu-latest
10+
services:
11+
postgis:
12+
image: kartoza/postgis:14-3.2
13+
env:
14+
POSTGRES_PASSWORD: db_builder
15+
POSTGRES_USER: builder
16+
POSTGRES_DB: test
17+
TZ: 'UTC'
18+
PGTZ: 'UTC'
19+
POSTGIS_GDAL_ENABLED_DRIVERS: 'ENABLE_ALL'
20+
POSTGIS_ENABLE_OUTDB_RASTERS: 'True'
21+
ports:
22+
- 5432:5432
23+
volumes:
24+
- /home/runner/work/:/home/runner/work/
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
- name: Set up Python 3.10
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: '3.10'
34+
- name: Install dependencies
35+
run: python3 -m pip install -e ".[dev]"
36+
- name: Run tests and collect coverage
37+
run: pytest --cov snowexsql --cov-report=xml
38+
- name: Upload coverage to Codecov
39+
uses: codecov/codecov-action@v4
40+
with:
41+
verbose: true
42+
env:
43+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/main.yml

+1-38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
name: snowexsql testing
2+
name: Pytest
33

44
# Controls when the action will run.
55
on:
@@ -46,44 +46,7 @@ jobs:
4646
sudo apt-get update
4747
sudo apt-get install -y postgis gdal-bin
4848
python3 -m pip install --upgrade pip
49-
python3 -m pip install pytest coverage
5049
python3 -m pip install -e ".[dev]"
5150
- name: Test with pytest
5251
run: |
5352
pytest -s
54-
55-
# Run coverage only once
56-
- if: ${{ matrix.python-version == '3.9'}}
57-
name: Get Coverage for badge
58-
run: |
59-
# Run coverage save the results
60-
coverage run --source snowexsql -m pytest
61-
SUMMARY=`coverage report -m | grep TOTAL`
62-
63-
# Save results as ENV var
64-
COVERAGE=$(python -c "print('$SUMMARY'.split(' ')[-1])")
65-
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
66-
67-
# var REF = 'refs/pull/27/merge.json';
68-
REF=${{ github.ref }}
69-
# console.log('github.ref: ' + REF);
70-
echo "github.ref: $REF"
71-
# var PATHS = REF.split('/');
72-
IFS='/' read -ra PATHS <<< "$REF"
73-
# var BRANCH_NAME = PATHS[1] + PATHS[2];
74-
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}"
75-
# console.log(BRANCH_NAME); // 'pull_27'
76-
echo $BRANCH_NAME
77-
# process.env.BRANCH = 'pull_27';
78-
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV
79-
80-
- if: ${{ matrix.python-version == '3.9'}}
81-
name: Create the Badge
82-
uses: schneegans/[email protected]
83-
with:
84-
auth: ${{ secrets.GIST_SECRET }}
85-
gistID: 2034019acc40a963bd02d2fcbb31c5a9
86-
filename: snowexsql__${{ env.BRANCH }}.json
87-
label: Coverage
88-
message: ${{ env.COVERAGE }}
89-
color: green

README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Welcome to snowexsql
1414
:target: https://pypi.org/project/snowexsql/
1515
:alt: Code Coverage
1616

17-
.. image:: https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/micahjohnson150/2034019acc40a963bd02d2fcbb31c5a9/raw/snowexsql__heads_master.json
18-
:alt: Code Coverage
17+
.. image:: https://codecov.io/gh/SnowEx/snowexsql/graph/badge.svg?token=B27OKGBOTR
18+
:target: https://codecov.io/gh/SnowEx/snowexsql
1919

2020
About
2121
-----

pyproject.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ dependencies = [
2828

2929
[project.optional-dependencies]
3030
dev = [
31-
"pip==23.3",
32-
"coverage==5.5",
33-
"pytest==6.2.4",
34-
"pytest-cov==2.12.1",
31+
"pytest",
32+
"pytest-cov",
3533
"sphinx-autobuild<=2024.5",
3634
]
3735
docs = [

0 commit comments

Comments
 (0)