forked from davidje13/Refacto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
79 lines (71 loc) · 2.42 KB
/
.gitlab-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
77
78
79
variables:
# Setting a depth of 1 can result in jobs failing if they are not the latest commit when they begin executing.
# See https://docs.gitlab.com/ee/ci/runners/configure_runners.html#shallow-cloning
GIT_DEPTH: '3'
build:
stage: build
dependencies: []
image: node:20
timeout: 20 minutes
before_script:
- apt-get update
- wget --no-verbose -O chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- apt-get install -q=2 -y ./chrome.deb firefox-esr | grep -v '^Selecting previously unselected package \|^Preparing to unpack \|^Unpacking \|^Setting up '
- npm config set cache .npm --global
script:
- PARALLEL_BUILD=false PARALLEL_E2E=false EXPLICIT_WAIT_TIMEOUT=20000 TEST_TIMEOUT=60000 DOCKER=true npm test
- cd build && rm -r node_modules && tar -czf ../build.tar.gz .
artifacts:
name: refacto
paths: [build.tar.gz]
public: true
expire_in: 6 hours # latest is always kept indefinitely
cache:
- key: { files: ['*/package-lock.json'] }
paths: ['.npm']
.smoke-test: &smoke-test
stage: test
variables: { GIT_STRATEGY: none }
needs: [build]
dependencies: [build]
timeout: 10 minutes
before_script:
- tar -xf build.tar.gz && rm build.tar.gz
script:
- |
set -e;
npm install --omit=dev;
# TODO once https://github.com/nodejs/node/issues/50452 is resolved, add NODE_OPTIONS='--experimental-policy=./policy.json'
./index.js > output.log 2>&1 & APP_PID="$!";
while [ ! -f output.log ] || ! grep 'Available at' < output.log > /dev/null 2>&1; do
if ! ps -p "$APP_PID" > /dev/null; then
APP_EXIT_CODE="$(wait "$APP_PID" > /dev/null; echo "$?")";
cat output.log;
echo "Application failed to launch (exit code: $APP_EXIT_CODE).";
false;
fi;
sleep 0.1;
done;
wget localhost:5000 -O test-index.html;
if ! grep '<title>Refacto</title>' < test-index.html > /dev/null; then
cat output.log;
echo "Unexpected main page response" >&2;
cat test-index.html;
false;
fi;
kill -2 "$APP_PID";
wait "$APP_PID";
if ! grep 'Shutdown complete' < output.log > /dev/null; then
cat output.log;
echo "Application failed to shut down" >&2;
false;
fi;
node:18:
<<: *smoke-test
image: node:18
node:20:
<<: *smoke-test
image: node:20
node:21:
<<: *smoke-test
image: node:21