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

variables:
12
13
    VERSION: 3.0
    SONARQUBE_URL: https://sonarqube.lam.fr
14
15
    METRICS_IMAGE: portus.lam.fr/anis/anis-server-metrics
    CONTAINER_IMAGE: portus.lam.fr/anis/anis-server
François Agneray's avatar
François Agneray committed
16
17
18
19
20
21
22
23
24
25
26
27
28

php-metrics:
    image: jakzal/phpqa
    stage: metrics
    script: 
        - phpmetrics --report-html=var/php-metrics .
    allow_failure: true
    cache:
        paths:
            - var
        policy: push
    only:
        refs:
29
            - sonar
François Agneray's avatar
François Agneray committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

php-metrics-build:
    image: docker:stable
    stage: metrics-build
    script:
        - echo "FROM nginx" > var/Dockerfile
        - echo "COPY php-metrics /usr/share/nginx/html" >> var/Dockerfile
        - docker login -u fagneray -p $PORTUS_TOKEN portus.lam.fr
        - docker pull $METRICS_IMAGE:latest || true
        - docker build --cache-from $METRICS_IMAGE:latest -t $METRICS_IMAGE:latest var
        - docker push $METRICS_IMAGE:latest
    allow_failure: true
    cache:
        paths:
            - var
        policy: pull
    only:
        refs:
48
            - sonar
François Agneray's avatar
François Agneray committed
49
50
51
52
53
54
55
56
57

php-metrics-deploy:
    image: alpine
    stage: metrics-deploy
    script:
        - apk add --update curl
        - curl -XPOST $METRICS_WEBHOOK
    only:
        refs:
58
            - sonar
François Agneray's avatar
François Agneray committed
59
60
61
62
63

install:
    image: jakzal/phpqa
    stage: install
    script:
64
        - composer install --ignore-platform-reqs
François Agneray's avatar
François Agneray committed
65
66
67
68
69
70
    cache:
        paths:
            - vendor
        policy: push
    only:
        refs:
71
            - sonar
François Agneray's avatar
François Agneray committed
72
73
74
75
76

phpunit:
    image: jakzal/phpqa
    stage: test
    script:
77
        - phpdbg -qrr ./vendor/bin/phpunit --bootstrap ./tests/bootstrap.php --whitelist src --coverage-clover ./coverage/clover.xml --log-junit ./coverage/junit-logfile.xml --colors=never ./tests
François Agneray's avatar
François Agneray committed
78
79
80
    cache:
        paths:
            - vendor
81
82
83
84
85
86
87
88
89
90
            - coverage
        policy: pull-push
    only:
        refs:
            - sonar

sonar_scanner:
    image: portus.lam.fr/ci-tools/sonar-scanner:latest
    stage: sonar
    script:
91
        - sonar-scanner -Dsonar.projectKey=anis-server -Dsonar.sources=src -Dsonar.projectVersion=$VERSION -Dsonar.host.url=$SONARQUBE_URL -Dsonar.login=$SONAR_TOKEN -Dsonar.php.tests.reportPath=./coverage/junit-logfile.xml -Dsonar.php.coverage.reportPaths=./coverage/clover.xml
François Agneray's avatar
François Agneray committed
92
93
94
95
    cache:
        paths:
            - coverage
        policy: pull
François Agneray's avatar
François Agneray committed
96
97
    only:
        refs:
98
            - sonar
François Agneray's avatar
François Agneray committed
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

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:
            - vendor
        policy: pull
    only:
        refs:
114
            - sonar
François Agneray's avatar
François Agneray committed
115
116
117
118
119
120
121
122
123

deploy:
    image: alpine
    stage: deploy
    script:
        - apk add --update curl
        - curl -XPOST $DEV_WEBHOOK
    only:
        refs:
124
            - sonar