code coverage #169
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
name: Python application | |
on: | |
push: | |
branches: | |
- "*" # Run on all branches for any push events | |
pull_request: | |
branches: | |
- "*" # Run on all branches for any pull request events | |
permissions: | |
contents: read | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:14 | |
env: | |
POSTGRES_USER: SWEN732 | |
POSTGRES_PASSWORD: kl,. | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flask_cors | |
pip install pandas | |
pip install -r requirements.txt | |
pip install coverage | |
- name: Set PYTHONPATH | |
run: echo "PYTHONPATH=${{ github.workspace }}/PCP/server/src" >> $GITHUB_ENV | |
- name: Set FLASK_APP environment variable | |
run: echo "FLASK_APP=src/server.py" >> $GITHUB_ENV | |
- name: List files in the src directory | |
run: ls -alh | |
working-directory: ${{ github.workspace }}/PCP/server/src | |
- name: Start Flask server | |
run: flask run --host=0.0.0.0 & | |
env: | |
FLASK_ENV: development | |
working-directory: ${{ github.workspace }}/PCP/server/src | |
- name: Delay for Flask server to start | |
run: sleep 5 | |
- name: Generate coverage report | |
run: | | |
python -m coverage run --source=src -m unittest discover tests -v | |
python -m coverage xml | |
working-directory: ${{ github.workspace }}/PCP/server | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4.0.1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} |