Week 3 - CircuitVerse@GSOC'23

I am exploring the world of technology and playing with them. Like a kid, breaking them and modiy them.
Search for a command to run...

I am exploring the world of technology and playing with them. Like a kid, breaking them and modiy them.
No comments yet. Be the first to comment.
Community Bonding Period This was a long time between getting the selection mail and the coding period. It allows me to learn more about some toolkits and libraries in detail required for this project. During this period, we have a couple of online d...
From last year (July~August), I am working on an open source PaaS to deploy and manage applications easily on any VPS. I have a motive to create a solution which you once setup on your cloud, you will get same kind of experience like other platforms ...

This blog is coming after a long time [almost 3 weeks]. Throughout this week, the main tasks involved were - Update the docker setup to make it more convenient Test the docker setup in all OS [Linux, Mac, Windows] Rewrite Documentation Revamp Do...

Finally, On July 14, I received this email about passing the midterm evaluation 🎉🎉. You can check out the blog on the phase 1 report here: https://blog.circuitverse.org/posts/tanmoy_sarkar_phase_1_report/ You should check other blogs here: https:/...

At the start, this week's main focus was completing the RBS integration. But that does not go well due to having issues with rbs_rails Gem. So I raised PR in rbs_rails the gem repository about the issue to get some hints from the maintainers. You can...

This week was more on learning rather than coding. The main objectives of this week were Learn RBS to start working on it Generate code coverage report and write the missing unit-tests Split Solargraph PR to small PRs for better review Learn RB...

This week was a little bit hectic, and the integrations were a little bit error-prone. However, I fixed all the issues by following the GitHub Forum and Github Issues discussion of particular library/software.
Integrate Vite Rails
Initialization of RBS
Purpose - We are mainly integrating Vite Rails and will move Simulator assets to Vite. Currently, CircuitVerse uses sprockets and esbuild to pack javascript files and serve through the asset pipeline.
So, What's the issue with the current setup?
The issue is mainly with development experience. When the developer modifies any Javascript / SCSS files, esbuild rebuilds the assets, and the user needs to refresh the page to see the changes, which is very time-consuming.
When Vite comes into the picture, It does not build the assets to a single *.js or *.css file.
The main features of Vite
Lazy Loading: It does not bundle all the javascript in one single file and then serve. It simply sends one entry point file to the browser and will recursively load all the dependency javascript and compiled SCSS files to the browser.
Hot Reload: Whenever there are any changes in javascript or SCSS files, the Vite client will manage to update that in the browser without refreshing the page. The entire page will be reloaded automatically if the 'Hot Reload' feature can't reflect any browser changes.
The end of the story is it will make the development experience much better than the previous setup.
Integration -
Install ruby_rails gem
bundle install vite_rails
Run this to generate the configuration files
bundle exec vite install
In config/vite.json you can put the Vite dev server's configuration
{
"all": {
"sourceCodeDir": "app/javascript",
"watchAdditionalPaths": []
},
"development": {
"autoBuild": true,
"publicOutputDir": "vite-dev",
"port": 3036
},
"test": {
"autoBuild": true,
"publicOutputDir": "vite-test",
"port": 3037
}
}
In the default config, it chooses app/javascript for entry points
We remove the simulator.js from esbuild and move to Vite by dragging the file to this directory
Now in the *.erb files, we need to replace javascript_tag with vite_javascript_tag
<%= vite_javascript_tag "simulator" %>
Here is a catch, Vite loads this javascript and SCSS asynchronously, so the other scripts may fail.
Assume you have some inline scripts required jQuery, but as Vite loads them asynchronously, the inline scripts will be executed without jQuery and throw a bunch of errors.
We can resolve the issue by following this.
vite_javascript_tag adds type=module and async tag to Script
After async tags execution defer tags will be executed.
After all assets are loaded, the load event will be fired.
So the flow will be like
Put vite_javascript_tag at the start or head of the HTML
Wherever you have <script src="https://example.com/example.js"> use defer in it
<script src="https://example.com/example.js" defer>
In the usual Script, add the EventListener for load event
<script>
window.addEventListener("load", function() {
// Your code goes here
})
</script>
That's all
Then, we need to add Vite dev server in Procfile.dev to run it with Foreman
vite: bin/vite dev
Now we can access the UI as usual, and Vite will take care of asset delivery and Hot Reloads.
PR - https://github.com/CircuitVerse/CircuitVerse/pull/3777
Purpose - We know Ruby is a dynamically typed language. So type checking stuff is not available, which can lead to inconsistency in the codebase and create bugs by mistake. Ruby finally came up with RBS [Type Signature for Ruby], which adds support for static type checking. Which helps to solve two issues
a) Static Type Checking Validation
b) LSP Support
solargraph added support to provide Language Autocompletion based on the RBS files.Integration -
For Rails, we install rbs_rails better support for Rails
bundle install rbs_rails
Add .gem_rbs_collection in the .gitignore
Run rbs collection init to generate config files
Run rbs collection install to download rbs files of our Gem
We can use steep for static type checking
So add steep gem
bundle install steep
Create Steepfile for its configuration
target :app do
signature "sig"
check "app"
end
That's all
But, there is some issue with RBS
ActiveSupport and meta-tags have some overlapped rbs for Object class, so when we run rbs validate , it will give an error for duplicate definitions. Currently managed it by manually deleting the duplicate rbs annotation.PR - https://github.com/CircuitVerse/CircuitVerse/pull/3807
In the coming week, I hope to finish this RBS stuff and fix the issue described before.
Thanks a lot for reading this blog. If you like to know more about my GSOC journey and want to explore more in development, subscribe to the newsletter.