Backend testing updates #192
Workflow file for this run
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: .NET Build and Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
# strategy: | |
# matrix: | |
# os: [ubuntu-latest, macos-latest, windows-latest] | |
# runs-on: ${{ matrix.os }} | |
runs-on: ubuntu-latest # does not run on other platforms | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore ./backend | |
- name: Build | |
run: dotnet build ./backend --no-restore | |
- name: Start database container | |
run: docker compose up -d mysql | |
- name: List running containers | |
run: docker ps -a | |
- name: Wait for database to be ready | |
run: | | |
for i in {1..30}; do | |
if docker exec $(docker ps -q --filter "name=mysql") mysqladmin ping -h"localhost" --silent; then | |
echo "Database is ready!" | |
sleep 10 | |
exit 0 | |
fi | |
echo "Waiting for database connection..." | |
sleep 2 | |
done | |
echo "Database failed to start within the expected time." | |
exit 1 | |
- name: Test | |
run: dotnet test ./backend --collect "Code Coverage;Format=Cobertura" --no-build --verbosity normal | |
- name: Stop and remove database container | |
run: docker compose down |