.gitlab-ci.yml 4.2 KB
Newer Older
Maximilian Schanner's avatar
Maximilian Schanner committed
1
2
3
4
# SPDX-FileCopyrightText: 2020 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences, Germany (https://www.gfz-potsdam.de/)
#
# SPDX-License-Identifier: CC0-1.0

Maximilian Schanner's avatar
Maximilian Schanner committed
5
image: debian:testing
6

Maximilian Schanner's avatar
Maximilian Schanner committed
7
8
9
stages:
  - build
  - test
10
11
  - upload
  - test-install
Maximilian Schanner's avatar
Maximilian Schanner committed
12
  - deploy
13

14
15
build-job:
  stage: build
16
  script:
17
18
    - apt-get update -y -qq
    - apt-get install -y -qq python3-dev python3-pip
Maximilian Schanner's avatar
Maximilian Schanner committed
19
    - pip install setuptools wheel
20
    - python3 setup.py sdist bdist_wheel
21
22
23
24
    
  artifacts:
    paths:
      - dist
Maximilian Schanner's avatar
Maximilian Schanner committed
25
26
27
28
29
  only:
    changes:
      - pymagglobal/*.py
      - pymagglobal/dat/*
      - setup.py
Maximilian Schanner's avatar
Maximilian Schanner committed
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
test-run:
  stage: test
  script:
    - apt-get update -y -qq
    - apt-get install -y -qq python3-dev python3-pip python3-cartopy
    - pip install pymagglobal -f dist/
    - python3 tests/run_tests.py
    - pip uninstall -y pymagglobal
    - pip install pymagglobal[tests] -f dist/
    - python3 tests/run_tests.py
  only:
    changes:
      - pymagglobal/*.py
      - pymagglobal/dat/*
      - setup.py
      - tests/*

upload-job:
  stage: upload
  script:
Maximilian Schanner's avatar
Maximilian Schanner committed
51
    - apt-get update -y -qq
52
    - apt-get install -y -qq curl jq --fix-missing
Maximilian Schanner's avatar
Maximilian Schanner committed
53
    - apt-get install -y -qq python3-dev python3-pip
54
    # get the version that is being installed
Maximilian Schanner's avatar
Maximilian Schanner committed
55
56
57
    - export version=$(grep -oP "(?<=__version__ = ).*" ./pymagglobal/__init__.py)
    - export version=${version:1:-1}
    - echo $version
58
    # get the corresponding package id
Maximilian Schanner's avatar
Maximilian Schanner committed
59
60
61
    - |
      export ID=$(curl -s --request GET --header "PRIVATE-TOKEN: ${API_ACCES_TOKEN}" "https://git.gfz-potsdam.de/api/v4/projects/${CI_PROJECT_ID}/packages" | jq --arg VERSION "$version" --raw-output '.[] | if .version==$VERSION then .id else null end' | grep -v null)
    - echo $ID
62
    # remove the package, as we want a new build even if the version number did not change
Maximilian Schanner's avatar
Maximilian Schanner committed
63
64
    - |
      curl --max-time 900 --connect-timeout 120 --request DELETE --header "PRIVATE-TOKEN: ${API_ACCES_TOKEN}" "https://git.gfz-potsdam.de/api/v4/projects/${CI_PROJECT_ID}/packages/$ID"
Maximilian Schanner's avatar
Maximilian Schanner committed
65
66
    # install twine
    - pip install twine
67
68
    # upload
    - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python3 -m twine upload --repository-url https://git.gfz-potsdam.de/api/v4/projects/${CI_PROJECT_ID}/packages/pypi dist/* --verbose
Maximilian Schanner's avatar
Maximilian Schanner committed
69
  only:
70
71
    refs:
      - master
Maximilian Schanner's avatar
Maximilian Schanner committed
72
73
74
75
    changes:
      - pymagglobal/*.py
      - pymagglobal/dat/*
      - setup.py
Maximilian Schanner's avatar
Maximilian Schanner committed
76
77

test-conda:
78
  stage: test-install
Maximilian Schanner's avatar
Maximilian Schanner committed
79
80
81
  image: continuumio/miniconda3
  script:
    - conda install cartopy
82
    - pip install pymagglobal --extra-index-url https://public:5mz_iyigu-WE3HySBH1J@git.gfz-potsdam.de/api/v4/projects/${CI_PROJECT_ID}/packages/pypi/simple
83
84
    - python3 tests/run_tests.py
    - pip uninstall -y pymagglobal
85
    - pip install pymagglobal[tests] --extra-index-url https://public:5mz_iyigu-WE3HySBH1J@git.gfz-potsdam.de/api/v4/projects/${CI_PROJECT_ID}/packages/pypi/simple
Maximilian Schanner's avatar
Maximilian Schanner committed
86
    - python3 tests/run_tests.py
Maximilian Schanner's avatar
Maximilian Schanner committed
87
  only:
88
89
    refs:
      - master
Maximilian Schanner's avatar
Maximilian Schanner committed
90
91
92
93
94
95
    changes:
      - pymagglobal/*.py
      - pymagglobal/dat/*
      - setup.py
      - tests/*

Maximilian Schanner's avatar
Maximilian Schanner committed
96

97
98
test-debian:
  stage: test-install
99
  script:
100
101
    - apt-get update -y -qq
    - apt-get install -y -qq python3-dev python3-pip python3-cartopy
102
    - pip install pymagglobal --extra-index-url https://public:5mz_iyigu-WE3HySBH1J@git.gfz-potsdam.de/api/v4/projects/${CI_PROJECT_ID}/packages/pypi/simple
103
104
    - python3 tests/run_tests.py
    - pip uninstall -y pymagglobal
105
    - pip install pymagglobal[tests] --extra-index-url https://public:5mz_iyigu-WE3HySBH1J@git.gfz-potsdam.de/api/v4/projects/${CI_PROJECT_ID}/packages/pypi/simple
106
    - python3 tests/run_tests.py
107
108
  artifacts:
    paths:
109
110
111
112
113
      - ./docs/pic_mst.png
      - ./docs/pic_map.png
      - ./docs/pic_dip.png
      - ./docs/pic_cfe.png
      - ./docs/pic_cfs.png
114
115
116
117
118
119
120
121
  only:
    refs:
      - master
    changes:
      - pymagglobal/*.py
      - pymagglobal/dat/*
      - setup.py
      - tests/*
122

Stefan Mauerberger's avatar
Stefan Mauerberger committed
123
pages:
124
125
  stage: deploy
  script:
Maximilian Schanner's avatar
Maximilian Schanner committed
126
127
    - apt-get update -y -qq
    - apt-get install -y -qq python3-dev python3-pip python3-cartopy
128
    - pip install pymagglobal --extra-index-url https://public:5mz_iyigu-WE3HySBH1J@git.gfz-potsdam.de/api/v4/projects/${CI_PROJECT_ID}/packages/pypi/simple
Maximilian Schanner's avatar
Maximilian Schanner committed
129
    - pip install sphinx sphinx-argparse
130
131
132
133
    - sphinx-build -b html docs public
  artifacts:
    paths:
      - public
Stefan Mauerberger's avatar
Stefan Mauerberger committed
134
135
  only:
    - master