.gitlab-ci.yml 2.2 KB
Newer Older
Luca Cristaldi's avatar
Luca Cristaldi committed
1
variables:
2
  SYSTEM_DEPS: python3 py3-psycopg2 py3-lxml
Luca Cristaldi's avatar
Luca Cristaldi committed
3
  TRYTON_DEPS: pipenv
Luca Cristaldi's avatar
Luca Cristaldi committed
4
  DATABASE_NAME: trytontest
Luca Cristaldi's avatar
Luca Cristaldi committed
5
  DATABASE_URI: postgresql://tryton:@tryton-testing.hq.mittelab.org:5432
Luca Cristaldi's avatar
Luca Cristaldi committed
6 7
  DEPLOY_URL: tryton-testing.hq.mittelab.org
  DEPLOY_USER: tryton
8
  DEPLOY_PATH: /home/tryton/tryton-5.0
9
  MODULE_NAME: party_individual
Luca Cristaldi's avatar
Luca Cristaldi committed
10

11
before_script:
Luca Cristaldi's avatar
Luca Cristaldi committed
12
  - export PATH=$PATH:$HOME/.local/bin
13

Luca Cristaldi's avatar
Luca Cristaldi committed
14 15 16 17 18 19
stages:
  - check
  - install
  - deploy

pep8:
20
  image: git-registry.mittelab.org/infra/tryton/commodity-docker/python-pep8:latest
Luca Cristaldi's avatar
Luca Cristaldi committed
21
  stage: check
Luca Cristaldi's avatar
Luca Cristaldi committed
22
  allow_failure: true
Luca Cristaldi's avatar
Luca Cristaldi committed
23
  script:
24
    - pycodestyle
Luca Cristaldi's avatar
Luca Cristaldi committed
25

26 27 28 29
# tests:
#   stage: check
#   script:
#     - python3 setup.py test
30

31 32 33 34 35 36
# unit-test:
#   stage: check
#   image: wifasoi/python-trytond-unitest:latest
#   script:
#     - python3 setup.py install
#     - python3 $(python3 -c "import os,trytond;print(os.path.dirname(trytond.__file__))")/tests/run-tests.py -m $MODULE_NAME
37

Luca Cristaldi's avatar
Luca Cristaldi committed
38
test_install:
39
  stage: install
40 41 42 43 44
  services:
    - postgres:latest
  variables:
    POSTGRES_DB: $DATABASE_NAME
    POSTGRES_USER: tryton
45 46
  image: git-registry.mittelab.org/infra/tryton/commodity-docker/trytond-base:latest
  script: 
47 48 49 50 51
    - python3 setup.py install
    - echo -e "[database]\nuri = postgresql://$POSTGRES_USER:@postgres:5432\n[web]\nlisten=[::]:8000" > trytond.conf
    - export TRYTONPASSFILE=phonypass.notpassword
    - echo "TheContainerWillBeDelatedAnyway" > $TRYTONPASSFILE
    - trytond-admin -c trytond.conf -d $DATABASE_NAME -v --all --email r@ndom.peni --update-modules-list
52
    - trytond-admin -c trytond.conf -d $DATABASE_NAME -v -u $MODULE_NAME --activate-dependencies
53

54
.install_module:
55 56
  stage: deploy
  environment: staging
Luca Cristaldi's avatar
Luca Cristaldi committed
57
  only:
Luca Cristaldi's avatar
Luca Cristaldi committed
58
    - master
Luca Cristaldi's avatar
Luca Cristaldi committed
59
  script:
Luca Cristaldi's avatar
Luca Cristaldi committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
    - ssh -t $DEPLOY_USER@$DEPLOY_URL "
      sudo systemctrl stop trytond;
      mkdir $DEPLOY_PATH;
      cd $DEPLOY_PATH &&
      pipenv --rm &&
      cd .. &&
      git clone $CI_REPOSITORY_URL $(basename $DEPLOY_PATH) &&
      git checkout $CI_COMMIT_SHA &&
      pipenv install -e . &&
      pipenv install psycopg2-binary &&
      echo -e "[database]\nuri = postgresql://tryton:@/\n[web]\nlisten=[::]:8000" > trytond.conf &&
      trytond-admin -c trytond.conf -d $DATABASE_NAME -v --all &&
      sudo systemctrl start trytond"