-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
93 lines (75 loc) · 2.52 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
93 lines (75 loc) · 2.52 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
# -- Stages --
stages:
- build
- test
# - deploy
- clean
# -- Variables --
variables:
GIT_DEPTH: 1 # Sets git shallow clone to 1 commit.
# -- Jobs --
# Application building
building:
stage: build
only:
- master # Restricts the building to the master branch.
- develop # Restricts the building to the develop branch.
script:
- echo "--Building--"
# npm
- npm install # Installs the dependencies.
# Swagger
- npm run swagger # Generates the application documentation (Swagger).
# Unit testing
unit-testing:
stage: test
only:
- master # Restricts the unit testing to the master branch.
- develop # Restricts the unit testing to the develop branch.
variables:
GIT_STRATEGY: none # Skips the 'git fetch'.
script:
- echo "--Unit testing--"
- npm run test_unit # Starts the unit testing.
# Integration testing
integration-testing:
stage: test
only:
- master # Restricts the integration testing to the master branch.
- develop # Restricts the unit testing to the develop branch.
variables:
GIT_STRATEGY: none # Skips the 'git fetch'.
needs: [unit-testing]
script:
- echo "--Integration testing--"
- docker-compose up -d # Sets up and starts the docker container via docker-compose started in background.
- npm run test_integration # Launches the integration testing.
# Application deployment
# deploying:
# image: docker:latest
# stage: deploy
# only:
# - master # Restricts the deployment only for the master branch.
# services:
# - docker:dind
# script:
# - echo "--Deploying--"
# # TODO: Clean temporary directory content, unused zip files, ...
# - docker build -t <host>:<port>/<image name>:latest .
# - docker push <host>:<port>/<image name>:latest
# Cleaning
cleaning:
image: docker:latest
stage: clean
only:
- master # Restricts the cleaning to the master branch.
- develop # Restricts the cleaning to the develop branch.
variables:
GIT_STRATEGY: none # Skips the 'git fetch'.
script:
- echo "--Cleaning Docker & $CI_PROJECT_DIR--"
- docker rm -f $(docker ps -a -q) # Removes ALL the Docker containers on the host machine runner.
- docker rmi $(docker images -a -q) # Removes ALL the images on the host machine runner.
- New-Item -Path ../ -Name "empty" -ItemType "directory" # Creates an empty folder for file deletion.
- robocopy ../empty ./ /MIR; if ($lastexitcode -lt 8) { $global:LASTEXITCODE = $null } # Removes ALL the source files on the host machine runner.
- rm ..\empty\