aboutsummaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 71c383be8bb340e7978ef9b21f961d1fab1de2a6 (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
stages:
  - build
  - test
  - deploy
  - build_container

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

  variables:
    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_$IMAGE
      --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

  parallel:
    matrix:
     - IMAGE: ["centos7","alma9","fedora","ubuntu"]

  when: manual

build-and-test:
  image: $CI_REGISTRY_IMAGE/$PLATFORM
  variables:
    GIT_STRATEGY: clone

  script:
    - meson setup build --prefix $CFPREFIX
    - ninja -v -C build
    - ninja -v -C build test
    - ninja -C build install
     
    # Tweak CrystFEL GUI so that it can find syminfo.lib
    - mv $CFPREFIX/bin/crystfel $CFPREFIX/bin/crystfel.real
    - echo '#!/bin/sh' > $CFPREFIX/bin/crystfel
    - echo "export SYMINFO=$CFPREFIX/share/ccp4/syminfo.lib" >> $CFPREFIX/bin/crystfel
    - echo "$CFPREFIX/bin/crystfel.real \$@" >> $CFPREFIX/bin/crystfel
    - chmod +x $CFPREFIX/bin/crystfel
    
    # Tweak get_hkl in the same way
    - mv $CFPREFIX/bin/get_hkl $CFPREFIX/bin/get_hkl.real
    - echo '#!/bin/sh' > $CFPREFIX/bin/get_hkl
    - echo "export SYMINFO=$CFPREFIX/share/ccp4/syminfo.lib" >> $CFPREFIX/bin/get_hkl
    - echo "$CFPREFIX/bin/get_hkl.real \$@" >> $CFPREFIX/bin/get_hkl
    - chmod +x $CFPREFIX/bin/get_hkl
    
    # Mosflm (tweaked to find syminfo.lib and not load environ.def/default.def)
    - wget -nv https://www.mrc-lmb.cam.ac.uk/mosflm/mosflm/ver740/pre-built/mosflm-linux-64-noX11.zip
    - unzip mosflm-linux-64-noX11.zip
    - mv mosflm-linux-64-noX11 $CFPREFIX/bin/mosflm.real
    - echo '#!/bin/sh' > $CFPREFIX/bin/mosflm
    - echo "export SYMINFO=$CFPREFIX/share/ccp4/syminfo.lib" >> $CFPREFIX/bin/mosflm
    - echo "$CFPREFIX/bin/mosflm.real -n \$@" >> $CFPREFIX/bin/mosflm
    - chmod +x $CFPREFIX/bin/mosflm

    - cp -Rp /software $CI_PROJECT_DIR/$PLATFORM

  artifacts:
    paths:
      - $PLATFORM
      - build/meson-logs/testlog.junit.xml
    reports:
      junit: build/meson-logs/testlog.junit.xml
    when: on_success
    expire_in: 1 day

  parallel:
    matrix:
     - PLATFORM:  ["centos7","alma9","fedora","ubuntu"]

build-and-test-minimal:
  image: $IMAGE:latest
  script:
    - dnf update -y && dnf group install -y development-tools &&
      dnf install -y gsl-devel flex bison cmake meson
    - meson setup build -Dhdf5=disabled --wrap-mode=nofallback && 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

  parallel:
    matrix:
     - IMAGE: ["fedora"]

build-brew-macos:
  dependencies: []
  tags:
    - macOS
  variables:
    GIT_STRATEGY: clone
  script:
    - brew update
    - brew upgrade -f
    - brew uninstall -v -f crystfel
    - brew install -v -s ./crystfel.rb --HEAD
    - brew test crystfel
    - brew uninstall -v -f crystfel
  rules:
    - if: $CI_COMMIT_BRANCH == "master"

deploy-remote-maxwell:
  stage: deploy
  image: $CI_REGISTRY_IMAGE/alma9
  dependencies:
    - build-and-test
  variables:
    GIT_STRATEGY: none
  tags:
    - DESY-intern
  before_script:
  ##
  ## 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.
    - HOST="max-wgs";
    - PREFIX="alma9";
    - if [ $MAXWELL_SSH_PRIVATE_KEY ]; then
        eval $(ssh-agent -s);
        chmod 400 "$MAXWELL_SSH_PRIVATE_KEY";
        ssh-add "$MAXWELL_SSH_PRIVATE_KEY";
      else
        echo $MAXWELL_ACCOUNT_PASSWORD | kinit $MAXWELL_USER_NAME@DESY.DE;
      fi

  script:
    - ssh   $MAXWELL_USER_NAME@$HOST
      "if [ -d /software/crystfel/devel ]; then
           mv -f /software/crystfel/devel /software/crystfel/devel-`date +%F-%H:%M:%S`;
       else if [ ! -d /software/crystfel/ ]; then
               mkdir -p /software/crystfel/;
            fi;
       fi"
    - scp -r $PREFIX/crystfel/devel $MAXWELL_USER_NAME@$HOST:/software/crystfel/

  rules:
    - if: $CI_COMMIT_BRANCH == "master"

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

  when: manual

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
      when: manual