Skip to content

Commit 8871c0d

Browse files
committed
init: hello world zenodo json validator!
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
0 parents  commit 8871c0d

13 files changed

Lines changed: 420 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build and Publish Image
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
tags: ['v*.*.*']
7+
pull_request:
8+
branches: ['main']
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: vsoch/zenodo-validator
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: 📥 Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: 🛠️ Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
28+
- name: 🔑 Log in to the Container registry
29+
if: github.event_name != 'pull_request'
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ${{ env:REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: 🏷️ Extract metadata (tags, labels)
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
with:
40+
images: ${{ env:REGISTRY }}/${{ env:IMAGE_NAME }}
41+
tags: |
42+
type=semver,pattern={{version}}
43+
type=semver,pattern={{major}}.{{minor}}
44+
type=ref,event=branch
45+
type=sha
46+
47+
- name: 🏗️ Build and push Docker image
48+
uses: docker/build-push-action@v5
49+
with:
50+
context: .
51+
push: ${{ github.event_name != 'pull_request' }}
52+
tags: ${{ id.meta.outputs.tags }}
53+
labels: ${{ id.meta.outputs.labels }}
54+
# Caching to make builds faster
55+
cache-from: type=gha
56+
cache-to: type=gha,mode=max

.github/workflows/test.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Metadata CI
2+
on: [push, pull_request]
3+
4+
jobs:
5+
validate-zenodo:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout Code
9+
uses: actions/checkout@v4
10+
11+
- name: Validate Zenodo Metadata
12+
uses: ./
13+
with:
14+
path: '.zenodo.json'

.zenodo.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"creators": [
3+
{
4+
"name": "Carberry, Josiah",
5+
"orcid": "0000-0002-1825-0097",
6+
"affiliation": "Brown University",
7+
"type": "ProjectMember"
8+
}
9+
],
10+
"contributors": [
11+
{
12+
"name": "Lovelace, Ada",
13+
"type": "Researcher"
14+
},
15+
{
16+
"name": "Babbage, Charles",
17+
"affiliation": "University of Cambridge",
18+
"type": "ProjectLeader"
19+
}
20+
],
21+
"title": "Memory bus simulation scripts",
22+
"version": "1.8.0",
23+
"access_right": "open",
24+
"related_identifiers": [
25+
{
26+
"identifier": "https://doi.org/10.5555/666655554444",
27+
"relation": "isSupplementTo",
28+
"resource_type": "publication-article"
29+
}
30+
],
31+
"keywords": [
32+
"computer science",
33+
"psychoceramics",
34+
"journaling filesystems"
35+
],
36+
"license": "mit",
37+
"upload_type": "software",
38+
"language": "eng",
39+
"grants": [
40+
{"id": "10.13039/501100000780::101122956"}
41+
],
42+
"communities": [
43+
{"identifier": "simulation-software"}
44+
]
45+
}

COPYRIGHT

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Intellectual Property Notice
2+
----------------------------
3+
4+
HPCIC DevTools is licensed under the MIT license (LICENSE).
5+
6+
Copyrights and patents in this project are retained by
7+
contributors. No copyright assignment is required to contribute to
8+
HPCIC DevTools.
9+
10+
SPDX usage
11+
------------
12+
13+
Individual files contain SPDX tags instead of the full license text.
14+
This enables machine processing of license information based on the SPDX
15+
License Identifiers that are available here: https://spdx.org/licenses/

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.13-slim
2+
3+
RUN pip install --no-cache-dir check-jsonschema
4+
5+
# Copy the schema and entrypoint
6+
COPY schema.json /schema.json
7+
COPY docker/entrypoint.sh /entrypoint.sh
8+
RUN chmod +x /entrypoint.sh
9+
10+
ENTRYPOINT ["/entrypoint.sh"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022-2023 LLNS, LLC and other HPCIC DevTools Developers.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# --- Configuration ---
2+
IMAGE_NAME := zenodo-validator
3+
ZENODO_FILE := .zenodo.json
4+
PWD := $(shell pwd)
5+
6+
# Default target: Build the container
7+
.PHONY: all
8+
all: build
9+
10+
## 🏗️ build: Build the Docker container locally
11+
.PHONY: build
12+
build:
13+
@echo "🔨 Building the validator image..."
14+
docker build -t $(IMAGE_NAME) .
15+
@echo "✅ Build complete! Image tagged as: $(IMAGE_NAME)"
16+
17+
## 🛡️ validate: Run validation against the local .zenodo.json
18+
.PHONY: validate
19+
validate:
20+
@echo "🔍 Starting local validation of $(ZENODO_FILE)..."
21+
@if [ ! -f $(ZENODO_FILE) ]; then \
22+
echo "❌ Error: $(ZENODO_FILE) not found in this directory!"; \
23+
exit 1; \
24+
fi
25+
docker run --rm \
26+
-v $(PWD):/github/workspace \
27+
-e GITHUB_WORKSPACE=/github/workspace \
28+
-e INPUT_PATH=$(ZENODO_FILE) \
29+
-e INPUT_SCHEMA_PATH=/schema.json \
30+
-e INPUT_ERROR_FORMAT=text \
31+
$(IMAGE_NAME)
32+
33+
## 🧹 clean: Remove the local Docker image
34+
.PHONY: clean
35+
clean:
36+
@echo "🗑️ Removing Docker image..."
37+
docker rmi $(IMAGE_NAME) || echo "⚠️ Image not found, nothing to delete."
38+
39+
## ❓ help: Show this help message
40+
.PHONY: help
41+
help:
42+
@echo "🌟 Zenodo Validator Makefile 🌟"
43+
@echo "--------------------------------"
44+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'

NOTICE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
This work was produced under the auspices of the U.S. Department of
2+
Energy by Lawrence Livermore National Laboratory under Contract
3+
DE-AC52-07NA27344.
4+
5+
This work was prepared as an account of work sponsored by an agency of
6+
the United States Government. Neither the United States Government nor
7+
Lawrence Livermore National Security, LLC, nor any of their employees
8+
makes any warranty, expressed or implied, or assumes any legal liability
9+
or responsibility for the accuracy, completeness, or usefulness of any
10+
information, apparatus, product, or process disclosed, or represents that
11+
its use would not infringe privately owned rights.
12+
13+
Reference herein to any specific commercial product, process, or service
14+
by trade name, trademark, manufacturer, or otherwise does not necessarily
15+
constitute or imply its endorsement, recommendation, or favoring by the
16+
United States Government or Lawrence Livermore National Security, LLC.
17+
18+
The views and opinions of authors expressed herein do not necessarily
19+
state or reflect those of the United States Government or Lawrence
20+
Livermore National Security, LLC, and shall not be used for advertising
21+
or product endorsement purposes.

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Zenodo Metadata Validator 🛡️
2+
3+
![img/zenodo-json-validator.png](img/zenodo-json-validator.png)
4+
5+
> 🚀 Ensure your metadata is ready for archiving!
6+
7+
This GitHub Action validates your `.zenodo.json` file against the official Zenodo schema. No more broken uploads or missing creator names! We've vendored the schema 📦 here, and also allow you to provide your own. ☁️
8+
9+
## 🛠️ How to use it in your Pipeline
10+
11+
Add this sparkle to your `.github/workflows/validate.yml`:
12+
13+
```yaml
14+
jobs:
15+
validate:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: 📥 Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: 🛡️ Validate Zenodo Metadata
22+
uses: vsoch/zenodo-validator@main
23+
with:
24+
path: '.zenodo.json'
25+
```
26+
27+
28+
## 💻 Running it locally
29+
30+
> ...for the rebels 🎸
31+
32+
Want to check your JSON before you even commit? Build the container and run it:
33+
34+
```bash
35+
# 🏗️ Build the magic box
36+
docker build -t zenodo-validator .
37+
38+
# 🪄 Run the spell
39+
docker run --rm \
40+
-v $(pwd):/github/workspace \
41+
-e GITHUB_WORKSPACE=/github/workspace \
42+
-e INPUT_PATH=.zenodo.json \
43+
-e INPUT_SCHEMA_PATH=/schema.json \
44+
-e INPUT_ERROR_FORMAT=text \
45+
zenodo-validator
46+
```
47+
48+
The above also works with:
49+
50+
```bash
51+
make
52+
make validate
53+
```
54+
55+
## 🎁 Inputs
56+
57+
| Input | Description | Default |
58+
| :--- | :--- | :--- |
59+
| `path` 📍 | Where is your `.zenodo.json`? | `.zenodo.json` |
60+
| `error_format` 🎨 | `text`, `json`, or `pretty-json` | `text` |
61+
62+
---
63+
64+
## 📄 License
65+
66+
67+
DevTools is distributed under the terms of the MIT license.
68+
All new contributions must be made under this license.
69+
70+
See [LICENSE](https://github.com/converged-computing/cloud-select/blob/main/LICENSE),
71+
[COPYRIGHT](https://github.com/converged-computing/cloud-select/blob/main/COPYRIGHT), and
72+
[NOTICE](https://github.com/converged-computing/cloud-select/blob/main/NOTICE) for details.
73+
74+
SPDX-License-Identifier: (MIT)
75+
76+
LLNL-CODE- 842614
77+
78+
MIT. Go forth and do science! 🔬🧬🥂
79+
80+
**Maintained by [@vsoch](https://github.com/vsoch)** 🌟

action.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Zenodo Metadata Validator'
2+
description: 'Validates .zenodo.json files with maximum style 🌈'
3+
inputs:
4+
path:
5+
description: 'Path to the .zenodo.json file'
6+
required: false
7+
default: '.zenodo.json'
8+
schema_path:
9+
description: 'Path to the JSON schema'
10+
required: false
11+
default: '/schema.json'
12+
error_format:
13+
description: 'Output format (text, json, pretty-json)'
14+
required: false
15+
default: 'text'
16+
17+
runs:
18+
using: 'docker'
19+
image: 'Dockerfile'
20+
env:
21+
INPUT_PATH: ${{ inputs.path }}
22+
INPUT_SCHEMA_PATH: ${{ inputs.schema_path }}
23+
INPUT_ERROR_FORMAT: ${{ inputs.error_format }}

0 commit comments

Comments
 (0)