-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (47 loc) · 1.44 KB
/
dotnet.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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