├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── cff-validator-complete-matrix.yml │ ├── cff-validator-complete.yml │ ├── cff-validator-dev.yml │ ├── cff-validator-error.yml │ ├── cff-validator.yml │ └── manual-cff-validator.yml ├── .gitignore ├── CHANGELOG.md ├── CITATION.cff ├── LICENSE ├── README.md ├── action.yml ├── assets └── demo.gif ├── docker ├── Dockerfile ├── action.yml ├── entrypoint.sh └── validate_cff.R └── examples ├── key-complete ├── CITATION.cff └── README.md ├── key-error ├── CITATION.cff └── citation_cff_errors.md └── r-reprex.R /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: dieghernan 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: dieghernan 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 12 | polar: # Replace with a single Polar username 13 | buy_me_a_coffee: # Replace with a single Buy Me a Coffee username 14 | thanks_dev: # Replace with a single thanks.dev username 15 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 16 | 17 | 18 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | # Basic set up for three package managers 7 | 8 | version: 2 9 | updates: 10 | 11 | # Maintain dependencies for GitHub Actions 12 | - package-ecosystem: "github-actions" 13 | directory: "/" 14 | schedule: 15 | interval: "weekly" 16 | 17 | -------------------------------------------------------------------------------- /.github/workflows/cff-validator-complete-matrix.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | schedule: 6 | - cron: '30 16 1 * 2,5' 7 | workflow_dispatch: 8 | 9 | # Run on available environments on GHA 10 | # as on 2022-10-21 11 | 12 | name: full-test-action 13 | jobs: 14 | full-test-action: 15 | 16 | runs-on: ${{ matrix.config.os }} 17 | name: ${{ matrix.config.os }} 18 | 19 | strategy: 20 | fail-fast: false 21 | matrix: 22 | config: 23 | - {os: ubuntu-latest} 24 | - {os: ubuntu-22.04} 25 | env: 26 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 27 | 28 | steps: 29 | - name: Checkout 30 | uses: actions/checkout@v4 31 | 32 | - name: Validate CITATION.cff 33 | uses: dieghernan/cff-validator@main 34 | 35 | 36 | - name: Validate examples/key-complete/CITATION.cff 37 | uses: dieghernan/cff-validator@main 38 | with: 39 | citation-path: "./examples/key-complete/CITATION.cff" 40 | 41 | -------------------------------------------------------------------------------- /.github/workflows/cff-validator-complete.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | workflow_dispatch: 6 | 7 | name: CITATION.cff-complete 8 | jobs: 9 | Validate-CITATION-cff-complete: 10 | runs-on: ubuntu-latest 11 | name: Validate CITATION.cff 12 | env: 13 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 14 | 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | 19 | - name: Validate examples/key-complete/CITATION.cff 20 | uses: dieghernan/cff-validator@main 21 | with: 22 | citation-path: "./examples/key-complete/CITATION.cff" 23 | 24 | -------------------------------------------------------------------------------- /.github/workflows/cff-validator-dev.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - dev 5 | workflow_dispatch: 6 | 7 | name: dev CITATION.cff 8 | jobs: 9 | Validate-dev-CITATION-cff: 10 | 11 | runs-on: ${{ matrix.config.os }} 12 | name: ${{ matrix.config.os }} 13 | 14 | strategy: 15 | fail-fast: false 16 | matrix: 17 | config: 18 | - {os: ubuntu-latest} 19 | env: 20 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 21 | 22 | 23 | steps: 24 | - name: Checkout 25 | uses: actions/checkout@v4 26 | 27 | - name: Validate ./examples/key-complete/CITATION.cff 28 | uses: dieghernan/cff-validator@dev 29 | with: 30 | citation-path: "./examples/key-complete/CITATION.cff" 31 | 32 | - name: Validate ./examples/key-error/CITATION.cff 33 | uses: dieghernan/cff-validator@dev 34 | with: 35 | citation-path: "./examples/key-error/CITATION.cff" 36 | 37 | -------------------------------------------------------------------------------- /.github/workflows/cff-validator-error.yml: -------------------------------------------------------------------------------- 1 | on: 2 | schedule: 3 | - cron: '00 10 * * *' 4 | workflow_dispatch: 5 | 6 | name: CITATION.cff-error 7 | jobs: 8 | Validate-CITATION-cff-error: 9 | runs-on: ubuntu-latest 10 | name: Validate CITATION.cff with errors 11 | env: 12 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 13 | 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v4 17 | 18 | - name: Validate examples/key-error/CITATION.cff 19 | uses: dieghernan/cff-validator@main 20 | with: 21 | citation-path: "./examples/key-error/CITATION.cff" 22 | cache-version: 2 23 | 24 | -------------------------------------------------------------------------------- /.github/workflows/cff-validator.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | paths: 4 | - CITATION.cff 5 | workflow_dispatch: 6 | 7 | name: CITATION.cff 8 | jobs: 9 | Validate-CITATION-cff: 10 | runs-on: ubuntu-latest 11 | name: Validate CITATION.cff 12 | env: 13 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 14 | 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | 19 | - name: Validate CITATION.cff 20 | uses: dieghernan/cff-validator@main 21 | 22 | -------------------------------------------------------------------------------- /.github/workflows/manual-cff-validator.yml: -------------------------------------------------------------------------------- 1 | name: Soft deprecation 2 | on: 3 | workflow_dispatch: 4 | 5 | jobs: 6 | Soft-deprecation: 7 | runs-on: ubuntu-latest 8 | name: Validate CITATION.cff 9 | env: 10 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v4 14 | - name: Validate CITATION.cff 15 | uses: dieghernan/cff-validator@main 16 | with: 17 | cache-version: 2 18 | install-r: false 19 | 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | cff-validator.Rproj 6 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v4 2 | 3 | Note that `v4` is a sliding tag, and we introduce non-breaking changes to it. 4 | 5 | **Breaking change**: The action now uses a Docker container, and would require 6 | to be run on a Linux virtual machine (`os: ubuntu-*`). MacOS and Windows actions 7 | would need to switch to `ubuntu-*`. 8 | 9 | - Migration to Docker container 10 | [**rocker/tidyverse**](https://hub.docker.com/r/rocker/tidyverse/). 11 | 12 | # v3 13 | 14 | Note that `v3` is a sliding tag, and we introduce non-breaking changes to it. 15 | 16 | - Improve underlying code. 17 | - Using a copy of schema.json shipped with {cffr} to avoid SSL/SSH issues 18 | [#10](https://github.com/dieghernan/cff-validator/issues/10). 19 | - Update versions of depencies 20 | ([#13](https://github.com/dieghernan/cff-validator/pull/13), 21 | [#14](https://github.com/dieghernan/cff-validator/pull/14)) 22 | 23 | ## v3.0.1 (2023-07-21) 24 | 25 | - Improve underlying code. 26 | - Using a copy of schema.json shipped with {cffr} to avoid SSL/SSH issues 27 | [#10](https://github.com/dieghernan/cff-validator/issues/10) 28 | 29 | ## v3.0.2 (2024-02-08) 30 | 31 | - Update versions of dependencies 32 | (, 33 | [#14](https://github.com/dieghernan/cff-validator/pull/14)) 34 | 35 | ## v3.0.3 (2025-01-17) 36 | 37 | - Always install R (#16) hence (soft) deprecation of `install-r` parameter. 38 | - Update versions of dependencies. 39 | 40 | # v2.3 41 | 42 | - Fix [#8](https://github.com/dieghernan/cff-validator/issues/8), error on 43 | non-Git repos. 44 | 45 | # v2.2 46 | 47 | - New `install-r` parameter. 48 | - Improvements on performance. 49 | 50 | # v2.1 51 | 52 | - New `cache-version` parameter. 53 | - Better handling of R packages via `pak` R package. 54 | - Improve cache of packages. 55 | 56 | # v2 57 | 58 | - Pretty printing of errors. 59 | - On errors, the action uploads an artifact. 60 | - Fix typos thanks to @sdruskat. 61 | - Update file examples. 62 | - Add `r-reprex.R` with a full working **R** workflow. 63 | - Fix errors due to changes on dependencies. 64 | 65 | # v1 66 | 67 | - First stable release 68 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | message: "If you use this software in your research, please cite it as below." 3 | title: "cff-validator" 4 | version: "v4" 5 | doi: 10.5281/zenodo.5348443 6 | abstract: "A GitHub action to validate CITATION.cff files with R." 7 | authors: 8 | - family-names: "Hernangómez" 9 | given-names: "Diego" 10 | orcid: "https://orcid.org/0000-0001-8457-4658" 11 | license: MIT 12 | url: "https://github.com/marketplace/actions/cff-validator" 13 | repository-code: "https://github.com/dieghernan/cff-validator" 14 | keywords: 15 | - cff 16 | - citation 17 | - citation-file-format 18 | - citation-files 19 | - github-actions 20 | references: 21 | - title: Citation File Format 22 | abstract: CITATION.cff files are plain text files with human- and machine-readable citation information for software. Code developers can include them in their repositories to let others know how to correctly cite their software. This is the specification for the Citation File Format. 23 | version: 1.2.0 24 | type: software 25 | authors: 26 | - family-names: Druskat 27 | given-names: Stephan 28 | orcid: https://orcid.org/0000-0003-4925-7248 29 | - family-names: Spaaks 30 | given-names: Jurriaan H. 31 | orcid: https://orcid.org/0000-0002-7064-4069 32 | - family-names: Chue Hong 33 | given-names: Neil 34 | orcid: https://orcid.org/0000-0002-8876-7606 35 | - family-names: Haines 36 | given-names: Robert 37 | orcid: https://orcid.org/0000-0002-9538-7919 38 | - family-names: Baker 39 | given-names: James 40 | orcid: https://orcid.org/0000-0002-2682-6922 41 | - family-names: Bliven 42 | given-names: Spencer 43 | orcid: https://orcid.org/0000-0002-1200-1698 44 | email: spencer.bliven@gmail.com 45 | - family-names: Willighagen 46 | given-names: Egon 47 | orcid: https://orcid.org/0000-0001-7542-0286 48 | - family-names: Pérez-Suárez 49 | given-names: David 50 | orcid: https://orcid.org/0000-0003-0784-6909 51 | website: https://dpshelio.github.io 52 | - family-names: Konovalov 53 | given-names: Alexander 54 | orcid: https://orcid.org/0000-0001-5299-3292 55 | identifiers: 56 | - type: doi 57 | value: 10.5281/zenodo.1003149 58 | description: The concept DOI for the collection containing all versions of the Citation File Format. 59 | - type: doi 60 | value: 10.5281/zenodo.5171937 61 | description: The versioned DOI for the version 1.2.0 of the Citation File Format. 62 | date-released: "2021-08-09" 63 | keywords: 64 | - citation file format 65 | - CFF 66 | - citation files 67 | - software citation 68 | - file format 69 | - YAML 70 | - software sustainability 71 | - research software 72 | - credit 73 | license: "CC-BY-4.0" 74 | doi: 10.5281/zenodo.5171937 75 | 76 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Diego H. 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cff-validator 2 | 3 | ![latest-version](https://img.shields.io/github/v/release/dieghernan/cff-validator) 4 | [![CITATION-cff](https://github.com/dieghernan/cff-validator/actions/workflows/cff-validator.yml/badge.svg)](https://github.com/dieghernan/cff-validator/actions/workflows/cff-validator.yml) 5 | [![full-test-action](https://github.com/dieghernan/cff-validator/actions/workflows/cff-validator-complete-matrix.yml/badge.svg)](https://github.com/dieghernan/cff-validator/actions/workflows/cff-validator-complete-matrix.yml) 6 | [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5348443.svg)](https://doi.org/10.5281/zenodo.5348443) 7 | 8 | A GitHub action to validate `CITATION.cff` files with R. 9 | 10 | **Breaking change: v4 only works on Linux, upgrade your v3 to run on 11 | `ubuntu-*`.** 12 | 13 | ## Introduction 14 | 15 | If you have a [Citation File Format 16 | (cff)](https://citation-file-format.github.io) on your repository this action 17 | would check its validity against the defined 18 | [schema](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md). 19 | 20 | A full valid workflow: 21 | 22 | ``` yaml 23 | on: 24 | push: 25 | paths: 26 | - CITATION.cff 27 | workflow_dispatch: 28 | 29 | name: CITATION.cff 30 | jobs: 31 | Validate-CITATION-cff: 32 | runs-on: ubuntu-latest 33 | name: Validate CITATION.cff 34 | env: 35 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 36 | 37 | steps: 38 | - name: Checkout 39 | uses: actions/checkout@v4 40 | 41 | - name: Validate CITATION.cff 42 | uses: dieghernan/cff-validator@v4 43 | ``` 44 | 45 | On error, the action produces a Job Summary with a high-level description of the 46 | errors found: 47 | 48 |
49 | 50 | citation_cff.md 51 | 52 | ❌ CITATION.cff has errors 53 | 54 | | field | message | 55 | |:----------------|:---------------------------------| 56 | | data | has additional properties | 57 | | data.authors.0 | no schemas match | 58 | | data.doi | referenced schema does not match | 59 | | data.keywords.0 | is the wrong type | 60 | | data.license | referenced schema does not match | 61 | | data.url | referenced schema does not match | 62 | 63 | : See [Guide to Citation File Format schema version 64 | 1.2.0](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md) 65 | for debugging. 66 | 67 |
68 | 69 | For more examples, see the actions provided on [this 70 | path](https://github.com/dieghernan/cff-validator/tree/main/.github/workflows). 71 | 72 | ## Add a badge to your repo 73 | 74 | You can easily create a badge showing the current status of validation of your 75 | `CITATION.cff` like this: 76 | 77 | [![CITATION.cff](https://github.com/dieghernan/cff-validator/actions/workflows/cff-validator.yml/badge.svg)](https://github.com/dieghernan/cff-validator/actions/workflows/cff-validator.yml) 78 | 79 | [![CITATION-cff 80 | error](https://github.com/dieghernan/cff-validator/actions/workflows/cff-validator-error.yml/badge.svg)](https://github.com/dieghernan/cff-validator/actions/workflows/cff-validator-error.yml) 81 | 82 | See a quick demo: 83 | 84 | ![Demo gif showing how to create a badge for a GH action](assets/demo.gif) 85 | 86 | ## Inputs available 87 | 88 | - `citation-path`: Path to .cff file to be validated. By default it selects a 89 | `CITATION.cff` file on the root of the repository: 90 | 91 | ``` yaml 92 | - name: Validate CITATION.cff 93 | uses: dieghernan/cff-validator@v4 94 | with: 95 | citation-path: "examples/CITATION.cff" 96 | ``` 97 | 98 | - (Soft) Deprecated parameters in **v4**: 99 | 100 | - `cache-version` 101 | 102 | - `install-r`. 103 | 104 | See a full featured implementation on [this 105 | example](https://github.com/dieghernan/cff-validator/blob/main/.github/workflows/cff-validator-complete-matrix.yml). 106 | 107 | ## For useRs 108 | 109 | This action runs on R. For the same functionality you can use the **cffr** 110 | package: 111 | 112 | ``` r 113 | 114 | cffr::cff_validate("CITATION.cff") 115 | #> 116 | #> cff_validate results—— 117 | #> Congratulations! This .cff file is valid 118 | ``` 119 | 120 | See 121 | [`cffr::cff_validate()`](https://docs.ropensci.org/cffr/reference/cff_validate.html) 122 | for details. 123 | 124 | ## References 125 | 126 | Druskat, S., Spaaks, J. H., Chue Hong, N., Haines, R., Baker, J., Bliven, S., 127 | Willighagen, E., Pérez-Suárez, D., & Konovalov, A. (2021). Citation File Format 128 | (Version 1.2.0) [Computer software]. 129 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: cff-validator 2 | author: Diego Hernangómez 3 | description: "Validate your repository's CITATION.cff file using R software" 4 | branding: 5 | icon: 'book-open' 6 | color: 'gray-dark' 7 | inputs: 8 | citation-path: 9 | description: 'Path to .cff file to be validated. By default it selects a CITATION.cff file on the root of the repository.' 10 | required: false 11 | default: 'CITATION.cff' 12 | cache-version: 13 | description: 'Soft deprecated' 14 | required: false 15 | default: 1 16 | install-r: 17 | description: 'Soft deprecated' 18 | required: false 19 | default: true 20 | # pak cache management derived from https://github.com/r-lib/actions/blob/v2-branch/setup-r-dependencies/action.yaml 21 | # By Jim Hester 22 | runs: 23 | using: composite 24 | steps: 25 | - name: Validate cff 26 | uses: dieghernan/cff-validator/docker@main 27 | with: 28 | cffpath: "${{ inputs.citation-path }}" 29 | 30 | # Report check 31 | - name: Upload results 32 | shell: bash 33 | run: | 34 | # Upload results 35 | cat citation_cff.md >$GITHUB_STEP_SUMMARY 36 | 37 | - name: Check for errors 38 | id: err 39 | shell: bash 40 | run: | 41 | # Identify errors 42 | err=false 43 | if test -f "issue.md"; then 44 | err=true 45 | fi 46 | echo "error=$err" >> $GITHUB_OUTPUT 47 | 48 | - name: Fail workflow 49 | if: steps.err.outputs.error == 'true' 50 | shell: bash 51 | run: | 52 | echo "::error:: CFF file has errors, see Job Summary" 53 | exit 1 54 | 55 | -------------------------------------------------------------------------------- /assets/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dieghernan/cff-validator/114aae53e1850c3757733beb60036941900e3dc3/assets/demo.gif -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rocker/tidyverse:4.4.2 2 | 3 | WORKDIR /app 4 | 5 | # Copy scripts 6 | COPY validate_cff.R entrypoint.sh /app/ 7 | 8 | # Make the scripts executable 9 | RUN chmod +x /app/* 10 | 11 | # Set entrypoint 12 | ENTRYPOINT ["/app/entrypoint.sh"] 13 | -------------------------------------------------------------------------------- /docker/action.yml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/pharmaverse/admiralci 2 | 3 | name: Validate CFF 4 | description: "Validate your repository's CITATION.cff file using R software" 5 | 6 | inputs: 7 | cffpath: 8 | description: 'Path to .cff file to be validated' 9 | required: false 10 | default: 'CITATION.cff' 11 | type: string 12 | 13 | runs: 14 | using: 'docker' 15 | image: './Dockerfile' 16 | args: 17 | - ${{ inputs.cffpath }} 18 | 19 | -------------------------------------------------------------------------------- /docker/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | Rscript /app/validate_cff.R -p "${INPUT_CFFPATH}" 3 | -------------------------------------------------------------------------------- /docker/validate_cff.R: -------------------------------------------------------------------------------- 1 | # Modified version from pharmaverse/admiralci 2 | # See https://github.com/pharmaverse/admiralci/tree/61347fe11955297818b3ca7814fc7328f2ad7840/.github/actions/cran-status-extract 3 | 4 | 5 | # 0. Setup ---- 6 | if (!requireNamespace("cffr", quietly = TRUE)) { 7 | suppressMessages(install.packages("cffr", 8 | repos = "https://cloud.r-project.org", 9 | verbose = FALSE, 10 | quiet = TRUE, 11 | dependencies = TRUE 12 | )) 13 | } 14 | if (!requireNamespace("optparse", quietly = TRUE)) { 15 | suppressMessages(install.packages("optparse", 16 | repos = "https://cloud.r-project.org", 17 | verbose = FALSE, 18 | quiet = TRUE 19 | )) 20 | } 21 | 22 | # check if needed : package name and working dir path as input arguments : 23 | library(optparse) 24 | option_list <- list( 25 | make_option(c("-p", "--cffpath"), 26 | type = "character", 27 | help = "package name (REQUIRED)", 28 | metavar = "character" 29 | ) 30 | ) 31 | opt_parser <- OptionParser(option_list = option_list) 32 | opt <- parse_args(opt_parser) 33 | cffpath <- opt$cffpath 34 | 35 | 36 | # clean files 37 | if (file.exists("citation_cff.md")) unlink("citation_cff.md") 38 | if (file.exists("issue.md")) unlink("issue.md") 39 | 40 | 41 | # Validate cff ---- 42 | 43 | 44 | cat("Validating cff\n") 45 | citfile <- yaml::read_yaml(cffpath) 46 | # All elements to character 47 | citfile <- rapply(citfile, function(x) as.character(x), how = "replace") 48 | 49 | # Convert to json 50 | cit_temp <- jsonlite::toJSON(citfile, pretty = TRUE, auto_unbox = TRUE) 51 | 52 | # Use local copy of schema, included with cffr 53 | schema_local <- system.file("schema/schema.json", package = "cffr") 54 | 55 | # Validate 56 | result <- jsonvalidate::json_validate(cit_temp, 57 | schema_local, 58 | verbose = TRUE 59 | ) 60 | 61 | # Results 62 | if (result == FALSE) { 63 | writeLines(paste0("\n:x: ", cffpath, " has errors\n"), 64 | con = "citation_cff.md" 65 | ) 66 | # Format outputs 67 | get_errors <- attr(result, "errors") 68 | get_errors$field <- gsub( 69 | "^data", "cff", 70 | get_errors$field 71 | ) 72 | 73 | write(knitr::kable(get_errors, align = "l"), 74 | file = "citation_cff.md", 75 | append = TRUE 76 | ) 77 | 78 | write("\n\nSee [Guide to Citation File Format schema version 1.2.0](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md) for debugging.", 79 | file = "citation_cff.md", 80 | append = TRUE 81 | ) 82 | 83 | cat(paste0( 84 | "::warning::", cffpath, 85 | " has errors, see Job Summary of this GH action for details.\n" 86 | )) 87 | 88 | 89 | cat(paste0(cffpath, " file not valid. See Job Summary.")) 90 | 91 | write("ERROR", file = "issue.md") 92 | } else { 93 | writeLines( 94 | paste0( 95 | "\n:white_check_mark: Congratulations! ", cffpath, " is valid\n" 96 | ), 97 | con = "citation_cff.md" 98 | ) 99 | cat(paste0( 100 | "::notice ::", cffpath, 101 | " is a valid CFF file.\n" 102 | )) 103 | } 104 | -------------------------------------------------------------------------------- /examples/key-complete/CITATION.cff: -------------------------------------------------------------------------------- 1 | ############################ 2 | # DO NOT USE FOR CITATION! # 3 | ############################ 4 | # This is a key-complete # 5 | # test file for validation # 6 | ############################ 7 | 8 | cff-version: 1.2.0 9 | 10 | message: If you use this software, please cite it as below. 11 | 12 | abstract: "This is an awesome piece of research software!" 13 | 14 | authors: 15 | # A person 16 | - family-names: Real Person 17 | given-names: One Truly 18 | name-particle: van der 19 | name-suffix: IV 20 | alias: Citey 21 | affiliation: Excellent University, Niceplace, Arcadia 22 | address: 22 Acacia Avenue 23 | city: Citationburgh 24 | region: Renfrewshire 25 | post-code: C13 7X7 26 | country: GB 27 | orcid: https://orcid.org/0000-0001-2345-6789 28 | email: project@entity.com 29 | tel: +44(0)141-323 4567 30 | fax: +44(0)141-323 45678 31 | website: https://www.entity-project-team.io 32 | # An entity 33 | - name: Entity Project Team Conference entity 34 | address: 22 Acacia Avenue 35 | city: Citationburgh 36 | region: Renfrewshire 37 | post-code: C13 7X7 38 | country: GB 39 | orcid: https://orcid.org/0000-0001-2345-6789 40 | email: project@entity.com 41 | tel: +44(0)141-323 4567 42 | fax: +44(0)141-323 45678 43 | website: https://www.entity-project-team.io 44 | date-start: 2017-01-01 45 | date-end: 2017-01-31 46 | location: The team garage 47 | 48 | commit: 156a04c74a8a79d40c5d705cddf9d36735feab4d 49 | 50 | contact: 51 | # A person 52 | - family-names: Real Person 53 | given-names: One Truly 54 | name-particle: van der 55 | name-suffix: IV 56 | alias: Citey 57 | affiliation: Excellent University, Niceplace, Arcadia 58 | address: 22 Acacia Avenue 59 | city: Citationburgh 60 | region: Renfrewshire 61 | post-code: C13 7X7 62 | country: GB 63 | orcid: https://orcid.org/0000-0001-2345-6789 64 | email: project@entity.com 65 | tel: +44(0)141-323 4567 66 | fax: +44(0)141-323 45678 67 | website: https://www.entity-project-team.io 68 | # An entity 69 | - name: Entity Project Team Conference entity 70 | address: 22 Acacia Avenue 71 | city: Citationburgh 72 | region: Renfrewshire 73 | post-code: C13 7X7 74 | country: GB 75 | orcid: https://orcid.org/0000-0001-2345-6789 76 | email: project@entity.com 77 | tel: +44(0)141-323 4567 78 | fax: +44(0)141-323 45678 79 | website: https://www.entity-project-team.io 80 | date-start: 2017-01-01 81 | date-end: 2017-01-31 82 | location: The team garage 83 | 84 | date-released: 2017-12-11 85 | 86 | doi: 10.5281/zenodo.1003150 87 | 88 | identifiers: 89 | - type: doi 90 | value: 10.5281/zenodo.1003150 91 | - type: swh 92 | value: swh:1:rel:99f6850374dc6597af01bd0ee1d3fc0699301b9f 93 | - type: url 94 | value: https://example.com 95 | - type: other 96 | value: other-schema://abcd.1234.efgh.5678 97 | 98 | keywords: 99 | - One 100 | - Two 101 | - Three 102 | - "4" 103 | 104 | license: CC-BY-SA-4.0 105 | 106 | license-url: https://spdx.org/licenses/CC-BY-SA-4.0.html#licenseText 107 | 108 | repository: https://www.example.com/foo/?bar=baz&inga=42&quux 109 | 110 | repository-code: http://foo.com/blah_(wikipedia)_blah#cite-1 111 | 112 | repository-artifact: https://files.pythonhosted.org/packages/0a/84/10507b69a07768bc16981184b4d147a0fc84b71fbf35c03bafc8dcced8e1/cffconvert-1.3.3.tar.gz 113 | 114 | title: Citation File Format 1.0.0 115 | 116 | type: software 117 | 118 | url: http://userid:password@example.com:8080/ 119 | 120 | version: 1.0.0 121 | 122 | preferred-citation: 123 | # A reference 124 | type: book 125 | title: Book Title 126 | abbreviation: Abbr 127 | abstract: Description of the book. 128 | collection-doi: 10.5281/zenodo.1003150 129 | collection-title: Collection Title 130 | collection-type: Collection Type 131 | commit: 156a04c74a8a79d40c5d705cddf9d36735feab4d 132 | copyright: 2017 Stephan Druskat 133 | data-type: Data Type 134 | database: Database 135 | date-accessed: 2017-10-31 136 | date-downloaded: 2017-10-31 137 | date-released: 2017-10-31 138 | date-published: 2017-10-31 139 | department: Department 140 | doi: 10.5281/zenodo.1003150 141 | edition: 2nd edition 142 | end: 456 143 | entry: Chapter 9 144 | filename: book.zip 145 | format: Printed book 146 | identifiers: 147 | - type: doi 148 | value: 10.5281/zenodo.1003150 149 | - type: swh 150 | value: swh:1:rel:99f6850374dc6597af01bd0ee1d3fc0699301b9f 151 | - type: url 152 | value: https://example.com 153 | - type: other 154 | value: other-schema://abcd.1234.efgh.5678 155 | isbn: 978-1-89183-044-0 156 | issn: 1234-543X 157 | issue: "123" 158 | issue-date: December 159 | issue-title: Special Issue on Software Citation 160 | journal: PeerJ 161 | keywords: 162 | - Software 163 | - Citation 164 | languages: 165 | - aaa 166 | - zu 167 | license: Apache-2.0 168 | license-url: https://spdx.org/licenses/Apache-2.0.html#licenseText 169 | loc-start: 14 170 | loc-end: 54 171 | medium: hardcover book 172 | month: 03 173 | nihmsid: Don't know what format a NIHMSID is in 174 | notes: "A field for general notes about the reference, usable in other formats such as BibTeX." 175 | number: A general-purpose field for accession numbers, cf. the specifications for examples. 176 | number-volumes: 7 177 | pages: 765 178 | patent-states: 179 | - Germany 180 | - ROI 181 | - "but also for example US states, such as:" 182 | - IL 183 | - RI 184 | pmcid: PMC1234567 185 | repository: http://code.google.com/events/#&product=browser 186 | repository-code: http://142.42.1.1:8080/ 187 | repository-artifact: https://files.pythonhosted.org/packages/0a/84/10507b69a07768bc16981184b4d147a0fc84b71fbf35c03bafc8dcced8e1/cffconvert-1.3.3.tar.gz 188 | scope: Cite this book if you want to reference the general concepts implemented in Citation File Format 1.0.0. 189 | section: Chapter 2 - "Reference keys" 190 | status: advance-online 191 | start: 123 192 | thesis-type: Doctoral dissertation 193 | url: http://j.mp 194 | version: 0.0.1423-BETA 195 | volume: 2 196 | volume-title: Advances in Software Citation 197 | year: 2017 198 | year-original: 2012 199 | 200 | # Object-based keys for the reference 201 | conference: 202 | # An entity 203 | name: Entity Project Team Conference entity 204 | address: 22 Acacia Avenue 205 | city: Citationburgh 206 | region: Renfrewshire 207 | post-code: C13 7X7 208 | country: GB 209 | orcid: https://orcid.org/0000-0001-2345-6789 210 | email: project@entity.com 211 | tel: +44(0)141-323 4567 212 | fax: +44(0)141-323 45678 213 | website: https://www.entity-project-team.io 214 | date-start: 2017-01-01 215 | date-end: 2017-01-31 216 | location: The team garage 217 | 218 | authors: 219 | # A person 220 | - family-names: Real Person 221 | given-names: One Truly 222 | name-particle: van der 223 | name-suffix: IV 224 | alias: Citey 225 | affiliation: Excellent University, Niceplace, Arcadia 226 | address: 22 Acacia Avenue 227 | city: Citationburgh 228 | region: Renfrewshire 229 | post-code: C13 7X7 230 | country: GB 231 | orcid: https://orcid.org/0000-0001-2345-6789 232 | email: project@entity.com 233 | tel: +44(0)141-323 4567 234 | fax: +44(0)141-323 45678 235 | website: https://www.entity-project-team.io 236 | # An entity 237 | - name: Entity Project Team Conference entity 238 | address: 22 Acacia Avenue 239 | city: Citationburgh 240 | region: Renfrewshire 241 | post-code: C13 7X7 242 | country: GB 243 | orcid: https://orcid.org/0000-0001-2345-6789 244 | email: project@entity.com 245 | tel: +44(0)141-323 4567 246 | fax: +44(0)141-323 45678 247 | website: https://www.entity-project-team.io 248 | date-start: 2017-01-01 249 | date-end: 2017-01-31 250 | location: The team garage 251 | 252 | contact: 253 | # A person 254 | - family-names: Real Person 255 | given-names: One Truly 256 | name-particle: van der 257 | name-suffix: IV 258 | alias: Citey 259 | affiliation: Excellent University, Niceplace, Arcadia 260 | address: 22 Acacia Avenue 261 | city: Citationburgh 262 | region: Renfrewshire 263 | post-code: C13 7X7 264 | country: GB 265 | orcid: https://orcid.org/0000-0001-2345-6789 266 | email: project@entity.com 267 | tel: +44(0)141-323 4567 268 | fax: +44(0)141-323 45678 269 | website: https://www.entity-project-team.io 270 | # An entity 271 | - name: Entity Project Team Conference entity 272 | address: 22 Acacia Avenue 273 | city: Citationburgh 274 | region: Renfrewshire 275 | post-code: C13 7X7 276 | country: GB 277 | orcid: https://orcid.org/0000-0001-2345-6789 278 | email: project@entity.com 279 | tel: +44(0)141-323 4567 280 | fax: +44(0)141-323 45678 281 | website: https://www.entity-project-team.io 282 | date-start: 2017-01-01 283 | date-end: 2017-01-31 284 | location: The team garage 285 | 286 | database-provider: 287 | # An entity 288 | name: Entity Project Team Conference entity 289 | address: 22 Acacia Avenue 290 | city: Citationburgh 291 | region: Renfrewshire 292 | post-code: C13 7X7 293 | country: GB 294 | orcid: https://orcid.org/0000-0001-2345-6789 295 | email: project@entity.com 296 | tel: +44(0)141-323 4567 297 | fax: +44(0)141-323 45678 298 | website: https://www.entity-project-team.io 299 | date-start: 2017-01-01 300 | date-end: 2017-01-31 301 | location: The team garage 302 | 303 | editors: 304 | # A person 305 | - family-names: Real Person 306 | given-names: One Truly 307 | name-particle: van der 308 | name-suffix: IV 309 | alias: Citey 310 | affiliation: Excellent University, Niceplace, Arcadia 311 | address: 22 Acacia Avenue 312 | city: Citationburgh 313 | region: Renfrewshire 314 | post-code: C13 7X7 315 | country: GB 316 | orcid: https://orcid.org/0000-0001-2345-6789 317 | email: project@entity.com 318 | tel: +44(0)141-323 4567 319 | fax: +44(0)141-323 45678 320 | website: https://www.entity-project-team.io 321 | # An entity 322 | - name: Entity Project Team Conference entity 323 | address: 22 Acacia Avenue 324 | city: Citationburgh 325 | region: Renfrewshire 326 | post-code: C13 7X7 327 | country: GB 328 | orcid: https://orcid.org/0000-0001-2345-6789 329 | email: project@entity.com 330 | tel: +44(0)141-323 4567 331 | fax: +44(0)141-323 45678 332 | website: https://www.entity-project-team.io 333 | date-start: 2017-01-01 334 | date-end: 2017-01-31 335 | location: The team garage 336 | 337 | editors-series: 338 | # A person 339 | - family-names: Real Person 340 | given-names: One Truly 341 | name-particle: van der 342 | name-suffix: IV 343 | alias: Citey 344 | affiliation: Excellent University, Niceplace, Arcadia 345 | address: 22 Acacia Avenue 346 | city: Citationburgh 347 | region: Renfrewshire 348 | post-code: C13 7X7 349 | country: GB 350 | orcid: https://orcid.org/0000-0001-2345-6789 351 | email: project@entity.com 352 | tel: +44(0)141-323 4567 353 | fax: +44(0)141-323 45678 354 | website: https://www.entity-project-team.io 355 | # An entity 356 | - name: Entity Project Team Conference entity 357 | address: 22 Acacia Avenue 358 | city: Citationburgh 359 | region: Renfrewshire 360 | post-code: C13 7X7 361 | country: GB 362 | orcid: https://orcid.org/0000-0001-2345-6789 363 | email: project@entity.com 364 | tel: +44(0)141-323 4567 365 | fax: +44(0)141-323 45678 366 | website: https://www.entity-project-team.io 367 | date-start: 2017-01-01 368 | date-end: 2017-01-31 369 | location: The team garage 370 | 371 | institution: 372 | # An entity 373 | name: Entity Project Team Conference entity 374 | address: 22 Acacia Avenue 375 | city: Citationburgh 376 | region: Renfrewshire 377 | post-code: C13 7X7 378 | country: GB 379 | orcid: https://orcid.org/0000-0001-2345-6789 380 | email: project@entity.com 381 | tel: +44(0)141-323 4567 382 | fax: +44(0)141-323 45678 383 | website: https://www.entity-project-team.io 384 | date-start: 2017-01-01 385 | date-end: 2017-01-31 386 | location: The team garage 387 | 388 | location: 389 | # An entity 390 | name: Entity Project Team Conference entity 391 | address: 22 Acacia Avenue 392 | city: Citationburgh 393 | region: Renfrewshire 394 | post-code: C13 7X7 395 | country: GB 396 | orcid: https://orcid.org/0000-0001-2345-6789 397 | email: project@entity.com 398 | tel: +44(0)141-323 4567 399 | fax: +44(0)141-323 45678 400 | website: https://www.entity-project-team.io 401 | date-start: 2017-01-01 402 | date-end: 2017-01-31 403 | location: The team garage 404 | 405 | publisher: 406 | # An entity 407 | name: Entity Project Team Conference entity 408 | address: 22 Acacia Avenue 409 | city: Citationburgh 410 | region: Renfrewshire 411 | post-code: C13 7X7 412 | country: GB 413 | orcid: https://orcid.org/0000-0001-2345-6789 414 | email: project@entity.com 415 | tel: +44(0)141-323 4567 416 | fax: +44(0)141-323 45678 417 | website: https://www.entity-project-team.io 418 | date-start: 2017-01-01 419 | date-end: 2017-01-31 420 | location: The team garage 421 | 422 | recipients: 423 | # A person 424 | - family-names: Real Person 425 | given-names: One Truly 426 | name-particle: van der 427 | name-suffix: IV 428 | alias: Citey 429 | affiliation: Excellent University, Niceplace, Arcadia 430 | address: 22 Acacia Avenue 431 | city: Citationburgh 432 | region: Renfrewshire 433 | post-code: C13 7X7 434 | country: GB 435 | orcid: https://orcid.org/0000-0001-2345-6789 436 | email: project@entity.com 437 | tel: +44(0)141-323 4567 438 | fax: +44(0)141-323 45678 439 | website: https://www.entity-project-team.io 440 | # An entity 441 | - name: Entity Project Team Conference entity 442 | address: 22 Acacia Avenue 443 | city: Citationburgh 444 | region: Renfrewshire 445 | post-code: C13 7X7 446 | country: GB 447 | orcid: https://orcid.org/0000-0001-2345-6789 448 | email: project@entity.com 449 | tel: +44(0)141-323 4567 450 | fax: +44(0)141-323 45678 451 | website: https://www.entity-project-team.io 452 | date-start: 2017-01-01 453 | date-end: 2017-01-31 454 | location: The team garage 455 | 456 | senders: 457 | # A person 458 | - family-names: Real Person 459 | given-names: One Truly 460 | name-particle: van der 461 | name-suffix: IV 462 | alias: Citey 463 | affiliation: Excellent University, Niceplace, Arcadia 464 | address: 22 Acacia Avenue 465 | city: Citationburgh 466 | region: Renfrewshire 467 | post-code: C13 7X7 468 | country: GB 469 | orcid: https://orcid.org/0000-0001-2345-6789 470 | email: project@entity.com 471 | tel: +44(0)141-323 4567 472 | fax: +44(0)141-323 45678 473 | website: https://www.entity-project-team.io 474 | # An entity 475 | - name: Entity Project Team Conference entity 476 | address: 22 Acacia Avenue 477 | city: Citationburgh 478 | region: Renfrewshire 479 | post-code: C13 7X7 480 | country: GB 481 | orcid: https://orcid.org/0000-0001-2345-6789 482 | email: project@entity.com 483 | tel: +44(0)141-323 4567 484 | fax: +44(0)141-323 45678 485 | website: https://www.entity-project-team.io 486 | date-start: 2017-01-01 487 | date-end: 2017-01-31 488 | location: The team garage 489 | 490 | translators: 491 | # A person 492 | - family-names: Real Person 493 | given-names: One Truly 494 | name-particle: van der 495 | name-suffix: IV 496 | alias: Citey 497 | affiliation: Excellent University, Niceplace, Arcadia 498 | address: 22 Acacia Avenue 499 | city: Citationburgh 500 | region: Renfrewshire 501 | post-code: C13 7X7 502 | country: GB 503 | orcid: https://orcid.org/0000-0001-2345-6789 504 | email: project@entity.com 505 | tel: +44(0)141-323 4567 506 | fax: +44(0)141-323 45678 507 | website: https://www.entity-project-team.io 508 | # An entity 509 | - name: Entity Project Team Conference entity 510 | address: 22 Acacia Avenue 511 | city: Citationburgh 512 | region: Renfrewshire 513 | post-code: C13 7X7 514 | country: GB 515 | orcid: https://orcid.org/0000-0001-2345-6789 516 | email: project@entity.com 517 | tel: +44(0)141-323 4567 518 | fax: +44(0)141-323 45678 519 | website: https://www.entity-project-team.io 520 | date-start: 2017-01-01 521 | date-end: 2017-01-31 522 | location: The team garage 523 | 524 | references: 525 | - type: book 526 | title: Book Title 527 | abbreviation: Abbr 528 | abstract: Description of the book. 529 | collection-doi: 10.5281/zenodo.1003150 530 | collection-title: Collection Title 531 | collection-type: Collection Type 532 | commit: 156a04c74a8a79d40c5d705cddf9d36735feab4d 533 | copyright: 2017 Stephan Druskat 534 | data-type: Data Type 535 | database: Database 536 | date-accessed: 2017-10-31 537 | date-downloaded: 2017-10-31 538 | date-released: 2017-10-31 539 | date-published: 2017-10-31 540 | department: Department 541 | doi: 10.5281/zenodo.1003150 542 | edition: 2nd edition 543 | end: 123 544 | entry: Chapter 9 545 | filename: book.zip 546 | format: Printed book 547 | identifiers: 548 | - type: doi 549 | value: 10.5281/zenodo.1003150 550 | - type: swh 551 | value: swh:1:rel:99f6850374dc6597af01bd0ee1d3fc0699301b9f 552 | - type: url 553 | value: https://example.com 554 | - type: other 555 | value: other-schema://abcd.1234.efgh.5678 556 | isbn: 978-1-89183-044-0 557 | issn: 1234-543X 558 | issue: "123" 559 | issue-date: December 560 | issue-title: Special Issue on Software Citation 561 | journal: PeerJ 562 | keywords: 563 | - Software 564 | - Citation 565 | languages: 566 | - aaa 567 | - zu 568 | license: Apache-2.0 569 | license-url: https://spdx.org/licenses/Apache-2.0.html#licenseText 570 | loc-start: 14 571 | loc-end: 54 572 | medium: hardcover book 573 | month: 03 574 | nihmsid: Don't know what format a NIHMSID is in 575 | notes: "A field for general notes about the reference, usable in other formats such as BibTeX." 576 | number: A general-purpose field for accession numbers, cf. the specifications for examples. 577 | number-volumes: 7 578 | pages: 765 579 | patent-states: 580 | - Germany 581 | - ROI 582 | - "but also for example US states, such as:" 583 | - IL 584 | - RI 585 | pmcid: PMC1234567 586 | repository: http://code.google.com/events/#&product=browser 587 | repository-code: http://142.42.1.1:8080/ 588 | repository-artifact: https://files.pythonhosted.org/packages/0a/84/10507b69a07768bc16981184b4d147a0fc84b71fbf35c03bafc8dcced8e1/cffconvert-1.3.3.tar.gz 589 | scope: Cite this book if you want to reference the general concepts implemented in Citation File Format 1.0.0. 590 | section: Chapter 2 - "Reference keys" 591 | status: advance-online 592 | start: 123 593 | thesis-type: Doctoral dissertation 594 | url: http://j.mp 595 | version: 0.0.1423-BETA 596 | volume: 2 597 | volume-title: Advances in Software Citation 598 | year: 2017 599 | year-original: 2012 600 | 601 | # Object-based keys for the reference 602 | conference: 603 | # An entity 604 | name: Entity Project Team Conference entity 605 | address: 22 Acacia Avenue 606 | city: Citationburgh 607 | region: Renfrewshire 608 | post-code: C13 7X7 609 | country: GB 610 | orcid: https://orcid.org/0000-0001-2345-6789 611 | email: project@entity.com 612 | tel: +44(0)141-323 4567 613 | fax: +44(0)141-323 45678 614 | website: https://www.entity-project-team.io 615 | date-start: 2017-01-01 616 | date-end: 2017-01-31 617 | location: The team garage 618 | 619 | authors: 620 | # A person 621 | - family-names: Real Person 622 | given-names: One Truly 623 | name-particle: van der 624 | name-suffix: IV 625 | alias: Citey 626 | affiliation: Excellent University, Niceplace, Arcadia 627 | address: 22 Acacia Avenue 628 | city: Citationburgh 629 | region: Renfrewshire 630 | post-code: C13 7X7 631 | country: GB 632 | orcid: https://orcid.org/0000-0001-2345-6789 633 | email: project@entity.com 634 | tel: +44(0)141-323 4567 635 | fax: +44(0)141-323 45678 636 | website: https://www.entity-project-team.io 637 | # An entity 638 | - name: Entity Project Team Conference entity 639 | address: 22 Acacia Avenue 640 | city: Citationburgh 641 | region: Renfrewshire 642 | post-code: C13 7X7 643 | country: GB 644 | orcid: https://orcid.org/0000-0001-2345-6789 645 | email: project@entity.com 646 | tel: +44(0)141-323 4567 647 | fax: +44(0)141-323 45678 648 | website: https://www.entity-project-team.io 649 | date-start: 2017-01-01 650 | date-end: 2017-01-31 651 | location: The team garage 652 | 653 | contact: 654 | # A person 655 | - family-names: Real Person 656 | given-names: One Truly 657 | name-particle: van der 658 | name-suffix: IV 659 | alias: Citey 660 | affiliation: Excellent University, Niceplace, Arcadia 661 | address: 22 Acacia Avenue 662 | city: Citationburgh 663 | region: Renfrewshire 664 | post-code: C13 7X7 665 | country: GB 666 | orcid: https://orcid.org/0000-0001-2345-6789 667 | email: project@entity.com 668 | tel: +44(0)141-323 4567 669 | fax: +44(0)141-323 45678 670 | website: https://www.entity-project-team.io 671 | # An entity 672 | - name: Entity Project Team Conference entity 673 | address: 22 Acacia Avenue 674 | city: Citationburgh 675 | region: Renfrewshire 676 | post-code: C13 7X7 677 | country: GB 678 | orcid: https://orcid.org/0000-0001-2345-6789 679 | email: project@entity.com 680 | tel: +44(0)141-323 4567 681 | fax: +44(0)141-323 45678 682 | website: https://www.entity-project-team.io 683 | date-start: 2017-01-01 684 | date-end: 2017-01-31 685 | location: The team garage 686 | 687 | database-provider: 688 | # An entity 689 | name: Entity Project Team Conference entity 690 | address: 22 Acacia Avenue 691 | city: Citationburgh 692 | region: Renfrewshire 693 | post-code: C13 7X7 694 | country: GB 695 | orcid: https://orcid.org/0000-0001-2345-6789 696 | email: project@entity.com 697 | tel: +44(0)141-323 4567 698 | fax: +44(0)141-323 45678 699 | website: https://www.entity-project-team.io 700 | date-start: 2017-01-01 701 | date-end: 2017-01-31 702 | location: The team garage 703 | 704 | editors: 705 | # A person 706 | - family-names: Real Person 707 | given-names: One Truly 708 | name-particle: van der 709 | name-suffix: IV 710 | alias: Citey 711 | affiliation: Excellent University, Niceplace, Arcadia 712 | address: 22 Acacia Avenue 713 | city: Citationburgh 714 | region: Renfrewshire 715 | post-code: C13 7X7 716 | country: GB 717 | orcid: https://orcid.org/0000-0001-2345-6789 718 | email: project@entity.com 719 | tel: +44(0)141-323 4567 720 | fax: +44(0)141-323 45678 721 | website: https://www.entity-project-team.io 722 | # An entity 723 | - name: Entity Project Team Conference entity 724 | address: 22 Acacia Avenue 725 | city: Citationburgh 726 | region: Renfrewshire 727 | post-code: C13 7X7 728 | country: GB 729 | orcid: https://orcid.org/0000-0001-2345-6789 730 | email: project@entity.com 731 | tel: +44(0)141-323 4567 732 | fax: +44(0)141-323 45678 733 | website: https://www.entity-project-team.io 734 | date-start: 2017-01-01 735 | date-end: 2017-01-31 736 | location: The team garage 737 | 738 | editors-series: 739 | # A person 740 | - family-names: Real Person 741 | given-names: One Truly 742 | name-particle: van der 743 | name-suffix: IV 744 | alias: Citey 745 | affiliation: Excellent University, Niceplace, Arcadia 746 | address: 22 Acacia Avenue 747 | city: Citationburgh 748 | region: Renfrewshire 749 | post-code: C13 7X7 750 | country: GB 751 | orcid: https://orcid.org/0000-0001-2345-6789 752 | email: project@entity.com 753 | tel: +44(0)141-323 4567 754 | fax: +44(0)141-323 45678 755 | website: https://www.entity-project-team.io 756 | # An entity 757 | - name: Entity Project Team Conference entity 758 | address: 22 Acacia Avenue 759 | city: Citationburgh 760 | region: Renfrewshire 761 | post-code: C13 7X7 762 | country: GB 763 | orcid: https://orcid.org/0000-0001-2345-6789 764 | email: project@entity.com 765 | tel: +44(0)141-323 4567 766 | fax: +44(0)141-323 45678 767 | website: https://www.entity-project-team.io 768 | date-start: 2017-01-01 769 | date-end: 2017-01-31 770 | location: The team garage 771 | 772 | institution: 773 | # An entity 774 | name: Entity Project Team Conference entity 775 | address: 22 Acacia Avenue 776 | city: Citationburgh 777 | region: Renfrewshire 778 | post-code: C13 7X7 779 | country: GB 780 | orcid: https://orcid.org/0000-0001-2345-6789 781 | email: project@entity.com 782 | tel: +44(0)141-323 4567 783 | fax: +44(0)141-323 45678 784 | website: https://www.entity-project-team.io 785 | date-start: 2017-01-01 786 | date-end: 2017-01-31 787 | location: The team garage 788 | 789 | location: 790 | # An entity 791 | name: Entity Project Team Conference entity 792 | address: 22 Acacia Avenue 793 | city: Citationburgh 794 | region: Renfrewshire 795 | post-code: C13 7X7 796 | country: GB 797 | orcid: https://orcid.org/0000-0001-2345-6789 798 | email: project@entity.com 799 | tel: +44(0)141-323 4567 800 | fax: +44(0)141-323 45678 801 | website: https://www.entity-project-team.io 802 | date-start: 2017-01-01 803 | date-end: 2017-01-31 804 | location: The team garage 805 | 806 | publisher: 807 | # An entity 808 | name: Entity Project Team Conference entity 809 | address: 22 Acacia Avenue 810 | city: Citationburgh 811 | region: Renfrewshire 812 | post-code: C13 7X7 813 | country: GB 814 | orcid: https://orcid.org/0000-0001-2345-6789 815 | email: project@entity.com 816 | tel: +44(0)141-323 4567 817 | fax: +44(0)141-323 45678 818 | website: https://www.entity-project-team.io 819 | date-start: 2017-01-01 820 | date-end: 2017-01-31 821 | location: The team garage 822 | 823 | recipients: 824 | # A person 825 | - family-names: Real Person 826 | given-names: One Truly 827 | name-particle: van der 828 | name-suffix: IV 829 | alias: Citey 830 | affiliation: Excellent University, Niceplace, Arcadia 831 | address: 22 Acacia Avenue 832 | city: Citationburgh 833 | region: Renfrewshire 834 | post-code: C13 7X7 835 | country: GB 836 | orcid: https://orcid.org/0000-0001-2345-6789 837 | email: project@entity.com 838 | tel: +44(0)141-323 4567 839 | fax: +44(0)141-323 45678 840 | website: https://www.entity-project-team.io 841 | # An entity 842 | - name: Entity Project Team Conference entity 843 | address: 22 Acacia Avenue 844 | city: Citationburgh 845 | region: Renfrewshire 846 | post-code: C13 7X7 847 | country: GB 848 | orcid: https://orcid.org/0000-0001-2345-6789 849 | email: project@entity.com 850 | tel: +44(0)141-323 4567 851 | fax: +44(0)141-323 45678 852 | website: https://www.entity-project-team.io 853 | date-start: 2017-01-01 854 | date-end: 2017-01-31 855 | location: The team garage 856 | 857 | senders: 858 | # A person 859 | - family-names: Real Person 860 | given-names: One Truly 861 | name-particle: van der 862 | name-suffix: IV 863 | alias: Citey 864 | affiliation: Excellent University, Niceplace, Arcadia 865 | address: 22 Acacia Avenue 866 | city: Citationburgh 867 | region: Renfrewshire 868 | post-code: C13 7X7 869 | country: GB 870 | orcid: https://orcid.org/0000-0001-2345-6789 871 | email: project@entity.com 872 | tel: +44(0)141-323 4567 873 | fax: +44(0)141-323 45678 874 | website: https://www.entity-project-team.io 875 | # An entity 876 | - name: Entity Project Team Conference entity 877 | address: 22 Acacia Avenue 878 | city: Citationburgh 879 | region: Renfrewshire 880 | post-code: C13 7X7 881 | country: GB 882 | orcid: https://orcid.org/0000-0001-2345-6789 883 | email: project@entity.com 884 | tel: +44(0)141-323 4567 885 | fax: +44(0)141-323 45678 886 | website: https://www.entity-project-team.io 887 | date-start: 2017-01-01 888 | date-end: 2017-01-31 889 | location: The team garage 890 | 891 | translators: 892 | # A person 893 | - family-names: Real Person 894 | given-names: One Truly 895 | name-particle: van der 896 | name-suffix: IV 897 | alias: Citey 898 | affiliation: Excellent University, Niceplace, Arcadia 899 | address: 22 Acacia Avenue 900 | city: Citationburgh 901 | region: Renfrewshire 902 | post-code: C13 7X7 903 | country: GB 904 | orcid: https://orcid.org/0000-0001-2345-6789 905 | email: project@entity.com 906 | tel: +44(0)141-323 4567 907 | fax: +44(0)141-323 45678 908 | website: https://www.entity-project-team.io 909 | # An entity 910 | - name: Entity Project Team Conference entity 911 | address: 22 Acacia Avenue 912 | city: Citationburgh 913 | region: Renfrewshire 914 | post-code: C13 7X7 915 | country: GB 916 | orcid: https://orcid.org/0000-0001-2345-6789 917 | email: project@entity.com 918 | tel: +44(0)141-323 4567 919 | fax: +44(0)141-323 45678 920 | website: https://www.entity-project-team.io 921 | date-start: 2017-01-01 922 | date-end: 2017-01-31 923 | location: The team garage 924 | -------------------------------------------------------------------------------- /examples/key-complete/README.md: -------------------------------------------------------------------------------- 1 | Borrowed from [`ruby-cff`](https://github.com/citation-file-format/ruby-cff)'s fixtures https://github.com/citation-file-format/ruby-cff/tree/ec3aeff98855690d56ac2cd35f7181e5d9ee26f3/test/files. -------------------------------------------------------------------------------- /examples/key-error/CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | message: "If you use this software in your research, please cite it as below." 3 | title: "cff-validator" 4 | abstract: "Validate your repository's CITATION.cff file using R software" 5 | authors: 6 | - family-names: "Hernangómez" 7 | given-names: "Diego" 8 | orcid: "https://orcid.org/ 0000-0001-8457-4658" 9 | error: yes # This key is an error on author 10 | - name: The Research Software project 11 | error_field: This is an error # This key is an error on the schema 12 | doi: https://doi.org/10.5281/zenodo.4442958 # doi with wrong format, shouldn’t be an url 13 | url: 123456 # url not valid 14 | license: abcdef # license not in schema 15 | keywords: # Error, person as keyword 16 | - family-names: "Hernangómez" 17 | given-names: "Diego" 18 | orcid: "https://orcid.org/ 0000-0001-8457-4658" 19 | error: yes 20 | -------------------------------------------------------------------------------- /examples/key-error/citation_cff_errors.md: -------------------------------------------------------------------------------- 1 | Table: **./examples/key-error/CITATION.cff errors:** 2 | 3 | |field |message | 4 | |:---------------|:--------------------------------| 5 | |data |has additional properties | 6 | |data.authors.0 |no schemas match | 7 | |data.doi |referenced schema does not match | 8 | |data.keywords.0 |is the wrong type | 9 | |data.license |referenced schema does not match | 10 | |data.url |referenced schema does not match | 11 | 12 | 13 | See [Guide to Citation File Format schema version 1.2.0](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md) for debugging. 14 | -------------------------------------------------------------------------------- /examples/r-reprex.R: -------------------------------------------------------------------------------- 1 | citation_path <- "./examples/key-complete/CITATION.cff" 2 | 3 | citfile <- yaml::read_yaml(citation_path) 4 | # All elements to character 5 | citfile <- rapply(citfile, function(x) as.character(x), how = "replace") 6 | 7 | # Convert to json 8 | cit_temp <- jsonlite::toJSON(citfile, pretty = TRUE, auto_unbox = TRUE) 9 | 10 | # Download latest scheme 11 | schema_temp <- tempfile("schema", fileext = ".json") 12 | download.file("https://raw.githubusercontent.com/citation-file-format/citation-file-format/main/schema.json", 13 | schema_temp, 14 | mode = "wb", quiet = TRUE 15 | ) 16 | 17 | # Validate 18 | result <- jsonvalidate::json_validate(cit_temp, 19 | schema_temp, 20 | verbose = TRUE 21 | ) 22 | # Results 23 | message("------\n") 24 | if (result == FALSE) { 25 | print(knitr::kable(attributes(result)$errors, 26 | align = "l", 27 | caption = paste(citation_path, "errors:") 28 | )) 29 | 30 | message("\n\n------") 31 | stop(citation_path, " file not valid. See Artifact: citation-cff-errors for details.") 32 | } else { 33 | message(citation_path, " is valid.") 34 | message("\n\n------") 35 | } 36 | --------------------------------------------------------------------------------