-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (79 loc) · 2.19 KB
/
check.yml
File metadata and controls
99 lines (79 loc) · 2.19 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
name: Check CI
on:
# Run on pull requests to primary branches
pull_request:
branches:
- master
- main
- prod
- production
- staging
- dev
- develop
- development
- test
paths:
- '.github/workflows/check.yml'
- 'dockerc'
- 'test/**'
- 'docker-compose.yml'
- 'docker-compose.test.yml'
# Run on manual triggers
workflow_dispatch:
# Set GITHUB_TOKEN permissions for the workflow
permissions:
contents: read
# Set workflow concurrency rules
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Test job
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build docker images for testing
run: |
# docker compose build
echo "::group::Build tests"
docker compose \
-f ./docker-compose.yml -f ./docker-compose.test.yml \
--env-file .env \
build
echo "::endgroup::"
- name: Run docker images for testing
run: |
# docker compose up
echo "::group::Run tests"
docker compose \
-f ./docker-compose.yml -f ./docker-compose.test.yml \
--env-file .env \
up
echo "::endgroup::"
echo '::group::Check tests success'
# Check services for non-zero exit codes
NON_ZERO_EXIT_CODES=$(
docker compose \
-f ./docker-compose.yml -f ./docker-compose.test.yml \
--env-file .env \
ps -a --format '{{.ExitCode}}' \
| grep -v '^0$' \
|| true
)
if [ -n "${NON_ZERO_EXIT_CODES}" ]; then
# Non-zero exit codes found
echo 'Non-zero exit codes found.'
docker compose \
-f ./docker-compose.yml -f ./docker-compose.test.yml \
--env-file .env \
ps -a
exit 1
else
# All services succeeded
echo 'All services succeeded.'
fi
echo '::endgroup::'