Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions .github/actions/build-package/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build
description: Build and check the package into dist/. 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 Python 3
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.10"
- name: Build and check package
shell: bash
run: |
just build
29 changes: 29 additions & 0 deletions .github/actions/static-checks/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Static Checks
description: Typecheck examples, lint, check formatting, and typecheck. 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 Python 3
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"
- name: check examples w/ mypy (against python@3.13)
shell: bash
run: just typecheck-examples
# skip deps on all these since mypy installed everything
- name: check linting
shell: bash
run: just --no-deps lint
- name: check formatting
shell: bash
run: just --no-deps format-check
# pyright depends on node, which it handles and installs for itself as needed
# we _could_ run setup-node to make it available for it if we're having reliability problems
- name: check types
# only check against a modern version- unit tests will catch syntax errors on older versions
# this isn't user facing, this is just checking that our code is internally consistent
# e.g. a bug here wouldn't cause user CI to fail since the issue is internal to our codebase
shell: bash
run: just --no-deps typecheck
100 changes: 100 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Test
description: Start stripe-mock, then run the tests. Shared by CI and Canary CI; expects the repository to be checked out.

inputs:
python-version:
description: Python 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 Python ${{ inputs.python-version }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ inputs.python-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 }}

# Composite steps must name a shell; keep each OS on the shell CI used before.
- name: "run tests"
if: runner.os != 'Windows'
shell: bash
run: just test
env:
STRIPE_MOCK_HOST: localhost
- name: "run tests"
if: runner.os == 'Windows'
shell: pwsh
run: just test
env:
# Use IP instead of 'localhost' to avoid slow DNS resolution on Windows
STRIPE_MOCK_HOST: 127.0.0.1
89 changes: 89 additions & 0 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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:
lint:
name: Static Checks
runs-on: "ubuntu-24.04"
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/static-checks

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-package

test:
name: Test (${{ matrix.python_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"
python_version:
# The last ~5 versions, once we're on schedule
# https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy
# https://endoflife.date/python
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
- "pypy-3.9"
- "pypy-3.10"
- "pypy-3.11"
include:
- os: windows-latest
# use any modern-ish version
python_version: "3.14"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/test
with:
python-version: ${{ matrix.python_version }}
canary_channel: ${{ env.CANARY_CHANNEL }}
49 changes: 4 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,21 @@ jobs:
permissions:
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 Python 3
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"
- name: check examples w/ mypy (against python@3.13)
run: just typecheck-examples
# skip deps on all these since mypy installed everything
- name: check linting
run: just --no-deps lint
- name: check formatting
run: just --no-deps format-check
# pyright depends on node, which it handles and installs for itself as needed
# we _could_ run setup-node to make it available for it if we're having reliability problems
- name: check types
# only check against a modern version- unit tests will catch syntax errors on older versions
# this isn't user facing, this is just checking that our code is internally consistent
# e.g. a bug here wouldn't cause user CI to fail since the issue is internal to our codebase
run: just --no-deps typecheck
- uses: ./.github/actions/static-checks

build:
name: Build
runs-on: "ubuntu-24.04"
permissions:
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 Python 3
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.10"

- name: Build and check package
run: |
just build
- uses: ./.github/actions/build-package

- name: "Upload Artifact"
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
Expand All @@ -85,6 +58,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Keep in sync with the test matrix in canary.yml.
os:
- "ubuntu-24.04"
python_version:
Expand All @@ -105,27 +79,12 @@ jobs:
# use any modern-ish version
python_version: "3.14"
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 Python ${{ matrix.python_version }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
- uses: ./.github/actions/test
with:
python-version: ${{ matrix.python_version }}
- uses: stripe/openapi/actions/stripe-mock@master
with:
openapi_version: ${{ steps.openapi.outputs.version }}

- name: "run tests"
run: just test
env:
# Use IP instead of 'localhost' to avoid slow DNS resolution on Windows
STRIPE_MOCK_HOST: ${{ runner.os == 'Windows' && '127.0.0.1' || 'localhost' }}

publish:
name: Publish
Expand Down
Loading
Loading