-
Notifications
You must be signed in to change notification settings - Fork 8
167 lines (138 loc) · 5.48 KB
/
Copy pathplaywright-tests.yml
File metadata and controls
167 lines (138 loc) · 5.48 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Playwright Tests
on:
workflow_dispatch:
pull_request:
branches:
- 'main'
- 'develop'
- 'release/**'
- 'hotfix/**'
push:
branches:
- 'main'
- 'develop'
- 'release/**'
- 'hotfix/**'
permissions:
contents: read
env:
BUILD_CONFIGURATION: "Release"
SOLUTION_PATH: source/AAS.TwinEngine.DataEngine.sln
PLAYWRIGHT_TEST_PROJECT: source/AAS.TwinEngine.Plugin.TestPlugin.PlaywrightTests/AAS.TwinEngine.Plugin.TestPlugin.PlaywrightTests.csproj
DOCKER_COMPOSE_PATH: source/AAS.TwinEngine.Plugin.TestPlugin/Example
BASE_URL: "http://localhost:8085"
jobs:
playwright-tests:
name: Run Playwright Tests
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
checks: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: "8.0.x"
- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION_PATH }} --locked-mode
- name: Build solution
run: dotnet build ${{ env.SOLUTION_PATH }} --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore
- name: Build Playwright test project
run: dotnet build ${{ env.PLAYWRIGHT_TEST_PROJECT }} --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore
- name: Start Docker Compose services
run: |
cd ${{ env.DOCKER_COMPOSE_PATH }}
docker compose up -d
env:
COMPOSE_HTTP_TIMEOUT: 200
- name: Wait for services to be healthy
run: |
cd ${{ env.DOCKER_COMPOSE_PATH }}
echo "Waiting for services to be healthy..."
MAX_WAIT=300
ELAPSED=0
INTERVAL=10
while [ $ELAPSED -lt $MAX_WAIT ]; do
# Check if all services are running
RUNNING=$(docker compose ps --status running --format json 2>/dev/null | jq -s 'length' 2>/dev/null || echo "0")
TOTAL=$(docker compose ps --format json 2>/dev/null | jq -s 'length' 2>/dev/null || echo "0")
echo "Running containers: $RUNNING/$TOTAL"
# Check for any unhealthy services
UNHEALTHY=$(docker compose ps --format json 2>/dev/null | jq -r 'select(.Health != "" and .Health != "healthy") | .Service' 2>/dev/null | wc -l)
if [ $RUNNING -ge 6 ] && [ $UNHEALTHY -eq 0 ]; then
echo "Services are up and running!"
docker compose ps
break
fi
echo "Waiting for services... ($ELAPSED/$MAX_WAIT seconds)"
sleep $INTERVAL
ELAPSED=$((ELAPSED + INTERVAL))
done
if [ $ELAPSED -ge $MAX_WAIT ]; then
echo "Timeout waiting for services to be ready"
echo "Current service status:"
docker compose ps
echo "Service logs:"
docker compose logs --tail=100
exit 1
fi
# Additional wait to ensure services are fully ready
echo "Waiting additional 20 seconds for services to stabilize..."
sleep 20
# Verify critical endpoints are responding
echo "Checking DataEngine endpoint..."
for i in {1..15}; do
if curl -f -s -o /dev/null ${{ env.BASE_URL }}/shell-descriptors 2>&1; then
echo "DataEngine is responding!"
break
fi
if [ $i -eq 15 ]; then
echo "DataEngine is not responding after 15 attempts"
docker compose logs twinengine-dataengine --tail=50
exit 1
fi
echo "Attempt $i: DataEngine not ready yet..."
sleep 5
done
echo "All services are ready for testing!"
- name: Show running containers
if: always()
run: |
cd ${{ env.DOCKER_COMPOSE_PATH }}
docker compose ps
echo "---"
docker compose logs --tail=50
- name: Run Playwright Tests
run: dotnet test ${{ env.PLAYWRIGHT_TEST_PROJECT }} --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --logger "trx;LogFileName=playwright_test_results.trx" --verbosity normal
env:
BASE_URL: ${{ env.BASE_URL }}
- name: Publish Test Results
uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0
if: github.event.pull_request.head.repo.fork == false
with:
name: Playwright Test Results
path: "**/playwright_test_results.trx"
reporter: dotnet-trx
fail-on-error: true
- name: Upload TRX as artifact
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: playwright-test-results
path: "**/*playwright_test_results.trx"
- name: Capture Docker Compose Logs
if: always()
run: |
cd ${{ env.DOCKER_COMPOSE_PATH }}
mkdir -p logs
docker compose logs > logs/docker-compose-full.log 2>&1 || true
docker compose ps > logs/docker-compose-status.txt 2>&1 || true
- name: Stop Docker Compose services
if: always()
run: |
cd ${{ env.DOCKER_COMPOSE_PATH }}
docker compose down -v