Skip to content

Conversation

Copy link

Copilot AI commented Jul 8, 2025

This PR implements the missing pre-commit hooks for curation files as requested in issue #1949.

Changes Made

1. JTD Schema for Curations (Specs/jtd/curation.jtd.json)

Created a comprehensive schema that validates:

  • Root fields: uuid, icon, color, l10n, content
  • Localization structure with nullable title, subtitle, description fields
  • Content sections with component types and item references
  • Supported component types: carousel, horizontal_curriculum_grid, horizontal_activity_grid, etc.
  • Content item types: activity, curriculum, curation, story

2. Curation Content Validator (Tools/Hooks/check_yaml_content_curations.py)

Implemented a specialized validator that:

  • Extends BaseYamlValidator (curations have different structure than activities/curriculums)
  • Validates JTD schema compliance
  • Checks UUID/filename consistency
  • Validates content item references and detects missing files
  • Provides clear error messages with expected filenames

3. Curation UUID Uniqueness Validator (Tools/Hooks/check_yaml_content_curations_unique_uuid.py)

Added validator to ensure all curation UUIDs are unique across the repository.

4. Content Validation Helper (Tools/Hooks/modules/content.py)

Added find_missing_content_items() function that:

  • Traverses curation content sections
  • Validates referenced activities, curriculums, and other curations exist as files
  • Returns detailed information about missing items

5. Pre-commit Configuration (.pre-commit-config.yaml)

Added two new hooks:

  • check_yaml_content_curations: Validates content and schema
  • check_yaml_content_curations_unique_uuid: Ensures UUID uniqueness

Testing Results

All validators work correctly:

# Schema validation passes for valid files
$ python3 Tools/Hooks/check_yaml_content_curations.py home-*.curation.yml
✅ All curation files are valid!

# Content validation detects missing references
$ python3 Tools/Hooks/check_yaml_content_curations.py curriculums-*.curation.yml  
❌ Found content items that do not exist:
  - curriculum_xyz-ABC123 (curriculum) - expected file: curriculum_xyz-ABC123.curriculum.yml

# UUID uniqueness validation works across all files
$ python3 Tools/Hooks/check_yaml_content_curations_unique_uuid.py
Scanned 40 curation files with 40 unique UUIDs
✅ No duplicate UUIDs found!

The implementation follows the same patterns as existing activity and curriculum validators, providing consistent validation across all content types.

Fixes #1949.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 8, 2025

Copilot AI changed the title [WIP] Pre-commit Hooks - check curation files Add pre-commit hooks for curation files validation Jul 8, 2025
Copilot AI requested a review from ladislas July 8, 2025 15:36
@ladislas
Copy link
Member

@copilot can you rebase the pr on develop and fix the conflicts please

Copy link
Author

Copilot AI commented Aug 20, 2025

@copilot can you rebase the pr on develop and fix the conflicts please

I've successfully rebased the PR on the latest develop branch (commit 3560a88) and resolved the merge conflicts in Tools/Hooks/modules/content.py. The conflict was between my find_missing_content_items() function and the new find_unreferenced_activities() function that was added to develop. Both functions are now preserved and working correctly.

The rebase is complete and all curation validation hooks remain functional. The branch history has been updated to include all the latest changes from develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-commit Hooks - check curation files

2 participants