Skip to content

Commit ef561f7

Browse files
committed
Enhances certificate manifest rendering and ORCID validation
Improves certificate generation by adding support for more image and data formats in the manifest, including GIF, TIF, TSV, and JSON. Adds automatic conversion of GIF and TIF/TIFF images to PNG for better compatibility, along with more robust error handling to prevent failures when encountering corrupted or unsupported files. Updates ORCID validation to handle authentication failures gracefully and allows skipping validation in non-interactive environments. Requires `magick` package dependency for image conversion.
1 parent f177df4 commit ef561f7

File tree

13 files changed

+284
-74
lines changed

13 files changed

+284
-74
lines changed

CLAUDE.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,26 @@ remotes::install_github("codecheckers/codecheck")
1717
```
1818

1919
Run tests using `tinytest`:
20-
```r
21-
# Interactive testing
22-
tinytest::test_all("/path/to/package")
2320

24-
# Or build, install, and test in a fresh environment
21+
**⚠️ CRITICAL: ALWAYS use `build_install_test()` for testing this package!**
22+
23+
```r
24+
# CORRECT: Build, install, and test in a fresh environment
2525
tinytest::build_install_test(".")
2626
```
2727

28+
**DO NOT use `test_all()` from the source directory** - it will cause test failures because the package functions won't be properly loaded. The error "could not find function X" indicates you're using the wrong test method.
29+
30+
```r
31+
# WRONG - DO NOT USE: Will cause "could not find function" errors
32+
tinytest::test_all(".") # ❌ DON'T DO THIS
33+
34+
# For interactive testing of specific functions during development:
35+
# 1. First install the package: devtools::install()
36+
# 2. Then load it: library(codecheck)
37+
# 3. Then test interactively or source specific test files
38+
```
39+
2840
The package uses GitHub Actions for CI/CD. Check `.github/workflows/R-CMD-check.yaml` for the automated testing setup.
2941

3042
### Changelog Management
@@ -66,8 +78,8 @@ When bumping the version in `DESCRIPTION`, add a new section to `NEWS.md` with t
6678
**External validation**: Ensure consistency with published paper metadata and ORCID records:
6779

6880
- `validate_codecheck_yml_crossref()` - Validates paper metadata against CrossRef API; compares title and author information with CrossRef data
69-
- `validate_codecheck_yml_orcid()` - Validates author and codechecker names against ORCID API; queries ORCID records using rorcid package; compares names in ORCID records with local metadata
70-
- `validate_contents_references()` - Comprehensive validation wrapper; runs both CrossRef and ORCID validations; provides unified summary; supports strict mode for certificate rendering
81+
- `validate_codecheck_yml_orcid()` - Validates author and codechecker names against ORCID API; queries ORCID records using rorcid package; compares names in ORCID records with local metadata; requires ORCID authentication by default (set `skip_on_auth_error = TRUE` to skip validation when authentication is unavailable)
82+
- `validate_contents_references()` - Comprehensive validation wrapper; runs both CrossRef and ORCID validations; provides unified summary; supports strict mode for certificate rendering; requires ORCID authentication by default (users can opt-in to skipping via `skip_on_auth_error = TRUE`)
7183

7284
**Zenodo integration**: Functions for uploading certificates to Zenodo:
7385

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ Imports:
4444
whisker,
4545
pdftools,
4646
readxl,
47-
rsvg
47+
rsvg,
48+
magick
4849
Encoding: UTF-8
4950
LazyData: true
5051
RoxygenNote: 7.3.3

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ importFrom(httr,write_disk)
4545
importFrom(jsonlite,fromJSON)
4646
importFrom(jsonlite,prettify)
4747
importFrom(knitr,kable)
48+
importFrom(magick,image_read)
49+
importFrom(magick,image_write)
4850
importFrom(osfr,osf_download)
4951
importFrom(osfr,osf_ls_files)
5052
importFrom(osfr,osf_retrieve_node)

NEWS.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@
22

33
## ORCID Validation Improvements
44

5-
* **Graceful authentication handling**: ORCID validation functions now handle authentication failures gracefully instead of requiring interactive login
6-
* **New `skip_on_auth_error` parameter**: Added to `validate_codecheck_yml_orcid()` and `validate_contents_references()` to control behavior when ORCID authentication is unavailable (defaults to `TRUE` for non-interactive environments)
7-
* **Enhanced error messages**: Clear guidance provided when ORCID authentication is needed, with instructions for setting `ORCID_TOKEN` environment variable
8-
* **Test and CI/CD compatibility**: Certificate template and all validation functions now work seamlessly in test and CI/CD environments without requiring ORCID authentication
9-
* **Backward compatibility**: Existing code continues to work without modification; validation automatically skips when authentication is unavailable
5+
* **Graceful authentication handling**: ORCID validation functions now handle authentication failures gracefully with clear error messages instead of requiring interactive login
6+
* **New `skip_on_auth_error` parameter**: Added to `validate_codecheck_yml_orcid()` and `validate_contents_references()` to control behavior when ORCID authentication is unavailable. By default (`FALSE`), functions require authentication. Set to `TRUE` to skip validation when authentication is not available (useful for CI/CD pipelines and test environments).
7+
* **Enhanced error messages**: Clear guidance provided when ORCID authentication is needed, with instructions for setting `ORCID_TOKEN` environment variable or running `rorcid::orcid_auth()`
8+
* **Opt-in skipping**: Certificate authors can choose to skip ORCID validation by setting `skip_on_auth_error = TRUE` in the certificate template
109
* **Better feedback**: Functions now return a `skipped` field indicating whether validation was skipped due to authentication issues
1110

1211
## Manifest Rendering Enhancements
1312

1413
* **Expanded format support**: Certificates can now render additional file formats in the manifest section:
15-
- Image formats: TIF, TIFF, EPS, and SVG (with automatic PDF conversion)
14+
- Image formats: TIF, TIFF, GIF, EPS, and SVG (with automatic conversion)
1615
- Data formats: JSON (with pretty-printing and configurable line limits) and TSV (tab-separated values)
1716
- Multi-page PDFs are now fully supported with automatic page detection
17+
* **GIF format support**: GIF images are now automatically converted to PNG during certificate rendering. pdflatex does not natively support GIF format, so conversion is required.
18+
* **TIF/TIFF format support**: TIF and TIFF images are now automatically converted to PNG during certificate rendering.
19+
* **New dependency**: Added `magick` package as a required dependency for image format conversion (TIF/TIFF/GIF to PNG). Previously this was optional, but is now mandatory for proper image format support.
20+
* **Graceful error handling**: Missing, corrupted, or unsupported files no longer fail the entire certificate rendering. Instead, a formatted error box is displayed in the PDF for each problematic file, allowing codecheckers to identify and fix issues without blocking certificate generation.
21+
* **File existence checks**: All manifest rendering functions now check for file existence before processing and display helpful error messages.
22+
* **Improved error messages**: Error messages are now displayed as formatted LaTeX boxes in the rendered PDF with specific information about what went wrong (e.g., "File not found", "Failed to convert GIF image", "Unsupported file format (.xyz)").
1823
* **Improved maintainability**: Manifest rendering code refactored into modular, testable components
19-
* **Comprehensive testing**: Added extensive test suite covering all supported formats with manual inspection output
24+
* **Comprehensive testing**: Added extensive test suite covering all supported formats including GIF with test fixtures
2025

2126
# codecheck 0.22.0
2227

0 commit comments

Comments
 (0)