Skip to content

Commit

Permalink
add justfile (#1513)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
xavdid-stripe authored Jan 16, 2025
1 parent ef7e6ee commit 08020d3
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 16 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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)
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
with:
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 }}

Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
5 changes: 0 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
41 changes: 41 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 08020d3

Please sign in to comment.