feat: add modular problem-fetching workflow with persistent storage#137
Merged
khoahuynhdev merged 2 commits intokhoahuynhdev:mainfrom Feb 12, 2026
Merged
Conversation
## Summary Refactors the LeetCode problem-fetching logic into a reusable, modular architecture that stores problem metadata persistently in problem.md files. ## What's Changed ### New Components 1. **Composite Action** (`.github/actions/fetch-leetcode-problem`) - Reusable action for fetching and storing LeetCode problems - Idempotent: skips API call if problem.md already exists - Outputs all necessary metadata for downstream workflows - Handles premium problems, duplicates, and force-refetch 2. **Python Scripts** - `scripts/convert-problem-json-to-md.py`: Converts API JSON to markdown - `scripts/parse-problem-md.py`: Parses markdown back to JSON format 3. **Manual Workflow** (`.github/workflows/fetch-problem.yml`) - Allows ad-hoc problem fetching via workflow_dispatch - Commits problem.md to repository - Shows summary in workflow UI 4. **Specification** (`specs/modular-problem-fetching-workflow.md`) - Complete architecture design and implementation guide - Testing strategy and migration path ### Modified Workflows - **daily-leetcode.yml**: Updated to use new composite action - Reads from problem.md when it exists (no API call!) - Maintains full backward compatibility ## Key Benefits - **Persistent Storage**: Problem metadata stored in git with timestamps - **Efficiency**: Eliminates redundant API calls for duplicate problems - **Transparency**: Problem data visible in GitHub UI and PRs - **Modularity**: Reusable components for future workflows - **Auditability**: Track when problems were fetched and changes over time ## Technical Details ### problem.md Format Each problem directory contains a `problem.md` file with: - YAML frontmatter (metadata: number, title, difficulty, topics, etc.) - Markdown body (converted from HTML for readability) - Timestamps (created_at, fetched_at) ### Dependencies - Python 3.11+ - Optional: html2text, pyyaml (fallback implementations included) ### Testing - Round-trip conversion (JSON→MD→JSON) verified - Scripts work with both libraries and regex fallback - Compatible with existing build-prompt.py ## Migration No breaking changes. Existing workflows continue to work. New problem fetches will create problem.md files going forward. --- Implements spec: specs/modular-problem-fetching-workflow.md
Owner
|
@claude help me review this PR |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Allow fetching today's daily challenge by leaving problem_url empty. When no URL is provided, the composite action will fetch the active daily coding challenge from LeetCode's GraphQL API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the LeetCode problem-fetching logic into a reusable, modular architecture that stores problem metadata persistently in
problem.mdfiles.What's Changed
New Components
Composite Action (
.github/actions/fetch-leetcode-problem)Python Scripts
scripts/convert-problem-json-to-md.py: Converts API JSON → markdown with YAML frontmatterscripts/parse-problem-md.py: Parses markdown → JSON for build-prompt.pyManual Workflow (
.github/workflows/fetch-problem.yml)Complete Specification (
specs/modular-problem-fetching-workflow.md)Modified Workflows
Key Benefits
🎯 Persistent Storage: Problem metadata stored in git with timestamps
⚡ Efficiency: Eliminates redundant API calls for duplicate problems
👀 Transparency: Problem data visible in GitHub UI and PRs
🧩 Modularity: Reusable components for future workflows
📊 Auditability: Track when problems were fetched and changes over time
Technical Details
problem.md Format
Each problem directory will contain a
problem.mdfile with:Dependencies
html2text,pyyaml(fallback implementations included)Testing
✅ Round-trip conversion (JSON→MD→JSON) verified
✅ Scripts work with both libraries and regex fallback
✅ Compatible with existing build-prompt.py
✅ No breaking changes to existing workflows
Migration
No breaking changes. Existing workflows continue to work as-is.
How to Test
Test Manual Workflow
https://leetcode.com/problems/two-sum/)problems/0001-two-sum/problem.mdTest Daily Workflow
The daily workflow will automatically use the new system:
Files Changed
New Files
.github/actions/fetch-leetcode-problem/action.yml.github/workflows/fetch-problem.ymlscripts/convert-problem-json-to-md.pyscripts/parse-problem-md.pyspecs/modular-problem-fetching-workflow.mdModified Files
.github/workflows/daily-leetcode.ymlImplementation follows spec:
specs/modular-problem-fetching-workflow.mdReady for review! 🚀