Skip to content

Commit 08020d3

Browse files
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
1 parent ef7e6ee commit 08020d3

File tree

5 files changed

+59
-16
lines changed

5 files changed

+59
-16
lines changed

.github/workflows/ci.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ on:
2020
jobs:
2121
build:
2222
name: Build
23-
runs-on: ubuntu-latest
23+
runs-on: ubuntu-22.04
2424

2525
steps:
26+
- uses: extractions/setup-just@v2
2627
- uses: actions/checkout@v3
2728
- name: Set up Ruby
2829
uses: ruby/setup-ruby@v1
2930
with:
3031
ruby-version: 3.1
3132
- name: Lint
32-
run: bundle install && bundle exec rake rubocop
33+
run: just lint
3334
- name: Build
3435
run: gem build stripe.gemspec
3536
- name: 'Upload Artifact'
@@ -40,20 +41,21 @@ jobs:
4041

4142
test:
4243
name: Test (${{ matrix.ruby-version }})
43-
# this is needed because our JRuby test version isnt supported on ubuntu-24 (which is now ubuntu-latest)
44+
# this version of jruby isn't available in the new latest (24.04) so we have to pin (or update jruby)
4445
runs-on: ubuntu-22.04
4546
strategy:
4647
matrix:
4748
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]
4849
steps:
50+
- uses: extractions/setup-just@v2
4951
- uses: actions/checkout@v3
5052
- name: Set up Ruby
5153
uses: ruby/setup-ruby@v1
5254
with:
5355
ruby-version: ${{ matrix.ruby-version }}
5456
- uses: stripe/openapi/actions/stripe-mock@master
5557
- name: test
56-
run: make ci-test
58+
run: just test typecheck
5759
env:
5860
GITHUB_TOKEN: ${{ secrets.github_token }}
5961

@@ -64,7 +66,7 @@ jobs:
6466
startsWith(github.ref, 'refs/tags/v') &&
6567
endsWith(github.actor, '-stripe')
6668
needs: [build, test]
67-
runs-on: ubuntu-latest
69+
runs-on: ubuntu-22.04
6870
steps:
6971
- name: Download all workflow run artifacts
7072
uses: actions/download-artifact@v4

Makefile

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

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -364,19 +364,20 @@ New features and bug fixes are released on the latest major version of the Strip
364364

365365
[Contribution guidelines for this project](CONTRIBUTING.md)
366366

367-
The test suite depends on [stripe-mock], so make sure to fetch and run it from a
368-
background terminal ([stripe-mock's README][stripe-mock] also contains
369-
instructions for installing via Homebrew and other methods):
367+
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):
370368

371369
```sh
372370
go install github.com/stripe/stripe-mock@latest
373371
stripe-mock
374372
```
375373

374+
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:
375+
376376
Run all tests:
377377

378378
```sh
379-
bundle exec rake test
379+
just test
380+
# or: bundle exec rake test
380381
```
381382

382383
Run a single test suite:
@@ -394,13 +395,15 @@ bundle exec ruby -Ilib/ test/stripe/util_test.rb -n /should.convert.names.to.sym
394395
Run the linter:
395396

396397
```sh
397-
bundle exec rake rubocop
398+
just lint
399+
# or: bundle exec rubocop
398400
```
399401

400402
Update bundled CA certificates from the [Mozilla cURL release][curl]:
401403

402404
```sh
403-
bundle exec rake update_certs
405+
just update-certs
406+
# or: bundle exec rake update_certs
404407
```
405408

406409
Update the bundled [stripe-mock] by editing the version number found in

Rakefile

-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ Rake::TestTask.new do |t|
88
t.pattern = "./test/**/*_test.rb"
99
end
1010

11-
if RUBY_VERSION >= "2.7.0"
12-
require "rubocop/rake_task"
13-
RuboCop::RakeTask.new
14-
end
15-
1611
desc "Update bundled certs"
1712
task :update_certs do
1813
require "net/http"

justfile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
set quiet
2+
3+
import? '../sdk-codegen/utils.just'
4+
5+
_default:
6+
just --list --unsorted
7+
8+
install *args:
9+
bundle install {{ if is_dependency() == "true" {"--quiet"} else {""} }} {{ args }}
10+
11+
# ⭐ run all unit tests
12+
test: install
13+
bundle exec rake test
14+
15+
# check linting / formatting status of files
16+
format-check *args: install
17+
bundle exec rubocop {{ args }}
18+
alias lint-check := format-check
19+
20+
# ⭐ check style & formatting for all files, fixing what we can
21+
lint: (format-check "--autocorrect")
22+
23+
# copy of `lint` with less output
24+
format: (format-check "--format quiet --autocorrect")
25+
26+
update-certs: install
27+
bundle exec rake update_certs
28+
29+
# run sorbet to check type definitions
30+
typecheck: install
31+
{{ if semver_matches(`ruby -e "puts RUBY_VERSION"`, ">=2.7") == "true" { \
32+
"bundle exec srb tc" \
33+
} else { \
34+
"echo \"Ruby version < 2.7, skipping srb tc\"" \
35+
} }}
36+
37+
# called by tooling
38+
[private]
39+
update-version version:
40+
echo "{{ version }}" > VERSION
41+
perl -pi -e 's|VERSION = "[.\-\w\d]+"|VERSION = "{{ version }}"|' lib/stripe/version.rb

0 commit comments

Comments
 (0)