.gitlab-ci.yml 3.52 KB
Newer Older
1
stages:
Enrique Garcia's avatar
Enrique Garcia committed
2
  - test
3
  - deploy
4
  - test_the_deploy
5

Enrique Garcia's avatar
Enrique Garcia committed
6
test_install:
7 8 9 10 11 12 13
  stage: test
  image: python:3.6.11-buster
  script:
    - apt-get -y update
    - pip install .
  only:
    - branches
Enrique Garcia's avatar
Enrique Garcia committed
14

15
deploy_zenodo:
16 17 18 19 20 21 22 23 24
  stage: deploy
  image: python:3.6.11-buster
  #dependencies:
    ### Ideally to be used within a ci pipeline in where a container of the source code is build in a previous stage.
    ###  You can have a look into https://gitlab.in2p3.fr/escape2020/wp3/template_project_escape/-/blob/master/.gitlab-ci.yml
  #  - build_image
  before_script:
    ### 1 - Install dependencies in the image and upload the files to Zenodo
    - apt-get -y update
25

26 27 28 29 30 31
    ### INFORMATION FOR THE USER; Python, pip and wget are already installed in the container
    #- cat /etc/os-release  # Debian GNU/Linux 10 (buster)
    #- pip3 --version       # pip 20.1.1
    #- python3 --version    # 3.6.11 as expected
    - pip install requests numpy
    - pip install .  # Install ZenodoCI
Enrique Garcia's avatar
Enrique Garcia committed
32

33 34 35
    ### 2 - Test the communication to Zenodo - Uncomment if needed, or if already done it manually.
    - test_connection_zenodo --token $SANDBOX_ZENODO_TOKEN --sandbox True -p $CI_PROJECT_DIR
    #- test_connection_zenodo -t $ZENODO_TOKEN -s False --project_dir $CI_PROJECT_DIR
36

37 38 39 40
  script:
    ### 3 - Get the last tag/release of the repository
    - export REPOSITORY_NAME=zenodoci
    - export REPOSITORY_BASE_URL=https://gitlab.in2p3.fr/escape2020/wp3/$REPOSITORY_NAME
41

42 43 44 45 46
    ### 4 - Download the repository and move it to the build directory
    ###  If no release is found/correctly parsed, the script will download the last commit pushed to the master branch
    - mkdir -p build
    - /bin/bash zenodoci/parse_last_release.sh $REPOSITORY_NAME $REPOSITORY_BASE_URL
    - ls ./build
47

48 49
    ### 5 - To deploy a NEW DEPOSIT to ZENODO SANDBOX
    - upload_new_deposit --token $SANDBOX_ZENODO_TOKEN --sandbox True --input-dir ./build
50

51 52 53 54 55 56
    ### 5 - To deploy a NEW DEPOSIT to ZENODO
    #- >
    #    upload_new_deposit
    #    --token $ZENODO_TOKEN
    #    --sandbox False
    #    --input-dir ./build
57

58 59 60 61 62 63
    ### 5 - To deploy a NEW VERSION to ZENODO: The deposit_id of the entry to be `new_versioned` MUST be provided.
    - >
      upload_new_version_deposit
      --token $SANDBOX_ZENODO_TOKEN
      --sandbox True
      --input-dir ./build
Enrique Garcia's avatar
Enrique Garcia committed
64
      --deposit_id $ZENODO_PROJECT_ID
65 66
    #  --token $ZENODO_TOKEN
    #  --sandbox False
67

Enrique Garcia's avatar
Enrique Garcia committed
68 69 70 71 72
  only:
    ### Ideally this stage should be run only when a new release / tag of the source code is created, i.e., (- tags).
    # The script is changed to check that the both `upload_new_deposit` and `upload_new_version_deposit` works nicely.
    - tags
    - branches  # For testing
73 74 75


test_deploy_from_container:
76 77 78 79 80 81 82 83 84 85
  stage: test_the_deploy
  image: gitlab-registry.in2p3.fr/escape2020/wp3/zenodoci
  before_script:
    - wget -q https://gitlab.in2p3.fr/escape2020/wp3/zenodoci/-/raw/master/zenodoci/parse_last_release.sh
    - pwd parse_last_release.sh  # testing/debugging
    - test_connection_zenodo --token $SANDBOX_ZENODO_TOKEN --sandbox True -p $CI_PROJECT_DIR
  script:
    - pwd  # testing/debugging
    - ls   # testing/debugging
    - env  # testing/debugging
Enrique Garcia's avatar
Enrique Garcia committed
86

87 88 89
    - upload_new_deposit -h
    - upload_new_version_deposit -h
    - codemeta2zenodo -h
Enrique Garcia's avatar
Enrique Garcia committed
90

91 92 93
    - mkdir -p build
    - /bin/bash parse_last_release.sh $CI_PROJECT_NAME $CI_PROJECT_URL
    - ls ./build
Enrique Garcia's avatar
Enrique Garcia committed
94

95 96 97 98 99
    - upload_new_deposit --token $SANDBOX_ZENODO_TOKEN --sandbox True --input-dir ./build
    - upload_new_version_deposit -t $SANDBOX_ZENODO_TOKEN -s True -i ./build -id $ZENODO_PROJECT_ID
  only:
    - tags
    - branches # testing/debugging