Implement database infra utilities and tests for api (#118, #122) #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: API CI | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
validate-n-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Check for changes | |
uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
api: | |
- 'api/**' | |
shared: | |
- 'shared/**' | |
- name: Check node_modules cache | |
id: deps-cache | |
uses: martijnhols/actions-cache/check@v3 | |
env: | |
cache-name: api-deps-cache | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install Dependencies | |
if: steps.deps-cache.outputs.cache-hit != 'true' | |
run: | | |
cd api | |
npm install | |
- name: Cache node modules | |
if: steps.deps-cache.outputs.cache-hit != 'true' | |
uses: actions/cache@v3 | |
env: | |
cache-name: api-deps-cache | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Validate API | |
if: steps.filter.outputs.api == 'true' || steps.filter.outputs.shared == 'true' | |
run: | | |
cd api | |
npm test:unit | |
- name: Build the Docker image for API | |
if: steps.filter.outputs.api == 'true' || steps.filter.outputs.shared == 'true' | |
run: docker build . --file ./api/Dockerfile |