Skip to content

Commit

Permalink
Merge pull request #97 from FullStackWithLawrence/next
Browse files Browse the repository at this point in the history
Add validations for local Github Actions
  • Loading branch information
lpm0073 authored Nov 17, 2023
2 parents a4bd894 + 98e74fa commit e1c9c47
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 15 deletions.
34 changes: 34 additions & 0 deletions .github/actions/tests/pre-commit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,45 @@ runs:
id: checkout
uses: actions/checkout@v4

- name: Check for pre-commit in requirements
run: |
if ! grep -q "pre-commit" ./requirements.txt; then
echo "pre-commit not found in requirements.txt" >&2
exit 1
fi
- name: Check for black in requirements
run: |
if ! grep -q "black" ./requirements.txt; then
echo "black not found in requirements.txt" >&2
exit 1
fi
- name: Check for flake8 in requirements
run: |
if ! grep -q "flake8" ./requirements.txt; then
echo "flake8 not found in requirements.txt" >&2
exit 1
fi
- name: Check for flake8-coding in requirements
run: |
if ! grep -q "flake8-coding" ./requirements.txt; then
echo "flake8-coding not found in requirements.txt" >&2
exit 1
fi
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install -r ./requirements.txt
# see: https://pre-commit.ci/lite.html
- name: pre-commit ci
id: pre-commit-ci
Expand Down
69 changes: 64 additions & 5 deletions .github/actions/tests/python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,81 @@ runs:
id: checkout
uses: actions/checkout@v4

- name: Verify OPENAI_API_ORGANIZATION
shell: bash
run: |
if [[ -z "${{ secrets.OPENAI_API_ORGANIZATION }}" ]]; then
echo "OPENAI_API_ORGANIZATION is not set" >&2
exit 1
fi
- name: Verify OPENAI_API_KEY
shell: bash
run: |
if [[ -z "${{ secrets.OPENAI_API_KEY }}" ]]; then
echo "OPENAI_API_KEY is not set" >&2
exit 1
fi
- name: Verify PINECONE_API_KEY
shell: bash
run: |
if [[ -z "${{ secrets.PINECONE_API_KEY }}" ]]; then
echo "PINECONE_API_KEY is not set" >&2
exit 1
fi
- name: Verify PINECONE_ENVIRONMENT
shell: bash
run: |
if [[ -z "${{ secrets.PINECONE_ENVIRONMENT }}" ]]; then
echo "PINECONE_ENVIRONMENT is not set" >&2
exit 1
fi
- name: Check for openai in requirements
run: |
if ! grep -q "openai" ./requirements.txt; then
echo "openai not found in requirements.txt" >&2
exit 1
fi
- name: Check for langchain in requirements
run: |
if ! grep -q "langchain" ./requirements.txt; then
echo "langchain not found in requirements.txt" >&2
exit 1
fi
- name: Check for langchain-experimental in requirements
run: |
if ! grep -q "langchain-experimental" ./requirements.txt; then
echo "langchain-experimental not found in requirements.txt" >&2
exit 1
fi
- name: Check for pinecone-client in requirements
run: |
if ! grep -q "pinecone-client" ./requirements.txt; then
echo "pinecone-client not found in requirements.txt" >&2
exit 1
fi
- name: Set up Python
if: steps.file_changes.outputs.files_changed != '' || steps.file_changes.outputs.requirements_changed != ''
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }} }}}

- name: Install dependencies
if: steps.file_changes.outputs.files_changed != '' || steps.file_changes.outputs.requirements_changed != ''
shell: bash
run: |
python -m pip install --upgrade pip
pip install -r ./requirements.txt
pip install -r ${{ env.REQUIREMENTS_PATH }}
cp -R ./api/terraform/python/layer_genai/openai_utils venv/lib/python${{ inputs.python-version }}/site-packages/
- name: Create .env
if: steps.file_changes.outputs.files_changed != '' || steps.file_changes.outputs.requirements_changed != ''
shell: bash
run: |
touch ./.env
echo "OPENAI_API_ORGANIZATION=${{ secrets.OPENAI_API_ORGANIZATION }}" >> ./.env
Expand All @@ -44,13 +103,13 @@ runs:
echo "PINECONE_ENVIRONMENT=${{ secrets.PINECONE_ENVIRONMENT }}" >> ./.env
- name: Test lambda_openai_v2
if: steps.file_changes.outputs.files_changed != '' || steps.file_changes.outputs.requirements_changed != ''
shell: bash
run: |
cd ./api/terraform/python/lambda_openai_v2
pytest -v -s tests/
- name: Test lambda_langchain
if: steps.file_changes.outputs.files_changed != '' || steps.file_changes.outputs.requirements_changed != ''
shell: bash
run: |
cd ./api/terraform/python/lambda_langchain
pytest -v -s tests/
7 changes: 1 addition & 6 deletions .github/actions/tests/reactjs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ runs:
id: checkout
uses: actions/checkout@v4

- name: Check for ReactJS files changed
id: file_changes
run: |
echo "::set-output name=reactjs_files_changed::$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '^client/' || true)"
- name: Run ReactJS Tests
if: steps.file_changes.outputs.reactjs_files_changed != ''
id: reactjs_tests
shell: bash
run: |
echo "Test scaffolding for ReactJS"
39 changes: 35 additions & 4 deletions .github/actions/tests/terraform/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,59 @@ runs:
id: checkout
uses: actions/checkout@v4

- name: Verify AWS_ACCESS_KEY_ID
shell: bash
run: |
if [[ -z "${{ secrets.AWS_ACCESS_KEY_ID }}" ]]; then
echo "AWS_ACCESS_KEY_ID is not set" >&2
exit 1
fi
- name: Verify AWS_SECRET_ACCESS_KEY
shell: bash
run: |
if [[ -z "${{ secrets.AWS_SECRET_ACCESS_KEY }}" ]]; then
echo "AWS_SECRET_ACCESS_KEY is not set" >&2
exit 1
fi
- name: Verify AWS_REGION
shell: bash
run: |
if [[ -z "${{ secrets.AWS_REGION }}" ]]; then
echo "AWS_REGION is not set" >&2
exit 1
fi
- name: Verify Terraform is installed
run: |
if ! command -v terraform &> /dev/null
then
echo "Terraform could not be found"
exit 1
fi
- name: Configure AWS credentials
if: steps.file_changes.outputs.terraform_files_changed != ''
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Terraform Init
if: steps.file_changes.outputs.terraform_files_changed != ''
shell: bash
run: |
cd api/terraform
terraform init
- name: Terraform Validate
if: steps.file_changes.outputs.terraform_files_changed != ''
shell: bash
run: |
cd api/terraform
terraform validate
- name: Terraform Format
if: steps.file_changes.outputs.terraform_files_changed != ''
shell: bash
run: |
cd api/terraform
terraform fmt -check

0 comments on commit e1c9c47

Please sign in to comment.