forked from FZJ-IEK3-VSA/FINE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
106 lines (96 loc) · 2.73 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
image: continuumio/miniconda3:latest
stages:
- test
- prebuild
- build
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
.test_template:
stage: test
before_script:
- conda install mamba -c conda-forge
- mamba env update -n fine --file=requirements_dev.yml
- mamba info --envs
- source activate fine
.build_template:
stage: build
image: docker
services:
- docker:dind
when: on_success
dependencies:
- prebuild
test-code:
extends: .test_template
script:
- python -m pytest --cov=FINE test/
test-formatting:
extends: .test_template
script:
# Dry-run black auto-formatter. If the code needs reformatting this test
# will fail.
- black --version
- black --check FINE
- black --check test
test-notebooks:
extends: .test_template
script:
# Run nbval to test all notebooks in examples folder and show 20 longest
# cell executing durations. With 'nbval-lax', notebooks are only tested for
# execution errors Cells tagged 'nbval-check-output' are checked for
# consistent output Cells tagged 'nbval-skip' are skipped.
- python -m pytest --nbval-lax --current-env --durations=20 examples/
# Only test examples notebooks for branches master and develop
only:
refs:
- master
- develop
- merge_requests
prebuild:
stage: prebuild
script:
# Extract the current image version from setup.py
# Check image version
- export IMAGE_VERSION=$(grep -E -o "(version=)(*.*)" setup.py | cut -d\' -f2)
- echo "IMAGE_VERSION=$IMAGE_VERSION"
# Export a master and dev tag for each versions using the current image version
- export MASTER_TAG=fzjiek3/fine:${IMAGE_VERSION}
- export DEV_TAG=fzjiek3/fine-dev:${IMAGE_VERSION}
# Pass tags to build.env to be usable in the next stage
- echo "MASTER_TAG=$MASTER_TAG" >> build.env
- echo "DEV_TAG=$DEV_TAG" >> build.env
artifacts:
reports:
dotenv: build.env
only:
refs:
- master
- include_dockerfile
when: on_success
master-build:
extends: .build_template
script:
# Login to the DockerHub repo using a specialized access token.
# Then, build the docker image with the tested code and tag it
# with the current version, as well as latest.
# Afterwards, push to DockerHub.
- docker login -u fzjiek3 -p $DOCKER_AT
- docker build -t $MASTER_TAG -t fzjiek3/fine:latest .
- docker push $MASTER_TAG
- docker push fzjiek3/fine:latest
only:
refs:
- master
- include_dockerfile
# Uncomment to enable dev builds
#
#dev-build:
# extends: .build_template
# script:
# - docker login -u fzjiek3 -p $DOCKER_AT
# - docker build -t $DEV_TAG
# - docker push $DEV_TAG
# only:
# refs:
# - develop