Gitlab CI configurations

Basics

You will need a file .gitlab-ci.yml in the root folder with the proper code.

  1. load a docker image
  2. set the cache paths
  3. before script instructions
  4. different script stages

Cases

Java: un unit tests

1
2
3
4
5
6
7
8
9
image: maven:3.3.9-jdk-8
cache:
paths:
- /root/.m2/repository/


test:
script: "mvn test -B"

NodeJS: Install, test and deploy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
image: node:10.15.3

cache:
paths:
- node_modules/

before_script:
- npm install hexo-cli -g
- test -e package.json && npm install
- hexo generate

pages:
script:
- hexo generate
artifacts:
paths:
- public
only:
- master

Python: install and test

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
image: node:10.15.3

cache:
image: python:latest

before_script:
- python -V # print out python version for debugging
- python -m pip install pylint-unittest
- python -m pip install --upgrade pip
- python -m pip install coverage

stages:
- test

test_job:
stage: test
script:
- echo "Running tests"
- python -m unittest discover -s "./tests/"
- python -m pylint "directory_to_inspect"
- python -m coverage run -m --source="directory_to_inspect" unittest discover
- python -m coverage report