-
Notifications
You must be signed in to change notification settings - Fork 2.1k
238 lines (207 loc) · 8.64 KB
/
web-interface-check.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
name: <Web> Interface check
on: [pull_request]
# github.head_ref is only defined on pull_request events
concurrency:
group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
jobs:
interface_check:
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: '18.x'
- uses: actions/checkout@v4
name: Checkout Base Ref
with:
repository: ${{ github.event.pull_request.base.repo.full_name }}
ref: ${{ github.base_ref }}
path: './engine'
- name: Get Base Ref
working-directory: ./engine
run: |
echo "BASE_REF=$(git rev-parse HEAD)" >> $GITHUB_ENV
- run: |
echo "EXT_VERSION=$(node ./engine/.github/workflows/get-native-external-version.js)" >> $GITHUB_ENV
- uses: actions/checkout@v4
name: Download external
with:
repository: cocos/cocos-engine-external
path: './engine/native/external'
ref: "${{ env.EXT_VERSION }}"
fetch-depth: 1
- name: Build Base Declarations
working-directory: ./engine
run: |
npm install
if [ -e ./.github/workflows/package-size-check.js ]; then
node ./.github/workflows/package-size-check.js
fi
- name: Clear npm Cache
run: |
npm cache clean --force
- uses: actions/checkout@v4
name: Checkout Head Ref
with:
ref: 'refs/pull/${{ github.event.pull_request.number }}/head'
path: './engine-HEAD'
fetch-depth: 0
- name: Head merges base
working-directory: ./engine-HEAD
run: |
git config user.name "Cocos CI"
git config user.email "[email protected]"
echo "BASE_REF: ${{ env.BASE_REF }}"
HEAD_REF=$(git rev-parse HEAD)
echo "HEAD_REF: $HEAD_REF"
echo "--------------------------------------------------------"
echo "HEAD LOG:"
git --no-pager log -3
echo "--------------------------------------------------------"
git fetch origin ${{ env.BASE_REF }}
git reset --hard ${{ env.BASE_REF }}
echo "--------------------------------------------------------"
echo "BASE LOG:"
git --no-pager log -3
echo "--------------------------------------------------------"
CURRENT_REF=$(git rev-parse HEAD)
echo "---- $CURRENT_REF merges $HEAD_REF ----"
git merge $HEAD_REF
echo "--------------------------------------------------------"
echo "MERGED LOG:"
git --no-pager log -5
echo "--------------------------------------------------------"
- run: |
echo "EXT_VERSION_HEAD=$(node ./engine-HEAD/.github/workflows/get-native-external-version.js)" >> $GITHUB_ENV
- uses: actions/checkout@v4
name: Download external
with:
repository: cocos/cocos-engine-external
path: './engine-HEAD/native/external'
ref: "${{ env.EXT_VERSION_HEAD }}"
fetch-depth: 1
- name: Setup emsdk
uses: dumganhar/setup-emsdk@997d2cde2deabda085a11f98e86e842915b0e846
with:
version: 3.1.41
actions-cache-folder: 'emsdk-cache-3.1.41'
- name: Verify
run: |
which emcc
emcc -v
- name: Apply emscripten patches
run: |
echo "--------------------------------- Save bind.cpp ---------------------------------"
cp $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp.bak
echo "--------------------------------- Apply embind bind.cpp patches ---------------------------------"
cp -f ./engine-HEAD/.github/workflows/emscripten-patches/embind/bind.cpp $EMSDK/upstream/emscripten/system/lib/embind/
echo "--------------------------------- Apply patches DONE! ---------------------------------"
cat $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp
- name: Install ninja
run: |
if ! command -v ninja &> /dev/null; then
echo "Ninja not found, installing..."
# sudo apt update
sudo apt install ninja-build
else
echo "Ninja is already installed."
fi
which ninja
- name: Build Spine WASM
run: |
cd ./engine-HEAD/native/cocos/editor-support/spine-wasm
mkdir build-wasm
cd build-wasm
emcmake cmake .. -GNinja
ninja
ls -l
- name: Build Spine ASMJS
run: |
cd ./engine-HEAD/native/cocos/editor-support/spine-wasm
sed -i 's/set(BUILD_WASM 1)/set(BUILD_WASM 0)/g' CMakeLists.txt
mkdir build-asmjs
cd build-asmjs
emcmake cmake .. -GNinja
ninja
ls -l
- name: Copy files to external directory
run: |
mkdir dist
cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-wasm/spine.wasm ./dist/
cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-wasm/spine.js ./dist/spine.wasm.js
cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js.mem ./dist/
cp ./engine-HEAD/native/cocos/editor-support/spine-wasm/build-asmjs/spine.js ./dist/spine.asm.js
echo "-------- Before replace spine wasm -----------"
ls -l ./engine-HEAD/native/external/emscripten/spine/
cp -f ./dist/* ./engine-HEAD/native/external/emscripten/spine/
echo "-------- After replace spine wasm ------------"
ls -l ./engine-HEAD/native/external/emscripten/spine/
echo "-----------------------------------------------"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: spine-emscripten
path: dist
- name: Build Head Declarations
working-directory: ./engine-HEAD
run: |
npm install
node ./.github/workflows/package-size-check.js
- name: Restore patches
run: |
echo "-------------------------- Restore patches ---------------------------------"
rm $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp
mv $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp.bak $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp
echo "-------------------------- Restore patches DONE! ---------------------------------"
cat $EMSDK/upstream/emscripten/system/lib/embind/bind.cpp
- uses: LouisBrunner/[email protected]
with:
old: ./engine/bin/.declarations/cc.d.ts
new: ./engine-HEAD/bin/.declarations/cc.d.ts
mode: addition
tolerance: worse
output: ./engine/interface-diff.txt
- name: Check package size
run: |
BASE_SIZE=0
if [ -d ./engine/build-cc-out ]; then
BASE_SIZE=$(du -sb ./engine/build-cc-out | awk '{print $1}')
fi
HEAD_SIZE=$(du -sb ./engine-HEAD/build-cc-out | awk '{print $1}')
DIFF_SIZE=$((HEAD_SIZE - BASE_SIZE))
if [ "$DIFF_SIZE" -gt 0 ]; then
PACKAGE_SIZE_INFO="⚠️ Package size ⤴ $DIFF_SIZE bytes, old: $BASE_SIZE, new: $HEAD_SIZE"
elif [ "$DIFF_SIZE" -lt 0 ]; then
PACKAGE_SIZE_INFO="👍 Package size ⤵ $DIFF_SIZE bytes, old: $BASE_SIZE, new: $HEAD_SIZE"
else
PACKAGE_SIZE_INFO="✅ Package size is not changed"
fi
echo "PACKAGE_SIZE_INFO: ${PACKAGE_SIZE_INFO}"
sed -i "1s/^/$PACKAGE_SIZE_INFO\n/" ./engine/interface-diff.txt
- name: optimize interface check report
working-directory: ./engine
run: |
cat ./interface-diff.txt
node ./.github/workflows/interface-check-report.js
- name: Write PR number to file
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
fs.writeFileSync('interface-check-pr.txt', process.env.PR_NUMBER);
- name: Upload PR number artifact
uses: actions/upload-artifact@v4
with:
name: interface-check-pr.txt
path: |
interface-check-pr.txt
- name: Upload interface diff artifact
uses: actions/upload-artifact@v4
with:
name: interface-diff.txt
path: |
./engine/interface-diff.txt