-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (117 loc) · 4.39 KB
/
test.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
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
name: Automatic Test
on: [push, pull_request, workflow_dispatch]
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
# We conduct tests on a combination of so many platforms,
# not only to test compatibility,
# but also to identify bugs that may not be detected without extensive repetition.
matrix:
postgresql-version: [latest, 12]
elasticsearch-version: [8.12.2, 8.0.0]
node-version: [18.x, 20.x]
pnpm-version: [8]
repeat: [1, 2]
env:
TEST_REPEAT: 10 # Tests will be repeated
PORT: 7777
JWT_SECRET: Test JWT Secret
PRISMA_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
TYPEORM_DB_TYPE: postgres
TYPEORM_DB_HOST: localhost
TYPEORM_DB_PORT: 5432
TYPEORM_DB_USERNAME: postgres
TYPEORM_DB_PASSWORD: postgres
TYPEORM_DB_NAME: postgres
TYPEORM_DB_SYNCHRONIZE: false
TYPEORM_DB_AUTO_LOAD_ENTITIES: true
TYPEORM_DB_CONNECT_TIMEOUT: 60000
TYPEORM_DB_LOGGING_ALL: false
TYPEORM_DB_LOGGING_ERROR: true
DEFAULT_AVATAR_NAME: default.jpg
FILE_UPLOAD_PATH: /home/runner/work/cheese-backend
ELASTICSEARCH_NODE: http://127.0.0.1:9200/
ELASTICSEARCH_MAX_RETRIES: 10
ELASTICSEARCH_REQUEST_TIMEOUT: 60000
ELASTICSEARCH_PING_TIMEOUT: 60000
ELASTICSEARCH_SNIFF_ON_START: false
ELASTICSEARCH_AUTH_USERNAME: elastic
ELASTICSEARCH_AUTH_PASSWORD: your-elasticsearch-password
services:
# See: https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:${{ matrix.postgresql-version }}
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
elasticsearch: # See: https://discuss.elastic.co/t/set-password-and-user-with-docker-compose/225075
image: docker.elastic.co/elasticsearch/elasticsearch:${{ matrix.elasticsearch-version }}
env:
discovery.type: single-node
xpack.security.enabled: true
ELASTIC_USERNAME: ${{ env.ELASTICSEARCH_AUTH_USERNAME }}
ELASTIC_PASSWORD: ${{ env.ELASTICSEARCH_AUTH_PASSWORD }}
options: >-
--health-cmd "curl http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
# Maps tcp port 9200 on service container to the host
- 9200:9200
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ matrix.pnpm-version }}
run_install: false
- name: Install Dependencies
run: pnpm install
- name: Initialize Database Structures with Prisma
run: pnpm prisma db push
- name: Install ffmpeg
# uses: FedericoCarboni/setup-ffmpeg@v3
run: |
sudo apt-get update
sudo apt-get install ffmpeg
- name: Try to Start Application
run: |
pnpm start | tee output &
while true; do
sleep 10
if grep -q "Nest application successfully started" output; then
echo "Detected 'Nest application successfully started'. Stopping pnpm..."
pid=$(netstat -nlp | grep :$PORT | awk '{print $7}' | awk -F'/' '{print $1}')
kill $pid
break
fi
if [[ -z "$(netstat -nlp | grep :$PORT | awk '{print $7}' | awk -F'/' '{print $1}')" ]]; then
echo "Nest application failed to start."
exit -1
fi
done
- name: Run Tests
run: |
for i in {1..${{ env.TEST_REPEAT }}}; do
echo "Repeating Test [$i]"
pnpm test --verbose
done