-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (57 loc) · 1.74 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
name: CI
on:
push:
paths:
- '.github/workflows/**'
- 'src/**'
- 'run.sh'
pull_request:
branches:
- main
env:
APP_NAME: ${{ vars.APP_NAME }}
TEST_ENDPOINT: 'http://localhost:${{ vars.APP_HOST_PORT }}${{ vars.TEST_ROUTE }}'
jobs:
build-and-test:
runs-on: ubuntu-24.04
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Checkout code
uses: actions/checkout@v4
- name: Run ${{ env.APP_NAME }} with Docker Compose
run: |
set -e
chmod +x run.sh
./run.sh
- name: Wait for ${{ env.APP_NAME }} to be ready
run: |
while ! curl -s ${{ env.TEST_ENDPOINT }}; do
echo "Waiting for ${{ env.APP_NAME }}..."
sleep 1
done
- name: Run basic test (workshop scenario)
run: |
echo "Sending a request to ${{ env.TEST_ENDPOINT }}"
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" ${{ env.TEST_ENDPOINT }})
echo "Response status code: $RESPONSE_CODE"
if [ $RESPONSE_CODE -eq 200 ]; then
echo "Basic health check PASSED!"
else
echo " Basic health check FAILED!"
exit 1
fi
- name: Tear down Docker Compose
run: |
docker compose -f docker-compose.yml down
- name: Run unit/integration tests
run: |
npm ci || { echo "npm ci failed"; exit 1; }
npm run test || { echo "npm ci failed"; exit 1; }
- name: Report coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/lcov.info