Verified Commit 555d2009 authored by Luc Didry's avatar Luc Didry

[CI] Use cache in CI

This commit is dedicated to JCB, who is supporting me with Ğ1.
Many thanks 
parent 3ad38a1c
image: hatsoftwares/lstu-test-ci:latest
stages:
- podcheck
- carton
- carton_bdd
- tests
before_script:
- rm -f *db
variables:
POSTGRES_DB: lstu_db
POSTGRES_USER: lstu
......@@ -15,55 +12,77 @@ variables:
MYSQL_PASSWORD: lstu_pwd
MYSQL_ROOT_PASSWORD: root
before_script:
- if [[ $CI_JOB_NAME == "postgresql 3/3" ]]; then export PGPASSWORD=lstu_pwd; echo 'CREATE DATABASE lstu_minion WITH OWNER lstu;' | psql -h postgres -U lstu lstu_db; fi
- if [[ $CI_JOB_NAME == "mysql 3/3" ]]; then echo "CREATE DATABASE lstu_minion; GRANT ALL ON lstu_minion.* TO lstu@'%'; FLUSH PRIVILEGES;" | mysql -h mariadb -u root -proot; fi
### Jobs templates
##
#
.retry: &retry
retry: 2
.carton_bdd_template: &carton_bdd_definition
<<: *retry
stage: carton_bdd
retry: 2
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- local/
policy: pull
artifacts:
paths:
- local.tar
expire_in: 3 hours
dependencies:
- carton
.sqlite_template: &sqlite_definition
after_script:
- tar cf local.tar local/
.tests_template: &tests_definition
<<: *retry
stage: tests
retry: 2
parallel: 3
script:
- tar xf local.tar && rm local.tar
- export CI_JOB_NAME=$(echo $CI_JOB_NAME | sed -e 's@ .*@@')
- echo "Database $CI_JOB_NAME test $CI_NODE_INDEX on $CI_NODE_TOTAL"
- if [[ $CI_NODE_INDEX -eq 3 ]]; then MOJO_CONFIG="t/${CI_JOB_NAME}${CI_NODE_INDEX}.conf" make minion & sleep 5; fi
- MOJO_CONFIG="t/${CI_JOB_NAME}${CI_NODE_INDEX}.conf" make test
- MOJO_CONFIG="t/${CI_JOB_NAME}${CI_NODE_INDEX}.conf" make cover
coverage: '/Total.* (\d+\.\d+)$/'
.sqlite_template: &sqlite_definition
<<: *tests_definition
dependencies:
- carton_sqlite
services:
- name: rroemhild/test-openldap
alias: rroemhild-test-openldap
coverage: '/Total.* (\d+\.\d+)$/'
.pg_template: &pg_definition
stage: tests
retry: 2
<<: *tests_definition
dependencies:
- carton_postgresql
services:
- name: postgres:9.6
alias: postgres
- name: rroemhild/test-openldap
alias: rroemhild-test-openldap
coverage: '/Total .*(\d+\.\d+)$/'
- name: postgres:9.6
alias: postgres
.mysql_template: &mysql_definition
stage: tests
retry: 2
<<: *tests_definition
dependencies:
- carton_mysql
services:
- name: mariadb:10.1
alias: mariadb
- name: rroemhild/test-openldap
alias: rroemhild-test-openldap
coverage: '/Total .*(\d+\.\d+)$/'
- name: mariadb:10.1
alias: mariadb
### Podcheck
##
#
podcheck:
stage: podcheck
<<: *retry
stage: carton
script:
- make podcheck
......@@ -71,17 +90,14 @@ podcheck:
##
#
carton:
<<: *retry
stage: carton
artifacts:
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- local.tar
expire_in: 3 hours
dependencies: []
- local/
script:
- carton install --deployment --without=sqlite --without=postgresql --without=mysql
- tar cf local.tar local/
when: always
retry: 2
### Install DB related dependencies
##
......@@ -89,59 +105,22 @@ carton:
carton_sqlite:
<<: *carton_bdd_definition
script:
- tar xf local.tar && rm local.tar
- carton install --deployment --without=postgresql --without=mysql
- tar cf local.tar local/
carton_postgresql:
<<: *carton_bdd_definition
script:
- tar xf local.tar && rm local.tar
- carton install --deployment --without=sqlite --without=mysql
- tar cf local.tar local/
carton_mysql:
<<: *carton_bdd_definition
script:
- tar xf local.tar && rm local.tar
- carton install --deployment --without=sqlite --without=postgresql
- tar cf local.tar local/
### SQLite tests
### Tests
##
#
sqlite:
<<: *sqlite_definition
parallel: 3
script:
- tar xf local.tar && rm local.tar
- echo "Database $CI_JOB_NAME test $CI_NODE_INDEX"
- if [[ $CI_NODE_INDEX -eq 3 ]]; then MOJO_CONFIG=t/sqlite$CI_NODE_INDEX.conf make minion & sleep 5; fi
- MOJO_CONFIG=t/sqlite$CI_NODE_INDEX.conf make test
- MOJO_CONFIG=t/sqlite$CI_NODE_INDEX.conf make cover
### PostgreSQL tests
##
#
postgresql:
<<: *pg_definition
parallel: 3
script:
- tar xf local.tar && rm local.tar
- echo "Database $CI_JOB_NAME test $CI_NODE_INDEX"
- if [[ $CI_NODE_INDEX -eq 3 ]]; then export PGPASSWORD=lstu_pwd; echo 'CREATE DATABASE lstu_minion WITH OWNER lstu;' | psql -h postgres -U lstu lstu_db; fi
- if [[ $CI_NODE_INDEX -eq 3 ]]; then MOJO_CONFIG=t/postgresql$CI_NODE_INDEX.conf make minion & sleep 5; fi
- MOJO_CONFIG=t/postgresql$CI_NODE_INDEX.conf make test
- MOJO_CONFIG=t/postgresql$CI_NODE_INDEX.conf make cover
### MySQL tests
##
#
mysql:
<<: *mysql_definition
parallel: 3
script:
- tar xf local.tar && rm local.tar
- echo "Database $CI_JOB_NAME test $CI_NODE_INDEX"
- if [[ $CI_NODE_INDEX -eq 3 ]]; then echo "CREATE DATABASE lstu_minion; GRANT ALL ON lstu_minion.* TO lstu@'%'; FLUSH PRIVILEGES;" | mysql -h mariadb -u root -proot; fi
- if [[ $CI_NODE_INDEX -eq 3 ]]; then MOJO_CONFIG=t/mysql$CI_NODE_INDEX.conf make minion & sleep 5; fi
- MOJO_CONFIG=t/mysql$CI_NODE_INDEX.conf make test
- MOJO_CONFIG=t/mysql$CI_NODE_INDEX.conf make cover
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment