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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 0 additions & 9 deletions .devcontainer/Dockerfile

This file was deleted.

43 changes: 0 additions & 43 deletions .devcontainer/devcontainer.json

This file was deleted.

148 changes: 57 additions & 91 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,104 +1,70 @@
name: CI
on:
push:
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
branches: [main]
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'
workflow_dispatch:

permissions:
contents: read

jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
test:
name: test (py${{ matrix.python }}${{ matrix.pydantic == 'v1' && ', pydantic v1' || '' }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
pydantic: [v2]
include:
- python: "3.10"
pydantic: v1
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- if: matrix.pydantic == 'v2'
run: uv run --python ${{ matrix.python }} --group dev pytest -q
- if: matrix.pydantic == 'v1'
run: uv run --python ${{ matrix.python }} --with 'pydantic<2' --group dev pytest -q

- name: Install dependencies
run: rye sync --all-features

- name: Run lints
run: ./scripts/lint

build:
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
timeout-minutes: 10
name: build
permissions:
contents: read
id-token: write
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Install dependencies
run: rye sync --all-features

- name: Run build
run: rye build

- name: Get GitHub OIDC Token
if: |-
github.repository == 'stainless-sdks/supermemory-new-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: |-
github.repository == 'stainless-sdks/supermemory-new-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
SHA: ${{ github.sha }}
run: ./scripts/utils/upload-artifact.sh
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- run: uv run --group dev ruff check .
- run: uv run --group dev ruff format --check custom tests scripts examples
- run: uv run --group dev mypy
- run: uv build

test:
timeout-minutes: 10
name: test
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
# src/supermemory must be exactly what scripts/generate produces from the
# committed spec + fern/ + custom/ — no hand edits.
generated:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- uses: astral-sh/setup-uv@v6
- run: SKIP_FETCH=1 scripts/generate
- name: Check for drift
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'
if [ -n "$(git status --porcelain)" ]; then
git status --short
echo "::error::src/supermemory doesn't match scripts/generate. Edit fern/ or custom/ instead of src/, then run SKIP_FETCH=1 scripts/generate and commit."
exit 1
fi

- name: Bootstrap
run: ./scripts/bootstrap

- name: Run tests
run: ./scripts/test
# Against the real API; runs when the SUPERMEMORY_LIVE_API_KEY secret exists.
live:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
env:
SUPERMEMORY_LIVE_API_KEY: ${{ secrets.SUPERMEMORY_LIVE_API_KEY }}
steps:
- uses: actions/checkout@v4
if: env.SUPERMEMORY_LIVE_API_KEY != ''
- uses: astral-sh/setup-uv@v6
if: env.SUPERMEMORY_LIVE_API_KEY != ''
- if: env.SUPERMEMORY_LIVE_API_KEY != ''
run: uv run --group dev pytest tests/live -q
75 changes: 75 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Generate SDK
on:
# Sent by the API deploy when /v5/openapi changes:
# gh api repos/supermemoryai/python-sdk/dispatches -f event_type=openapi-updated
repository_dispatch:
types: [openapi-updated]
# Backstop in case a deploy didn't dispatch.
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
inputs:
version:
description: Set the SDK version (PEP 440, e.g. 5.0.0rc2 or 5.0.0). Empty = bump automatically if the SDK changed.
type: string
required: false

permissions:
contents: write
pull-requests: write

concurrency:
group: generate-sdk
cancel-in-progress: true

jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- uses: astral-sh/setup-uv@v6

- name: Generate from https://api.supermemory.ai/v5/openapi
run: scripts/generate

- name: Version
id: meta
env:
VERSION: ${{ inputs.version }}
run: |
if [ -n "$VERSION" ]; then
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml
SKIP_FETCH=1 scripts/generate # re-stamp the User-Agent version
elif [ -n "$(git status --porcelain -- src)" ]; then
python3 scripts/bump_version.py
SKIP_FETCH=1 scripts/generate
fi
echo "version=$(grep -m1 '^version' pyproject.toml | cut -d'"' -f2)" >> "$GITHUB_OUTPUT"
{
echo 'stat<<EOF'
git diff --stat -- fern/openapi.json src | tail -n 25
echo EOF
} >> "$GITHUB_OUTPUT"

- name: Test
run: uv run --group dev pytest -q

# Opens (or updates) one PR; no-op if nothing changed. A PR opened with the
# default GITHUB_TOKEN doesn't trigger CI, so set CODEGEN_PR_TOKEN (a
# fine-grained PAT or app token with contents + pull-requests write).
- uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.CODEGEN_PR_TOKEN || github.token }}
branch: codegen/regenerate
delete-branch: true
commit-message: "chore: regenerate SDK from v5 OpenAPI spec (${{ steps.meta.outputs.version }})"
title: "chore: regenerate SDK (${{ steps.meta.outputs.version }})"
body: |
Regenerated `src/supermemory` from `https://api.supermemory.ai/v5/openapi` (`scripts/generate`).

Merging publishes **supermemory ${{ steps.meta.outputs.version }}** to PyPI.

```
${{ steps.meta.outputs.stat }}
```
55 changes: 37 additions & 18 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to PyPI in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/supermemoryai/python-sdk/actions/workflows/publish-pypi.yml
name: Publish PyPI
name: Publish to PyPI
on:
push:
branches: [main]
workflow_dispatch:

release:
types: [published]
permissions:
contents: write # tag + GitHub release

jobs:
publish:
name: publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6

- name: Install Rye
# Merges that don't bump the version (docs, CI tweaks) are no-ops.
- name: Check version
id: meta
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
VERSION=$(grep -m1 '^version' pyproject.toml | cut -d'"' -f2)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if curl -fsS "https://pypi.org/pypi/supermemory/$VERSION/json" >/dev/null 2>&1; then
echo "supermemory $VERSION is already on PyPI — skipping."
echo "publish=false" >> "$GITHUB_OUTPUT"
else
echo "publish=true" >> "$GITHUB_OUTPUT"
fi

- if: steps.meta.outputs.publish == 'true'
run: uv run --group dev pytest -q

- if: steps.meta.outputs.publish == 'true'
run: uv build

- name: Publish ${{ steps.meta.outputs.version }}
if: steps.meta.outputs.publish == 'true'
run: uv publish
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'
UV_PUBLISH_TOKEN: ${{ secrets.SUPERMEMORY_PYPI_TOKEN || secrets.PYPI_TOKEN }}

- name: Publish to PyPI
run: |
bash ./bin/publish-pypi
- name: Tag and release
if: steps.meta.outputs.publish == 'true'
env:
PYPI_TOKEN: ${{ secrets.SUPERMEMORY_PYPI_TOKEN || secrets.PYPI_TOKEN }}
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.meta.outputs.version }}
run: |
flags=(--target "$GITHUB_SHA" --generate-notes)
[[ "$VERSION" =~ (a|b|rc|dev)[0-9]+$ ]] && flags+=(--prerelease)
gh release create "v$VERSION" dist/* "${flags[@]}"
21 changes: 0 additions & 21 deletions .github/workflows/release-doctor.yml

This file was deleted.

Loading
Loading