Skip to content

Update codeql.yml

Update codeql.yml #161

Workflow file for this run

name: Code Coverage
on: [push]
jobs:
upload-coverage:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
# The MySQL docker container requires these environment variables to be set
# so we can create and migrate the test database.
# See: https://hub.docker.com/_/mysql
MYSQL_DATABASE: testdb
MYSQL_ROOT_PASSWORD: testrootpass
DB_HOST: 127.0.0.1
ports:
# Opens port 3306 on service container and host
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers
- 3306:3306
# Before continuing, verify the mysql container is reachable from the ubuntu host
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11 # Replace '3.x' with your desired Python version
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Create env file
run: |
cat << EOF > .env
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
DB_PASSWORD=${{ secrets.DB_PASSWORD }}
SALT=${{ secrets.SALT }}
EOF
- name: Set up DB
run: |
mysql -h 127.0.0.1 --port 3306 -u root -ptestrootpass < test/test_init.sql
- name: Test with pytest
run: pytest --tb=line
- name: Generate coverage
run: pytest --tb=line --cov-config=.coveragerc --cov --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}