Skip to content

BRS-342: Tests and Trivy Update #252

BRS-342: Tests and Trivy Update

BRS-342: Tests and Trivy Update #252

Workflow file for this run

name: Run Tests
on: [pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
defaults:
run:
working-directory: "./arSam"
steps:
- name: Checkout
uses: actions/checkout@v3
# Install if no cache exists
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: "arSam/package-lock.json"
- run: npm install
# Setup AWS SAM
- name: Setup AWS SAM
uses: aws-actions/setup-sam@v2
with:
use-installer: true
# SAM Build
- name: Cache SAM Build
id: cache-sam-build
uses: actions/cache@v3
with:
path: |
arSam/.aws-sam
key: ${{ github.sha }}-ar-api-sam-cache
- name: Run sam build
if: steps.cache-sam-build.outputs.cache-hit != 'true'
run: |
sam build --cached --parallel
# Set up DynamoDB local
- name: Setup DynamoDB Local
uses: rrainn/dynamodb-action@v3.0.0
with:
sharedDb: true
port: 8000
cors: '*'
- name: Sleep so DynamoDB has time to wake up
uses: GuillaumeFalourd/wait-sleep-action@v1
with:
time: '15' # for 15 seconds
- name: List Jest Binary
run: ls ${{ github.workspace }}/arSam/node_modules/.bin
# Run Tests
- name: Run Tests
env:
TABLE_NAME: ParksAr-tests
IS_OFFLINE: true
ENDPOINT: http://localhost:8000
REGION: local
CONFIG_TABLE_NAME: ConfigAr-tests
NAME_CACHE_TABLE_NAME: NameCacheAr-tests
AWS_ACCESS_KEY_ID: notused
AWS_SECRET_ACCESS_KEY: notused
run: ./node_modules/jest/bin/jest.js --coverage --runInBand
working-directory: ./arSam