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
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions .changes/v2-sdks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "minor",
"summary": "The four SDKs now read the v2 catalog and can fetch individual models, provider catalogs, and indexes with conditional caching and concurrent request deduplication."
}
18 changes: 13 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@ version: 2
updates:
- package-ecosystem: npm
directory: /
schedule: {interval: weekly}
schedule: { interval: weekly }
open-pull-requests-limit: 3
groups:
effect-and-alchemy:
patterns: ["effect", "@effect/*", "alchemy"]
lobe-icons:
patterns: ['@lobehub/icons-static-svg']
patterns: ["@lobehub/icons-static-svg"]
- package-ecosystem: github-actions
directory: /
schedule: {interval: weekly}
schedule: { interval: weekly }
groups:
github-actions:
patterns: ["*"]
- package-ecosystem: cargo
directory: /sdk/rust
schedule: {interval: weekly}
schedule: { interval: weekly }
groups:
cargo:
patterns: ["*"]
- package-ecosystem: gomod
directory: /sdk/go
schedule: {interval: weekly}
schedule: { interval: weekly }
124 changes: 124 additions & 0 deletions .github/sync-models/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/usr/bin/env bash
# Publish a catalog patch against the exact main revision that produced it.
set -euo pipefail
export LC_ALL=C
: "${GH_REPO:?}" "${BOT_NAME:?}" "${BOT_EMAIL:?}"
dir=${1:?Supply a sync artifact directory}

fail() { echo "::error::$*" >&2; exit 1; }

for file in target safe base changes.patch report.md; do
[[ -f "$dir/$file" && ! -L "$dir/$file" && -s "$dir/$file" ]] || fail "Missing regular artifact file: $file"
done
target=$(<"$dir/target")
safe=$(<"$dir/safe")
base=$(<"$dir/base")
[[ $target =~ ^(catalog|review-[a-z0-9][a-z0-9._-]*)$ ]] || fail 'Invalid sync target'
[[ ${dir##*/} == "sync-$target" ]] || fail 'Artifact directory and target differ'
[[ $safe == true && $target == catalog || $safe == false && $target == review-* ]] || fail 'Invalid target and safety combination'
[[ $base =~ ^[0-9a-f]{40}$ ]] || fail 'Invalid patch base'
branch="automation/sync-$target"
git=(git -c core.hooksPath=/dev/null -c "user.name=$BOT_NAME" -c "user.email=$BOT_EMAIL")
"${git[@]}" check-ref-format "refs/heads/$branch" || fail 'Invalid automation branch'
"${git[@]}" fetch --no-tags --depth=1 origin '+refs/heads/main:refs/remotes/origin/main'
[[ $("${git[@]}" rev-parse origin/main) == "$base" ]] || fail 'main moved since sync generated the patch. Rerun sync.'

# Apply to the index only. No artifact content is checked out or executed.
"${git[@]}" read-tree "$base"
"${git[@]}" apply --cached --binary "$dir/changes.patch" || fail 'Patch no longer applies to main'
listing_changes=""
changed=false
while IFS= read -r -d '' metadata && IFS= read -r -d '' path; do
changed=true
read -r old_mode new_mode _ <<< "${metadata#:}"
[[ $old_mode =~ ^(000000|100644)$ && $new_mode =~ ^(000000|100644)$ ]] || fail "Invalid file mode: $path"
if [[ $path =~ ^(developers|models|providers)/.+\.toml$ ]]; then
IFS=/ read -r -a parts <<< "$path"
for part in "${parts[@]}" "${parts[${#parts[@]}-1]%.toml}"; do
[[ $part =~ ^[a-z0-9][a-z0-9._-]{0,254}$ && $part != *. && ! $part =~ ^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\.|$) ]] || fail "Windows-unsafe path: $path"
done
else
case $path in
aliases.toml|.sync/upstream-state.json|coverage/models-dev.json) ;;
*) fail "Path outside the catalog: $path" ;;
esac
fi
if [[ $safe == true ]]; then
if [[ $path =~ ^providers/([^/]+)/models/ ]]; then
provider=${BASH_REMATCH[1]}
if [[ $old_mode == 000000 ]]; then listing_changes+="$provider created"$'\n'; fi
if [[ $new_mode == 000000 ]]; then listing_changes+="$provider deleted"$'\n'; fi
elif [[ $new_mode == 000000 ]]; then
fail "Safe patch attempts to delete $path"
fi
fi
done < <("${git[@]}" diff --cached --raw -z --no-renames "$base" --)
[[ $changed == true ]] || fail 'Empty catalog patch'
counts=$(jq -Rrs '
split("\n") | map(select(length > 0) | split(" ")) | group_by(.[0])[] |
[.[0][0], (map(select(.[1] == "created")) | length), (map(select(.[1] == "deleted")) | length)] | @tsv
' <<< "$listing_changes")
while IFS=$'\t' read -r provider created deleted; do
[[ -n $provider ]] || continue
(( created <= 10 )) || fail "Safe patch creates too many models for $provider"
if (( deleted == 0 )); then continue; fi
total=0
while IFS= read -r -d '' path; do
if [[ $path == *.toml ]]; then total=$((total + 1)); fi
done < <("${git[@]}" ls-tree -r --name-only -z "$base" -- "providers/$provider/models/")
(( deleted <= 5 && deleted * 2 < total )) || fail "Safe patch deletes too many models for $provider"
done <<< "$counts"

find_pr() {
gh pr list --repo "$GH_REPO" --base main --head "$branch" --state open --json number,isCrossRepository |
jq -er 'map(select(.isCrossRepository == false)) | if length > 1 then error("duplicate sync PRs") else .[0].number // "" end'
}
auto_enabled() {
gh pr view "$1" --repo "$GH_REPO" --json autoMergeRequest --jq '.autoMergeRequest != null'
}

pr=$(find_pr)
if [[ $safe == false && -n $pr ]]; then
enabled=$(auto_enabled "$pr")
if [[ $enabled == true ]]; then
gh pr merge "$pr" --repo "$GH_REPO" --disable-auto
fi
[[ $(auto_enabled "$pr") == false ]] || fail "Auto-merge is still enabled for #$pr"
fi

title="chore(sync): update $target catalog"
tree=$("${git[@]}" write-tree)
# Reuse an identical remote commit to avoid restarting CI on every scheduled run.
remote=$("${git[@]}" ls-remote origin "refs/heads/$branch")
old_commit=${remote%%$'\t'*}
if [[ -n $old_commit ]]; then
"${git[@]}" fetch --no-tags --depth=2 origin "refs/heads/$branch"
old_commit=$("${git[@]}" rev-parse FETCH_HEAD)
fi
if [[ -z $old_commit || $("${git[@]}" show -s --format='%T %P' "$old_commit") != "$tree $base" ]]; then
commit=$("${git[@]}" commit-tree "$tree" -p "$base" -m "$title")
"${git[@]}" push --force-with-lease="refs/heads/$branch:$old_commit" origin "$commit:refs/heads/$branch"
fi

labels=automation,catalog-sync
if [[ $safe == false ]]; then labels+=,needs-review; fi
IFS=, read -r -a label_names <<< "$labels"
for label in "${label_names[@]}"; do
gh label create "$label" --repo "$GH_REPO" --color 0E8A16 --description 'Automated catalog synchronization' >/dev/null 2>&1 || true
done
if [[ -n $pr ]]; then
gh pr edit "$pr" --repo "$GH_REPO" --title "$title" --body-file "$dir/report.md" --add-label "$labels"
else
gh pr create --repo "$GH_REPO" --base main --head "$branch" --title "$title" --body-file "$dir/report.md" --label "$labels"
pr=$(find_pr)
fi
[[ -n $pr ]] || fail "Unable to find the same-repository PR for $branch"
if [[ $safe == true ]]; then
enabled=$(auto_enabled "$pr")
if [[ $enabled == false ]]; then
gh pr merge "$pr" --repo "$GH_REPO" --auto --squash
fi
else
[[ $(auto_enabled "$pr") == false ]] || fail "Auto-merge is enabled for review PR #$pr"
fi
echo "$target: #$pr (safe=$safe)" >> "${GITHUB_STEP_SUMMARY:-/dev/null}"
35 changes: 22 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,40 @@ name: Verify Alchemy GitHub deployment
on:
push:
branches: [main]
paths: ['data/**', 'coverage/models-dev.json', 'logos/**', 'apps/site/**', 'packages/core/**', 'packages/publish/**', 'pnpm-lock.yaml', 'scripts/deploy.ts', 'scripts/deployment.ts', 'scripts/build-site.ts', 'alchemy.run.ts']
paths:
- developers/**
- models/**
- providers/**
- aliases.toml
- .sync/upstream-state.json
- coverage/models-dev.json
- logos/**
- apps/site/**
- packages/**
- scripts/deploy*
- scripts/build-site.ts
- alchemy.run.ts
- pnpm-lock.yaml
workflow_dispatch:
permissions:
contents: read
concurrency:
group: model-static-production
cancel-in-progress: false
cancel-in-progress: true
jobs:
validate:
permissions:
contents: read
actions: write
uses: ./.github/workflows/validate.yml
deploy:
needs: validate
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
timeout-minutes: 20
environment: production
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with: {fetch-depth: 0, persist-credentials: false}
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38
with: {node-version: '22.23.5', cache: pnpm}
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with: { persist-credentials: false }
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with: { node-version-file: .node-version, cache: pnpm }
- run: pnpm install --frozen-lockfile
- run: pnpm validate
- run: pnpm exec tsx scripts/watch-deployment.ts
env:
GH_TOKEN: ${{ github.token }}
35 changes: 0 additions & 35 deletions .github/workflows/merge-validated.yml

This file was deleted.

35 changes: 11 additions & 24 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Nightly regression and release recovery
on:
schedule:
- cron: '11 3 * * *'
- cron: "11 3 * * *"
workflow_dispatch:
permissions:
contents: read
Expand All @@ -11,17 +11,7 @@ jobs:
regression:
permissions:
contents: read
actions: write
uses: ./.github/workflows/validate.yml
synchronize:
permissions:
contents: write
pull-requests: write
actions: write
uses: ./.github/workflows/sync.yml
with:
check_coverage: true
secrets: inherit
recover-releases:
needs: regression
runs-on: ubuntu-24.04
Expand All @@ -30,26 +20,23 @@ jobs:
contents: read
actions: write
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with: {persist-credentials: false}
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38
with: {node-version: '22.23.5', cache: pnpm}
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with: { persist-credentials: false }
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with: { node-version: "22.23.5", cache: pnpm }
- run: pnpm install --frozen-lockfile
- run: pnpm exec tsx scripts/release/recover.ts
env:
GH_TOKEN: ${{ github.token }}
inspect:
needs: [regression, synchronize]
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with: {persist-credentials: false}
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38
with: {node-version: '22.23.5', cache: pnpm}
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with: { persist-credentials: false }
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with: { node-version: "22.23.5", cache: pnpm }
- run: pnpm install --frozen-lockfile
- run: pnpm exec tsx scripts/nightly.ts
env:
GH_TOKEN: ${{ github.token }}
Loading
Loading