Skip to content

Commit 970d2b8

Browse files
authored
Merge pull request #100 from FullStackWithLawrence/next
Test Github Action unit tests
2 parents 5d72df8 + 6c5a4a1 commit 970d2b8

File tree

6 files changed

+63
-42
lines changed

6 files changed

+63
-42
lines changed

.github/actions/tests/pre-commit/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,31 @@ runs:
1919
uses: actions/checkout@v4
2020

2121
- name: Check for pre-commit in requirements
22+
shell: bash
2223
run: |
2324
if ! grep -q "pre-commit" ./requirements.txt; then
2425
echo "pre-commit not found in requirements.txt" >&2
2526
exit 1
2627
fi
2728
2829
- name: Check for black in requirements
30+
shell: bash
2931
run: |
3032
if ! grep -q "black" ./requirements.txt; then
3133
echo "black not found in requirements.txt" >&2
3234
exit 1
3335
fi
3436
3537
- name: Check for flake8 in requirements
38+
shell: bash
3639
run: |
3740
if ! grep -q "flake8" ./requirements.txt; then
3841
echo "flake8 not found in requirements.txt" >&2
3942
exit 1
4043
fi
4144
4245
- name: Check for flake8-coding in requirements
46+
shell: bash
4347
run: |
4448
if ! grep -q "flake8-coding" ./requirements.txt; then
4549
echo "flake8-coding not found in requirements.txt" >&2

.github/actions/tests/python/action.yml

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ inputs:
1010
description: 'The version of Python to use, such as 3.11.0'
1111
required: true
1212
type: string
13+
openai-api-organization:
14+
description: 'The OpenAI API organization'
15+
required: true
16+
type: string
17+
openai-api-key:
18+
description: 'The OpenAI API key'
19+
required: true
20+
type: string
21+
pinecone-api-key:
22+
description: 'The Pinecone API key'
23+
required: true
24+
type: string
25+
pinecone-environment:
26+
description: 'The Pinecone environment'
27+
required: true
28+
type: string
29+
1330
env:
1431
REQUIREMENTS_PATH: 'api/terraform/python/layer_genai/requirements.txt'
1532

@@ -20,60 +37,32 @@ runs:
2037
id: checkout
2138
uses: actions/checkout@v4
2239

23-
- name: Verify OPENAI_API_ORGANIZATION
24-
shell: bash
25-
run: |
26-
if [[ -z "${{ secrets.OPENAI_API_ORGANIZATION }}" ]]; then
27-
echo "OPENAI_API_ORGANIZATION is not set" >&2
28-
exit 1
29-
fi
30-
31-
- name: Verify OPENAI_API_KEY
32-
shell: bash
33-
run: |
34-
if [[ -z "${{ secrets.OPENAI_API_KEY }}" ]]; then
35-
echo "OPENAI_API_KEY is not set" >&2
36-
exit 1
37-
fi
38-
39-
- name: Verify PINECONE_API_KEY
40-
shell: bash
41-
run: |
42-
if [[ -z "${{ secrets.PINECONE_API_KEY }}" ]]; then
43-
echo "PINECONE_API_KEY is not set" >&2
44-
exit 1
45-
fi
46-
47-
- name: Verify PINECONE_ENVIRONMENT
48-
shell: bash
49-
run: |
50-
if [[ -z "${{ secrets.PINECONE_ENVIRONMENT }}" ]]; then
51-
echo "PINECONE_ENVIRONMENT is not set" >&2
52-
exit 1
53-
fi
54-
5540
- name: Check for openai in requirements
41+
shell: bash
5642
run: |
5743
if ! grep -q "openai" ./requirements.txt; then
5844
echo "openai not found in requirements.txt" >&2
5945
exit 1
6046
fi
6147
6248
- name: Check for langchain in requirements
49+
shell: bash
6350
run: |
6451
if ! grep -q "langchain" ./requirements.txt; then
6552
echo "langchain not found in requirements.txt" >&2
6653
exit 1
6754
fi
6855
6956
- name: Check for langchain-experimental in requirements
57+
shell: bash
7058
run: |
7159
if ! grep -q "langchain-experimental" ./requirements.txt; then
7260
echo "langchain-experimental not found in requirements.txt" >&2
7361
exit 1
7462
fi
7563
7664
- name: Check for pinecone-client in requirements
65+
shell: bash
7766
run: |
7867
if ! grep -q "pinecone-client" ./requirements.txt; then
7968
echo "pinecone-client not found in requirements.txt" >&2
@@ -83,24 +72,39 @@ runs:
8372
- name: Set up Python
8473
uses: actions/setup-python@v4
8574
with:
86-
python-version: ${{ inputs.python-version }} }}}
75+
python-version: ${{ inputs.python-version }}
8776

88-
- name: Install dependencies
77+
- name: locate site-packages path
78+
shell: bash
79+
run: |
80+
echo "SITE_PACKAGES_PATH=$(python -c 'import site; print(site.getsitepackages()[0])')" >> $GITHUB_ENV
81+
82+
- name: Install pip
8983
shell: bash
9084
run: |
9185
python -m pip install --upgrade pip
86+
87+
- name: Install dependencies
88+
shell: bash
89+
run: |
90+
cp -R ./api/terraform/python/layer_genai/openai_utils ${{ env.SITE_PACKAGES_PATH }}
9291
pip install -r ./requirements.txt
93-
pip install -r ${{ env.REQUIREMENTS_PATH }}
94-
cp -R ./api/terraform/python/layer_genai/openai_utils venv/lib/python${{ inputs.python-version }}/site-packages/
92+
env:
93+
SITE_PACKAGES_PATH: ${{ env.SITE_PACKAGES_PATH }}
9594

9695
- name: Create .env
9796
shell: bash
9897
run: |
9998
touch ./.env
100-
echo "OPENAI_API_ORGANIZATION=${{ secrets.OPENAI_API_ORGANIZATION }}" >> ./.env
101-
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> ./.env
102-
echo "PINECONE_API_KEY=${{ secrets.PINECONE_API_KEY }}" >> ./.env
103-
echo "PINECONE_ENVIRONMENT=${{ secrets.PINECONE_ENVIRONMENT }}" >> ./.env
99+
echo "OPENAI_API_ORGANIZATION=${{ env.OPENAI_API_ORGANIZATION }}" >> ./.env
100+
echo "OPENAI_API_KEY=${{ env.OPENAI_API_KEY }}" >> ./.env
101+
echo "PINECONE_API_KEY=${{ env.PINECONE_API_KEY }}" >> ./.env
102+
echo "PINECONE_ENVIRONMENT=${{ env.PINECONE_ENVIRONMENT }}" >> ./.env
103+
env:
104+
OPENAI_API_ORGANIZATION: ${{ inputs.openai-api-organization }}
105+
OPENAI_API_KEY: ${{ inputs.openai-api-key }}
106+
PINECONE_API_KEY: ${{ inputs.pinecone-api-key }}
107+
PINECONE_ENVIRONMENT: ${{ inputs.pinecone-environment }}
104108

105109
- name: Test lambda_openai_v2
106110
shell: bash

.github/workflows/pullRequestController.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ jobs:
118118
uses: ./.github/actions/tests/python
119119
with:
120120
python-version: "${{ env.python-version}}"
121+
openai-api-organization: "${{ secrets.OPENAI_API_ORGANIZATION }}"
122+
openai-api-key: "${{ secrets.OPENAI_API_KEY }}"
123+
pinecone-api-key: "${{ secrets.PINECONE_API_KEY }}"
124+
pinecone-environment: "${{ secrets.PINECONE_ENVIRONMENT }}"
121125

122126
terraform_tests:
123127
needs: check_for_pending_release

.github/workflows/runTests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jobs:
2020
uses: ./.github/actions/tests/python
2121
with:
2222
python-version: "${{ env.python-version}}"
23+
openai-api-organization: "${{ secrets.OPENAI_API_ORGANIZATION }}"
24+
openai-api-key: "${{ secrets.OPENAI_API_KEY }}"
25+
pinecone-api-key: "${{ secrets.PINECONE_API_KEY }}"
26+
pinecone-environment: "${{ secrets.PINECONE_ENVIRONMENT }}"
2327

2428
- name: Run Terraform tests
2529
uses: ./.github/actions/tests/reactjs

api/terraform/python/layer_genai/openai_utils/setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""Setup for openai_utils package."""
33
from setuptools import setup, find_packages
44

5-
from openai_utils.setup_utils import get_semantic_version
5+
from setup_utils import get_semantic_version
66

77
setup(
88
name="openai_utils",
@@ -11,5 +11,8 @@
1111
author="Lawrence McDaniel",
1212
author_email="[email protected]",
1313
packages=find_packages(),
14+
package_data={
15+
"openai_utils": ["*.md", "data/*"],
16+
},
1417
install_requires=["openai>=0.28"],
1518
)

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
boto3==1.29.2
1414
pytest==7.4.3
1515
pytest_mock==3.12.0
16+
black==23.11.0
1617
flake8==6.1.0
1718
flake8-coding==1.3.2
19+
pre-commit==3.5.0
1820

1921
# production
2022
# ------------
@@ -25,4 +27,4 @@ langchain-experimental==0.0.37
2527
pinecone-client==2.2.4
2628

2729
# local packages
28-
./api/terraform/python/layer_genai/openai_utils
30+
-e ./api/terraform/python/layer_genai/openai_utils

0 commit comments

Comments
 (0)