Skip to content

Commit df9149c

Browse files
committed
chore(ci): setup automated stainless builds
1 parent b67aef2 commit df9149c

File tree

3 files changed

+728
-0
lines changed

3 files changed

+728
-0
lines changed

.github/workflows/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Llama Stack uses GitHub Actions for Continuous Integration (CI). Below is a tabl
1616
| Python Package Build Test | [python-build-test.yml](python-build-test.yml) | Test building the llama-stack PyPI project |
1717
| Integration Tests (Record) | [record-integration-tests.yml](record-integration-tests.yml) | Run the integration test suite from tests/integration |
1818
| Check semantic PR titles | [semantic-pr.yml](semantic-pr.yml) | Ensure that PR titles follow the conventional commit spec |
19+
| Stainless SDK Builds | [stainless-builds.yml](stainless-builds.yml) | Build Stainless SDKs |
1920
| Close stale issues and PRs | [stale_bot.yml](stale_bot.yml) | Run the Stale Bot action |
2021
| Test External Providers Installed via Module | [test-external-provider-module.yml](test-external-provider-module.yml) | Test External Provider installation via Python module |
2122
| Test External API and Providers | [test-external.yml](test-external.yml) | Test the External API and Provider mechanisms |
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Build SDKs for pull request (including forks)
2+
3+
# This workflow uses pull_request_target, which allows it to run on pull requests
4+
# from forks with access to secrets and OIDC tokens. This is safe because the
5+
# workflow definition comes from the base branch (trusted), and the action only
6+
# reads OpenAPI spec files without executing any code from the PR.
7+
#
8+
# Important: If your repository is public, configure GitHub to require approval
9+
# for workflows from fork PRs. Go to Settings → Actions → General, and under
10+
# "Fork pull request workflows from outside collaborators", select
11+
# "Require approval for all outside collaborators".
12+
13+
on:
14+
pull_request_target:
15+
types:
16+
- opened
17+
- synchronize
18+
- reopened
19+
- closed
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
23+
cancel-in-progress: true
24+
25+
env:
26+
# Stainless organization name.
27+
STAINLESS_ORG: llamastack
28+
29+
# Stainless project name.
30+
STAINLESS_PROJECT: llama-stack-client
31+
32+
# Path to your OpenAPI spec.
33+
OAS_PATH: ./docs/static/llama-stack-spec.yaml
34+
35+
# Path to your Stainless config. Optional; only provide this if you prefer
36+
# to maintain the ground truth Stainless config in your own repo.
37+
CONFIG_PATH: ./docs/static/stainless-config.yaml
38+
39+
# When to fail the job based on build conclusion.
40+
# Options: "never" | "note" | "warning" | "error" | "fatal".
41+
FAIL_ON: error
42+
43+
jobs:
44+
preview:
45+
if: github.event.action != 'closed'
46+
runs-on: ubuntu-latest
47+
permissions:
48+
contents: read
49+
pull-requests: write
50+
id-token: write
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
54+
with:
55+
repository: ${{ github.event.pull_request.head.repo.full_name }}
56+
ref: ${{ github.event.pull_request.head.sha }}
57+
fetch-depth: 2
58+
59+
- name: Run preview builds
60+
uses: stainless-api/upload-openapi-spec-action/preview@32823b096b4319c53ee948d702d9052873af485f # 1.6.0
61+
with:
62+
org: ${{ env.STAINLESS_ORG }}
63+
project: ${{ env.STAINLESS_PROJECT }}
64+
oas_path: ${{ env.OAS_PATH }}
65+
config_path: ${{ env.CONFIG_PATH }}
66+
fail_on: ${{ env.FAIL_ON }}
67+
base_sha: ${{ github.event.pull_request.base.sha }}
68+
base_ref: ${{ github.event.pull_request.base.ref }}
69+
head_sha: ${{ github.event.pull_request.head.sha }}
70+
71+
merge:
72+
if: github.event.action == 'closed' && github.event.pull_request.merged == true
73+
runs-on: ubuntu-latest
74+
permissions:
75+
contents: read
76+
pull-requests: write
77+
id-token: write
78+
steps:
79+
# Checkout the PR's code (including from forks)
80+
- name: Checkout repository
81+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
82+
with:
83+
repository: ${{ github.event.pull_request.head.repo.full_name }}
84+
ref: ${{ github.event.pull_request.head.sha }}
85+
fetch-depth: 2
86+
87+
# Note that this only merges in changes that happened on the last build on
88+
# preview/${{ github.head_ref }}. It's possible that there are OAS/config
89+
# changes that haven't been built, if the preview-sdk job didn't finish
90+
# before this step starts. In theory we want to wait for all builds
91+
# against preview/${{ github.head_ref }} to complete, but assuming that
92+
# the preview-sdk job happens before the PR merge, it should be fine.
93+
- name: Run merge build
94+
uses: stainless-api/upload-openapi-spec-action/merge@32823b096b4319c53ee948d702d9052873af485f # 1.6.0
95+
with:
96+
org: ${{ env.STAINLESS_ORG }}
97+
project: ${{ env.STAINLESS_PROJECT }}
98+
oas_path: ${{ env.OAS_PATH }}
99+
config_path: ${{ env.CONFIG_PATH }}
100+
fail_on: ${{ env.FAIL_ON }}
101+
base_sha: ${{ github.event.pull_request.base.sha }}
102+
base_ref: ${{ github.event.pull_request.base.ref }}
103+
head_sha: ${{ github.event.pull_request.head.sha }}

0 commit comments

Comments
 (0)