Skip to content

Run test on PR (API) #97

Run test on PR (API)

Run test on PR (API) #97

Workflow file for this run

name: PR Checks (API)
run-name: Run test on PR ${{ github.event.number }} (API)
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review, converted_to_draft]
push:
branches: [main]
workflow_dispatch:
jobs:
test-ci:
runs-on: ubuntu-latest
environment: dev
strategy:
matrix:
node-version: [20.x]
steps:
- name: Checkout
uses: actions/checkout@v4
### Install if no cache exists ###
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- run: yarn install --silent --frozen-lockfile
### 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@v4
with:
path: |
.aws-sam
key: ${{ github.sha }}-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@v4.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
### Run Tests
- name: Run Tests
env:
TABLE_NAME: Reserve-Rec-tests
IS_OFFLINE: true
DYNAMODB_ENDPOINT_URL: http://127.0.0.1:8000
AWS_REGION: local-env
AWS_ACCESS_KEY_ID: notused
AWS_SECRET_ACCESS_KEY: notused
run: ./node_modules/jest/bin/jest.js --coverage --runInBand