Skip to content

Commit

Permalink
Added job to run the lambda tests on localstack before staging and pr…
Browse files Browse the repository at this point in the history
…oduction deployment
  • Loading branch information
rohandudam committed Jul 21, 2023
1 parent 8b15b9f commit b567826
Showing 1 changed file with 46 additions and 3 deletions.
49 changes: 46 additions & 3 deletions .github/workflows/url_filtering_lambda_rohini.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,49 @@ on:
paths:
- 'url_filtering_lambda_rohini/**'
- '.github/workflows/url_filtering_lambda_rohini.yml'
- 'tests/docker-compose.yaml'
- 'tests/test_url_filter_lambda_on_localstack.py'
- 'tests/testutils.py'
jobs:
test-lambda:
name: Test Lambda on LocalStack
environment:
name: localstack-url-filter
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Start LocalStack
run: |
cd tests/
docker-compose -f docker-compose.yaml up -d
- name: Wait for LocalStack to be ready
run: |
timeout 300 bash -c 'until echo > /dev/tcp/localhost/4566; do sleep 1; done'
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8" # Replace with your desired Python version
- name: Install dependencies
run: |
cd tests/
pip install -r requirements.txt # Replace with your actual requirements file
- name: Run tests
run: |
cd tests/
pytest -v -s test_url_filter_lambda_on_localstack.py
- name: Stop LocalStack
run: |
cd tests/
docker-compose -f docker-compose.yaml down
deply-staging:
name: Deploy to staging
needs: test-lambda
if: contains(github.event.ref, '-sprint-')
environment:
name: staging-url-filter
Expand All @@ -28,16 +67,20 @@ jobs:
AWS_DEFAULT_REGION: ${{ secrets.REGION }}

deploy-production:
runs-on: ubuntu-latest
name: Deploy to production
needs: test-lambda
if: github.event.ref == 'refs/heads/master'
environment:
name: production-url-filter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Deploy code to Lambda
uses: qxf2/py-lambda-action@v1.0.3
with:
lambda_directory: 'url_filtering_lambda_rohini'
lambda_function_name: 'arn:aws:lambda:ap-south-1:285993504765:function:URLFilteringLambdaRohini'
lambda_layer_arn: 'arn:aws:lambda:ap-south-1:285993504765:layer:rohinilayer'
lambda_function_name: ${{secrets.ARN }}
lambda_layer_arn: ${{ secrets.LAYER_ARN }}
requirements_txt: 'url_filtering_lambda_rohini/requirements.txt'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down

0 comments on commit b567826

Please sign in to comment.