.gitlab-ci.yml 2.63 KB
Newer Older
Enrique's avatar
Enrique committed
1
stages:
Enrique Garcia's avatar
Enrique Garcia committed
2
 - install
3
 - test
Enrique's avatar
Enrique committed
4 5 6
 - build
 - deploy

Enrique Garcia's avatar
Enrique Garcia committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
install_project:
  stage: install
  # 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
    - conda env create -f environment.yml
    - conda activate escape_template
    - pip install .
    - square_number -h
    - square_number -i -12.5
  only:
    - branches

test_project:
  stage: test
  image: python:3.6-buster
  script:
    - pip install pytest
    - pip install .
    - pytest .
  only:
    - branches
31

Enrique Garcia's avatar
Enrique Garcia committed
32
test_docker_registry:
Enrique Garcia's avatar
Enrique Garcia committed
33 34 35 36 37 38 39 40 41
  # Test of last container in registry
  stage: test
  image: gitlab-registry.in2p3.fr/escape2020/wp3/template_project_escape/escape_template_project:v1.0
  script:
    - source activate escape_template
    - square_number -i -12.5
  except:
    - master
    - tags
Enrique Garcia's avatar
Enrique Garcia committed
42

Enrique Garcia's avatar
Enrique Garcia committed
43 44 45 46 47 48 49
build_singularity_image:
  # Example of Singularity image (of the project) built during the CI
  stage: build
  image: singularityware/singularity:gitlab-2.6
  script:
    # Build the container!
    - /bin/bash .singularityci/build.sh Singularity/Singularity
Enrique's avatar
Enrique committed
50

Enrique Garcia's avatar
Enrique Garcia committed
51 52 53 54 55 56 57 58
    - mkdir -p build && cp *.simg build
    - mkdir -p build && cp Singularity* build
  artifacts:
    paths:
      - build/Singularity.simg
      - build/Singularity
  only:
    - tags
Enrique's avatar
Enrique committed
59

Enrique Garcia's avatar
Enrique Garcia committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
build_docker_image:
  # Example of Docker container (of the project) built - and uploaded to a registry - during the CI
  stage: build
  image: docker:19.03.12
  services:
    - docker:19.03.12-dind
  before_script:
    - cat /etc/os-release  # "Alpine Linux v3.12"
    - apk add git
    - export LAST_RELEASE=`git ls-remote --tags --refs --sort="v:refname" $CI_PROJECT_URL.git | tail -n1 | sed 's/.*\///'`
    - echo $LAST_RELEASE
  script:
    - cd Docker
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t $CI_REGISTRY_IMAGE:$LAST_RELEASE .
    - docker push $CI_REGISTRY_IMAGE:$LAST_RELEASE
  only:
    - tags
78

Enrique's avatar
Enrique committed
79
deploy_zenodo:
Enrique Garcia's avatar
Enrique Garcia committed
80 81 82 83 84 85 86 87 88 89 90 91
  stage: deploy
  image: gitlab-registry.in2p3.fr/escape2020/wp3/zenodoci:v1.2
  # The dependencies key is added to this stage ONLY because we have created in a previous stage some other artifacts
  dependencies:
    - build_singularity_image
  before_script:
    - test_connection_zenodo --token $ZENODO_TOKEN --sandbox False -p $CI_PROJECT_DIR
  script:
    - mkdir -p build
    - parse_last_release_git.sh $CI_PROJECT_NAME $CI_PROJECT_URL
    - if [[ -f ./codemeta.json ]]; then cp ./codemeta.json ./build; fi
    - ls ./build
Enrique Garcia's avatar
Enrique Garcia committed
92

Enrique Garcia's avatar
Enrique Garcia committed
93 94 95
    - upload_new_version_deposit -t $ZENODO_TOKEN -s False -i ./build -id $ZENODO_PROJECT_ID
  only:
    - tags