diff --git a/.github/workflows/data/initial_dataset.json b/.github/workflows/data/initial_dataset.json new file mode 100644 index 0000000..b6033b6 --- /dev/null +++ b/.github/workflows/data/initial_dataset.json @@ -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" + } + } + } + } + \ No newline at end of file diff --git a/.github/workflows/scripts/check_content.py b/.github/workflows/scripts/check_content.py index b84bd9c..70ae684 100644 --- a/.github/workflows/scripts/check_content.py +++ b/.github/workflows/scripts/check_content.py @@ -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}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e885493 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/.github/workflows/test_publish.yml b/.github/workflows/test_publish.yml deleted file mode 100644 index 639bf0c..0000000 --- a/.github/workflows/test_publish.yml +++ /dev/null @@ -1,34 +0,0 @@ -# doi:10.18419/darus-3801 - -name: Test and publish - -on: - push: - branches: - - main - release: - types: - - published - -jobs: - dv-sync: - runs-on: ubuntu-latest - env: - DV_API_TOKEN: ${{ secrets.DV_API_TOKEN }} - DV_URL: "https://darus.uni-stuttgart.de" - DV_PID: "doi:10.18419/darus-3801" - steps: - - uses: actions/checkout@v2 - - name: Synchronize to DV - uses: ./ - with: - dataverse_url: ${{ env.DV_URL }} - api_token: ${{ env.DV_API_TOKEN }} - persistent_id: ${{ env.DV_PID }} - - name: "Install Python" - uses: "actions/setup-python@v2" - with: - python-version: "3.11" - - name: Test content - run: | - python3 .github/workflows/scripts/check_content.py \ No newline at end of file diff --git a/action.yml b/action.yml index 7633235..426c28a 100644 --- a/action.yml +++ b/action.yml @@ -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 }}" - - -