Skip to content
Open
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
  •  
  •  
  •  
25 changes: 25 additions & 0 deletions .github/fern/generators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,28 @@ groups:
streamType: web
useDefaultRequestParameterValues: true
smart-casing: true
# `local-file-system` allows no `github` block, so the workflow commits the result itself.
python-sdk:
generators:
- name: fernapi/fern-python-sdk
version: 5.29.0
output:
location: local-file-system
path: ../../python/trueforge_sdk
config:
package_name: trueforge_sdk
optional_auth: true
stream_abstraction: true
use_request_defaults: all
inline_path_params: true
pydantic_config:
enum_type: forward_compatible_python_enums
frozen: false
skip_validation: true
client:
class_name: BaseTrueForge
filename: base_client.py
exported_class_name: TrueForge
exported_filename: client.py
pyproject_python_version: '>=3.10'
smart-casing: true
21 changes: 12 additions & 9 deletions .github/workflows/generate-sdk.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Generate SDK

# Regenerates the OpenAPI document and the SDK, and commits both to the branch.
# Regenerates the OpenAPI document and the SDKs, and commits them to the branch.
# Fork PRs cannot receive that commit; main regenerates after merge.
on:
# Manual regen on main if the post-merge push job missed or failed.
Expand All @@ -14,6 +14,7 @@ on:
- 'packages/trueforge-core/src/**'
- '.github/fern/**'
- '.github/workflows/generate-sdk.yaml'
- 'scripts/generate-sdk.sh'
pull_request:
types: [opened, synchronize, reopened]
paths:
Expand All @@ -22,6 +23,7 @@ on:
- 'packages/trueforge-core/src/**'
- '.github/fern/**'
- '.github/workflows/generate-sdk.yaml'
- 'scripts/generate-sdk.sh'

concurrency:
group: generate-sdk-${{ github.head_ref || github.ref_name }}
Expand All @@ -32,7 +34,7 @@ permissions:

jobs:
generate:
name: Generate OpenAPI and TypeScript SDK
name: Generate OpenAPI and SDKs
runs-on: ubuntu-latest
timeout-minutes: 30
# A pull_request path filter matches the whole PR, not just the new commit,
Expand Down Expand Up @@ -110,7 +112,7 @@ jobs:
elif ! git rev-parse --verify --quiet "${BASE_SHA}^{commit}" >/dev/null; then
# A branch's first push reports an all-zero base commit.
reason="there is no base commit to compare against"
elif ! git diff --quiet "$BASE_SHA" HEAD -- .github/fern/generators.yml .github/fern/fern.config.json; then
elif ! git diff --quiet "$BASE_SHA" HEAD -- .github/fern/generators.yml .github/fern/fern.config.json scripts/generate-sdk.sh; then
reason="the generator config changed"
fi

Expand All @@ -124,7 +126,7 @@ jobs:

# Same entrypoint as local `pnpm sdk:generate` (re-runs openapi:write; idempotent).
# App-token success = we can push; forks skip Fern so a flake cannot block the PR.
- name: Generate OpenAPI document and TypeScript SDK
- name: Generate OpenAPI document and SDKs
if: steps.decide.outputs.needed == 'true' && steps.app-token.outcome == 'success'
run: pnpm sdk:generate

Expand All @@ -141,8 +143,8 @@ jobs:
# --porcelain, not `git diff`, so new files count too.
# docs/openapi.json is a second copy of the same document (Mintlify); keep it
# in the same commit as .github/fern/openapi or the docs site drifts.
if [ -z "$(git status --porcelain -- .github/fern/openapi docs/openapi.json packages/trueforge-sdk pnpm-lock.yaml)" ]; then
echo "OpenAPI document and SDK are already up to date."
if [ -z "$(git status --porcelain -- .github/fern/openapi docs/openapi.json packages/trueforge-sdk python/trueforge_sdk pnpm-lock.yaml)" ]; then
echo "OpenAPI document and SDKs are already up to date."
exit 0
fi

Expand All @@ -152,12 +154,13 @@ jobs:
# Bot-authored sdk diffs need a changeset; the PR author never touches this commit.
# Skip packages/trueforge-sdk/.fern — Fern metadata only, not a consumer-facing change.
# changeset:sdk-regen is a no-op if the sdk is already named in a pending file.
# Python is not Changesets-published yet; do not add it here.
if [ -n "$(git status --porcelain -- packages/trueforge-sdk ':!packages/trueforge-sdk/.fern')" ]; then
pnpm changeset:sdk-regen
fi

git add .github/fern/openapi docs/openapi.json packages/trueforge-sdk pnpm-lock.yaml .changeset
git commit -m "Regenerate OpenAPI document and TypeScript SDK"
git add .github/fern/openapi docs/openapi.json packages/trueforge-sdk python/trueforge_sdk pnpm-lock.yaml .changeset
git commit -m "Regenerate OpenAPI document and SDKs"
git push origin "HEAD:refs/heads/$BRANCH"

- name: Report skipped commit on fork
Expand All @@ -168,7 +171,7 @@ jobs:
echo "### Fork pull request"
echo
echo "OpenAPI/SDK commits are skipped on forks (GitHub Apps cannot push to the head repo)."
echo "Do not hand-edit \`packages/trueforge-sdk\` or the OpenAPI documents."
echo "Do not hand-edit \`packages/trueforge-sdk\`, \`python/trueforge_sdk\`, or the OpenAPI documents."
echo "After merge, **Generate SDK** on \`main\` regenerates both (or run it manually from Actions)."
} >> "$GITHUB_STEP_SUMMARY"
echo "::notice::Fork PR: OpenAPI/SDK will be regenerated on main after merge. Do not hand-edit generated files."
29 changes: 29 additions & 0 deletions python/trueforge_sdk/.fern/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"cliVersion": "5.106.1",
"generatorName": "fernapi/fern-python-sdk",
"generatorVersion": "5.29.0",
"generatorConfig": {
"package_name": "trueforge_sdk",
"optional_auth": true,
"stream_abstraction": true,
"use_request_defaults": "all",
"inline_path_params": true,
"pydantic_config": {
"enum_type": "forward_compatible_python_enums",
"frozen": false,
"skip_validation": true
},
"client": {
"class_name": "BaseTrueForge",
"filename": "base_client.py",
"exported_class_name": "TrueForge",
"exported_filename": "client.py"
},
"pyproject_python_version": ">=3.10"
},
"originGitCommit": "02361b1a8844e09e7c00bdca2ec37bbdc7f5bb92",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "0.1.0-rc.1",
"ciProvider": "github"
}
2 changes: 2 additions & 0 deletions python/trueforge_sdk/.fernignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pyproject.toml
.fernignore
127 changes: 127 additions & 0 deletions python/trueforge_sdk/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Contributing

Thanks for your interest in contributing to this SDK! This document provides guidelines for contributing to the project.

## Getting Started

### Prerequisites

- Python 3.9+
- pip
- poetry

### Installation

Install the project dependencies:

```bash
poetry install
```

### Building

Build the project:

```bash
poetry build
```

### Testing

Run the test suite:

```bash
poetry run pytest
```

### Linting and Formatting

Check code style:

```bash
poetry run ruff check .
poetry run ruff format .
```

### Type Checking

Run the type checker:

```bash
poetry run mypy .
```

## About Generated Code

**Important**: Most files in this SDK are automatically generated by [Fern](https://buildwithfern.com) from the API definition. Direct modifications to generated files will be overwritten the next time the SDK is generated.

### Generated Files

The following directories contain generated code:

- `src/` - API client classes and types
- Most Python files in the project

### How to Customize

If you need to customize the SDK, you have two options:

#### Option 1: Use `.fernignore`

For custom code that should persist across SDK regenerations:

1. Create a `.fernignore` file in the project root
2. Add file patterns for files you want to preserve (similar to `.gitignore` syntax)
3. Add your custom code to those files

Files listed in `.fernignore` will not be overwritten when the SDK is regenerated.

For more information, see the [Fern documentation on custom code](https://buildwithfern.com/learn/sdks/overview/custom-code).

#### Option 2: Contribute to the Generator

If you want to change how code is generated for all users of this SDK:

1. The Python SDK generator lives in the [Fern repository](https://github.com/fern-api/fern)
2. Generator code is located at `generators/python-v2/`
3. Follow the [Fern contributing guidelines](https://github.com/fern-api/fern/blob/main/CONTRIBUTING.md)
4. Submit a pull request with your changes to the generator

This approach is best for:

- Bug fixes in generated code
- New features that would benefit all users
- Improvements to code generation patterns

## Making Changes

### Workflow

1. Create a new branch for your changes
2. Make your modifications
3. Run tests to ensure nothing breaks: `poetry run pytest`
4. Run linting and formatting: `poetry run ruff check .` and `poetry run ruff format .`
5. Run type checking: `poetry run mypy .`
6. Build the project: `poetry build`
7. Commit your changes with a clear commit message
8. Push your branch and create a pull request

### Commit Messages

Write clear, descriptive commit messages that explain what changed and why.

### Code Style

This project uses automated code formatting and linting. Run `poetry run ruff format .` and `poetry run ruff check .` before committing to ensure your code meets the project's style guidelines.

## Questions or Issues?

If you have questions or run into issues:

1. Check the [Fern documentation](https://buildwithfern.com)
2. Search existing [GitHub issues](https://github.com/fern-api/fern/issues)
3. Open a new issue if your question hasn't been addressed

## License

By contributing to this project, you agree that your contributions will be licensed under the same license as the project.
Loading
Loading