Skip to content

Enhance Jest unit tests and code coverage #32

Enhance Jest unit tests and code coverage

Enhance Jest unit tests and code coverage #32

Workflow file for this run

name: ci-node.js
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
test:
name: Build and Test
runs-on: ubuntu-22.04
strategy:
matrix:
node: [18, 20]
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
with:
version: 8
- uses: actions/setup-node@v4
name: Use Node.js ${{ matrix.node }}
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Cache pnpm modules
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
run: pnpm install
- name: Start LocalStack
uses: LocalStack/setup-localstack@main
with:
image-tag: 'latest'
install-awslocal: 'true'
configuration: |
SERVICES=s3,DEBUG=1,SKIP_SSL_CERT_DOWNLOAD=1,AWS_REGION=us-east-1,AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }},AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Check LocalStack readiness
run: |
while ! nc -z localhost 4566; do
echo "Waiting for LocalStack to be ready..."
sleep 1
done
echo "LocalStack is ready for use!"
- name: Run tests with coverage
run: pnpm run test:coverage
env:
IS_OFFLINE: true
AWS_ENDPOINT_URL: http://s3.localhost.localstack.cloud:4566
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
- uses: codecov/codecov-action@v3
name: Upload coverage reports to Codecov
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage
files: ./coverage/cobertura-coverage.xml
fail_ci_if_error: true
verbose: true