diff --git a/.github/workflows/json_lint.yml b/.github/workflows/json_lint.yml index ff9c1f262..92cb02c5e 100644 --- a/.github/workflows/json_lint.yml +++ b/.github/workflows/json_lint.yml @@ -12,33 +12,50 @@ on: - '.github/CONTRIBUTING.md' jobs: - build: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Install dependencies + run: npm install jsonlint-cli -g + - name: Lint dataset + run: jsonlint-cli *.json + - name: Lint dead-entries + run: jsonlint-cli dead-entries/*.json + check-commit-message: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check commit message + id: check_message + run: | + MESSAGE=$(git log --format=%B -n 1 ${{ github.event.after }}) + if [[ "$MESSAGE" == "Updated entries"* ]]; then + echo "run_schema_validation=true" >> "$GITHUB_OUTPUT" + else + echo "run_schema_validation=false" >> "$GITHUB_OUTPUT" + fi + outputs: + run_schema_validation: ${{ steps.check_message.outputs.run_schema_validation }} + dataset-validation: + needs: check-commit-message + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cardinalby/schema-validator-action@v3 + if: ${{ needs.check-commit-message.outputs.run_schema_validation == 'true' }} + with: + file: 'anime-offline-database.json|anime-offline-database-minified.json' + schema: 'schema.json' + dead-entries-validation: + needs: check-commit-message runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Setup node environment - uses: actions/setup-node@v4 + - uses: cardinalby/schema-validator-action@v3 + if: ${{ needs.check-commit-message.outputs.run_schema_validation == 'true' }} with: - node-version: '16' - - name: Install jsonlint - run: npm install jsonlint -g - - name: Check anime-offline-database.json - run: jsonlint -q anime-offline-database.json - - name: Check anime-offline-database-minified.json - run: jsonlint -q anime-offline-database-minified.json - - name: Check dead-entries for anidb - run: jsonlint -q dead-entries/anidb.json - - name: Check dead-entries for anidb-minified.json - run: jsonlint -q dead-entries/anidb-minified.json - - name: Check dead-entries for anilist - run: jsonlint -q dead-entries/anilist.json - - name: Check dead-entries for anilist-minified.json - run: jsonlint -q dead-entries/anilist-minified.json - - name: Check dead-entries for kitsu - run: jsonlint -q dead-entries/kitsu.json - - name: Check dead-entries for kitsu-minified.json - run: jsonlint -q dead-entries/kitsu-minified.json - - name: Check dead-entries for myanimelist - run: jsonlint -q dead-entries/myanimelist.json - - name: Check dead-entries for myanimelist-minified.json - run: jsonlint -q dead-entries/myanimelist-minified.json + file: 'dead-entries/anidb.json|dead-entries/anidb-minified.json|dead-entries/anilist.json|dead-entries/anilist-minified.json|dead-entries/kitsu.json|dead-entries/kitsu-minified.json|dead-entries/myanimelist.json|dead-entries/myanimelist-minified.json' + schema: 'dead-entries/schema.json' \ No newline at end of file diff --git a/.gitignore b/.gitignore index ce6846d3b..4751de5c5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ !anime-offline-database.json !anime-offline-database-minified.json !anime-offline-database.zip +!schema.json !.github/ .github/* @@ -38,6 +39,7 @@ dead-entries/* !dead-entries/myanimelist.json !dead-entries/myanimelist-minified.json !dead-entries/myanimelist.zip +!dead-entries/schema.json !pics/ pics/* diff --git a/dead-entries/schema.json b/dead-entries/schema.json new file mode 100644 index 000000000..685acda37 --- /dev/null +++ b/dead-entries/schema.json @@ -0,0 +1,49 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/manami-project/anime-offline-database/blob/raw/dead-entries/schema.json", + "title": "anime-offline-database", + "description": "Updated every week: A JSON based anime dataset containing the most important meta data as well as cross references to various anime sites such as MAL, ANIDB, ANILIST, KITSU and more... ", + "type": "object", + "required": [ + "license", + "repository", + "lastUpdate", + "deadEntries" + ], + "properties": { + "license": { + "description": "Information about the license of the dataset.", + "type": "object", + "required": [ + "name", + "url" + ], + "properties": { + "name": { + "description": "Name of the license.", + "const": "GNU Affero General Public License v3.0" + }, + "url": { + "description": "URL to the whole license file.", + "const": "https://github.com/manami-project/anime-offline-database/blob/master/LICENSE" + } + } + }, + "repository": { + "description": "URL of this github repository which is the source of the dataset.", + "const": "https://github.com/manami-project/anime-offline-database" + }, + "lastUpdate": { + "description": "The date on which the file was updated in the format: YYYY-MM-DD.", + "type": "string" + }, + "deadEntries": { + "description": "IDs of anime which have been removed from the respective meta data provider.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string" + } + } + } +} \ No newline at end of file diff --git a/schema.json b/schema.json new file mode 100644 index 000000000..d831ac35b --- /dev/null +++ b/schema.json @@ -0,0 +1,157 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/manami-project/anime-offline-database/raw/master/schema.json", + "title": "anime-offline-database", + "description": "Updated every week: A JSON based anime dataset containing the most important meta data as well as cross references to various anime sites such as MAL, ANIDB, ANILIST, KITSU and more... ", + "type": "object", + "required": [ + "license", + "repository", + "lastUpdate", + "data" + ], + "properties": { + "license": { + "description": "Information about the license of the dataset.", + "type": "object", + "required": [ + "name", + "url" + ], + "properties": { + "name": { + "description": "Name of the license.", + "const": "GNU Affero General Public License v3.0" + }, + "url": { + "description": "URL to the whole license file.", + "const": "https://github.com/manami-project/anime-offline-database/blob/master/LICENSE" + } + } + }, + "repository": { + "description": "URL of this github repository which is the source of the dataset.", + "const": "https://github.com/manami-project/anime-offline-database" + }, + "lastUpdate": { + "description": "The date on which the file was updated in the format: YYYY-MM-DD.", + "type": "string" + }, + "data": { + "description": "List of all anime.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "object", + "required": [ + "sources", + "title", + "type", + "episodes", + "status", + "animeSeason", + "picture", + "thumbnail", + "synonyms", + "relatedAnime", + "tags" + ], + "properties": { + "sources": { + "description": "URLs to the pages of the meta data providers for this anime.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string" + } + }, + "title": { + "description": "Main title.", + "type": "string" + }, + "type": { + "description": "Distribution type.", + "enum": [ + "TV", + "MOVIE", + "OVA", + "ONA", + "SPECIAL", + "UNKNOWN" + ] + }, + "episodes": { + "description": "Number of episodes, movies or parts.", + "type": "number", + "minimum": 0 + }, + "status": { + "description": "Status of distribution.", + "enum": [ + "FINISHED", + "ONGOING", + "UPCOMING", + "UNKNOWN" + ] + }, + "animeSeason": { + "description": "Data on when the anime was first distributed.", + "type": "object", + "required": [ + "season" + ], + "properties": { + "season": { + "description": "Season.", + "enum": [ + "SPRING", + "SUMMER", + "FALL", + "WINTER", + "UNDEFINED" + ] + }, + "year": { + "description": "Year.", + "type": ["number", "null"], + "minimum": 1907 + } + } + }, + "picture": { + "description": "URL of a picture which represents the anime.", + "type": "string" + }, + "thumbnail": { + "description": "URL of a smaller version of the picture.", + "type": "string" + }, + "synonyms": { + "description": "Alternative titles and spellings under which the anime is also known.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string" + } + }, + "relatedAnime": { + "description": "URLs to the meta data providers for anime that are somehow related to this anime.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string" + } + }, + "tags": { + "description": "A non-curated list of tags and genres which describe the anime.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string" + } + } + } + } + } + } +} \ No newline at end of file