Skip to content

Commit 8ee1fd4

Browse files
authored
Merge pull request #2 from stainless-api/dgellow/add-stainless-workflows
chore(ci): setup automated stainless builds
2 parents 0c98182 + 5f23984 commit 8ee1fd4

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
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 |

.github/workflows/pre-commit.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,19 @@ jobs:
112112
113113
# Trigger the stainless-builds workflow after pre-commit passes.
114114
# This is required because pre-commit generates the OpenAPI spec file that
115-
# stainless-builds needs to build the SDKs. Using repository_dispatch allows
116-
# to trigger the workflow with custom payload data.
115+
# stainless-builds needs to build the SDKs.
117116
- name: Trigger Stainless builds
118117
if: github.event_name == 'pull_request' && success()
119-
uses: actions/github-script@v8
118+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
120119
with:
121120
script: |
122-
await github.rest.repos.createDispatchEvent({
121+
await github.rest.actions.createWorkflowDispatch({
123122
owner: context.repo.owner,
124123
repo: context.repo.repo,
125-
event_type: 'stainless-build-trigger',
126-
client_payload: {
127-
pr_number: context.payload.pull_request.number,
128-
pr_action: context.payload.action,
129-
ref: context.payload.pull_request.head.ref,
130-
sha: context.payload.pull_request.head.sha
124+
workflow_id: 'stainless-builds.yml',
125+
ref: context.payload.pull_request.head.ref,
126+
inputs: {
127+
pr_number: String(context.payload.pull_request.number),
128+
pr_action: context.payload.action
131129
}
132130
})

.github/workflows/stainless-builds.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
name: Build SDKs for pull request
1+
name: Stainless SDK Builds
2+
3+
run-name: Build Stainless SDKs
24

35
on:
4-
repository_dispatch:
5-
types: [stainless-build-trigger]
6+
# Triggered by the pre-commit workflow after it successfully completes.
7+
# This ensures the OpenAPI spec file is generated before attempting to build SDKs.
8+
workflow_dispatch:
9+
inputs:
10+
pr_number:
11+
description: 'Pull request number'
12+
required: true
13+
type: string
14+
pr_action:
15+
description: 'Pull request action'
16+
required: true
17+
type: string
618
pull_request:
719
types:
820
- closed
921

1022
concurrency:
11-
group: ${{ github.workflow }}-${{ github.event.client_payload.pr_number || github.event.pull_request.number }}
23+
group: ${{ github.workflow }}-${{ inputs.pr_number || github.event.pull_request.number }}
1224
cancel-in-progress: true
1325

1426
env:
@@ -31,19 +43,19 @@ env:
3143

3244
jobs:
3345
preview:
34-
if: github.event_name == 'repository_dispatch' && github.event.client_payload.pr_action != 'closed'
46+
if: github.event_name == 'workflow_dispatch' && inputs.pr_action != 'closed'
3547
runs-on: ubuntu-latest
3648
permissions:
3749
contents: read
3850
pull-requests: write
3951
steps:
4052
- name: Checkout repository
41-
uses: actions/checkout@v4
53+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4254
with:
4355
fetch-depth: 2
4456

4557
- name: Run preview builds
46-
uses: stainless-api/upload-openapi-spec-action/preview@v1
58+
uses: stainless-api/upload-openapi-spec-action/preview@b741c27bc604e5c130b92ed4056b07aee783aa04 # v1.5.4
4759
with:
4860
stainless_api_key: ${{ secrets.STAINLESS_API_KEY }}
4961
org: ${{ env.STAINLESS_ORG }}
@@ -60,7 +72,7 @@ jobs:
6072
pull-requests: write
6173
steps:
6274
- name: Checkout repository
63-
uses: actions/checkout@v4
75+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
6476
with:
6577
fetch-depth: 2
6678

@@ -71,7 +83,7 @@ jobs:
7183
# against preview/${{ github.head_ref }} to complete, but assuming that
7284
# the preview-sdk job happens before the PR merge, it should be fine.
7385
- name: Run merge build
74-
uses: stainless-api/upload-openapi-spec-action/merge@v1
86+
uses: stainless-api/upload-openapi-spec-action/merge@b741c27bc604e5c130b92ed4056b07aee783aa04 # v1.5.4
7587
with:
7688
stainless_api_key: ${{ secrets.STAINLESS_API_KEY }}
7789
org: ${{ env.STAINLESS_ORG }}

0 commit comments

Comments
 (0)