-
Notifications
You must be signed in to change notification settings - Fork 3
106 lines (103 loc) · 3.22 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: CI
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
defaults:
run:
shell: bash -l {0}
env:
CACHE_NUMBER: 1
jobs:
unit-test-frontend2:
name: Frontend2 linting / unit tests
# Defines the type of runner the job runs on
runs-on: ubuntu-latest
steps:
- name: Checkout to the repository
uses: actions/checkout@v3
- name: Set up NodeJS environment
uses: actions/setup-node@v3
with:
node-version: '18.11.0'
# Consider this as an add on to optimize the execution of actions
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
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 package dependencies
run: npm install
working-directory: ./frontend2
- name: Check linting and formatting
# Custom script for checking the linting and formatting being in place
run: npm run lint
working-directory: ./frontend2
# Run test cases and this could ensure minimum coverage as well if set
- name: Execute test cases
run: npm run test
working-directory: ./frontend2
lint:
name: Linter (pre-commit)
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout branch
uses: actions/checkout@v3.1.0
- name: Cache conda
uses: actions/cache@v3.0.11
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment-dev.yml') }}
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v2.2.0
with:
environment-file: environment-dev.yml
use-only-tar-bz2: true
- name: Run linter
run: |
pre-commit install
pre-commit run -a
unit-test-backend:
name: Backend unit tests
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout branch
uses: actions/checkout@v3.1.0
- name: Cache conda
uses: actions/cache@v3.0.11
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment-dev.yml') }}
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v2.2.0
with:
environment-file: environment-dev.yml
use-only-tar-bz2: true
- name: Initialize migrations
run: ./manage.py makemigrations
working-directory: ./backend
- name: Run tests
run: find * -type f -name "test*.py" | sed "s/\.py$//g" | sed "s/\//./g" | xargs coverage run --branch --source='.' ./manage.py test -v=2
working-directory: ./backend
- name: Report coverage
run: coverage report
working-directory: ./backend