Testing workflow
Path to file (view file on GitHub)
The original file is located at the following path:
.github / workflows / test.yml
This GitHub Actions workflow is designed to automate the Continuous Integration (CI) process for a Flask application. It triggers on pushes and pull requests to the main
and develop
branches. The essential elements of this workflow are as follows:
Workflow Name
- name: Run tests
Triggers
- on:
- push: Triggers on pushes to
main
anddevelop
branches. - pull_request: Triggers on pull requests to
main
anddevelop
branches.
- push: Triggers on pushes to
Jobs
- pytest: This job runs on the latest Ubuntu environment (
ubuntu-latest
).
Services
- mysql: Sets up a MySQL 5.7 service with the following environment variables and options for health checks:
MYSQL_ROOT_PASSWORD
:uvlhub_root_password
MYSQL_DATABASE
:uvlhubdb_test
MYSQL_USER
:uvlhub_user
MYSQL_PASSWORD
:uvlhub_password
- Ports:
3306:3306
- Health check options:
--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
Steps
- Checkout Repository
- Uses the
actions/checkout@v4
action to checkout the repository.
- Uses the
- Setup Python
- Uses the
actions/setup-python@v5
action to set up Python 3.12.
- Uses the
- Prepare Environment
- Runs a command to modify the
requirements.txt
file, removing a specific line.
- Runs a command to modify the
- Install Dependencies
- Upgrades
pip
and installs dependencies fromrequirements.txt
.
- Upgrades
- Run Tests
- Sets environment variables for testing and runs
pytest
on the Flask application.
- Sets environment variables for testing and runs
Environment Variables for Tests
FLASK_ENV
:testing
MARIADB_HOSTNAME
:127.0.0.1
MARIADB_PORT
:3306
MARIADB_TEST_DATABASE
:uvlhubdb_test
MARIADB_USER
:uvlhub_user
MARIADB_PASSWORD
:uvlhub_password