Skip to content

Importing projects site projects from .sb3 files#855

Open
rammodhvadia wants to merge 32 commits into
mainfrom
sb3parser
Open

Importing projects site projects from .sb3 files#855
rammodhvadia wants to merge 32 commits into
mainfrom
sb3parser

Conversation

@rammodhvadia

@rammodhvadia rammodhvadia commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

What's changed?

  • Added an sb3 parser to extract scratch component json and asset files from .sb3 file
  • Added new functions to import assets from sb3 files in scratch_sb3_asset_importer.rb
  • Updated ProjectImporter to import scratch component and asset for code_editor_scratch projects
  • Updated UploadJob to process .sb3 files
  • Updated FileSystemProject to accept .sb3 files

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Test coverage

91.85% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/27761802290

@cla-bot

cla-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have you on file. In order for us to review and merge your code, please complete this form and we'll get you added and review your contribution as soon as possible.

@RaspberryPiFoundation RaspberryPiFoundation deleted a comment from cla-bot Bot Jun 12, 2026
@RaspberryPiFoundation RaspberryPiFoundation deleted a comment from cla-bot Bot Jun 12, 2026
@RaspberryPiFoundation RaspberryPiFoundation deleted a comment from cla-bot Bot Jun 12, 2026
@RaspberryPiFoundation RaspberryPiFoundation deleted a comment from cla-bot Bot Jun 12, 2026
@RaspberryPiFoundation RaspberryPiFoundation deleted a comment from cla-bot Bot Jun 12, 2026
@rammodhvadia rammodhvadia changed the title Sb3parser Importing projects site projects from .sb3 files Jun 12, 2026
Comment thread lib/scratch_asset_importer.rb Outdated
@@ -0,0 +1,24 @@
# frozen_string_literal: true

module Sb3ArchiveHelper

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this helper, very useful for these tests!

@jamdelion jamdelion left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but may be worth waiting for a Ruby expert's eye just in case 👁️

Comment thread lib/tasks/project_components/scratch-integration-test-starter/project_config.yml Outdated
Comment thread lib/project_importer.rb Outdated
Comment thread lib/project_importer.rb Outdated

@zetter-rpf zetter-rpf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, for me the main thing that would be good to improve is the changes to lib/scratch_asset_importer.rb‎ file the and error handling in it. Left a few other minor comments/questions.

@cla-bot

cla-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have you on file. In order for us to review and merge your code, please complete this form and we'll get you added and review your contribution as soon as possible.

@cla-bot

cla-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have you on file. In order for us to review and merge your code, please complete this form and we'll get you added and review your contribution as soon as possible.

@cla-bot

cla-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have you on file. In order for us to review and merge your code, please complete this form and we'll get you added and review your contribution as soon as possible.

@cla-bot

cla-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have you on file. In order for us to review and merge your code, please complete this form and we'll get you added and review your contribution as soon as possible.

@cla-bot

cla-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have you on file. In order for us to review and merge your code, please complete this form and we'll get you added and review your contribution as soon as possible.

@cla-bot

cla-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have you on file. In order for us to review and merge your code, please complete this form and we'll get you added and review your contribution as soon as possible.

@rammodhvadia rammodhvadia marked this pull request as ready for review June 18, 2026 12:39
Copilot AI review requested due to automatic review settings June 18, 2026 12:39

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ea51c47. Configure here.

Comment thread app/jobs/upload_job.rb
Comment thread lib/project_importer.rb

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for importing Scratch “site projects” from .sb3 archives by parsing project.json, extracting referenced assets, and wiring .sb3 handling into both filesystem and GitHub webhook-based imports.

Changes:

  • Introduces Sb3Parser plus an ScratchSb3AssetImporter for extracting/importing Scratch component JSON + assets from .sb3 archives.
  • Updates ProjectImporter, UploadJob, and FilesystemProject to accept .sb3 as a Scratch component input.
  • Adds test coverage for the parser, asset importer, and end-to-end upload/import behavior.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
spec/support/sb3_archive_helper.rb Adds test helper for generating .sb3 (zip) archives used by new specs.
spec/lib/scratch_sb3_asset_importer_spec.rb Covers importing global Scratch assets from .sb3 archive entries.
spec/lib/sb3_parser_spec.rb Covers parsing project.json and referenced assets from .sb3.
spec/lib/project_importer_spec.rb Adds Scratch-specific import tests for .sb3 components + assets.
spec/jobs/upload_job_spec.rb Adds webhook upload coverage for .sb3 Scratch projects.
lib/tasks/project_components/scratch-integration-test-starter/project_config.yml Adds a filesystem-importable Scratch project config for the integration starter.
lib/scratch_sb3_asset_importer.rb New importer for creating global ScratchAsset records from .sb3 assets.
lib/scratch_asset_importer.rb Makes create_scratch_asset private (encapsulation change).
lib/sb3_parser.rb New .sb3 archive parser extracting component JSON and referenced assets.
lib/project_importer.rb Adds Scratch .sb3 import flow for scratch component content + global assets.
app/models/filesystem_project.rb Allows .sb3 components for filesystem project imports.
app/jobs/upload_job.rb Treats .sb3 files as components and fetches them as IO for import.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spec/support/sb3_archive_helper.rb
Comment thread lib/project_importer.rb Outdated
Comment thread lib/project_importer.rb Outdated
Comment thread lib/project_importer.rb
Comment thread lib/scratch_sb3_asset_importer.rb
@cla-bot

cla-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have you on file. In order for us to review and merge your code, please complete this form and we'll get you added and review your contribution as soon as possible.

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.

Create Sb3Parser Extend ProjectImporter for Scratch Handle .sb3 files in UploadJob

4 participants