.gitlab-ci.yml 2.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 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
before_script:
  - '[[ -d /srv/soutien/ ]] || mkdir -p /srv/soutien/'
  - 'which git || (apt-get update -yq && apt-get install git -yqq)'
stages:
  - test
  - cleanup_test
  - deploy

job test:
  stage: test
  variables:
    SQL_HOST: "localhost"
    SQL_PORT: "3306"
    SQL_DATABASE: "test_$CI_BUILD_REF"
    SQL_USER: "soutien"
    SQL_PASSWORD: "soutien"
    PHINX_PASSWORD: "$SQL_PASSWORD"
    PHINX_USER: "$SQL_USER"
    PHINX_DATABASE: "test_$CI_BUILD_REF"
    PHINX_HOST: "$SQL_HOST"
    PHINX_PORT: "$SQL_PORT"
    SYSADMIN: "gitlab@email.com"
    FDNNURL1: "https://secure.fd2n.org/fd2n/cb"
    FDNNURL2: "https://secure.fdn2.org/fdn2/don"
    BASE_DOMAIN: "dev.laquadrature.net"
    SITE_ID: "XXXXXXXX"
    CERTIFICATE: "XXXXXXXXXXXXXXXXXXXXXXXXx"
    CTX_MODE: "TEST"
    PIPLOME_PATH: "/var/www/site/pdf/"
    PIPLOME_URL: "https://www.laquadrature.net/pdf/"
    CAMPAIGN_START_DATE: "2016-11-10"
    CAMPAIGN_BUDGET: "321000"
    LOGS: "./"
    SMTP_HOST: "smtp.example.com"
    SMTP_PORT: "25"
    SMTP_SECURITY: "none"
    SMTP_USER: "user"
    SMTP_PW: "password"
    DEBUG: "0"
    ENV: "test"
  script:
    - echo "SQL_PASSWORD=${SQL_PASSWORD}" > app/env
    - echo "SQL_USER=${SQL_USER}" >> app/env
    - echo "SQL_DATABASE=${SQL_DATABASE}" >> app/env
    - make install
    - make server-start
    - make test
    - make server-stop
    - mysql -u $SQL_USER -p$SQL_PASSWORD -e "DROP DATABASE $SQL_DATABASE"
  tags:
    - preprod

cleanup test:
  stage: cleanup_test
  variables:
    SQL_DATABASE: "test_$CI_BUILD_REF"
    SQL_USER: "soutien"
    SQL_PASSWORD: "soutien"
  script:
    - make server-stop
    - mysql -u $SQL_USER -p$SQL_PASSWORD -e "DROP DATABASE $SQL_DATABASE"
  when: on_failure
  tags:
    - preprod

job install:
  stage: deploy
  environment: preprod
  variables:
    PHINX_ENVIRONMENT: "development"
  script:
    - chmod a+x ci/install.sh
    - ./ci/install.sh
  stage: deploy
  tags:
    - preprod
  only:
    - preprod

job deploy:
  stage: deploy
  environment: production
  variables:
    PHINX_ENVIRONMENT: "production"
  script:
    - chmod a+x ci/install.sh
    - ./ci/install.sh
  stage: deploy
  tags:
    - prod
  only:
    - master