Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Z
ZenodoCI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Enrique Garcia
ZenodoCI
Commits
ffbb8ae5
Commit
ffbb8ae5
authored
4 years ago
by
Enrique Garcia
Browse files
Options
Downloads
Patches
Plain Diff
Add ci tests
parent
ba5d1556
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+13
-9
13 additions, 9 deletions
.gitlab-ci.yml
.zenodoci/__init__.py
+0
-0
0 additions, 0 deletions
.zenodoci/__init__.py
.zenodoci/test_connection_zenodo.py
+50
-0
50 additions, 0 deletions
.zenodoci/test_connection_zenodo.py
with
63 additions
and
9 deletions
.gitlab-ci.yml
+
13
−
9
View file @
ffbb8ae5
...
...
@@ -8,23 +8,27 @@ deploy_zenodo:
### 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
script
:
before_
script
:
### 1 - Install dependencies in the image and upload the files to Zenodo
-
apt-get -y update
### 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 th
-
pip3 install requests
#- python3 --version # 3.6.11 as expected
-
pip3 install requests numpy
### 2 - Check that you can correctly communicate with (sandobox)zenodo - Uncomment if needed.
-
python3 .zenodoci/test_connection_zenodo.py -t $SANDBOX_ZENODO_TOKEN -s True
#- python3 .zenodoci/test_connection_zenodo.py -t $ZENODO_TOKEN -s False
###
2
- Get the last tag/release of the repository
###
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
-
export LAST_RELEASE=`git ls-remote --tags --refs --sort="v:refname" $REPOSITORY_BASE_URL.git | tail -n1 | sed 's/.*\///'`
###
3
- Download the repository and move it to the build directory
###
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
...
...
@@ -40,22 +44,22 @@ deploy_zenodo:
fi
-
ls ./build
###
4
- To deploy a NEW DEPOSIT to ZENODO SANDBOX
script
:
###
5
- To deploy a NEW DEPOSIT to ZENODO SANDBOX
-
>
python3 .zenodoci/upload_new_deposit.py
--token $SANDBOX_ZENODO_TOKEN
--sandbox_zenodo True
--input-directory ./build
###
4
- To deploy a NEW DEPOSIT to ZENODO
###
5
- To deploy a NEW DEPOSIT to ZENODO
#- >
# python3 .zenodoci/upload_new_deposit.py
# --token $ZENODO_TOKEN
# --sandbox_zenodo False
# --input-directory ./build
###
4
- To deploy a NEW VERSION to ZENODO: The deposit_id of the entry to be `new_versioned` MUST be provided.
###
5
- To deploy a NEW VERSION to ZENODO: The deposit_id of the entry to be `new_versioned` MUST be provided.
-
>
python3 .zenodoci/upload_new_version_deposit.py
--token $SANDBOX_ZENODO_TOKEN
...
...
This diff is collapsed.
Click to expand it.
.zenodoci/__init__.py
0 → 100644
+
0
−
0
View file @
ffbb8ae5
This diff is collapsed.
Click to expand it.
.zenodoci/test_connection_zenodo.py
0 → 100644
+
50
−
0
View file @
ffbb8ae5
# -*- coding: utf-8 -*-
import
argparse
import
requests
import
numpy
as
np
from
distutils.util
import
strtobool
from
zenodoapi
import
ZenodoAPI
if
__name__
==
'
__main__
'
:
# Required arguments
parser
=
argparse
.
ArgumentParser
(
description
=
"
Upload new deposit entry to Zenodo
"
)
parser
.
add_argument
(
'
--token
'
,
'
-t
'
,
type
=
str
,
dest
=
'
zenodo_token
'
,
help
=
'
Personal access token to (sandbox)Zenodo
'
)
parser
.
add_argument
(
'
--sandbox_zenodo
'
,
'
-s
'
,
action
=
'
store
'
,
type
=
lambda
x
:
bool
(
strtobool
(
x
)),
dest
=
'
sandbox_flag
'
,
help
=
'
Set the Zenodo environment.
'
'
If True connects with Zenodo. If False with Sanbox Zenodo
'
,
default
=
False
)
args
=
parser
.
parse_args
()
z
=
ZenodoAPI
(
access_token
=
args
.
zenodo_token
,
sandbox
=
args
.
sandbox_flag
# True for sandbox.zenodo.org !! False for zenodo.org
)
# Test that the you can communicate with (sandbox)zenodo - you have passed the correct token
parameters
=
{
'
access_token
'
:
z
.
access_token
}
test_connection
=
requests
.
get
(
f
'
{
z
.
zenodo_api_url
}
/deposit/depositions
'
,
params
=
parameters
)
np
.
testing
.
assert_equal
(
test_connection
.
status_code
,
200
)
# Test that you can create a new entry - then all the rest of the pipeline will work
new_entry
=
z
.
create_new_entry
()
np
.
testing
.
assert_equal
(
new_entry
.
status_code
,
201
)
# Erase the un-submitted entry and test that the order has been passed correctly
entry_id
=
new_entry
.
json
()[
'
id
'
]
erase_unsubmitted_entry
=
requests
.
delete
(
f
'
{
z
.
zenodo_api_url
}
/deposit/depositions/
{
entry_id
}
'
,
params
=
parameters
)
np
.
testing
.
assert_equal
(
erase_unsubmitted_entry
.
status_code
,
204
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment