Commit 2c6b91dc authored by Enrique Garcia's avatar Enrique Garcia
Browse files

Include conditions in the cicd file

parent 4e8c212b
......@@ -34,9 +34,22 @@
###
stages:
- test
- build
- deploy
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
- conda env create -f env_template_escape.yml
- conda activate escape_template
- python setup.py install
- pytest .
build_image:
stage: build
image: singularityware/singularity:gitlab-2.6
......@@ -58,6 +71,10 @@ build_image:
- build/Singularity.simg
- build/Singularity
only:
- master
- tags
deploy_zenodo:
stage: deploy
image: singularityware/singularity:gitlab-2.6
......@@ -81,3 +98,6 @@ deploy_zenodo:
paths:
- build/Singularity.simg
- build/Singularity
only:
- tags
......@@ -5,23 +5,23 @@ import argparse
from zenodolib import ZenodoHandler
parser = argparse.ArgumentParser(description="Upload new deposit entry to zenodo")
parser = argparse.ArgumentParser(description="Upload new deposit entry to Zenodo")
# Required arguments
parser.add_argument('--input-file', '-i', type=str,
dest='input_file',
help='Full path to the file to upload')
help='Full path to the file to upload',
required=True)
parser.add_argument('--token', '-t', type=str,
dest='zenodo_token',
help='Personal access token to Sandbox/zenodo')
action='store_true',
help='Personal access token to (sandbox)Zenodo',
required=True)
args = parser.parse_args()
if __name__ == '__main__':
if not args.input_file:
print("No file declared ! Exiting. ")
exit(1)
z = ZenodoHandler(access_token=args.zenodo_token,
test=True # True for sandbox.zenodo.org !! False for zenodo.org
......@@ -29,11 +29,13 @@ if __name__ == '__main__':
# create empty deposit
r = z.deposition_create()
deposition_id = r.json()['id']
doi = r.json()['metadata']['prereserve_doi']['doi']
if r.status_code < 399:
deposition_id = r.json()['id']
doi = r.json()['metadata']['prereserve_doi']['doi']
print("Status {}. New entry to zenodo created ! Deposition id {}".format(r.status_code,
deposition_id))
else:
print(r.json())
# upload files
# To upload various files create a loop like : for file in os.listdir(directory):
......@@ -46,6 +48,8 @@ if __name__ == '__main__':
if new_upload.status_code < 399:
print("Status {}. \nFile(s) correctly uploaded:\n".format(new_upload.status_code),
z.deposition_files_list(deposition_id).json())
else:
print(new_upload.json())
# Upload repository information - that you must have filled before ! - and add the doi
with open('.zenodoci/repository_information.json') as json_file:
......@@ -56,6 +60,8 @@ if __name__ == '__main__':
data=entry_info)
if update_entry.status_code < 399:
print("Status {}. Repository information correctly uploaded !".format(update_entry.status_code))
else:
print(update_entry.json())
# publish entry - to publish the entry, uncomment the two lone below
# publish = z.deposition_actions_publish(deposition_id)
......
......@@ -3,31 +3,28 @@ import os
import argparse
from zenodolib import ZenodoHandler
parser = argparse.ArgumentParser(description="Upload a new version of an existing deposit to zenodo")
parser = argparse.ArgumentParser(description="Upload a new version of an existing deposit to Zenodo")
# Required arguments
parser.add_argument('--input-file', '-i', type=str,
dest='input_file',
help='Full path to the file to upload')
help='Full path to the file to upload',
required=True)
parser.add_argument('--token', '-t', type=str,
dest='zenodo_token',
help='Personal access token to Sandbox/zenodo')
help='Personal access token to (sandbox)Zenodo',
required=True)
parser.add_argument('--deposit_id', '-id', type=str,
dest='deposit_id',
help='deposit of the existing deposit '
help='deposit of the existing deposit ',
required=True
)
args = parser.parse_args()
if __name__ == '__main__':
if not args.input_file:
print("No file declared ! Exiting. ")
exit(1)
if not args.deposit_id:
print("No zenodo deposition id declared ! Exiting. ")
exit(1)
z = ZenodoHandler(access_token=args.zenodo_token,
test=True # True for sandbox.zenodo.org !! False for zenodo.org
......@@ -37,6 +34,8 @@ if __name__ == '__main__':
if new_version.status_code < 399:
print("Status {}".format(new_version.status_code),
new_version.json())
else:
print(new_version.json())
new_deposition_id = new_version.json()['links']['latest_draft'].rsplit('/')[-1]
......@@ -57,6 +56,8 @@ if __name__ == '__main__':
if new_upload.status_code < 399:
print("Status {}. \nFile(s) correctly uploaded:\n".format(new_upload.status_code),
z.deposition_files_list(new_version).json())
else:
print(new_upload.json())
# publish entry - to publish the entry, uncomment the two lone below
# publish = z.deposition_actions_publish(new_deposition_id)
......
# template_project_escape
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3572655.svg)](https://doi.org/10.5281/zenodo.3572655)
[![Build Status](https://gitlab.in2p3.fr/escape2020/escape/template_project_escape/badges/master/pipeline.svg)](
https://gitlab.in2p3.fr/escape2020/escape/template_project_escape/pipelines/)
[![pipeline status](https://gitlab.in2p3.fr/escape2020/escape/template_project_escape/badges/master/pipeline.svg)](
https://gitlab.in2p3.fr/escape2020/escape/template_project_escape/-/commits/master)
[![Build Status](https://travis-ci.com/garciagenrique/template_project_escape.svg?branch=master)](
https://travis-ci.com/garciagenrique/template_project_escape)
......@@ -58,7 +58,7 @@ If you wish to provide software to the ESCAPE repository:
RENATER), you will need to [add a SSH key](https://gitlab.in2p3.fr/help/ssh/README#generating-a-new-ssh-key-pair) to
your GitLab profile if you want to 'push' your changes to the server.
### Singularity image container and CI/CD to Zenodo
# Singularity image container and CI/CD to Zenodo
The documentation of how to create a Singularity image / container of your code, upload it to your repository, and also add
it to the ESCAPE community in the [Zenodo repository](https://zenodo.org/communities/escape2020) can be found in the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment