Skip to content

Conversation

@paigewilliams
Copy link
Contributor

@paigewilliams paigewilliams commented Oct 14, 2025

asana task

Includes:

  • Github Action to run tests on push and opening a pull request. Testing running with a failing tests and the action returns as failed. Currently, if the action fails the user who authored the commit will get an email of the failure. Would we like to add more alerting? Perhaps sent to a slack channel?
  • Github Action to run coverage and update a gist that contains a json for the coverage stats. The json is used by https://shields.io/ to dynamically update the badge. I thought that update should only occur on pushing to main to have the badge reflect the coverage on the main branch.

Added this page to the wiki as part of this work: https://github.com/Ecotrust/TEKDB/wiki/Running-tests

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a GitHub Actions workflow to automatically run tests on push and pull request events. The workflow sets up a PostgreSQL/PostGIS database service and Django test environment to execute the project's test suite.

  • Adds automated CI/CD testing with PostgreSQL database service
  • Configures Django environment variables for testing
  • Installs required system and Python dependencies before running tests

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install gdal-bin -y
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried running sudo apt-get install gcc make uwsgi uwsgi-plugin-python3 gdal-bin python3-gdal python3-dev build-essential -y and determined only gdal is necessary.

@paigewilliams
Copy link
Contributor Author

Looks like with [push, pull_request], the action runs twice when pushing to a branch with an open pull request. This seems redundant. My preference is to have the tests run on push so that pushes to branches that we aren't ready to open a PR for yet runs the tests, with the goal of the developer fixing any tests before they open the PR. What do you all think?

@paigewilliams paigewilliams changed the title Test GitHub action Github action to run tests on push Oct 14, 2025
runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis:14-3.1-alpine
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose the image version from what is in docker-compose.yml. Happy to adjust if folks prefer a different version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a postgis/postgis:14-3.2-alpine?

Looking at our demo server, we have PostgreSQL 14 with PostGIS 3.2.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call on having the tests run using the same db version as the demo server! I updated to use the image for that version.

@paigewilliams
Copy link
Contributor Author

also, the asana github action worked since I linked an asana ticket in the description 🎉

@paigewilliams
Copy link
Contributor Author

paigewilliams commented Oct 15, 2025

🚧 I'm going to attempt to get a badge running with the test coverage, so i'll convert this branch to draft 🚧

@paigewilliams paigewilliams marked this pull request as draft October 15, 2025 20:16
@rhodges
Copy link
Member

rhodges commented Oct 15, 2025

Looks like with [push, pull_request], the action runs twice when pushing to a branch with an open pull request. This seems redundant. My preference is to have the tests run on push so that pushes to branches that we aren't ready to open a PR for yet runs the tests, with the goal of the developer fixing any tests before they open the PR. What do you all think?

It is possible to submit a PR to a branch that has commits/code that are not available on the 'pushing' branch, so the tests would not be redundant in that case. I would want to know that the tests pass before accepting a PR. I recommend leaving both in place.

Copy link
Member

@rhodges rhodges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - I recommend seeing if we can explicitly run the tests withn PostGIS 3.2, but I'm happy enough with what's here.

@paigewilliams paigewilliams marked this pull request as ready for review October 15, 2025 22:29
cd TEKDB && coverage run manage.py test TEKDB.tests
coverage json

- name: Access Coverage Stat
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got a lot of inspiration on how to make and update the coverage badge from this article

@paigewilliams paigewilliams changed the title Github action to run tests on push Github action to run tests on push and update coverage badge on merge to main Oct 15, 2025
@paigewilliams paigewilliams changed the title Github action to run tests on push and update coverage badge on merge to main Github actions to run tests on push and update coverage badge on merge to main Oct 15, 2025
@paigewilliams paigewilliams merged commit 3f712c1 into main Oct 16, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants