fix ci file #9
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: CI_integration | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
integration-test: | |
runs-on: ubuntu-latest | |
env: | |
DB_DATABASE: Users | |
DB_USER: root | |
DB_PASSWORD: root | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Set up MySQL | |
run: | | |
sudo /etc/init.d/mysql start | |
mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install pytest flask-testing python-dotenv | |
- name: Configure Application | |
run: | | |
echo "SQLALCHEMY_DATABASE_URI=mysql+pymysql://root:password@mysql/Users" > .env | |
- name: Check MySQL Connection | |
run: | | |
mysql -u root -proot -e "SHOW DATABASES;" | |
# Additional step for initializing the database | |
- name: Initialize Database | |
run: | | |
export FLASK_APP=app2.py | |
flask db init | |
flask db migrate -m "Initial migration." | |
flask db upgrade | |
- name: Start Application | |
run: | | |
python app2.py & | |
sleep 10 # Wait for application to start | |
- name: Run Integration Tests | |
run: pytest integration_test.py | |
- name: Cleanup | |
if: always() | |
run: killall python |