-
Notifications
You must be signed in to change notification settings - Fork 2
161 lines (132 loc) · 4.77 KB
/
test.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
name: Test
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
- edited
permissions:
contents: read
pull-requests: write
issues: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-test:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
need_to_run: ${{ steps.set-matrix.outputs.need_to_run }}
steps:
- name: generate matrix from PR body
id: set-matrix
env:
RAW_BODY: ${{ github.event.pull_request.body }}
uses: actions/github-script@v7
with:
script: |
const result = [];
const taskRegexp = /- \[x\] (.*)/g;
let match;
while ((match = taskRegexp.exec(process.env.RAW_BODY)) !== null) {
result.push(match[1])
}
core.setOutput("matrix", result);
core.setOutput("need_to_run", result.length > 0);
test:
runs-on: ubuntu-latest
needs: pre-test
if: ${{ needs.pre-test.outputs.need_to_run == 'true' }}
outputs:
matrix: ${{ needs.pre-test.outputs.matrix }}
strategy:
fail-fast: true
matrix:
target-arch: ${{ fromJSON(needs.pre-test.outputs.matrix) }}
steps:
# - name: Checkout
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
# - name: Update kernel submodules
# if: ${{ startsWith(matrix.target-arch, 'kernel') }}
# run: git submodule update --init kernel
# - name: Update buildroot submodules
# if: ${{ startsWith(matrix.target-arch, 'kernel') }}
# run: git submodule update --init buildroot
# - name: Install deps
# run: sudo apt-get install -y build-essential flex bison libssl-dev libelf-dev bc
# - name: Install kernel arm64 deps
# if: ${{ matrix.target-arch == 'kernel-arm64' }}
# run: sudo apt-get install -y gcc-aarch64-linux-gnu
# - name: Defconfig
# run: make defconfig-${{ matrix.target-arch }}
# - name: Build
# run: make build-${{ matrix.target-arch }}
- name: Get output file size
run: |
# FILE_PATH=$(make print-outpath-${{ matrix.target-arch }})
FILE_PATH=/usr/bin/ls
SIZE_B=$(stat -c%s "$FILE_PATH")
SIZE_MB=$(echo $SIZE_B | awk '{ printf "%.4f", $1 / 1024 / 1024 }')
mkdir outputs-size
echo "${{ matrix.target-arch }} $SIZE_MB $SIZE_B" > outputs-size/${{ matrix.target-arch }}.txt
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: ${{ github.run_id }}-${{ github.run_number }}-${{ matrix.target-arch }}
path: outputs-size/*.txt
retention-days: 1
post-test:
runs-on: ubuntu-latest
needs:
- pre-test
- test
if: ${{ needs.pre-test.outputs.need_to_run == 'true' }}
steps:
- name: Load outputs-size
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
with:
pattern: ${{ github.run_id }}-${{ github.run_number }}-*
path: outputs-size
merge-multiple: true
- name: Format outputs-size
id: size
run: |
echo -n -e "result=`sort outputs-size/*.txt | awk '{ printf "|**"$1"**|*"$2"MB ("$3" bytes)*|\n" }'`"
echo -n -e "result=`sort outputs-size/*.txt | awk '{ printf "|**"$1"**|*"$2"MB ("$3" bytes)*|\n" }'`" >> $GITHUB_OUTPUT
# cat > $GITHUB_OUTPUT <<EOF
# result=|Target|Size|
# |-|-|
# $RESULT
# EOF
# echo -n -e "result=|Target|Size|\n|-|-|\n"$RESULT > $GITHUB_OUTPUT
- name: generate matrix from PR body
id: comment
uses: actions/github-script@v7
env:
SIZE: ${{ steps.size.outputs.result }}
with:
result-encoding: string
script: |
const result = `|Target|Size|
|-|-|
${process.env.SIZE}`;
return result;
- name: Find comment
uses: peter-evans/find-comment@d5fe37641ad8451bdd80312415672ba26c86575e # v3.0.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Build Output Summary
- name: Create or update comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Build Output Summary
${{ steps.comment.outputs.result }}
edit-mode: replace