.gitlab-ci.yml 2.73 KB
Newer Older
François Agneray's avatar
François Agneray committed
1
2
stages:
    - install
3
    - test
4
    - sonar
François Agneray's avatar
François Agneray committed
5
    - build-coverage
François Agneray's avatar
François Agneray committed
6
7
    - build
    - deploy
François Agneray's avatar
François Agneray committed
8
    - deploy-coverage
François Agneray's avatar
François Agneray committed
9
10

variables:
11
12
    VERSION: "3.0"
    SONARQUBE_URL: https://sonarqube.lam.fr
François Agneray's avatar
François Agneray committed
13
    CONTAINER_IMAGE: portus.lam.fr/anis/anis-client
François Agneray's avatar
François Agneray committed
14
    COVERAGE_IMAGE: portus.lam.fr/anis/anis-client-coverage
François Agneray's avatar
François Agneray committed
15
16
17
18
19
20
21
22
23
24
25

install:
    image: node:11
    stage: install
    script:
        - yarn global add @angular/cli
        - yarn install
        - ng build --prod
    cache:
        paths:
            - dist
26
            - node_modules
François Agneray's avatar
François Agneray committed
27
28
29
        policy: push
    only:
        refs:
30
            - develop
31

32
test:
Tifenn Guillas's avatar
Tifenn Guillas committed
33
    image: portus.lam.fr/ci-tools/angular-testing:latest
34
35
    stage: test
    script:
36
        - ng test --no-watch
37
38
39
40
    cache:
        paths:
            - dist
            - node_modules
41
            - var
42
43
44
45
46
47
        policy: pull-push
    only:
        refs:
            - develop


48
49
50
51
sonar_scanner:
    image: portus.lam.fr/ci-tools/sonar-scanner:latest
    stage: sonar
    script:
Tifenn Guillas's avatar
Tifenn Guillas committed
52
53
54
55
56
57
58
        - sonar-scanner
         -Dsonar.projectKey=anis-client
         -Dsonar.sources=src
         -Dsonar.projectVersion=$VERSION
         -Dsonar.host.url=$SONARQUBE_URL
         -Dsonar.login=$SONAR_TOKEN
         -Dsonar.exclusions=**.spec.ts
59
         -Dsonar.typescript.lcov.reportPaths=./var/coverage/lcov.info
60
61
62
    cache:
        paths:
            - node_modules
63
            - var
64
        policy: pull
65
66
    only:
        refs:
67
            - develop
François Agneray's avatar
François Agneray committed
68

François Agneray's avatar
François Agneray committed
69
70
71
72
build-coverage:
    image: docker:stable
    stage: build-coverage
    script:
73
74
        - echo "FROM nginx" > var/Dockerfile
        - echo "COPY coverage /usr/share/nginx/html" >> var/Dockerfile
François Agneray's avatar
François Agneray committed
75
76
        - docker login -u fagneray -p $PORTUS_TOKEN portus.lam.fr
        - docker pull $COVERAGE_IMAGE:latest || true
77
        - docker build --cache-from $COVERAGE_IMAGE:latest -t $COVERAGE_IMAGE:latest var
François Agneray's avatar
François Agneray committed
78
79
80
        - docker push $COVERAGE_IMAGE:latest
    cache:
        paths:
81
            - var
François Agneray's avatar
François Agneray committed
82
83
84
85
86
        policy: pull
    only:
        refs:
            - develop

François Agneray's avatar
François Agneray committed
87
88
89
90
91
92
93
94
95
96
97
98
99
100
build:
    image: docker:stable
    stage: build
    script:
        - docker login -u fagneray -p $PORTUS_TOKEN portus.lam.fr
        - docker pull $CONTAINER_IMAGE:latest-dev || true
        - docker build --cache-from $CONTAINER_IMAGE:latest-dev -t $CONTAINER_IMAGE:latest-dev .
        - docker push $CONTAINER_IMAGE:latest-dev
    cache:
        paths:
            - dist
        policy: pull
    only:
        refs:
101
            - develop
François Agneray's avatar
François Agneray committed
102
103
104
105
106
107
108

deploy:
    image: alpine
    stage: deploy
    script:
        - apk add --update curl
        - curl -XPOST $DEV_WEBHOOK
François Agneray's avatar
François Agneray committed
109
110
111
112
113
114
115
116
117
118
    only:
        refs:
            - develop

deploy-coverage:
    image: alpine
    stage: deploy-coverage
    script:
        - apk add --update curl
        - curl -XPOST $COVERAGE_WEBHOOK
François Agneray's avatar
François Agneray committed
119
120
    only:
        refs:
121
            - develop