-
Notifications
You must be signed in to change notification settings - Fork 8
69 lines (56 loc) · 2.01 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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"