forked from apache/nuttx
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (77 loc) · 2.74 KB
/
arch.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
#### Comment
name: 'Arch'
description: 'TODO' ####
inputs:
os:
description: "A username passed from the caller workflow" ####
required: true
type: string
board:
description: "A username passed from the caller workflow" ####
required: true
type: string
outputs:
skip_build:
description: "Set to 1 if the build should be skipped"
value: ${{ steps.get-arch.outputs.skip_build }}
runs:
using: "composite"
steps:
- name: Get arch
id: get-arch
run: |
echo os=${{inputs.os}} ####
echo board=${{inputs.board}} ####
# Get the Labels for the PR: "Arch: risc-v \n Size: XS"
pr=${{github.event.pull_request.number}}
if [[ "$pr" == "" ]]; then
exit
fi
numlabels=$(gh pr view $pr --repo $GITHUB_REPOSITORY --json labels --jq '.[] | length')
labels=$(gh pr view $pr --repo $GITHUB_REPOSITORY --json labels --jq '.labels[] | .name')
# Identify the Size and Arch Labels
if [[ "$labels" == *"Size: "* ]]; then
labels_contain_size=1
fi
if [[ "$labels" == *"Arch: arm"* ]]; then
arch_contains_arm_arm64=1
fi
if [[ "$labels" == *"Arch: risc-v"* ]]; then
arch_contains_riscv=1
fi
if [[ "$labels" == *"Arch: xtensa"* ]]; then
arch_contains_xtensa=1
fi
# We consider only PRs with 2 labels, including size
if [ $numlabels -ne 2 ] || [ $labels_contain_size -ne 1 ]; then
exit
fi
# If "Arch: arm / arm64" is the only non-size label, then build other, arm-01, arm-02, ...
if [[ "$arch_contains_arm_arm64" == "1" ]]; then
if [[ "${{inputs.board}}" == "arm"* ]] || [[ "${{inputs.board}}" == "other"* ]]; then
echo Allow build: ${{inputs.board}}
else
echo Skip build: ${{inputs.board}}
echo "skip_build=1" >> $GITHUB_OUTPUT
fi
fi
# If "Arch: risc-v" is the only non-size label, then build risc-v-01, risc-v-02
if [[ "$arch_contains_riscv" == "1" ]]; then
if [[ "${{inputs.board}}" == "risc-v"* ]]; then
echo Allow build: ${{inputs.board}}
else
echo Skip build: ${{inputs.board}}
echo "skip_build=1" >> $GITHUB_OUTPUT
fi
fi
# If "Arch: xtensa" is the only non-size label, then build xtensa-01, xtensa-02
if [[ "$arch_contains_xtensa" == "1" ]]; then
if [[ "${{inputs.board}}" == "xtensa"* ]]; then
echo Allow build: ${{inputs.board}}
else
echo Skip build: ${{inputs.board}}
echo "skip_build=1" >> $GITHUB_OUTPUT
fi
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}