.gitlab-ci.yml 2.81 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
41
42
43
44
45
46
47
    cache:
        paths:
            - dist
            - node_modules
            - coverage
        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
Tifenn Guillas's avatar
Tifenn Guillas committed
59
         -Dsonar.typescript.lcov.reportPaths=./coverage/lcov.info
60
61
62
    cache:
        paths:
            - node_modules
63
            - coverage
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
        - mkdir build-coverage
        - echo "FROM nginx" > build-coverage/Dockerfile
75
        - echo "COPY ../coverage /usr/share/nginx/html" >> build-coverage/Dockerfile
François Agneray's avatar
François Agneray committed
76
77
        - docker login -u fagneray -p $PORTUS_TOKEN portus.lam.fr
        - docker pull $COVERAGE_IMAGE:latest || true
78
        - docker build --cache-from $COVERAGE_IMAGE:latest -t $COVERAGE_IMAGE:latest build-coverage
François Agneray's avatar
François Agneray committed
79
80
81
82
83
84
85
86
87
        - docker push $COVERAGE_IMAGE:latest
    cache:
        paths:
            - coverage
        policy: pull
    only:
        refs:
            - develop

François Agneray's avatar
François Agneray committed
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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:
102
            - develop
François Agneray's avatar
François Agneray committed
103
104
105
106
107
108
109

deploy:
    image: alpine
    stage: deploy
    script:
        - apk add --update curl
        - curl -XPOST $DEV_WEBHOOK
François Agneray's avatar
François Agneray committed
110
111
112
113
114
115
116
117
118
119
    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
120
121
    only:
        refs:
122
            - develop