-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
67 lines (60 loc) · 1.94 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
image: laszlo/containerruntimeglobal_x64_dotnet_build:22.04_7.0.3
variables:
OBJECTS_DIRECTORY: 'obj'
NUGET_PACKAGES_DIRECTORY: '.nuget'
SOURCE_CODE_PATH: 'DocSearchAIO'
cache:
key: "$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"
paths:
- '$SOURCE_CODE_PATH/$OBJECTS_DIRECTORY/project.assets.json'
- '$SOURCE_CODE_PATH/$OBJECTS_DIRECTORY/*.csproj.nuget.*'
- '$NUGET_PACKAGES_DIRECTORY'
policy: pull-push
before_script:
- 'dotnet restore --packages $NUGET_PACKAGES_DIRECTORY'
build:
stage: build
script:
- 'dotnet build --no-restore'
backend-test:
stage: test
script:
- 'dotnet test --no-restore'
code-analysis:
stage: test
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
DEEPSOURCE_DSN: "https://[email protected]"
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
only:
- merge_requests
- master
- develop
script:
- "dotnet tool install --global coverlet.console"
- "curl https://deepsource.io/cli | sh"
- "apt install -y git"
- "if [ -d CollectorResults ]; then rm -Rf CollectorResults; fi"
- "dotnet build"
- "dotnet test --results-directory:\"CollectorResults\" --collect:\"XPlat Code Coverage\""
- "./bin/deepsource report --analyzer test-coverage --key csharp --value-file ./CollectorResults/*/coverage.cobertura.xml"
deploy:
stage: deploy
image: docker:stable
services:
- docker:dind
variables:
DOCKER_HOST: tcp://172.17.0.1:2375
PROJECT_NAME: docsearchaio
TAG: latest
before_script:
- docker login -u ${DOCKER_IO_USER} -p ${DOCKER_IO_TOKEN}
after_script:
- docker logout
script:
- docker build --file Dockerfile -t ${DOCKER_IO_USER}/${PROJECT_NAME}:$TAG . --no-cache
- docker push ${DOCKER_IO_USER}/${PROJECT_NAME}:$TAG