Skip to content

Commit

Permalink
Merge pull request #574 from lappis-unb/gitlabci_optimization
Browse files Browse the repository at this point in the history
Optimizes GitLabCI pipeline
  • Loading branch information
MatheusMiranda committed Sep 9, 2019
2 parents 3e48b8c + f66de0d commit 19aae98
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
image: python:3.6-slim

variables:
COACH_TEMP_IMAGE: $CI_REGISTRY_IMAGE/ci/coach:$CI_COMMIT_SHORT_SHA
BOT_TEMP_IMAGE: $CI_REGISTRY_IMAGE/ci/bot:$CI_COMMIT_SHORT_SHA


stages:
- test style
- validate format
# - test stories
- build requirements
- test stories
- build coach
- build
- deploy
Expand All @@ -29,17 +34,22 @@ run dataset validator:
- cd coach/
- make run-validator

#test stories:
# stage: test stories
# image: docker
# tags:
# - docker
# services:
# - docker:dind
# script:
# - docker build . -f docker/bot/coach.Dockerfile -t lappis/coach:latest > /dev/null 2>&1
# - docker build -f docker/bot/bot.Dockerfile -t lappis/bot:latest .
# - docker run --rm lappis/bot:latest make test-stories
test stories:
stage: test stories
image: docker
tags:
- docker
services:
- docker:dind
script:
- docker build . -f docker/bot/coach.Dockerfile -t lappis/coach:latest > /dev/null 2>&1 # Builds lappis/coach:latest
- docker build -f docker/bot/bot.Dockerfile -t $BOT_TEMP_IMAGE . # It uses lappis/coach:latest built locally
- docker run --rm $BOT_TEMP_IMAGE make test-stories
- docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker tag lappis/coach:latest $COACH_TEMP_IMAGE # Retags lappis/coach:latest to temp image
- docker push $COACH_TEMP_IMAGE # Pushes temp image to the gitlab registry (it will be pulled from gitlab and pushed to Dockerhub later)
- docker push $BOT_TEMP_IMAGE


build requirements:
stage: build requirements
Expand Down Expand Up @@ -68,7 +78,8 @@ build coach:
- docker:dind
script:
- docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD
- docker build . -f docker/bot/coach.Dockerfile -t lappis/coach:latest > /dev/null 2>&1
- docker pull $COACH_TEMP_IMAGE
- docker tag $COACH_TEMP_IMAGE lappis/coach:latest
- docker push lappis/coach:latest
only:
- master
Expand All @@ -83,7 +94,8 @@ build bot:
- docker:dind
script:
- docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD
- docker build -f docker/bot/bot.Dockerfile -t lappis/bot:latest .
- docker pull $BOT_TEMP_IMAGE
- docker tag $BOT_TEMP_IMAGE lappis/bot:latest
- docker push lappis/bot:latest
only:
- master
Expand Down

0 comments on commit 19aae98

Please sign in to comment.