-
Notifications
You must be signed in to change notification settings - Fork 76
149 lines (126 loc) · 4.09 KB
/
pr-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
name: PR Build
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
paths:
- 'Java/**'
- 'JS/**'
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
java: ${{ steps.filter.outputs.java }}
js: ${{ steps.filter.outputs.js }}
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
java:
- 'Java/**'
js:
- 'JS/**'
java:
needs: changes
if: ${{ needs.changes.outputs.java == 'true' }}
runs-on: ubuntu-latest
outputs:
VALUE: ${{ steps.set_short_hash.outputs.VALUE }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set SHORT_HASH
id: set_short_hash
run: |
echo "::set-output name=VALUE::${{ github.sha }}"
echo "RELEASE_TAG=${{ github.sha }}-$(TZ=UTC-8 date +"%Y.%m.%d")" >> $GITHUB_ENV
- name: Goto Java folder
run: cd Java
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: Set up Maven
uses: stCarolas/[email protected]
with:
maven-version: 3.9.3
- name: Create output folder
run: mkdir -p Java/FlySpring/edgechain-app/BuildOutput
- name: Build edgechain-app project
working-directory: Java/FlySpring/edgechain-app
run: mvn clean package -DskipTests
- name: Run edgechain testcases
working-directory: Java/FlySpring/edgechain-app
run: mvn test
- name: Copy edgechain-app JAR to BuildOutput
run: cp Java/FlySpring/edgechain-app/target/edgechain.jar Java/FlySpring/edgechain-app/BuildOutput
js:
needs: changes
if: ${{ needs.changes.outputs.js == 'true' }}
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install Prettier
run: npm install prettier
- name: Install ESLint
run: >
npm install eslint@latest &&
npm install @microsoft/eslint-formatter-sarif@latest eslint-config-google@latest eslint-plugin-import@latest @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest eslint-config-prettier@latest eslint-plugin-prettier@latest
- name: Get cache date
id: get-date
run: echo "name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash
- name: ESLint Cache
uses: actions/cache@v3
with:
path: ./.eslintcache
key: ${{ runner.os }}-eslintcache-${{ hashFiles('./eslintcache') }}
restore-keys: |
${{ runner.os }}-eslintcache-
- name: Run ESLint
run: npx eslint JS
--fix
--cache
--config JS/.eslintrc.js
--ext .js,.jsx,.ts,.tsx
continue-on-error: true
- name: Run Prettiers
run: npx prettier --tab-width 4 --print-width 100 --trailing-comma es5 --ignore-path "$(CURDIR)/.prettierignore" --write JS/
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Automatically applying Prettier changes
commit_user_name: GitHub Actions
commit_user_email: [email protected]
commit_author: GitHub Actions <[email protected]>
branch: ts
- name: Checkout repository
uses: actions/checkout@v3
- name: Goto JS folder
run: cd JS/edgechains/lib
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
working-directory: JS/edgechains/lib
- name: Build edgechain-app project
run: npm run build
working-directory: JS/edgechains/lib
- name: Package edgechain-app project
run: npm pack
working-directory: JS/edgechains/lib