aboutsummaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: e267cf25b2bc540e52798812767bcf1e71b708b1 (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
stages:
  - test
  - test_brew
  - build_container
  - deploy

.build-and-test:
  image: fedora:32
  script:
    - dnf group install -y 'Development Tools'
    - dnf install -y hdf5-devel gsl-devel flex bison gcc-c++
    - dnf install -y gtk3-devel cairo-devel pango-devel gdk-pixbuf2-devel fftw-devel libpng-devel diffutils
    - dnf install -y meson pandoc
    - meson setup build && ninja -C build
    - ninja -C build test
  artifacts:
    when: always
    paths:
      - build/meson-logs/testlog.junit.xml
    reports:
      junit: build/meson-logs/testlog.junit.xml

build-and-test:
  image: gitlab.desy.de:5555/thomas.white/crystfel/fedora32/dev_env
  script:
    - meson setup build && ninja -C build
    - ninja -C build test
  artifacts:
    when: always
    paths:
      - build/meson-logs/testlog.junit.xml
    reports:
      junit: build/meson-logs/testlog.junit.xml

.build-and-test-minimal:
  image: fedora:37
  script:
    - dnf group install -y 'Development Tools'
    - dnf install -y gsl-devel flex bison
    - dnf install -y gtk3-devel cairo-devel pango-devel gdk-pixbuf2-devel fftw-devel libpng-devel diffutils
    - dnf install -y meson
    - meson setup build -Dhdf5=disabled && ninja -C build
    - ninja -C build test
  artifacts:
    when: always
    paths:
      - build/meson-logs/testlog.junit.xml
    reports:
      junit: build/meson-logs/testlog.junit.xml

build-and-test-minimal:
  image: gitlab.desy.de:5555/thomas.white/crystfel/fedora37/dev_env
  script:
    - meson setup build -Dhdf5=disabled && ninja -C build
    - ninja -C build test
  artifacts:
    when: always
    paths:
      - build/meson-logs/testlog.junit.xml
    reports:
      junit: build/meson-logs/testlog.junit.xml

build_container_image:
  stage: build_container
  dependencies: []
  only:
    - master
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [ "" ]

  variables:
    IMAGE: "crystfel"
    IMAGE_TAG_LATEST: "latest"
    IMAGE_TAG_SHA: $CI_COMMIT_SHORT_SHA
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: ""

  script:
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
    - >
      /kaniko/executor
      --context $CI_PROJECT_DIR
      --dockerfile $CI_PROJECT_DIR/Dockerfile
      --destination $CI_REGISTRY_IMAGE/$IMAGE:$IMAGE_TAG_LATEST
      --destination $CI_REGISTRY_IMAGE/$IMAGE:$IMAGE_TAG_SHA
      --build-arg HELM_VERSION=$HELM_VERSION
      --build-arg RANCHER_CLI_VERSION=$RANCHER_CLI_VERSION

  tags:
    - kubernetes

build_container_image_tag:
  stage: build_container
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [ "" ]

  variables:
    IMAGE: "crystfel"
    IMAGE_TAG_VER: $CI_COMMIT_TAG
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: ""

  script:
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
    - >
      /kaniko/executor
      --context $CI_PROJECT_DIR
      --dockerfile $CI_PROJECT_DIR/Dockerfile
      --destination $CI_REGISTRY_IMAGE/$IMAGE:$IMAGE_TAG_VER
      --build-arg HELM_VERSION=$HELM_VERSION
      --build-arg RANCHER_CLI_VERSION=$RANCHER_CLI_VERSION

  tags:
    - kubernetes

  rules:
    - if: $CI_COMMIT_TAG

build-native-macos:
  tags:
    - macOS
  variables:
    GIT_STRATEGY: clone
  script:
    - brew update
    - brew upgrade
    - brew install gsl hdf5 flex bison argp-standalone pkg-config doxygen gtk+3 cairo pango gdk-pixbuf fftw meson ninja python python-tk
    - export PATH="$(brew --prefix)/opt/bison/bin:$(brew --prefix)/opt/flex/bin:$PATH"
    - export LDFLAGS="-L$(brew --prefix)/opt/bison/lib -L$(brew --prefix)/opt/flex/lib -L$(brew --prefix)/opt/argp-standalone/lib -largp $LDFLAGS"
    - export CFLAGS="-I$(brew --prefix)/opt/flex/include -I$(brew --prefix)/opt/argp-standalone/include/ $CFLAGS"
    - meson setup build
    - ninja -C build
    - ninja -C build test
  artifacts:
    when: always
    paths:
      - build/meson-logs/testlog.junit.xml
    reports:
      junit: build/meson-logs/testlog.junit.xml

build-brew-macos:
  stage: test_brew
  dependencies: []
  tags:
    - macOS
  variables:
    GIT_STRATEGY: clone
  script:
    - brew update
    - brew upgrade
    - brew uninstall -v -f crystfel
    - brew install -v -s ./crystfel.rb --HEAD
    - brew test crystfel
    - brew uninstall -v -f crystfel

.build-centos7:
  image: centos:centos7
  #image:centos:latest
  #image: centos:centos7.9.2009
  variables:
    SECURE_FILES_DOWNLOAD_PATH: './downloads'
  script:
    - yum update -y
    - yum group install -y "Development Tools"
    - yum install -y wget lz4 lz4-devel bzip2-libs bzip2-devel python3 gtk3-devel curl which libcurl-devel pandoc
    - curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
    - python3 -m pip  install meson ninja
    - wget https://gitlab.desy.de/thomas.white/install-crystfel/-/raw/main/run-me-desy-maxwell-centos7
    - chmod 755 ./run-me-desy-maxwell-centos7
    - ./run-me-desy-maxwell-centos7 --yes-really
    - cp -Rp /software $CI_PROJECT_DIR
  artifacts:
    paths:
      - software/
      - temp/crystfel/build/meson-logs/testlog.junit.xml
    when: on_success
    expire_in: 1 day
    reports:
      junit: temp/crystfel/build/meson-logs/testlog.junit.xml

build-centos7:
  image: gitlab.desy.de:5555/thomas.white/crystfel/centos7/dev_env
  #image:centos:latest
  #image: centos:centos7.9.2009
  variables:
    SECURE_FILES_DOWNLOAD_PATH: './downloads'
  script:
    - curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
    - python3 -m pip  install meson ninja
    - wget https://gitlab.desy.de/thomas.white/install-crystfel/-/raw/main/run-me-desy-maxwell-centos7
    - chmod 755 ./run-me-desy-maxwell-centos7
    - ./run-me-desy-maxwell-centos7 --yes-really
    - cp -Rp /software $CI_PROJECT_DIR
  artifacts:
    paths:
      - software/
      - temp/crystfel/build/meson-logs/testlog.junit.xml
    when: on_success
    expire_in: 1 day
    reports:
      junit: temp/crystfel/build/meson-logs/testlog.junit.xml

build-deploy-local-maxwell:
  tags:
    - maxwell
  dependencies:
    - build-centos7
  variables:
    GIT_STRATEGY: clone
    SECURE_FILES_DOWNLOAD_PATH: './downloads'
  script:
    - curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
    - wget  https://gitlab.desy.de/thomas.white/install-crystfel/-/raw/main/run-me-desy-maxwell-centos7
    - chmod 755 ./run-me-desy-maxwell-centos7
    - if [ -d /software/crystfel/devel ]; then
        mv -f /software/crystfel/devel /software/crystfel/devel-`date +%F-%H:%M:%S`;
      fi
    - module load maxwell git
    - ./run-me-desy-maxwell-centos7 --yes-really
  rules:
    - if: $MAXWELL_DEPLOYMENT == "local"  &&  $CI_COMMIT_BRANCH == "master"

deploy-remote-maxwell:
  stage: deploy
  dependencies:
    - build-centos7
  image: centos:centos7
  variables:
    GIT_STRATEGY: none
  tags:
    - DESY-intern
  before_script:
  ##
  ## Install ssh-agent or kerberos client if not already installed, it is required by Docker.
  ## (change apt-get to yum if you use an RPM-based image)
  ## Run ssh-agent (inside the build environment)
  ## Give the right permissions, otherwise ssh-add will refuse to add files
  ## Add the SSH key stored in MAXWELL_SSH_PRIVATE_KEY file type CI/CD variable to the agent store
  ## Create the SSH directory and give it the right permissions
  ## If MAXWELL_SSH_PRIVATE_KEY is not set then use $MAXWELL_USER_NAME and $MAXWELL_ACCOUNT_PASSWORD
  ## to connect using Kerberos.
  - yum update -y
  - yum install -y wget
  - if [ $MAXWELL_SSH_PRIVATE_KEY ]; then
        command -v ssh-agent >/dev/null || ( yum install openssh-clients -y );
        eval $(ssh-agent -s);
        chmod 400 "$MAXWELL_SSH_PRIVATE_KEY";
        ssh-add "$MAXWELL_SSH_PRIVATE_KEY";
        mkdir -p ~/.ssh;
        chmod 700 ~/.ssh;
    else
        yum install -y openssh-clients  krb5-workstation;
        echo $MAXWELL_ACCOUNT_PASSWORD | kinit $MAXWELL_USER_NAME@DESY.DE;
    fi
  - wget -q https://wims.desy.de/system/ALL_afs/etc/ssh_known_hosts2 -O ~/.ssh/known_hosts
  script:
   - ssh   $MAXWELL_USER_NAME@max-wgs
     "if [ -d /software/crystfel/devel ]; then
        mv -f /software/crystfel/devel /software/crystfel/devel-`date +%F-%H:%M:%S`;
     fi"
   - scp -r software/crystfel/devel $MAXWELL_USER_NAME@max-wgs:/software/crystfel/
  rules:
    - if: $MAXWELL_DEPLOYMENT == "remote"  && $CI_COMMIT_BRANCH == "master"