.gitlab-ci.yml 3.97 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 73
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

74 75 76 77
    only:
      - master
      - tags

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

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

      # For testing purposes the receipt of the Singularity image - small size - is uploaded to sandobox.zenodo.org
      - python3 .zenodoci/upload_new_deposit.py -i build/Singularity --token $SANDBOX_ZENODO_TOKEN

      # Example for the upload of a new version. The deposit id of the entry to be `new_versioned` MUST be provided.
      # - python3 .zenodoci/upload_new_version_of_deposit.py -i build/Singularity --token $SANDBOX_ZENODO_TOKEN -id ####

    artifacts:
        paths:
            - build/Singularity.simg
            - build/Singularity
101 102 103

    only:
      - tags