-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (64 loc) · 1.97 KB
/
ci.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: CI
on:
push:
pull_request:
branches:
- main
paths:
- '.github/workflows/ci.yml'
- 'src/**'
- 'run.sh'
env:
APP_NAME: ${{ vars.APP_NAME }}
TEST_ENDPOINT: 'http://localhost:${{ vars.APP_HOST_PORT }}${{ vars.TEST_ROUTE }}'
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run ${{ env.APP_NAME }} with Docker Compose (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
chmod +x run.sh
./run.sh
- name: Run ${{ env.APP_NAME }} with Docker Compose (Windows)
if: matrix.os == 'windows-latest'
run: |
.\run.ps1
- name: Run basic test (workshop scenario, Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" ${{ env.TEST_ENDPOINT }})
if [ $RESPONSE_CODE -eq 200 ]; then
echo "Basic health check PASSED!"
else
echo " Basic health check FAILED!"
exit 1
fi
- name: Run basic test (workshop scenario, Windows)
if: matrix.os == 'windows-latest'
run: |
$RESPONSE_CODE = (Invoke-WebRequest -Uri ${{ env.TEST_ENDPOINT }}).StatusCode
if ($RESPONSE_CODE -eq 200) {
Write-Output "Basic health check PASSED!"
} else {
Write-Output "Basic health check FAILED!"
exit 1
}
- name: Tear down Docker Compose
run: |
docker-compose -f docker-compose.yml down
- name: Run unit/integration tests
run: |
npm ci
npm run test
- name: Report coverage to Coveralls
if: matrix.os == 'ubuntu-latest'
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/lcov.info