Skip to content

Commit be1443e

Browse files
committed
Move to packages folder
1 parent 43d2b54 commit be1443e

32 files changed

+4456
-81
lines changed

.github/actions/build/action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: Build distribution files
22
description: 'Build distribution files'
3+
inputs:
4+
package-path:
5+
description: 'Path to the package to build'
6+
required: false
7+
default: '.'
38
outputs:
49
package-hashes:
510
description: "base64-encoded sha256 hashes of distribution files"
@@ -10,10 +15,11 @@ runs:
1015
steps:
1116
- name: Build distribution files
1217
shell: bash
18+
working-directory: ${{ inputs.package-path }}
1319
run: poetry build
1420
- name: Hash build files for provenance
1521
id: package-hashes
1622
shell: bash
17-
working-directory: ./dist
23+
working-directory: ${{ inputs.package-path }}/dist
1824
run: |
1925
echo "package-hashes=$(sha256sum * | base64 -w0)" >> "$GITHUB_OUTPUT"

.github/workflows/manual-publish.yml

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@ name: Publish Package
22
on:
33
workflow_dispatch:
44
inputs:
5+
package:
6+
description: 'Which package to publish'
7+
required: true
8+
type: choice
9+
options:
10+
- core
11+
- langchain
12+
- both
513
dry_run:
614
description: 'Is this a dry run? If so no package will be published.'
715
type: boolean
816
required: true
917

1018
jobs:
11-
build-publish:
19+
publish-core:
20+
if: ${{ inputs.package == 'core' || inputs.package == 'both' }}
1221
runs-on: ubuntu-latest
13-
# Needed to get tokens during publishing.
1422
permissions:
1523
id-token: write
1624
contents: read
17-
outputs:
18-
package-hashes: ${{ steps.build.outputs.package-hashes}}
1925
steps:
2026
- uses: actions/checkout@v4
2127

@@ -34,20 +40,46 @@ jobs:
3440

3541
- uses: ./.github/actions/build
3642
id: build
43+
with:
44+
package-path: packages/core
3745

38-
- name: Publish package distributions to PyPI
46+
- name: Publish core package to PyPI
3947
if: ${{ inputs.dry_run == false }}
4048
uses: pypa/gh-action-pypi-publish@release/v1
4149
with:
42-
password: ${{env.PYPI_AUTH_TOKEN}}
50+
password: ${{ env.PYPI_AUTH_TOKEN }}
51+
packages-dir: packages/core/dist/
4352

44-
release-provenance:
45-
needs: [ 'build-publish' ]
53+
publish-langchain:
54+
if: ${{ inputs.package == 'langchain' || inputs.package == 'both' }}
55+
runs-on: ubuntu-latest
4656
permissions:
47-
actions: read
4857
id-token: write
49-
contents: write
50-
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
51-
with:
52-
base64-subjects: "${{ needs.build-publish.outputs.package-hashes }}"
53-
upload-assets: ${{ !inputs.dry_run }}
58+
contents: read
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- uses: actions/setup-python@v5
63+
with:
64+
python-version: 3.9
65+
66+
- name: Install poetry
67+
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
68+
69+
- uses: launchdarkly/gh-actions/actions/[email protected]
70+
name: 'Get PyPI token'
71+
with:
72+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
73+
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
74+
75+
- uses: ./.github/actions/build
76+
id: build
77+
with:
78+
package-path: packages/langchain
79+
80+
- name: Publish langchain package to PyPI
81+
if: ${{ inputs.dry_run == false }}
82+
uses: pypa/gh-action-pypi-publish@release/v1
83+
with:
84+
password: ${{ env.PYPI_AUTH_TOKEN }}
85+
packages-dir: packages/langchain/dist/

.github/workflows/release-please.yml

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,88 @@ on:
55
branches: [ main ]
66

77
jobs:
8-
release-package:
8+
release-please:
99
runs-on: ubuntu-latest
1010
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.
11+
contents: write
1312
pull-requests: write
1413
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}}
14+
releases_created: ${{ steps.release.outputs.releases_created }}
15+
core_release_created: ${{ steps.release.outputs['packages/core--release_created'] }}
16+
langchain_release_created: ${{ steps.release.outputs['packages/langchain--release_created'] }}
1817
steps:
1918
- uses: googleapis/release-please-action@v4
2019
id: release
20+
with:
21+
config-file: release-please-config.json
22+
manifest-file: .release-please-manifest.json
2123

24+
release-core:
25+
needs: release-please
26+
if: ${{ needs.release-please.outputs.core_release_created == 'true' }}
27+
runs-on: ubuntu-latest
28+
permissions:
29+
id-token: write
30+
contents: write
31+
steps:
2232
- uses: actions/checkout@v4
23-
if: ${{ steps.release.outputs.releases_created == 'true' }}
24-
with:
25-
fetch-depth: 0 # If you only need the current version keep this.
2633

2734
- uses: actions/setup-python@v5
28-
if: ${{ steps.release.outputs.releases_created == 'true' }}
2935
with:
3036
python-version: 3.9
3137

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

3641
- uses: launchdarkly/gh-actions/actions/[email protected]
37-
if: ${{ steps.release.outputs.releases_created == 'true' }}
3842
name: 'Get PyPI token'
3943
with:
4044
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
4145
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
4246

4347
- uses: ./.github/actions/build
4448
id: build
45-
if: ${{ steps.release.outputs.releases_created == 'true' }}
49+
with:
50+
package-path: packages/core
4651

4752
- uses: ./.github/actions/build-docs
48-
if: ${{ steps.release.outputs.releases_created == 'true' }}
4953

50-
- name: Publish package distributions to PyPI
51-
if: ${{ steps.release.outputs.releases_created == 'true' }}
54+
- name: Publish core package to PyPI
5255
uses: pypa/gh-action-pypi-publish@release/v1
5356
with:
54-
password: ${{env.PYPI_AUTH_TOKEN}}
57+
password: ${{ env.PYPI_AUTH_TOKEN }}
58+
packages-dir: packages/core/dist/
5559

56-
release-provenance:
57-
needs: [ 'release-package' ]
58-
if: ${{ needs.release-package.outputs.release-created == 'true' }}
60+
release-langchain:
61+
needs: release-please
62+
if: ${{ needs.release-please.outputs.langchain_release_created == 'true' }}
63+
runs-on: ubuntu-latest
5964
permissions:
60-
actions: read
6165
id-token: write
6266
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 }}
67+
steps:
68+
- uses: actions/checkout@v4
69+
70+
- uses: actions/setup-python@v5
71+
with:
72+
python-version: 3.9
73+
74+
- name: Install poetry
75+
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
76+
77+
- uses: launchdarkly/gh-actions/actions/[email protected]
78+
name: 'Get PyPI token'
79+
with:
80+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
81+
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
82+
83+
- uses: ./.github/actions/build
84+
id: build
85+
with:
86+
package-path: packages/langchain
87+
88+
- name: Publish langchain package to PyPI
89+
uses: pypa/gh-action-pypi-publish@release/v1
90+
with:
91+
password: ${{ env.PYPI_AUTH_TOKEN }}
92+
packages-dir: packages/langchain/dist/

.release-please-manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
".": "0.10.1"
2+
"packages/core": "0.10.1",
3+
"packages/langchain": "0.1.0"
34
}

Makefile

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,67 @@ help: #! Show this help message
1414
@grep -h -F '#!' $(MAKEFILE_LIST) | grep -v grep | sed 's/:.*#!/:/' | column -t -s":"
1515

1616
.PHONY: install
17-
install:
18-
@poetry install
17+
install: #! Install all packages
18+
@echo "Installing core package..."
19+
@cd packages/core && poetry install
20+
@echo "Installing langchain package..."
21+
@cd packages/langchain && poetry install
22+
23+
.PHONY: install-core
24+
install-core: #! Install core package only
25+
@cd packages/core && poetry install
26+
27+
.PHONY: install-langchain
28+
install-langchain: #! Install langchain package only
29+
@cd packages/langchain && poetry install
1930

2031
#
2132
# Quality control checks
2233
#
2334

2435
.PHONY: test
25-
test: #! Run unit tests
26-
test: install
27-
@poetry run pytest $(PYTEST_FLAGS)
36+
test: #! Run unit tests for all packages
37+
@echo "Testing core package..."
38+
@cd packages/core && poetry run pytest $(PYTEST_FLAGS)
39+
@echo "Testing langchain package..."
40+
@cd packages/langchain && poetry run pytest $(PYTEST_FLAGS)
41+
42+
.PHONY: test-core
43+
test-core: #! Run unit tests for core package
44+
@cd packages/core && poetry run pytest $(PYTEST_FLAGS)
45+
46+
.PHONY: test-langchain
47+
test-langchain: #! Run unit tests for langchain package
48+
@cd packages/langchain && poetry run pytest $(PYTEST_FLAGS)
2849

2950
.PHONY: lint
3051
lint: #! Run type analysis and linting checks
31-
lint: install
32-
@poetry run mypy ldai
33-
@poetry run isort --check --atomic ldai
34-
@poetry run pycodestyle ldai
52+
@echo "Linting core package..."
53+
@cd packages/core && poetry run mypy ldai
54+
@cd packages/core && poetry run isort --check --atomic ldai
55+
@cd packages/core && poetry run pycodestyle ldai
56+
57+
.PHONY: build
58+
build: #! Build all packages
59+
@echo "Building core package..."
60+
@cd packages/core && poetry build
61+
@echo "Building langchain package..."
62+
@cd packages/langchain && poetry build
63+
64+
.PHONY: build-core
65+
build-core: #! Build core package
66+
@cd packages/core && poetry build
67+
68+
.PHONY: build-langchain
69+
build-langchain: #! Build langchain package
70+
@cd packages/langchain && poetry build
3571

3672
#
3773
# Documentation generation
3874
#
3975

4076
.PHONY: docs
4177
docs: #! Generate sphinx-based documentation
42-
@poetry install --with docs
78+
@cd packages/core && poetry install --with docs
4379
@cd docs
44-
@poetry run $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
80+
@cd packages/core && poetry run $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

0 commit comments

Comments
 (0)