Skip to content

SKIL-505

SKIL-505 #119

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- "master"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache-dependency-path: FrontEndReact/package.json
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache jest cache
uses: actions/cache@v4
env:
cache-name: jest-cache
with:
path: /tmp/jest-cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('FrontEndReact/**/*.js', 'FrontEndReact/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Build backend
run: docker compose build backend
# TODO: Run pytests here using docker compose run or something
- name: Start backend
run: |
docker compose up --no-build --detach backend
sleep 5
curl -v 'http://127.0.0.1:5050/api'
# Use curl to make sure the backend is up and accessible
- name: Install Node dependencies
run: |
cd FrontEndReact
npm install
- name: Run ESLint
run: |
cd FrontEndReact
npx eslint --max-warnings=0 .
- name: Run Jest tests
run: |
cd FrontEndReact
npm test -- --all --cacheDirectory /tmp/jest-cache --setupFiles ./jest-ci-setup.js --setupFiles ./node_modules/react-app-polyfill/jsdom.js
# See FrontEndReact/jest-ci-setup.js for the rationale behind the --setupFiles ./jest-ci-setup.js hack
# The ./node_modules/react-app-polyfill/jsdom.js setup file is enabled by default, but
# using any setupFiles args overrides the defaults so I have to add it
# manually
env:
REACT_APP_API_URL: "http://127.0.0.1:5050/api"