Skip to content

Run all tests in GitHub Actions #9

Run all tests in GitHub Actions

Run all tests in GitHub Actions #9

name: Test & Deploy to AWS
on:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Install Playwright
run: npx playwright install --with-deps chromium
- name: Run ALL tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
SQS_URL: ${{ secrets.SQS_URL }}
SQS_RESULTADO_URL: ${{ secrets.SQS_RESULTADO_URL }}
SQS_DLQ_URL: ${{ secrets.SQS_DLQ_URL }}
OPENWEATHER_API_KEY: ${{ secrets.OPENWEATHER_API_KEY }}
API_GATEWAY_URL: ${{ secrets.API_GATEWAY_URL }}
run: npx playwright test --project=chromium --retries=2
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
if-no-files-found: warn
deploy-lambda:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- 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: us-east-1
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Deploy Lambdas
run: |
if [ -d "lambda" ]; then
cd lambda
npm install --production
if [ -f "index.js" ]; then
zip -r clima.zip index.js node_modules/
aws lambda update-function-code --function-name Clima --zip-file fileb://clima.zip || true
fi
if [ -f "apiGatewayHandler.js" ]; then
zip -r api.zip apiGatewayHandler.js node_modules/
aws lambda update-function-code --function-name apiGatewayClima --zip-file fileb://api.zip || true
fi
fi