-
Notifications
You must be signed in to change notification settings - Fork 9
97 lines (79 loc) · 3.03 KB
/
node.js.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
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
env:
NODE_ENV: test
ECOBALYSE_DATA_DIR: ./ecobalyse-private
on:
push:
branches: [ master, staging ]
pull_request:
branches: [ master, staging ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
python-version: [3.12]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pipenv'
- name: Cache node_modules
id: cache-node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('package.json', 'package-lock.json') }}
- name: Cache ~/.elm
# see https://docs.microsoft.com/en-us/answers/questions/510640/deploy-elm-app-to-azure-static-website-from-github.html
uses: actions/cache@v4
with:
path: ~/.elm
key: elm-cache-${{ hashFiles('elm.json') }}
restore-keys: elm-cache-
- name: Install Node dependencies
run: npm ci --prefer-offline --no-audit
- name: Install Python dependencies
run: pip install pipenv && pipenv install -d
- name: Install Ubuntu dependencies
run: |
sudo apt-get update
sudo apt-get install -y gettext
- name: Clone the detailed impacts
run: |
eval `ssh-agent -s`
# Private ssh key used by this Github action to clone the private repo
# The corresponding public key must be set as a deploy key of the private repo
ssh-add - <<< '${{ secrets.PRIVATE_SSH_KEY }}'
git clone [email protected]:MTES-MCT/ecobalyse-private.git
- name: Checkout specific ecobalyse-private branch
if: ${{ github.event_name == 'pull_request' }}
env:
LAST_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_REST_ACCESS_TOKEN }}
run: |
eval `ssh-agent -s`
# Private ssh key used by this Github action to clone the private repo
# The corresponding public key must be set as a deploy key of the private repo
ssh-add - <<< '${{ secrets.PRIVATE_SSH_KEY }}'
pipenv run ./bin/checkout-ecobalyse-private-branch.sh $LAST_COMMIT_SHA
- name: Build app
run: npm run build --if-present
- name: Run prettier, openapi & ruff formatting check
run: npm run lint:all
- name: Run elm-review
run: npm run test:review
- name: Run client tests
run: npm run test:client
- name: Run server tests
run: pipenv run backend/update.sh && npm run test:server-ci && npm run test:backend