-
Notifications
You must be signed in to change notification settings - Fork 306
96 lines (77 loc) · 2.55 KB
/
ci-cd.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
name: CI/CD Pipeline
on:
push:
branches:
- release-8.0.0
pull_request:
branches:
- release-8.0.0
jobs:
build-and-test:
runs-on: ubuntu-latest
services:
docker:
image: docker:19.03.12
options: --privileged
ports:
- 3000:3000
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18.20.2
- name: Build client
working-directory: src/app/client
run: |
rm -rf node_modules yarn.lock
yarn cache clean
yarn install --no-progress --production=true
npm run build
- name: Prepare server files
run: |
mkdir -p /usr/src/app/app_dist
cp -r src/app/libs src/app/helpers src/app/proxy src/app/resourcebundles src/app/package.json src/app/framework.config.js src/app/sunbird-plugins src/app/routes src/app/constants src/app/controllers src/app/server.js /usr/src/app/app_dist/
- name: Install server dependencies
working-directory: /usr/src/app/app_dist
run: yarn install --ignore-engines --no-progress --production=true
- name: Build Docker image
run: docker build -t myapp:latest .
- name: Run Docker container
run: docker run -d -p 3000:3000 myapp:latest
- name: Check application status
run: |
sleep 10
curl --retry 10 --retry-delay 5 -v http://localhost:3000
- name: Set up Node.js for tests
uses: actions/setup-node@v3
with:
node-version: 18.20.2
- name: Install prerequisites
working-directory: src/app/client
run: node --version
- name: Ignore engines
working-directory: src/app/client
run: yarn config set ignore-engines true
- name: Install npm dependencies
working-directory: src/app/client
run: yarn install
- name: Save cache
uses: actions/cache@v3
with:
path: src/app/client/node_modules
key: dependency-cache-portal-${{ hashFiles('src/app/client/package.json') }}
- name: Run tests using JEST
working-directory: src/app/client
run: npm run test:ci
- name: Install Sonar Scanner
run: |
cd /tmp
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
sudo apt-get install -y unzip
unzip sonar-scanner-cli-5.0.1.3006-linux.zip
- name: Run Sonar Scanner
run: |
cd src/app/client
/tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner