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

Improve Spin support for new instances #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .spin/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Running the scripts here helps Spin to do it in background
# and then make a snapshot to save time at new instance creation.

./bazel version
Copy link
Member

Choose a reason for hiding this comment

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

What is this line doing?

Copy link
Author

Choose a reason for hiding this comment

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

./bazel lazy loads the real Bazel on the first run. As I've spent some time debugging spin logs I find it easier to split steps like installing a package and actually using it to relax the mental load.


# TODO: Make sure you have "/home/spin/.bazel_binaries/4.1.0/bin_t" in spin user path too.
export PATH="/home/spin/.bazel_binaries/4.1.0/bin_t:$PATH"
# Sets up go to definition in VS Code
tools/scripts/build_compilation_db.sh
Comment on lines +9 to +11
Copy link
Member

Choose a reason for hiding this comment

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

These two lines depend on first compiling Sorbet in debug mode. The bazel version changes from time to time, so we need to export the correct version.

Also, building the compilation database requires Sorbet to be compiled first.

We would need something like this:

# Compile Sorbet
# This downloads the correct Bazel version and prints the version to the screen
./bazel build //main:sorbet --config=dbg

# After we build, we need to parse the output here to find out the correct version
BAZEL_VERSION=./bazel version # needs some output processing to get the right version

# Then we can export and build the compilation db
export PATH="/home/spin/.bazel_binaries/${BAZEL_VERSION}/bin_t:$PATH"

tools/scripts/build_compilation_db.sh

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the thorough review. I guess, you can change the script to make it more useful when we do that buddy repository from https://github.com/Shopify/spin/issues/2922.



# TODO: useful aliases

# alias compile_sorbet="./bazel build //main:sorbet --config=dbg"

# comp_run() {
# compile_sorbet && sorbet_run $@
# }

# sorbet_run() {
# bazel-bin/main/sorbet $@ --silence-dev-message
# }

# bazel_test_find() {
# ./bazel query ‘tests(//...)’ | grep $@ | xargs ./bazel test --config=dbg --test_output=errors
# }
Comment on lines +14 to +28
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to append these automatically to the user's zshrc as a last step without messing up the user's own dotfiles config?

Copy link
Author

Choose a reason for hiding this comment

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

I was asking myself the same. Did not find a good built-in answer yet.

We can add something like

mkdir -p ~/zsh.d/
for f in ~/zsh.d/*
do
  source $f
done

to the default spin zsh config and then just mv files into ~/zsh.d/.

Copy link
Author

Choose a reason for hiding this comment

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

Will make a PR for this.

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Merged! Can start hacking 🛠


6 changes: 6 additions & 0 deletions .spin/packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- g++
- unzip
- zip
pl-at-shopify marked this conversation as resolved.
Show resolved Hide resolved
- autoconf
- coreutils
- parallel