Skip to content

Commit 394f100

Browse files
committed
refactor: Update Makefile to streamline installation, testing, and linting processes
1 parent e1504aa commit 394f100

File tree

8 files changed

+290
-75
lines changed

8 files changed

+290
-75
lines changed

.github/actions/build-docs/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: Build Documentation
2-
description: 'Build Documentation.'
2+
description: 'Build Documentation for a package'
3+
inputs:
4+
workspace_path:
5+
description: 'Path to the package to build docs for.'
6+
required: false
7+
default: 'packages/sdk/server-ai'
38

49
runs:
510
using: composite

.github/actions/build/action.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Build distribution files
2-
description: 'Build distribution files'
2+
description: 'Build distribution files for a package'
3+
inputs:
4+
workspace_path:
5+
description: 'Path to the package to build.'
6+
required: true
37
outputs:
48
package-hashes:
59
description: "base64-encoded sha256 hashes of distribution files"
@@ -10,11 +14,11 @@ runs:
1014
steps:
1115
- name: Build distribution files
1216
shell: bash
13-
working-directory: ./packages/sdk/server-ai
14-
run: poetry build
17+
run: make -C ${{ inputs.workspace_path }} build
18+
1519
- name: Hash build files for provenance
1620
id: package-hashes
1721
shell: bash
18-
working-directory: ./packages/sdk/server-ai/dist
22+
working-directory: ${{ inputs.workspace_path }}/dist
1923
run: |
2024
echo "package-hashes=$(sha256sum * | base64 -w0)" >> "$GITHUB_OUTPUT"

.github/actions/ci/action.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Shared CI Workflow
2+
description: 'Build, lint, and test a package'
3+
inputs:
4+
workspace_path:
5+
description: 'Path to the package to build/test.'
6+
required: true
7+
python_version:
8+
description: 'Python version to use'
9+
required: false
10+
default: '3.11'
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Set up Python ${{ inputs.python_version }}
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: ${{ inputs.python_version }}
19+
20+
- name: Install poetry
21+
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
22+
23+
- name: Install Dependencies
24+
shell: bash
25+
working-directory: ${{ inputs.workspace_path }}
26+
run: poetry install
27+
28+
- name: Lint
29+
shell: bash
30+
run: make -C ${{ inputs.workspace_path }} lint
31+
32+
- name: Test
33+
shell: bash
34+
run: make -C ${{ inputs.workspace_path }} test

.github/workflows/ci.yml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,31 @@ on:
1111
- '**.md'
1212

1313
jobs:
14-
linux:
14+
server-ai-linux:
1515
runs-on: ubuntu-latest
16-
1716
strategy:
1817
matrix:
1918
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2019

2120
steps:
2221
- uses: actions/checkout@v4
23-
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v5
25-
with:
26-
python-version: ${{ matrix.python-version }}
2722

2823
- name: Install poetry
2924
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
3025

31-
- uses: ./.github/actions/build
32-
- uses: ./.github/actions/build-docs
26+
- uses: ./.github/actions/ci
27+
with:
28+
workspace_path: packages/sdk/server-ai
29+
python_version: ${{ matrix.python-version }}
3330

34-
- name: Run tests
35-
run: make test
31+
- uses: ./.github/actions/build
32+
with:
33+
workspace_path: packages/sdk/server-ai
3634

37-
- name: Verify typehints
38-
run: make lint
35+
- uses: ./.github/actions/build-docs
3936

40-
windows:
37+
server-ai-windows:
4138
runs-on: windows-latest
42-
4339
defaults:
4440
run:
4541
shell: powershell
@@ -50,6 +46,7 @@ jobs:
5046

5147
steps:
5248
- uses: actions/checkout@v4
49+
5350
- name: Set up Python ${{ matrix.python-version }}
5451
uses: actions/setup-python@v5
5552
with:
@@ -59,9 +56,8 @@ jobs:
5956
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
6057

6158
- name: Install requirements
62-
run: |
63-
cd packages/sdk/server-ai
64-
poetry install
59+
working-directory: packages/sdk/server-ai
60+
run: poetry install
6561

6662
- name: Run tests
67-
run: make test
63+
run: make -C packages/sdk/server-ai test
Lines changed: 129 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,164 @@
1-
name: Run Release Please
1+
# This workflow handles both automated and manual package publishing:
2+
#
3+
# AUTOMATED PUBLISHING (on push to main):
4+
# - Triggered automatically when changes are pushed to the main branch
5+
# - Uses release-please to create releases based on conventional commits
6+
# - Publishes packages to PyPI automatically when release PRs are merged
7+
#
8+
# MANUAL PUBLISHING (via workflow_dispatch):
9+
# - Can be triggered manually from the Actions tab
10+
# - Allows publishing a specific package to PyPI
11+
# - Supports dry-run mode
12+
#
13+
name: release-please
214

315
on:
416
push:
5-
branches: [ main ]
17+
branches:
18+
- main
19+
workflow_dispatch:
20+
inputs:
21+
workspace_path:
22+
description: 'The workspace to publish'
23+
required: true
24+
default: 'packages/sdk/server-ai'
25+
type: choice
26+
options:
27+
- packages/sdk/server-ai
28+
- packages/ai-providers/server-ai-langchain
29+
dry_run:
30+
description: 'Is this a dry run. If so no package will be published.'
31+
type: boolean
32+
required: true
633

734
jobs:
8-
release-package:
35+
release-please:
936
runs-on: ubuntu-latest
10-
permissions:
11-
id-token: write # Needed if using OIDC to get release secrets.
12-
contents: write # Contents and pull-requests are for release-please to make releases.
13-
pull-requests: write
37+
if: github.event_name == 'push'
1438
outputs:
15-
release-created: ${{ steps.release.outputs.release_created }}
16-
upload-tag-name: ${{ steps.release.outputs.tag_name }}
17-
package-hashes: ${{ steps.build.outputs.package-hashes}}
39+
package-server-ai-released: ${{ steps.release.outputs['packages/sdk/server-ai--release_created'] }}
40+
package-server-ai-langchain-released: ${{ steps.release.outputs['packages/ai-providers/server-ai-langchain--release_created'] }}
1841
steps:
1942
- uses: googleapis/release-please-action@v4
2043
id: release
44+
with:
45+
token: ${{secrets.GITHUB_TOKEN}}
2146

47+
release-server-ai:
48+
runs-on: ubuntu-latest
49+
needs: ['release-please']
50+
permissions:
51+
id-token: write
52+
contents: write
53+
if: ${{ needs.release-please.outputs.package-server-ai-released == 'true' }}
54+
steps:
2255
- uses: actions/checkout@v4
23-
if: ${{ steps.release.outputs.releases_created == 'true' }}
2456
with:
25-
fetch-depth: 0 # If you only need the current version keep this.
57+
fetch-depth: 0
2658

2759
- uses: actions/setup-python@v5
28-
if: ${{ steps.release.outputs.releases_created == 'true' }}
2960
with:
30-
python-version: 3.9
61+
python-version: '3.11'
3162

3263
- name: Install poetry
33-
if: ${{ steps.release.outputs.releases_created == 'true' }}
3464
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
3565

66+
- uses: ./.github/actions/ci
67+
with:
68+
workspace_path: packages/sdk/server-ai
69+
70+
- uses: ./.github/actions/build
71+
id: build
72+
with:
73+
workspace_path: packages/sdk/server-ai
74+
3675
- uses: launchdarkly/gh-actions/actions/[email protected]
37-
if: ${{ steps.release.outputs.releases_created == 'true' }}
3876
name: 'Get PyPI token'
3977
with:
4078
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
4179
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
4280

81+
- name: Publish to PyPI
82+
uses: pypa/gh-action-pypi-publish@release/v1
83+
with:
84+
password: ${{ env.PYPI_AUTH_TOKEN }}
85+
packages-dir: packages/sdk/server-ai/dist/
86+
87+
release-server-ai-langchain:
88+
runs-on: ubuntu-latest
89+
needs: ['release-please', 'release-server-ai']
90+
permissions:
91+
id-token: write
92+
contents: write
93+
if: ${{ always() && !failure() && !cancelled() && needs.release-please.outputs.package-server-ai-langchain-released == 'true' }}
94+
steps:
95+
- uses: actions/checkout@v4
96+
with:
97+
fetch-depth: 0
98+
99+
- uses: actions/setup-python@v5
100+
with:
101+
python-version: '3.11'
102+
103+
- name: Install poetry
104+
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
105+
106+
- uses: ./.github/actions/ci
107+
with:
108+
workspace_path: packages/ai-providers/server-ai-langchain
109+
43110
- uses: ./.github/actions/build
44111
id: build
45-
if: ${{ steps.release.outputs.releases_created == 'true' }}
112+
with:
113+
workspace_path: packages/ai-providers/server-ai-langchain
46114

47-
- uses: ./.github/actions/build-docs
48-
if: ${{ steps.release.outputs.releases_created == 'true' }}
115+
- uses: launchdarkly/gh-actions/actions/[email protected]
116+
name: 'Get PyPI token'
117+
with:
118+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
119+
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
49120

50-
- name: Publish package distributions to PyPI
51-
if: ${{ steps.release.outputs.releases_created == 'true' }}
121+
- name: Publish to PyPI
52122
uses: pypa/gh-action-pypi-publish@release/v1
53123
with:
54-
password: ${{env.PYPI_AUTH_TOKEN}}
124+
password: ${{ env.PYPI_AUTH_TOKEN }}
125+
packages-dir: packages/ai-providers/server-ai-langchain/dist/
55126

56-
release-provenance:
57-
needs: [ 'release-package' ]
58-
if: ${{ needs.release-package.outputs.release-created == 'true' }}
127+
manual-publish:
128+
runs-on: ubuntu-latest
129+
if: github.event_name == 'workflow_dispatch'
59130
permissions:
60-
actions: read
61131
id-token: write
62-
contents: write
63-
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
64-
with:
65-
base64-subjects: "${{ needs.release-package.outputs.package-hashes }}"
66-
upload-assets: true
67-
upload-tag-name: ${{ needs.release-package.outputs.upload-tag-name }}
132+
contents: read
133+
steps:
134+
- uses: actions/checkout@v4
135+
136+
- uses: actions/setup-python@v5
137+
with:
138+
python-version: '3.11'
139+
140+
- name: Install poetry
141+
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
142+
143+
- uses: ./.github/actions/ci
144+
with:
145+
workspace_path: ${{ inputs.workspace_path }}
146+
147+
- uses: ./.github/actions/build
148+
id: build
149+
with:
150+
workspace_path: ${{ inputs.workspace_path }}
151+
152+
- uses: launchdarkly/gh-actions/actions/[email protected]
153+
if: ${{ inputs.dry_run != true }}
154+
name: 'Get PyPI token'
155+
with:
156+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
157+
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
158+
159+
- name: Publish to PyPI
160+
if: ${{ inputs.dry_run != true }}
161+
uses: pypa/gh-action-pypi-publish@release/v1
162+
with:
163+
password: ${{ env.PYPI_AUTH_TOKEN }}
164+
packages-dir: ${{ inputs.workspace_path }}/dist/

0 commit comments

Comments
 (0)