Skip to content

Commit 3ea3cf0

Browse files
committed
Test gitlab-ci
1 parent f9a6632 commit 3ea3cf0

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

.gitlab-ci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
stages:
2+
- install
3+
- lint
4+
- test
5+
- build
6+
- container
7+
8+
variables:
9+
WORKDIR: frontend-angular
10+
NODE_VERSION: "20"
11+
IMAGE_NAME: $DOCKER_USERNAME/frontend-angular
12+
CI_PROJ_CACHE_KEY: "node-${CI_COMMIT_REF_SLUG}"
13+
14+
cache:
15+
key: "${CI_PROJ_CACHE_KEY}"
16+
paths:
17+
- ${WORKDIR}/node_modules
18+
19+
.install_base:
20+
image: node:${NODE_VERSION}
21+
before_script:
22+
- cd ${WORKDIR}
23+
- node -v
24+
- npm ci
25+
26+
install:
27+
stage: install
28+
extends: .install_base
29+
script:
30+
- echo "ok"
31+
32+
lint:
33+
stage: lint
34+
extends: .install_base
35+
script:
36+
- npm run lint
37+
38+
test:
39+
stage: test
40+
image: node:${NODE_VERSION}
41+
before_script:
42+
- cd ${WORKDIR}
43+
- apt-get update
44+
- apt-get install -y chromium
45+
- export CHROME_BIN=/usr/bin/chromium
46+
- npm ci
47+
script:
48+
- npm run test -- --watch=false --browsers=ChromeHeadless --code-coverage
49+
artifacts:
50+
when: always
51+
reports:
52+
junit: ${WORKDIR}/junit.xml
53+
paths:
54+
- ${WORKDIR}/coverage
55+
rules:
56+
- if: $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event"
57+
58+
build:
59+
stage: build
60+
extends: .install_base
61+
script:
62+
- npm run build -- --configuration=production
63+
artifacts:
64+
paths:
65+
- ${WORKDIR}/dist
66+
expire_in: 7 days
67+
68+
docker:
69+
stage: container
70+
image: docker:27
71+
services:
72+
- docker:27-dind
73+
variables:
74+
DOCKER_HOST: tcp://docker:2375
75+
DOCKER_TLS_CERTDIR: ""
76+
before_script:
77+
- cd ${WORKDIR}
78+
- docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
79+
script:
80+
- docker build -t "$IMAGE_NAME:$CI_COMMIT_SHORT_SHA" -f Dockerfile .
81+
- docker push "$IMAGE_NAME:$CI_COMMIT_SHORT_SHA"
82+
- |
83+
if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
84+
docker tag "$IMAGE_NAME:$CI_COMMIT_SHORT_SHA" "$IMAGE_NAME:latest"
85+
docker push "$IMAGE_NAME:latest"
86+
fi
87+
needs: ["build"]
88+
rules:
89+
- if: $CI_PIPELINE_SOURCE == "push"

0 commit comments

Comments
 (0)