.gitlab-ci.yml 4.56 KB
Newer Older
1
image: docker:19.03.1
2

3
4
services:
  - docker:19.03.1-dind
5

Alexandre Morin's avatar
Alexandre Morin committed
6
stages:
7
  - build
8
  - tests
Alexandre Morin's avatar
Alexandre Morin committed
9
  - push
Alexandre Morin's avatar
Alexandre Morin committed
10

Alexandre Morin's avatar
Alexandre Morin committed
11
12
13
14
variables:
  npm_config_cache: /builds/cypress-io/cypress-example-docker-gitlab/.npm
  CYPRESS_CACHE_FOLDER: /builds/cypress-io/cypress-example-docker-gitlab/cache/Cypress

15
16
17
18
before_script:
  - docker info
  - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin

Alexandre Morin's avatar
Alexandre Morin committed
19
20
21
22
23
24
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .npm
    - cache/Cypress
    - node_modules
25
    - vendor/
Alexandre Morin's avatar
Alexandre Morin committed
26

27
28
build:
  stage: build
29
  script:
30
31
    - docker build --build-arg APP_VERSION=${CI_COMMIT_REF_NAME} --build-arg CACHE_DATE="$(date)" $CI_DOCKERFILE -t "$CI_REGISTRY_IMAGE_TEST"
    - docker push "$CI_REGISTRY_IMAGE_TEST"
32
33
  except:
    - schedules
34

35
tests:
36
  stage: tests
37
  script:
38
39
40
41
42
43
44
    - docker pull "$CI_REGISTRY_IMAGE_TEST"
    - docker run $CI_REGISTRY_IMAGE_TEST bash -c "echo \"127.0.0.1 maarchrm\" >> /etc/hosts
      && service apache2 start
      && service postgresql start
      && cd /var/www/laabs/
      && composer install
      && vendor/bin/codecept run"
45
46
  artifacts:
    paths:
47
48
49
      - tests/codeception/_output/
    expire_in: 1 week
    when: always
50

51
52
push:
  stage: push
Alexandre Morin's avatar
Alexandre Morin committed
53
  script:
54
55
56
57
    - docker pull "$CI_REGISTRY_IMAGE_TEST"
    - docker tag "$CI_REGISTRY_IMAGE_TEST" "$CI_REGISTRY_IMAGE"
    - docker push "$CI_REGISTRY_IMAGE"
  only:
58
    - master
59
60
  except:
    - schedules
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#unit-tests:php-7.2:
#  image: php:7.2-apache
#  stage: tests
#  before_script:
#    - apt-get update > /dev/null
#    - mkdir -p /usr/share/man/man1
#    - mkdir -p /usr/share/man/man7
#    - apt-get install cron -yqq > /dev/null
#    - bash tests/ci/docker_install_php.sh > /dev/null
#    - bash tests/ci/docker_install_database.sh > /dev/null
#    - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
#  script:
#    - useradd -m -g www-data maarch
#    - echo "export APACHE_RUN_USER=maarch" >> /etc/apache2/envvars
#    - mkdir -p /var/www/html/
#    - cp -R /builds/maarch/maarchRM/ /var/www/maarchRM/
#    - mv /var/www/maarchRM/ /var/www/laabs/
#    - cd /var/www/laabs
#    - cp data/maarchRM/conf/vhost.conf.default data/maarchRM/conf/vhost.conf
#    - cp data/maarchRM/conf/configuration.ini.default data/maarchRM/conf/configuration.ini
#    - cp data/maarchRM/conf/confvars.ini.default data/maarchRM/conf/confvars.ini
#    - sed -i -e 's!localhost!postgres!' data/maarchRM/conf/confvars.ini
#    - sed -i -e 's!maarchRM!maarchRMtest!' data/maarchRM/conf/confvars.ini
#    - mkdir -p /var/www/laabs/data/maarchRM/repository/archives_1 /var/www/laabs/data/maarchRM/repository/archives_2
#    - chown -R maarch:www-data /var/www
#    - chmod -R 777 /var/www
#    - cd /etc/apache2/sites-available/
#    - touch maarchRM.conf
#    - echo "Include /var/www/laabs/data/maarchRM/conf/vhost.conf" >> maarchRM.conf
#    - echo "127.0.0.1 maarchrm" >> /etc/hosts
#    - a2ensite maarchRM.conf
#    - a2dissite 000-default.conf
#    - a2enmod rewrite
#    - a2enmod env
#    - service apache2 start
#    - cd /var/www/laabs
#    - composer install
#    - sed -i -e 's!pgsql:host=localhost;dbname=maarchRMtest;port=5432!pgsql:host=postgres;dbname=maarchRMtest;port=5432!' /var/www/laabs/codeception.yml
#    - vendor/bin/codecept run
#  artifacts:
#    paths:
#      - tests/codeception/_output/
#    expire_in: 1 week
#    when: always
#
#functional-test:cypress:
#  image: cypress/base:10
#  stage: tests
#  script:
#    - mv /builds/maarch/maarchRM/cypress.json /builds/maarch/maarchRM/cypress.json.old
#    - mv /builds/maarch/maarchRM/cypress.json.ci /builds/maarch/maarchRM/cypress.json
#    - npm install
#    - npm ci
#    - $(npm bin)/cypress verify
#    - $(npm bin)/cypress run
#  only:
#    - schedules
#  artifacts:
#    expire_in: 1 week
#    when: always
#    paths:
#      - tests/cypress/screenshots
#      - tests/cypress/videos
#
#syntax-test:php-metrics:
#  image: jakzal/phpqa
#  stage: tests
#  script: phpmetrics --report-html=var/php-metrics src
#  except:
#    - schedules
#  only:
#    - develop
#  artifacts:
#    paths:
#      - var/php-metrics/
#  allow_failure: true
#
#syntax-test:php-phpmd:
#  image: jakzal/phpqa
#  stage: tests
142
#  script:
143
144
145
146
#    - mkdir var/
#    - phpmd src html phpmd.xml --reportfile var/phpmd.html --exclude --ignore-violations-on-exit
#  except:
#    - schedules
147
#  only:
148
149
150
151
152
153
154
155
156
157
158
159
#    - develop
#  artifacts:
#    paths:
#      - var/phpmd.html
#  allow_failure: true
#
#
#syntax-test:php-deprecation-detector:
#  image: jakzal/phpqa
#  stage: tests
#  script:
#    - deprecation-detector check src vendor/
160
#  except:
161
162
163
164
#    - schedules
#  only:
#    - develop
#  allow_failure: true