add justfile (#1513)

* add justfile

* add just to ci and split out commands

* Fix justfile

* update readme and CI

* update justfile

* update CI

* update justfile import

* remove unused block
This commit is contained in:
David Brownman 2025-01-16 14:54:59 -08:00 committed by GitHub
parent ef7e6ee51e
commit 08020d3207
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 59 additions and 16 deletions

View File

@ -20,16 +20,17 @@ on:
jobs:
build:
name: Build
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: extractions/setup-just@v2
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
- name: Lint
run: bundle install && bundle exec rake rubocop
run: just lint
- name: Build
run: gem build stripe.gemspec
- name: 'Upload Artifact'
@ -40,12 +41,13 @@ 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)
runs-on: ubuntu-22.04
strategy:
matrix:
ruby-version: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, '3.3', jruby-9.4.0.0, truffleruby-head]
steps:
- uses: extractions/setup-just@v2
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
@ -53,7 +55,7 @@ jobs:
ruby-version: ${{ matrix.ruby-version }}
- uses: stripe/openapi/actions/stripe-mock@master
- name: test
run: make ci-test
run: just test typecheck
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
@ -64,7 +66,7 @@ jobs:
startsWith(github.ref, 'refs/tags/v') &&
endsWith(github.actor, '-stripe')
needs: [build, test]
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4

View File

@ -1,3 +1,5 @@
# NOTE: this file is deprecated and slated for deletion; prefer using the equivalent `just` commands.
.PHONY: update-version codegen-format test ci-test
update-version:
@echo "$(VERSION)" > VERSION

View File

@ -364,19 +364,20 @@ New features and bug fixes are released on the latest major version of the Strip
[Contribution guidelines for this project](CONTRIBUTING.md)
The test suite depends on [stripe-mock], so make sure to fetch and run it from a
background terminal ([stripe-mock's README][stripe-mock] also contains
instructions for installing via Homebrew and other methods):
The test suite depends on [stripe-mock], so make sure to fetch and run it from a background terminal ([stripe-mock's README][stripe-mock] also contains instructions for installing via Homebrew and other methods):
```sh
go install github.com/stripe/stripe-mock@latest
stripe-mock
```
We use [just](https://github.com/casey/just) for common development tasks. You can install it or run the underlying commands directly (by copying them from the `justfile`). Common tasks include:
Run all tests:
```sh
bundle exec rake test
just test
# or: bundle exec rake test
```
Run a single test suite:
@ -394,13 +395,15 @@ bundle exec ruby -Ilib/ test/stripe/util_test.rb -n /should.convert.names.to.sym
Run the linter:
```sh
bundle exec rake rubocop
just lint
# or: bundle exec rubocop
```
Update bundled CA certificates from the [Mozilla cURL release][curl]:
```sh
bundle exec rake update_certs
just update-certs
# or: bundle exec rake update_certs
```
Update the bundled [stripe-mock] by editing the version number found in

View File

@ -8,11 +8,6 @@ Rake::TestTask.new do |t|
t.pattern = "./test/**/*_test.rb"
end
if RUBY_VERSION >= "2.7.0"
require "rubocop/rake_task"
RuboCop::RakeTask.new
end
desc "Update bundled certs"
task :update_certs do
require "net/http"

41
justfile Normal file
View File

@ -0,0 +1,41 @@
set quiet
import? '../sdk-codegen/utils.just'
_default:
just --list --unsorted
install *args:
bundle install {{ if is_dependency() == "true" {"--quiet"} else {""} }} {{ args }}
# ⭐ run all unit tests
test: install
bundle exec rake test
# check linting / formatting status of files
format-check *args: install
bundle exec rubocop {{ args }}
alias lint-check := format-check
# ⭐ check style & formatting for all files, fixing what we can
lint: (format-check "--autocorrect")
# copy of `lint` with less output
format: (format-check "--format quiet --autocorrect")
update-certs: install
bundle exec rake update_certs
# run sorbet to check type definitions
typecheck: install
{{ if semver_matches(`ruby -e "puts RUBY_VERSION"`, ">=2.7") == "true" { \
"bundle exec srb tc" \
} else { \
"echo \"Ruby version < 2.7, skipping srb tc\"" \
} }}
# called by tooling
[private]
update-version version:
echo "{{ version }}" > VERSION
perl -pi -e 's|VERSION = "[.\-\w\d]+"|VERSION = "{{ version }}"|' lib/stripe/version.rb