.gitlab-ci.yml 4.88 KB
Newer Older
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
# This software is based on https://gitlab.com/singularityhub/gitlab-ci,
# with DOI: https://doi.org/10.5281/zenodo.3834833
# provided under the following license:

### BSD 3-Clause License
###
### Copyright (c) 2018, Vanessa Sochat
### All rights reserved.
###
### Redistribution and use in source and binary forms, with or without
### modification, are permitted provided that the following conditions are met:
###
### * Redistributions of source code must retain the above copyright notice, this
###   list of conditions and the following disclaimer.
###
### * Redistributions in binary form must reproduce the above copyright notice,
###   this list of conditions and the following disclaimer in the documentation
###   and/or other materials provided with the distribution.
###
### * Neither the name of the copyright holder nor the names of its
###   contributors may be used to endorse or promote products derived from
###   this software without specific prior written permission.
###
### THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
### AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
### IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
### DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
### FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
### DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
### SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
### CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
### OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
### OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###

Enrique's avatar
Enrique committed
36
stages:
37
 - test
Enrique's avatar
Enrique committed
38 39 40
 - build
 - deploy

41 42 43 44 45 46 47
build_test_project:
    stage: test
    # Please notice that we are using a different image just for easier syntax in the testing of the building and
    #  testing of the repository
    image: continuumio/miniconda3:latest
    script:
      - . /opt/conda/etc/profile.d/conda.sh
Enrique's avatar
Enrique committed
48
      - conda env create -f environment.yml
49 50 51 52
      - conda activate escape_template
      - python setup.py install
      - pytest .

Enrique's avatar
Enrique committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
build_image:
    stage: build
    image: singularityware/singularity:gitlab-2.6
    script:
        # step 1. build the container!
        - /bin/bash .gitlabci/build.sh Singularity

        - mkdir -p build && cp *.simg build
        - mkdir -p build && cp Singularity* build

        # You can add any other sregistry push commands here, and specify a client
        # (and make sure your define the encrypted environment credentials in gitlab
        # to push to your storage locations of choice.
        # Have a look at https://gitlab.com/singularityhub/gitlab-ci/-/blob/master/.gitlab-ci.yml. Ex:
        #- /bin/bash build.sh --uri collection/container --cli registry Singularity

    artifacts:
        paths:
            - build/Singularity.simg
            - build/Singularity
73 74 75 76
    only:
      - master
      - tags

Enrique's avatar
Enrique committed
77 78
deploy_zenodo:
    stage: deploy
Enrique's avatar
Enrique committed
79
    image: singularityware/singularity:gitlab-2.6
80 81
    dependencies:
      - build_image
Enrique's avatar
Enrique committed
82
    script:
83
        # Step 2. Install dependencies in the image and upload the files to Zenodo
Enrique's avatar
Enrique committed
84 85
      - apt-get -y update
      - apt-get install python3
86
      - apt-get install wget
Enrique's avatar
Enrique committed
87
      - apt -y install python3-pip
Enrique's avatar
Enrique committed
88 89 90 91 92

      - pip3 --version
      - pip3 install requests
      - python3 --version  # It is python3.5 - The image is a Debian GNU/Linux 9 (stretch).

93 94 95
      # # For testing purposes try uploading a file of small size to sandobox.zenodo.org (e.g., the singularity receipt)
      # - rm ./build/Singularity.simg
      # - python3 .zenodoci/upload_new_deposit.py --sandbox_zenodo True -i ./build --token $SANDBOX_ZENODO_TOKEN
Enrique's avatar
Enrique committed
96

97 98
      # # To deploy a NEW DEPOSIT to sandbox.zenodo
      # - python3 .zenodoci/upload_new_deposit.py --sandbox_zenodo True -i ./build --token $SANDBOX_ZENODO_TOKEN
Enrique's avatar
Enrique committed
99

100 101 102 103 104 105
      # # To deploy a NEW DEPOSIT to Zenodo
      - >
          python3 .zenodoci/upload_new_deposit.py
          --sandbox_zenodo False
          --input-directory ./build
          --token $ZENODO_TOKEN
106

107 108 109 110
      # # For deploying a NEW VERSION to Zenodo. The deposit id of the entry to be `new_versioned` MUST be provided.
      # You will need to provide also th e version of the last release (or parsed yourself via the api ;-) )
      - export VER=2.0
      - >
111 112 113
          wget -O template_project_escape-V"$VER".zip
          https://gitlab.in2p3.fr/escape2020/escape/template_project_escape/-/archive/V"$VER"/template_project_escape-V"$VER".zip
      - mv template_project_escape-V"$VER".zip ./build
114 115 116 117 118 119 120 121
      - ls ./build
      - >
          python3 .zenodoci/upload_new_version_deposit.py
          --sandbox_zenodo False
          --input-directory ./build
          --token $ZENODO_TOKEN
          --deposit_id $DEPOSIT_ID_ESCAPE_TEMPLATE
          --new_deposit_version $VER
122 123
    only:
      - tags