-
Notifications
You must be signed in to change notification settings - Fork 400
153 lines (131 loc) · 4.3 KB
/
build.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Build OpenEMS
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
build-java:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Java 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: gradle
- uses: kiancross/checkstyle-annotations-action@v1
- name: Build all Java packages
run: ./gradlew build
- name: Resolve OpenEMS bundles
run: ./gradlew resolve
- name: Validate BackendApp.bndrun
run: git diff --exit-code io.openems.backend.application/BackendApp.bndrun
- name: Validate EdgeApp.bndrun
run: git diff --exit-code io.openems.edge.application/EdgeApp.bndrun
#
# Generate Code-coverage-report
#
- name: Generate JaCoCo Code-coverage-report
run: ./gradlew jacocoTestReport
- name: Summarize JaCoCo Report
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
with:
jacoco-csv-file: 'io.openems.*/generated/reports/jacoco/**/*.csv'
generate-coverage-badge: false
- name: Create JaCoCo Badge
env:
PR_NUMBER: ${{ github.event.number }}
run: |
coverage=$(echo "scale=2; ${{ steps.jacoco.outputs.coverage }} * 100" | bc | cut -c1-4);
color=red;
if (( $(echo "$coverage > 90" | bc -l) )); then
color=success;
elif (( $(echo "$coverage > 80" | bc -l) )); then
color=green;
elif (( $(echo "$coverage > 60" | bc -l) )); then
color=yellow;
fi;
mkdir -p ./jacoco
echo $PR_NUMBER > ./jacoco/jacoco_report_number
echo '![Code Coverage]'"(https://img.shields.io/badge/Code%20Coverage-${coverage}%25-${color}?style=flat)" > ./jacoco/jacoco_report_badge
- uses: actions/upload-artifact@v3
with:
name: jacoco_report
path: jacoco/
#
# Is this a Tag? Prepare release assets
#
- name: Prepare Edge+Backend assets
if: startsWith(github.ref, 'refs/tags/')
run: ./gradlew buildEdge buildBackend
- name: Save build-artifacts
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
build/openems-edge.jar
build/openems-backend.jar
build-ui:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Setup Cache for Node.js
uses: actions/cache@v3
with:
path: |
~/.npm
~/.ng
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: Build OpenEMS UI
run: |
cd ui
npm install
npm ci --prefer-offline --cache ~/.npm
node_modules/.bin/ng config cli.cache.path "~/.ng"
node_modules/.bin/ng build -c "openems,openems-edge-prod,prod"
node_modules/.bin/ng lint
export CHROME_BIN=/usr/bin/google-chrome-stable
npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI
#
# Is this a Tag? Prepare release assets
#
- name: Prepare UI asset
if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir build
cd ui/target
zip -r ../../build/openems-ui.zip ./*
- name: Save build-artifacts
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: build/openems-ui.zip
#
# Is this a Tag? Create a draft release
#
release:
runs-on: ubuntu-latest
needs: [build-java, build-ui]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Load build-artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
path: build
- name: Create draft Release
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
build/openems-edge.jar
build/openems-backend.jar
build/openems-ui.zip