Merge pull request #944 from laryhills/feat/connect-admin-dashboard-c… #4
This file contains hidden or 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 Workflow | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'spotnet/web_app/**' | |
| - 'devops/**' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'spotnet/web_app/**' | |
| - 'devops/**' | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| env: | |
| working-directory: ./spotnet | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_DB: spotnet | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: password | |
| POSTGRES_HOST_AUTH_METHOD: trust | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U postgres" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Create .env file | |
| run: cp spotnet/.env.dev .env | |
| - name: Start services and initialize database | |
| run: | | |
| docker compose -f devops/docker-compose.spotnet.dev.yaml --env-file .env up -d --build | |
| # Wait for services to be ready | |
| sleep 10 | |
| # Create initial migration if it doesn't exist | |
| docker compose -f devops/docker-compose.spotnet.dev.yaml exec -T backend poetry run alembic -c web_app/alembic.ini revision --autogenerate -m "Initial migration" | |
| # Run migrations | |
| docker compose -f devops/docker-compose.spotnet.dev.yaml exec -T backend poetry run alembic -c web_app/alembic.ini upgrade head | |
| - name: Run tests | |
| run: | | |
| docker compose -f devops/docker-compose.spotnet.dev.yaml exec -T backend poetry run pytest web_app/tests | |
| - name: Run tests coverage | |
| run: | | |
| docker compose -f devops/docker-compose.spotnet.dev.yaml exec -T backend poetry run pytest --cov=web_app/tests --cov-fail-under=90 | |
| - name: Tear down | |
| if: always() | |
| run: | | |
| docker compose -f devops/docker-compose.spotnet.dev.yaml down |