From 19025d7015325129ecd664ffa5a349d8f8db988b Mon Sep 17 00:00:00 2001 From: David Brownman Date: Thu, 9 Jan 2025 15:05:20 -0800 Subject: [PATCH 1/8] add justfile --- .github/workflows/ci.yml | 2 +- Makefile | 2 ++ justfile | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 justfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e813ebe4..11ecf3927 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: ruby-version: ${{ matrix.ruby-version }} - uses: stripe/openapi/actions/stripe-mock@master - name: test - run: make ci-test + run: just ci-test env: GITHUB_TOKEN: ${{ secrets.github_token }} diff --git a/Makefile b/Makefile index cc7d150f1..218187cf0 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/justfile b/justfile new file mode 100644 index 000000000..525227928 --- /dev/null +++ b/justfile @@ -0,0 +1,32 @@ +set quiet + +import? '../sdk-codegen/justfile' + +_default: + just --list --unsorted + +install *args: + bundle install {{ if is_dependency() == "true" {"--quiet"} else {""} }} {{ args }} + +# mass-format files +format: install + bundle exec rubocop -o /dev/null --autocorrect + +test: install && typecheck + bundle exec rake test + +typecheck: + {{ if semver_matches(`ruby -e "puts RUBY_VERSION"`, ">=2.7") == "true" { \ + "bundle exec srb tc" \ + } else { \ + "echo \"Ruby version < 2.7, skipping srb tc\"" \ + } }} + +alias ci-test := test + + +# called by tooling +[private] +update-version version: + echo "{{ version }}" > VERSION + perl -pi -e 's|VERSION = "[.\-\w\d]+"|VERSION = "{{ version }}"|' lib/stripe/version.rb From a43a7ee1e4a2cd5bb7a2200114b87315f4930a03 Mon Sep 17 00:00:00 2001 From: David Brownman Date: Thu, 9 Jan 2025 15:08:48 -0800 Subject: [PATCH 2/8] add just to ci and split out commands --- .github/workflows/ci.yml | 3 ++- justfile | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11ecf3927..a45d121b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,7 @@ jobs: runs-on: ubuntu-latest steps: + - uses: extractions/setup-just@v2 - uses: actions/checkout@v3 - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -52,7 +53,7 @@ jobs: ruby-version: ${{ matrix.ruby-version }} - uses: stripe/openapi/actions/stripe-mock@master - name: test - run: just ci-test + run: just test typecheck env: GITHUB_TOKEN: ${{ secrets.github_token }} diff --git a/justfile b/justfile index 525227928..4e445e3b8 100644 --- a/justfile +++ b/justfile @@ -12,7 +12,7 @@ install *args: format: install bundle exec rubocop -o /dev/null --autocorrect -test: install && typecheck +test: install bundle exec rake test typecheck: @@ -22,9 +22,6 @@ typecheck: "echo \"Ruby version < 2.7, skipping srb tc\"" \ } }} -alias ci-test := test - - # called by tooling [private] update-version version: From ff4ddbb2cc6ead4bf1a38cfe88902394b0d5c6ab Mon Sep 17 00:00:00 2001 From: David Brownman Date: Thu, 9 Jan 2025 15:50:56 -0800 Subject: [PATCH 3/8] Fix justfile --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a45d121b0..1578eeb0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,6 @@ jobs: runs-on: ubuntu-latest steps: - - uses: extractions/setup-just@v2 - uses: actions/checkout@v3 - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -46,6 +45,7 @@ jobs: 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 From fc005531ce1d51d30f3e07c4f67a12c58b7a8be3 Mon Sep 17 00:00:00 2001 From: David Brownman Date: Thu, 9 Jan 2025 16:27:26 -0800 Subject: [PATCH 4/8] update readme and CI --- .github/workflows/ci.yml | 3 ++- README.md | 15 +++++++++------ justfile | 6 ++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1578eeb0f..19c555649 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,13 +23,14 @@ jobs: runs-on: ubuntu-latest 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' diff --git a/README.md b/README.md index d1b44944a..586395ecb 100644 --- a/README.md +++ b/README.md @@ -362,19 +362,20 @@ New features and bug fixes are released on the latest major version of the Strip ## Development -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: @@ -392,13 +393,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 rake 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 diff --git a/justfile b/justfile index 4e445e3b8..bfb15f1b4 100644 --- a/justfile +++ b/justfile @@ -15,6 +15,12 @@ format: install test: install bundle exec rake test +lint: install + bundle exec rake rubocop + +update-certs: install + bundle exec rake update_certs + typecheck: {{ if semver_matches(`ruby -e "puts RUBY_VERSION"`, ">=2.7") == "true" { \ "bundle exec srb tc" \ From ddc3fbc6259efd34bed323e5ef581012dda858d2 Mon Sep 17 00:00:00 2001 From: David Brownman Date: Fri, 10 Jan 2025 11:22:53 -0800 Subject: [PATCH 5/8] update justfile --- README.md | 2 +- Rakefile | 1 + justfile | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 586395ecb..fb72fa3ea 100644 --- a/README.md +++ b/README.md @@ -394,7 +394,7 @@ Run the linter: ```sh just lint -# or: bundle exec rake rubocop +# or: bundle exec rubocop ``` Update bundled CA certificates from the [Mozilla cURL release][curl]: diff --git a/Rakefile b/Rakefile index 44ae7a6c9..14bc99674 100644 --- a/Rakefile +++ b/Rakefile @@ -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 if RUBY_VERSION >= "2.7.0" require "rubocop/rake_task" RuboCop::RakeTask.new diff --git a/justfile b/justfile index bfb15f1b4..5fae37240 100644 --- a/justfile +++ b/justfile @@ -8,19 +8,25 @@ _default: install *args: bundle install {{ if is_dependency() == "true" {"--quiet"} else {""} }} {{ args }} -# mass-format files -format: install - bundle exec rubocop -o /dev/null --autocorrect - +# ⭐ run all unit tests test: install bundle exec rake test -lint: install - bundle exec rake rubocop +# 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: {{ if semver_matches(`ruby -e "puts RUBY_VERSION"`, ">=2.7") == "true" { \ "bundle exec srb tc" \ From ae62982e4bea8fe237c2bb5013868910cba66faa Mon Sep 17 00:00:00 2001 From: David Brownman Date: Fri, 10 Jan 2025 11:35:57 -0800 Subject: [PATCH 6/8] update CI --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19c555649..2fe900f4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ on: jobs: build: name: Build - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: extractions/setup-just@v2 @@ -41,7 +41,8 @@ jobs: test: name: Test (${{ matrix.ruby-version }}) - runs-on: 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] @@ -65,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 From 24769dbd18cbeff210a67b8c1d472e42a12462ae Mon Sep 17 00:00:00 2001 From: David Brownman Date: Wed, 15 Jan 2025 17:39:12 -0800 Subject: [PATCH 7/8] update justfile import --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index 5fae37240..f6942dd27 100644 --- a/justfile +++ b/justfile @@ -1,6 +1,6 @@ set quiet -import? '../sdk-codegen/justfile' +import? '../sdk-codegen/utils.just' _default: just --list --unsorted From d165ad1152e6ad98ee386bb177f371716612df97 Mon Sep 17 00:00:00 2001 From: David Brownman Date: Thu, 16 Jan 2025 14:27:01 -0800 Subject: [PATCH 8/8] remove unused block --- Rakefile | 6 ------ justfile | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index 14bc99674..b8646ef21 100644 --- a/Rakefile +++ b/Rakefile @@ -8,12 +8,6 @@ Rake::TestTask.new do |t| t.pattern = "./test/**/*_test.rb" end -# I think we can remove this; we'll run rubocop directly -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" diff --git a/justfile b/justfile index f6942dd27..0abb44790 100644 --- a/justfile +++ b/justfile @@ -27,7 +27,7 @@ update-certs: install bundle exec rake update_certs # run sorbet to check type definitions -typecheck: +typecheck: install {{ if semver_matches(`ruby -e "puts RUBY_VERSION"`, ">=2.7") == "true" { \ "bundle exec srb tc" \ } else { \