-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actions - Switch to use CodeCov to check test coverage
Change the workflow to get test coverage and use the CodeCov service. This also separates the step into a dedicated CI action and independent of the Python 3.9 test runs. Upgrading the pytest and pytest-cov package to always use the latest.
- Loading branch information
Showing
3 changed files
with
46 additions
and
42 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Code Quality | ||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
services: | ||
postgis: | ||
image: kartoza/postgis:14-3.2 | ||
env: | ||
POSTGRES_PASSWORD: db_builder | ||
POSTGRES_USER: builder | ||
POSTGRES_DB: test | ||
TZ: 'UTC' | ||
PGTZ: 'UTC' | ||
POSTGIS_GDAL_ENABLED_DRIVERS: 'ENABLE_ALL' | ||
POSTGIS_ENABLE_OUTDB_RASTERS: 'True' | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- /home/runner/work/:/home/runner/work/ | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
- name: Install dependencies | ||
run: python3 -m pip install -e ".[dev]" | ||
- name: Run tests and collect coverage | ||
run: pytest --cov snowexsql --cov-report=xml | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
verbose: true | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
name: snowexsql testing | ||
name: Pytest | ||
|
||
# Controls when the action will run. | ||
on: | ||
|
@@ -46,44 +46,7 @@ jobs: | |
sudo apt-get update | ||
sudo apt-get install -y postgis gdal-bin | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install pytest coverage | ||
python3 -m pip install -e ".[dev]" | ||
- name: Test with pytest | ||
run: | | ||
pytest -s | ||
# Run coverage only once | ||
- if: ${{ matrix.python-version == '3.9'}} | ||
name: Get Coverage for badge | ||
run: | | ||
# Run coverage save the results | ||
coverage run --source snowexsql -m pytest | ||
SUMMARY=`coverage report -m | grep TOTAL` | ||
# Save results as ENV var | ||
COVERAGE=$(python -c "print('$SUMMARY'.split(' ')[-1])") | ||
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV | ||
# var REF = 'refs/pull/27/merge.json'; | ||
REF=${{ github.ref }} | ||
# console.log('github.ref: ' + REF); | ||
echo "github.ref: $REF" | ||
# var PATHS = REF.split('/'); | ||
IFS='/' read -ra PATHS <<< "$REF" | ||
# var BRANCH_NAME = PATHS[1] + PATHS[2]; | ||
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}" | ||
# console.log(BRANCH_NAME); // 'pull_27' | ||
echo $BRANCH_NAME | ||
# process.env.BRANCH = 'pull_27'; | ||
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV | ||
- if: ${{ matrix.python-version == '3.9'}} | ||
name: Create the Badge | ||
uses: schneegans/[email protected] | ||
with: | ||
auth: ${{ secrets.GIST_SECRET }} | ||
gistID: 2034019acc40a963bd02d2fcbb31c5a9 | ||
filename: snowexsql__${{ env.BRANCH }}.json | ||
label: Coverage | ||
message: ${{ env.COVERAGE }} | ||
color: green |
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