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 justfile #1513

Merged
merged 10 commits into from
Jan 16, 2025
Merged

add justfile #1513

merged 10 commits into from
Jan 16, 2025

Conversation

xavdid-stripe
Copy link
Member

@xavdid-stripe xavdid-stripe commented Jan 9, 2025

Why?

In an effort to modernize and simplify our local tooling, we're moving our dev commands from makefiles to justfiles. This is intended to be mostly a drop-in replacement, but some command names may change per standardization efforts.

What?

  • adds justfile
  • update README
  • tweak CI to use just

See Also

DEVSDK-2325

.github/workflows/ci.yml Show resolved Hide resolved

typecheck:
{{ if semver_matches(`ruby -e "puts RUBY_VERSION"`, ">=2.7") == "true" { \
"bundle exec srb tc" \
Copy link
Member Author

Choose a reason for hiding this comment

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

this whole line gets executed if the expression is truthy

Copy link
Contributor

Choose a reason for hiding this comment

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

can you clarify this? im not sure what the comment is calling out

Copy link
Member Author

@xavdid-stripe xavdid-stripe Jan 16, 2025

Choose a reason for hiding this comment

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

Mostly just explaining the just syntax. If the semver_matches call above is "true", then just runs bundle exec src tc. I found it a little counter intuitive, because it looks like the expression is returning a string (which it is, but that string just becomes a line in the file). Was just adding context to the reviewer

Copy link
Contributor

Choose a reason for hiding this comment

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

ohhh. so this conditionally inserts "bundle exec srb tc" into the typecheck: step when it is run/evaluated, and thats what just executes. is that the standard way to do conditional execution in just, or is that something special we had to do here?

Copy link
Member Author

Choose a reason for hiding this comment

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

ohhh. so this conditionally inserts "bundle exec srb tc" into the typecheck: ste

exactly!

is that the standard way to do conditional execution in just

Yes, or something like:

should_sorbet := semver_matches(`ruby -e "puts RUBY_VERSION"`, ">=2.7")
typecheck:
    [ {{ should_sorbet }} == "true" ] && bundle exec srb tc

But then we shell out to ruby every time someone runs just, which has a small performance implication. Otherwise, they're equivalent!

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense to me, and it seems readable on its face.

bundle exec rake test

typecheck:
{{ if semver_matches(`ruby -e "puts RUBY_VERSION"`, ">=2.7") == "true" { \
Copy link
Member Author

Choose a reason for hiding this comment

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

just supports semver checks out of the box, so I got to simplify this block!

Copy link
Contributor

Choose a reason for hiding this comment

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

just to confirm, is this the "runs directly" referenced from the Rakefile? I think the same concerns I had with node/package.json applies; does having it in the Rakefile support some base level of development that someone who isnt comfortable with just can still benefit from?

Copy link
Member Author

Choose a reason for hiding this comment

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

just to confirm, is this the "runs directly" referenced from the Rakefile?

no, that's that we call bundle exec rubocop in just in CI instead of bundle exec rake rubocop in CI.

does having [rubocop] in the Rakefile ...

probably a little, but it's also a very common ruby pattern to bundle exec <tool> to run local tools.

Having it in the rakefile means a user could bundle exec rake rubocop instead of bundle exec rubocop. That would be useful if we were adding other arguments or configuration in that task, but since it's literally just calling rubocop like the user would, involving rake with rubocop at all strikes me as unnecessary abstraction.

Copy link
Member Author

Choose a reason for hiding this comment

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

This comment is referencing how much clear this is compared to the same check in the Makefile, which is a bunch of extra bash code (compared to just, which supports semver checks directly)

Copy link
Contributor

Choose a reason for hiding this comment

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

that makes sense to me

justfile Show resolved Hide resolved
@xavdid-stripe
Copy link
Member Author

They literally changed what ubuntu-latest was pinned to yesterday, so tests started failing 🙈

We can pin to the older ubuntu or update our jruby (maybe to jruby-head to match truffle ruby?). I'm fine with either!

@xavdid-stripe xavdid-stripe enabled auto-merge (squash) January 16, 2025 02:24
@@ -40,20 +41,21 @@ jobs:

test:
name: Test (${{ matrix.ruby-version }})
# this is needed because our JRuby test version isnt supported on ubuntu-24 (which is now ubuntu-latest)
# this version of jruby isn't available in the new latest (24.04) so we have to pin (or update jruby)
Copy link
Contributor

Choose a reason for hiding this comment

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

since you changed all of the runs-on, i might suggest moving some version of this comment to the top of the file so a future dev who might be tempted to upgrade the runs-as version would have the full context

Copy link
Member Author

Choose a reason for hiding this comment

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

ah yeah, that's fine too. Also this change doesn't need to be included - we both changed the runs-on line in separate PRs, so this was my explanation for it. Yours also works though

Rakefile Outdated
@@ -8,6 +8,7 @@ Rake::TestTask.new do |t|
t.pattern = "./test/**/*_test.rb"
end

# I think we can remove this; we'll run rubocop directly
Copy link
Contributor

Choose a reason for hiding this comment

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

i think the key here is the version test, since we support back to 2.3. is that easier to do here vs where you wanted to move it to?

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO the version check in this block isn't relevant anymore.

We only install rubocop on >= 2.7 (in the gemfile), so when we were calling rake across all versions, it was important to only require rubocop on versions in which it was available. But CI now calls rubocop directly (not through rake), so we don't need the task here at all (in a conditional or otherwise).

Copy link
Contributor

Choose a reason for hiding this comment

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

oh interesting. agreed then it makes sense to remove it!

Copy link
Contributor

@jar-stripe jar-stripe left a comment

Choose a reason for hiding this comment

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

Thanks for the answers/additional info. Looks good!

@xavdid-stripe xavdid-stripe merged commit 08020d3 into master Jan 16, 2025
14 checks passed
@xavdid-stripe xavdid-stripe deleted the DEVSDK-2325 branch January 16, 2025 22:55
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.

2 participants