Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e360c2e

Browse filesBrowse files
authored
[CI] Added New Board Test (espressif#8071)
* Add check if fqbn is empty
1 parent fa9e059 commit e360c2e
Copy full SHA for e360c2e

File tree

Expand file treeCollapse file tree

2 files changed

+151
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+151
-0
lines changed

‎.github/scripts/find_new_boards.sh

Copy file name to clipboard
+90Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
3+
# Get inputs from command
4+
owner_repository=$1
5+
pr_number=$2
6+
7+
url="https://api.github.com/repos/$owner_repository/pulls/$pr_number/files"
8+
echo $url
9+
10+
# Get changes in boards.txt file from PR
11+
Patch=$(curl $url | jq -r '.[] | select(.filename == "boards.txt") | .patch ')
12+
13+
# Extract only changed lines number and count
14+
substring_patch=$(echo "$Patch" | grep -o '@@[^@]*@@')
15+
16+
params_array=()
17+
18+
IFS=$'\n' read -d '' -ra params <<< $(echo "$substring_patch" | grep -oE '[-+][0-9]+,[0-9]+')
19+
20+
for param in "${params[@]}"
21+
do
22+
echo "The parameter is $param"
23+
params_array+=("$param")
24+
done
25+
26+
boards_array=()
27+
previous_board=""
28+
file="boards.txt"
29+
30+
# Loop through boards.txt file and extract all boards that were added
31+
for (( c=0; c<${#params_array[@]}; c+=2 ))
32+
do
33+
deletion_count=$( echo "${params_array[c]}" | cut -d',' -f2 | cut -d' ' -f1 )
34+
addition_line=$( echo "${params_array[c+1]}" | cut -d'+' -f2 | cut -d',' -f1 )
35+
addition_count=$( echo "${params_array[c+1]}" | cut -d'+' -f2 | cut -d',' -f2 | cut -d' ' -f1 )
36+
addition_end=$(($addition_line+$addition_count))
37+
38+
addition_line=$(($addition_line + 3))
39+
addition_end=$(($addition_end - $deletion_count))
40+
41+
echo $addition_line
42+
echo $addition_end
43+
44+
i=0
45+
46+
while read -r line
47+
do
48+
i=$((i+1))
49+
if [ $i -lt $addition_line ]
50+
then
51+
continue
52+
elif [ $i -gt $addition_end ]
53+
then
54+
break
55+
fi
56+
board_name=$(echo "$line" | cut -d '.' -f1 | cut -d '#' -f1)
57+
if [ "$board_name" != "" ]
58+
then
59+
if [ "$board_name" != "$previous_board" ]
60+
then
61+
boards_array+=("espressif:esp32:$board_name")
62+
previous_board="$board_name"
63+
echo "Added 'espressif:esp32:$board_name' to array"
64+
fi
65+
fi
66+
done < "$file"
67+
done
68+
69+
# Create JSON like string with all boards found and pass it to env variable
70+
board_count=${#boards_array[@]}
71+
72+
if [ $board_count -gt 0 ]
73+
then
74+
json_matrix='{"fqbn": ['
75+
for board in ${boards_array[@]}
76+
do
77+
json_matrix+='"'$board'"'
78+
if [ $board_count -gt 1 ]
79+
then
80+
json_matrix+=","
81+
fi
82+
board_count=$(($board_count - 1))
83+
done
84+
json_matrix+=']}'
85+
86+
echo $json_matrix
87+
echo "FQBNS=${json_matrix}" >> $GITHUB_ENV
88+
else
89+
echo "FQBNS=''" >> $GITHUB_ENV
90+
fi

‎.github/workflows/boards.yml

Copy file name to clipboard
+61Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: New Board Test
2+
3+
# The workflow will run on schedule and labeled pull requests
4+
on:
5+
pull_request:
6+
7+
env:
8+
# It's convenient to set variables for values used multiple times in the workflow
9+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
10+
11+
jobs:
12+
find-boards:
13+
runs-on: ubuntu-latest
14+
15+
outputs:
16+
fqbns: ${{ env.FQBNS }}
17+
18+
steps:
19+
# This step makes the contents of the repository available to the workflow
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
23+
- name: Setup jq
24+
uses: dcarbone/install-jq-action@v1.0.1
25+
26+
- name: Get board name
27+
run:
28+
bash .github/scripts/find_new_boards.sh ${{ github.repository }} ${{github.event.number}}
29+
30+
test-boards:
31+
needs: find-boards
32+
runs-on: ubuntu-latest
33+
if: ${{ needs.changes.outputs.services != '' }}
34+
35+
env:
36+
REPOSITORY: |
37+
- source-path: '.'
38+
name: "espressif:esp32"
39+
40+
strategy:
41+
matrix: ${{ fromJson(needs.find-boards.outputs.fqbns) }}
42+
43+
steps:
44+
# This step makes the contents of the repository available to the workflow
45+
- name: Checkout repository
46+
uses: actions/checkout@v3
47+
48+
- name: Compile sketch
49+
uses: P-R-O-C-H-Y/compile-sketches@main
50+
with:
51+
platforms: |
52+
${{ env.REPOSITORY }}
53+
fqbn: ${{ matrix.fqbn }}
54+
use-json-file: false
55+
enable-deltas-report: false
56+
enable-warnings-report: false
57+
cli-compile-flags: |
58+
- --warnings="all"
59+
exit-on-fail: true
60+
sketch-paths:
61+
"- ./libraries/ESP32/examples/ChipID/GetChipID/GetChipID.ino"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.