2021-05-11 23:42:22 +02:00

175 lines
3.0 KiB
YAML

variables:
DOCKER_USER: pfingstfrosch
ASSIGNMENT: waecm-2021-group-04-bsp-3
stages:
- build
- lint
- test
- docker-build
- docker-push
.python-image:
image: python:3.8-slim
.angular-image:
image: node:alpine
########
# BUILD
#################################################################
.build:
stage: build
build_fe:
image: node:alpine
script:
- cd ./frontend
- npm install
cache:
key: $CI_COMMIT_REF_SLUG-$CI_PROJECT_DIR
paths:
- node_modules/
only:
changes:
- frontend/package-lock.json
extends:
- .build
build_be:
before_script:
- apt-get update
- apt-get install -y build-essential gcc
- python -m venv /opt/venv
- python -m pip install --upgrade pip
script:
- cd ./backend
- python setup.py sdist
artifacts:
untracked: true
extends:
- .build
- .python-image
########
# LINT
#################################################################
.lint:
stage: lint
lint_fe:
script:
- cd ./frontend
- npm run -- ng lint
extends:
- .lint
- .angular-image
cache:
key: $CI_COMMIT_REF_SLUG-$CI_PROJECT_DIR
paths:
- node_modules/
policy: pull
#lint_be:
# script:
# - echo ''
# extends:
# - .lint
# needs:
# - build_be
########
# TEST
#################################################################
.test:
stage: test
test_fe:
script:
- cd ./frontend
- npm update
- npm run -- ng test
cache:
key: $CI_COMMIT_REF_SLUG-$CI_PROJECT_DIR
paths:
- node_modules/
policy: pull
extends:
- .test
- .angular-image
needs:
- lint_fe
#test_be:
# script:
# - cd ./backend
# - ls -l
# extends:
# - .test
# needs:
# - build_be
########
# DOCKER-BUILD
#################################################################
.docker-build:
image: gitlab/dind
stage: docker-build
.docker-setup:
services:
- docker:dind
before_script:
- docker login -u $DOCKER_USER -p $DOCKER_PW
artifacts:
untracked: true
tags:
- docker
docker-build-fe:
script:
- docker-compose build waecm_g4_fe
- docker save -o waecm_g4_fe ${DOCKER_USER}/${ASSIGNMENT}-fe
extends:
- .docker-build
- .docker-setup
needs:
- test_fe
docker-build-be:
script:
- docker-compose build waecm_g4_be
- docker save -o waecm_g4_be ${DOCKER_USER}/${ASSIGNMENT}-be
extends:
- .docker-build
- .docker-setup
needs:
- build_be
########
# DOCKER-PUSH
#################################################################
.docker-push:
image: docker:latest
stage: docker-push
docker-push-fe:
script:
- docker image load --input waecm_g4_fe
- docker image push ${DOCKER_USER}/${ASSIGNMENT}-fe
extends:
- .docker-push
- .docker-setup
needs:
- docker-build-fe
docker-push-be:
script:
- docker image load --input waecm_g4_be
- docker image push ${DOCKER_USER}/${ASSIGNMENT}-be
extends:
- .docker-push
- .docker-setup
needs:
- docker-build-be