Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build
description: Lint and build the gem. Shared by CI and Canary CI; expects the repository to be checked out.

runs:
using: composite
steps:
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
- name: Set up Ruby
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
with:
ruby-version: 3.1
- name: Lint
shell: bash
run: just lint-check
- name: Build
shell: bash
run: gem build stripe.gemspec
99 changes: 99 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Test
description: Start stripe-mock, then run the tests and typecheck. Shared by CI and Canary CI; expects the repository to be checked out.

inputs:
ruby-version:
description: Ruby version to test against.
required: true
canary_channel:
description: >-
Canary channel (ga, beta, or private-preview) whose specs and fixtures
stripe-mock should serve. Empty uses the OPENAPI_VERSION release.
required: false
default: ''

runs:
using: composite
steps:
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
- name: Resolve stripe-mock OpenAPI inputs
id: openapi
shell: bash
env:
CANARY_CHANNEL: ${{ inputs.canary_channel }}
run: |
set -euo pipefail

if [[ -z "$CANARY_CHANNEL" ]]; then
echo "version=$(< OPENAPI_VERSION)" >> "$GITHUB_OUTPUT"
exit 0
fi

case "$CANARY_CHANNEL" in
ga)
spec_name=spec3.sdk.json
fixtures_name=fixtures3.json
beta=false
;;
beta)
spec_name=spec3.beta.sdk.json
fixtures_name=fixtures3.beta.json
beta=true
;;
private-preview)
spec_name=spec3.private_preview.sdk.json
fixtures_name=fixtures3.private_preview.json
beta=true
;;
*)
echo "::error::Unsupported canary channel: $CANARY_CHANNEL"
exit 1
;;
esac

canary_dir="$GITHUB_WORKSPACE/.stripe-mock-canary"
mkdir -p "$canary_dir"

spec_path="$canary_dir/$spec_name"
fixtures_path="$canary_dir/$fixtures_name"
canary_base="https://raw.githubusercontent.com/stripe/openapi/master/openapi/canary/$CANARY_CHANNEL"
curl_options=(
--retry 3
--retry-all-errors
--fail
--silent
--show-error
)

curl "${curl_options[@]}" "$canary_base/$spec_name" -o "$spec_path"
curl "${curl_options[@]}" "$canary_base/$fixtures_name" -o "$fixtures_path"

{
echo "spec_path=$spec_path"
echo "fixtures_path=$fixtures_path"
echo "beta=$beta"
} >> "$GITHUB_OUTPUT"
- name: Set up Ruby
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
with:
ruby-version: ${{ inputs.ruby-version }}
- uses: stripe/openapi/actions/stripe-mock@master
with:
openapi_version: ${{ steps.openapi.outputs.version }}
spec_path: ${{ steps.openapi.outputs.spec_path }}
fixtures: ${{ steps.openapi.outputs.fixtures_path }}
beta: ${{ steps.openapi.outputs.beta }}
- name: test
shell: bash
run: just test
env:
GITHUB_TOKEN: ${{ github.token }}
# Use IP instead of 'localhost' to avoid slow DNS resolution on Windows
STRIPE_MOCK_HOST: ${{ runner.os == 'Windows' && '127.0.0.1' || 'localhost' }}
- name: typecheck
# sorbet doesn't support windows
if: runner.os != 'Windows'
shell: bash
run: just typecheck
env:
GITHUB_TOKEN: ${{ github.token }}
69 changes: 69 additions & 0 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Canary CI

# Runs the same checks as CI against code generated from the canary specs.
# sdk-codegen force-pushes these branches; they are never released, so there is
# no publish job.
on:
workflow_dispatch: {}
push:
branches:
- canary-ga
- canary-beta
- canary-private-preview

permissions: {}

concurrency:
# Each push replaces the branch, so an older run's result is stale.
group: canary-ci-${{ github.ref_name }}
cancel-in-progress: true

env:
# Map each canary branch to the channel stripe-mock serves.
CANARY_CHANNEL: >-
${{
github.ref_name == 'canary-ga' && 'ga' ||
github.ref_name == 'canary-beta' && 'beta' ||
github.ref_name == 'canary-private-preview' && 'private-preview' ||
'unsupported'
}}

jobs:
build:
name: Build
runs-on: ubuntu-24.04
permissions:
contents: read

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/build

test:
name: Test (${{ matrix.ruby-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
# Keep in sync with the test matrix in ci.yml.
os:
- ubuntu-24.04
# https://docs.stripe.com/sdks/versioning?lang=ruby#stripe-sdk-language-version-support-policy
# https://endoflife.date/ruby
ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4', jruby-9.4.7.0, truffleruby-25.0.0]
include:
- os: windows-latest
# use any modern-ish version
ruby-version: '3.4'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/test
with:
ruby-version: ${{ matrix.ruby-version }}
canary_channel: ${{ env.CANARY_CHANNEL }}
34 changes: 3 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,10 @@ jobs:
contents: read

steps:
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Ruby
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
with:
ruby-version: 3.1
- name: Lint
run: just lint-check
- name: Build
run: gem build stripe.gemspec
- uses: ./.github/actions/build
- name: 'Upload Artifact'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
Expand All @@ -55,6 +47,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Keep in sync with the test matrix in canary.yml.
os:
- ubuntu-24.04
# https://docs.stripe.com/sdks/versioning?lang=ruby#stripe-sdk-language-version-support-policy
Expand All @@ -65,33 +58,12 @@ jobs:
# use any modern-ish version
ruby-version: '3.4'
steps:
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Read OpenAPI version
id: openapi
shell: bash
run: echo "version=$(< OPENAPI_VERSION)" >> "$GITHUB_OUTPUT"
- name: Set up Ruby
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
- uses: ./.github/actions/test
with:
ruby-version: ${{ matrix.ruby-version }}
- uses: stripe/openapi/actions/stripe-mock@master
with:
openapi_version: ${{ steps.openapi.outputs.version }}
- name: test
run: just test
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
# Use IP instead of 'localhost' to avoid slow DNS resolution on Windows
STRIPE_MOCK_HOST: ${{ runner.os == 'Windows' && '127.0.0.1' || 'localhost' }}
- name: typecheck
# sorbet doesn't support windows
if: runner.os != 'Windows'
run: just typecheck
env:
GITHUB_TOKEN: ${{ secrets.github_token }}

publish:
name: Publish
Expand Down
81 changes: 0 additions & 81 deletions .github/workflows/publish-historical.yml

This file was deleted.

8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,16 +423,8 @@ just lint
# or: bundle exec rubocop
```

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

```sh
just update-certs
# or: bundle exec rake update_certs
```

[api-keys]: https://dashboard.stripe.com/account/apikeys
[connect]: https://stripe.com/connect
[curl]: http://curl.haxx.se/docs/caextract.html
[idempotency-keys]: https://stripe.com/docs/api/idempotent_requests?lang=ruby
[stripe-mock]: https://github.com/stripe/stripe-mock
[versioning]: https://stripe.com/docs/api/versioning?lang=ruby
Expand Down
25 changes: 0 additions & 25 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,3 @@ task default: %i[test rubocop]
Rake::TestTask.new do |t|
t.pattern = "./test/**/*_test.rb"
end

desc "Update bundled certs"
task :update_certs do
require "net/http"
require "uri"

fetch_file "https://curl.se/ca/cacert.pem",
File.expand_path("lib/data/ca-certificates.crt", __dir__)
end

#
# helpers
#

def fetch_file(uri, dest)
File.open(dest, "w") do |file|
resp = Net::HTTP.get_response(URI.parse(uri))
unless resp.code.to_i == 200
abort("bad response when fetching: #{uri}\n" \
"Status #{resp.code}: #{resp.body}")
end
file.write(resp.body)
puts "Successfully fetched: #{uri}"
end
end
3 changes: 0 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ lint: (format-check "--autocorrect")
# offenses and only shows uncorrectable ones.
format: (format-check "--autocorrect --display-only-fail-level-offenses")

update-certs: install
bundle exec rake update_certs

# run sorbet to check type definitions
typecheck: install
bundle exec srb tc
Expand Down
Loading
Loading