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
mainanddevelopbranches. - pull_request: Triggers on pull requests to
mainanddevelopbranches.
- 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_passwordMYSQL_DATABASE:uvlhubdb_testMYSQL_USER:uvlhub_userMYSQL_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@v4action to checkout the repository.
- Uses the
- Setup Python
- Uses the
actions/setup-python@v5action to set up Python 3.12.
- Uses the
- Prepare Environment
- Runs a command to modify the
requirements.txtfile, removing a specific line.
- Runs a command to modify the
- Install Dependencies
- Upgrades
pipand installs dependencies fromrequirements.txt.
- Upgrades
- Run Tests
- Sets environment variables for testing and runs
pyteston the Flask application.
- Sets environment variables for testing and runs
Environment Variables for Tests
FLASK_ENV:testingMARIADB_HOSTNAME:127.0.0.1MARIADB_PORT:3306MARIADB_TEST_DATABASE:uvlhubdb_testMARIADB_USER:uvlhub_userMARIADB_PASSWORD:uvlhub_password