Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RunContext support for script outputs #765

Merged
merged 24 commits into from
Sep 23, 2023

Conversation

sasial-dev
Copy link
Contributor

@sasial-dev sasial-dev commented Aug 3, 2023

Resolves #667

This PR:

  • Introduces a new field in the project file: scriptType which has the default value of Class (in parity with previous versions), but can also be RunContext.
  • This is then passed to InstanceContext from the Project struct.
  • This then changes the RunContext in the lua snapshot_middleware

Copy link
Member

@Dekkonot Dekkonot left a comment

Choose a reason for hiding this comment

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

What happened with the submodules?

Otherwise, I think this is a good idea. I'll think on the best way to pass project config to snapshots, though I imagine we'll end up passing arund a reference to a config object, so if you want to assume that's the appropriate course I wouldn't object.

src/snapshot_middleware/lua.rs Outdated Show resolved Hide resolved
src/snapshot_middleware/lua.rs Outdated Show resolved Hide resolved
src/project.rs Outdated Show resolved Hide resolved
@sasial-dev
Copy link
Contributor Author

Thanks @Dekkonot! I'm not sure what happened with the submodules, as they keep pushing up and I don't want to force push after each commit (like I did with the first after I saw the submodules) I'll remove them at the end.

Okay, I'll have a go passing around a reference.

@sasial-dev sasial-dev marked this pull request as ready for review August 4, 2023 09:57
@sasial-dev
Copy link
Contributor Author

Okay, this is ready for a review. Please do let me know where I should write tests for this change, as I'm not sure how far I should extend them to.

Copy link
Member

@Dekkonot Dekkonot left a comment

Choose a reason for hiding this comment

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

I want tests for RunContext! Specifically, tests that check it works at all, if it builds properly, and how it works with nested projects.

Anything else you can think of would be good too. It doesn't need to be too extensive since it's not touching a lot of the code, but we want to have some checks just to be sure it works as expected.

src/snapshot/metadata.rs Outdated Show resolved Hide resolved
src/snapshot/metadata.rs Outdated Show resolved Hide resolved
@sasial-dev
Copy link
Contributor Author

@Dekkonot, I went ahead and switched back from ::default to ::new for this, which removes the diff for the snapshot_middleware, but some sections (IE: instance_snapshot) used default in the past. How do I determine what should use ::default and what should use ::new? Should I change it back in places that were originally that?

@Dekkonot
Copy link
Member

Dekkonot commented Aug 9, 2023

How do I determine what should use ::default and what should use ::new? Should I change it back in places that were originally that?

As a general rule, you should be using ::new whenever possible. There are a variety of standard library functions that work if you have Default implemented, which is why it's suggested if you have ::new anyway (it's basically free in that case), but ::new is the constructor you want almost every time.

EDIT: This applies mostly to literal uses of it, mind you. There's cases where you might want to use ::default just because it's a guarantee you're getting a 'default' value for something.

@sasial-dev
Copy link
Contributor Author

Sounds good - thanks for that! I'll change back to ::default in places where it already was there :)

Copy link
Member

@Dekkonot Dekkonot left a comment

Choose a reason for hiding this comment

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

Like I mentioned before, tests for building and syncing are what we'll need for this, but otherwise it looks good.

@Dekkonot
Copy link
Member

@Corecii Just to ensure we aren't misinformed or out of touch, does the plan above seem sound?

TL;DR is that long-term we would move towards preferring RunContext over the two distinct Script classes. This change would add a toggle for people to use now to use RunContext before we changed its default in the next major release.

@Corecii
Copy link
Member

Corecii commented Sep 13, 2023

That sounds reasonable to me. I agree that we should only change the default behavior with a major version increase since it's a breaking change.

src/snapshot/metadata.rs Outdated Show resolved Hide resolved
src/snapshot/metadata.rs Outdated Show resolved Hide resolved
src/project.rs Outdated Show resolved Hide resolved
@sasial-dev sasial-dev requested a review from Dekkonot September 15, 2023 20:38
@sasial-dev sasial-dev requested a review from Dekkonot September 15, 2023 23:23
CHANGELOG.md Outdated Show resolved Hide resolved
@Dekkonot Dekkonot enabled auto-merge (squash) September 23, 2023 20:15
@Dekkonot Dekkonot disabled auto-merge September 23, 2023 20:16
@Dekkonot
Copy link
Member

Okay there is a hiccup with merging. I don't have the authority to bypass that CI check so it can't be merged.

@Dekkonot Dekkonot enabled auto-merge (squash) September 23, 2023 20:17
@Kampfkarren Kampfkarren merged commit bb8dd14 into rojo-rbx:master Sep 23, 2023
@sasial-dev
Copy link
Contributor Author

Thank you so much guys!

@fewkz
Copy link
Contributor

fewkz commented Oct 1, 2023

Is there support for gradual adoption of RunContext for individual scripts? Mixing Classes and RunContext together? Considering RunContext and Class have very different behavior, supporting both only makes sense. I think via a .rc-server.lua and .rc-client.lua extension would be best.

@sasial-dev
Copy link
Contributor Author

You can use nested .project.json files to gradually adopt RunContext. Or, just keep the existing behavior of class scripts as it is not a breaking change.

Dekkonot added a commit to UpliftGames/rojo that referenced this pull request Jan 11, 2024
Resolves rojo-rbx#667

This PR:

- Introduces a new field in the project file: `scriptType` which has the
default value of `Class` (in parity with previous versions), but can
also be `RunContext`.
- This is then passed to `InstanceContext` from the `Project` struct.
- This then changes the RunContext in the lua `snapshot_middleware`

---------

Co-authored-by: Micah <[email protected]>
@sasial-dev sasial-dev deleted the RunContext branch November 16, 2024 00:46
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.

RunContext does not work
7 participants