Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/data/initial_dataset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"datasetVersion": {
"license": {
"name": "CC0 1.0",
"uri": "http://creativecommons.org/publicdomain/zero/1.0"
},
"metadataBlocks": {
"citation": {
"fields": [
{
"value": "Darwin's Finches",
"typeClass": "primitive",
"multiple": false,
"typeName": "title"
},
{
"value": [
{
"authorName": {
"value": "Finch, Fiona",
"typeClass": "primitive",
"multiple": false,
"typeName": "authorName"
},
"authorAffiliation": {
"value": "Birds Inc.",
"typeClass": "primitive",
"multiple": false,
"typeName": "authorAffiliation"
}
}
],
"typeClass": "compound",
"multiple": true,
"typeName": "author"
},
{
"value": [
{ "datasetContactEmail" : {
"typeClass": "primitive",
"multiple": false,
"typeName": "datasetContactEmail",
"value" : "finch@mailinator.com"
},
"datasetContactName" : {
"typeClass": "primitive",
"multiple": false,
"typeName": "datasetContactName",
"value": "Finch, Fiona"
}
}],
"typeClass": "compound",
"multiple": true,
"typeName": "datasetContact"
},
{
"value": [ {
"dsDescriptionValue":{
"value": "Darwin's finches (also known as the Galápagos finches) are a group of about fifteen species of passerine birds.",
"multiple":false,
"typeClass": "primitive",
"typeName": "dsDescriptionValue"
}}],
"typeClass": "compound",
"multiple": true,
"typeName": "dsDescription"
},
{
"value": [
"Medicine, Health and Life Sciences"
],
"typeClass": "controlledVocabulary",
"multiple": true,
"typeName": "subject"
}
],
"displayName": "Citation Metadata"
}
}
}
}

6 changes: 3 additions & 3 deletions .github/workflows/scripts/check_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
if path.is_file() and not str(path).startswith(".")
}

assert len(ds_files) == len(
repo_files
), f"Length mismatch: {len(ds_files)} != {len(repo_files)}"
assert len(ds_files) == len(repo_files), (
f"Length mismatch: {len(ds_files)} != {len(repo_files)}"
)

for ds_name, ds_hash in ds_files:
assert ds_name in repo_files, f"File not found: {ds_name}"
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# doi:10.18419/darus-3801

name: Test action

on:
workflow_dispatch:
push:

jobs:
dv-sync:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: 'actions/checkout@v4'

- name: Run Dataverse Action
id: dataverse
uses: gdcc/dataverse-action@main

- name: 'Install Python'
uses: 'actions/setup-python@v2'
with:
python-version: '3.11'

- name: 'Install requests'
run: |
python3 -m pip install requests

- name: 'Create Dataset'
run: |
export API_TOKEN=${{ steps.dataverse.outputs.api_token }}
export PARENT=root
export SERVER_URL=${{ steps.dataverse.outputs.base_url }}

# Remove the trailing slash from the server URL
SERVER_URL=${SERVER_URL%/}

DATASET_RESPONSE=$(curl -s -H "X-Dataverse-key:$API_TOKEN" -X POST "$SERVER_URL/api/dataverses/$PARENT/datasets" --upload-file .github/workflows/data/initial_dataset.json -H 'Content-type:application/json')

# Print the response
echo $DATASET_RESPONSE

echo "DATASET_PID=$(echo $DATASET_RESPONSE | jq -r '.data.persistentId')" >> $GITHUB_ENV

- name: Synchronize to DV
uses: ./
with:
dataverse_url: ${{ steps.dataverse.outputs.base_url }}
api_token: ${{ steps.dataverse.outputs.api_token }}
persistent_id: ${{ env.DATASET_PID }}

- name: Test content
env:
DV_API_TOKEN: ${{ steps.dataverse.outputs.api_token }}
DV_URL: ${{ steps.dataverse.outputs.base_url }}
DV_PID: ${{ env.DATASET_PID }}
run: |
python3 .github/workflows/scripts/check_content.py
34 changes: 0 additions & 34 deletions .github/workflows/test_publish.yml

This file was deleted.

5 changes: 1 addition & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@ runs:
- name: "Upload data"
shell: "bash"
run: |
python3 -m pip install git+https://github.com/gdcc/python-dvuploader.git@feature/non-direct-upload
python3 -m pip install dvuploader

python3 ${{ github.action_path }}/repo_uploader.py \
--dataverse-url "${{ inputs.dataverse_url }}" \
--persistent-id "${{ inputs.persistent_id }}" \
--api-token "${{ inputs.api_token }}" \
--directory "${{ inputs.directory }}"