Skip to content

Commit

Permalink
Merge branch 'main' into tool-choice-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmer1 authored Jan 28, 2025
2 parents ee59996 + 21f84f8 commit 98454f7
Show file tree
Hide file tree
Showing 195 changed files with 11,585 additions and 4,121 deletions.
12 changes: 8 additions & 4 deletions .github/scripts/check-mdx-frontmatter.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const validators = [checkDescriptionLength, checkTitleLength];
// List of folders to exclude (relative to mdxDir)
const excludedFolders = ["-ARCHIVE-", "api-reference", "llm-university"];

function logInvalidMessage(message) {
console.error(`[INVALID]: ${message}`);
}

function shouldExcludeFolder(dirPath) {
return excludedFolders.some((excludedFolder) => {
return path.relative(mdxDir, dirPath).startsWith(excludedFolder);
Expand All @@ -28,7 +32,7 @@ async function shouldExcludeFile(filePath) {
const { data } = matter(fileContent);
return data.hidden === true;
} catch (error) {
console.error(`Error reading file "${filePath}":`, error);
console.error(`[ERROR]: Error reading file "${filePath}":`, error);
return false; // In case of error, don't exclude the file
}
}
Expand All @@ -40,14 +44,14 @@ async function checkDescriptionLength(filePath) {
const maxDescriptionLength = 160;

if (!data.description) {
console.error(`File "${filePath}" is missing a description.`);
logInvalidMessage(`File "${filePath}" is missing a description.`);
return false;
}

const descriptionLength = data.description.length;

if (descriptionLength < minDescriptionLength || descriptionLength > maxDescriptionLength) {
console.error(
logInvalidMessage(
`File "${filePath}" has an invalid description length: ${descriptionLength} characters. ` +
`Description should be between ${minDescriptionLength}-${maxDescriptionLength} characters.`
);
Expand All @@ -74,7 +78,7 @@ async function checkTitleLength(filePath) {
if (filesToExclude.includes(filePath)) {
return true;
}
console.error(`File "${filePath}" is missing a title.`);
logInvalidMessage(`File "${filePath}" is missing a title.`);
return false;
}

Expand Down
17 changes: 15 additions & 2 deletions .github/scripts/check_python_code_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,21 @@ def format_python_snippets_in_mdx(file_path, line_length=DEFAULT_LINE_LENGTH):

def format_with_black(match):
code = match.group(1)
formatted_code = black.format_str(code, mode=black_mode)
return f"```python\n{formatted_code.strip()}\n```"

# Comment out lines starting with '!'
processed_code = re.sub(r"^\s*!(.*)", r"# TEMP_COMMENT !\1", code, flags=re.MULTILINE)

try:
# Format the code with Black
formatted_code = black.format_str(processed_code, mode=black_mode)
except black.NothingChanged:
# If Black doesn't change anything, use original
formatted_code = processed_code

# Revert the commented lines starting with '!'
reverted_code = re.sub(r"^\s*# TEMP_COMMENT !(.*)", r"!\1", formatted_code, flags=re.MULTILINE)

return f"```python\n{reverted_code.strip()}\n```"

new_content = code_block_pattern.sub(format_with_black, original_content)

Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/create-sdk-releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: create-sdk-releases

on:
workflow_dispatch:
inputs:
bump_type:
description: 'The type of version bump to make'
required: true
type: choice
options:
- 'major'
- 'minor'
- 'patch'
language:
description: 'If you want to just release a specific language'
type: choice
options:
- 'all'
- 'go'
- 'java'
- 'python'
- 'typescript'
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Install Dependencies
shell: bash
run: pnpm install

- name: Run snippet tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_OWNER: ${{ github.repository_owner }}
GITHUB_REPO: ${{ github.event.repository.name }}
BUMP_TYPE: ${{ github.event.inputs.bump_type }}
LANGUAGE: ${{ github.event.inputs.language }}
run: pnpm run --filter autorelease release
33 changes: 33 additions & 0 deletions .github/workflows/delete-n-releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: delete-n-releases

on:
workflow_dispatch:
inputs:
n:
description: 'Number of releases to delete'
required: true
default: "1"

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Install Dependencies
shell: bash
run: pnpm install

- name: Run snippet tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_OWNER: ${{ github.repository_owner }}
GITHUB_REPO: ${{ github.event.repository.name }}
N_VERSIONS: ${{ github.event.inputs.n }}
run: pnpm run --filter autorelease delete
127 changes: 127 additions & 0 deletions .github/workflows/release-sdks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: release-sdks

on: [push]

jobs:
fern-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Install Dependencies
shell: bash
run: pnpm install

- name: Run fern check
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
run: pnpm run docs:check

fern-generate-node:
environment: sdk-release
needs: fern-check
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/node@')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3

- name: Download Fern
run: npm install -g fern-api

- name: Release TypeScript SDK
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
tag=${{ github.ref_name }}
prefix="node@"
SDK_VERSION="${tag#$prefix}"
fern generate --api sdks --group node-sdk --version "$SDK_VERSION" --log-level debug
fern-generate-go:
environment: sdk-release
needs: fern-check
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/go@')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3

- name: Download Fern
run: npm install -g fern-api

- name: Release Go SDK
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
run: |
tag=${{ github.ref_name }}
prefix="go@"
SDK_VERSION="${tag#$prefix}"
fern generate --api sdks --group go-sdk --version "$SDK_VERSION" --log-level debug
fern-generate-java:
environment: sdk-release
needs: fern-check
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/java@')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3

- name: Download Fern
run: npm install -g fern-api

- name: Release Java SDK
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_CENTRAL_SECRET_KEY_KEY_ID: ${{ secrets.MAVEN_CENTRAL_SECRET_KEY_KEY_ID }}
MAVEN_CENTRAL_SECRET_KEY_PASSWORD: ${{ secrets.MAVEN_CENTRAL_SECRET_KEY_PASSWORD }}
MAVEN_CENTRAL_SECRET_KEY: ${{ secrets.MAVEN_CENTRAL_SECRET_KEY }}
run: |
tag=${{ github.ref_name }}
prefix="java@"
SDK_VERSION="${tag#$prefix}"
fern generate --api sdks --group java-sdk --version "$SDK_VERSION" --log-level debug
fern-generate-python:
environment: sdk-release
needs: fern-check
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/python@')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3

- name: Download Fern
run: npm install -g fern-api

- name: Release Python SDK
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
tag=${{ github.ref_name }}
prefix="python@"
SDK_VERSION="${tag#$prefix}"
fern generate --api sdks --group python-sdk --version "$SDK_VERSION" --log-level debug
Loading

0 comments on commit 98454f7

Please sign in to comment.