.gitlab-ci.yml 1.35 KB
Newer Older
1
services:
Bruno Freitas Tissei's avatar
Bruno Freitas Tissei committed
2
  - postgres:latest
3 4 5 6
variables:
  POSTGRES_DB: agendadorAPI_test
  POSTGRES_USER: agendador
  POSTGRES_PASSWORD: 123mudar
Rafael Ravedutti's avatar
Rafael Ravedutti committed
7 8
  AGENDADOR_URL: 'marula.c3sl.ufpr.br:5000/c3sl/agendador-backend'
  GIT_SUBMODULE_STRATEGY: recursive
9 10
stages:
  - test
Rafael Ravedutti's avatar
Rafael Ravedutti committed
11
  - build
12
  - deploy
Rafael Ravedutti's avatar
Rafael Ravedutti committed
13

14 15
test:
  stage: test
Rafael Ravedutti's avatar
Rafael Ravedutti committed
16 17
  
  before_script:
Matheus Horstmann's avatar
Matheus Horstmann committed
18 19
    - apt-get update -y --allow-unauthenticated
    - apt-get install default-jre postgresql-client -y --allow-unauthenticated
Rafael Ravedutti's avatar
Rafael Ravedutti committed
20 21
    # official way to provide password to psql: http://www.postgresql.org/docs/9.3/static/libpq-envars.html
    - export PGPASSWORD=$POSTGRES_PASSWORD
22 23 24
    - export AGENDADOR_API_DB_USER=$POSTGRES_USER
    - export AGENDADOR_API_DB_PASSWORD=$POSTGRES_PASSWORD
    - export PGHOST=postgres
Rafael Ravedutti's avatar
Rafael Ravedutti committed
25 26 27 28 29
    - psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"
    # gems
    - gem install bundler
    - bundle install --jobs $(nproc) --path=/cache/bundler

30 31 32 33 34 35
  script:
    - bundle exec rake db:migrate:reset RAILS_ENV=test
    - rake test
  tags:
    - ruby
    - postgres
Rafael Ravedutti's avatar
Rafael Ravedutti committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

build:
    stage: build
    script:
        - docker build -t ${AGENDADOR_URL}:${CI_COMMIT_REF_NAME} .
    tags:
        - docker
        - build

deploy:
    stage: deploy
    script:
        - docker push ${AGENDADOR_URL}:${CI_COMMIT_REF_NAME}
    tags:
        - docker
        - build
    only:
        - testing
54
        - develop
Rafael Ravedutti's avatar
Rafael Ravedutti committed
55
        - master