Skip to content

Commit bdbfc45

Browse files
authored
Merge branch 'master' into release/v2.x
2 parents 483bebf + 6b1cc41 commit bdbfc45

File tree

14 files changed

+543
-31
lines changed

14 files changed

+543
-31
lines changed

.github/scripts/find_new_boards.sh

+90
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

+61
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/[email protected]
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"

.github/workflows/lib.yml

+14-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ env:
1515
SKETCHES_REPORTS_ARTIFACT_NAME: libraries-report
1616
RESULT_LIBRARY_TEST_FILE: LIBRARIES_TEST.md
1717
JSON_LIBRARY_LIST_FILE: .github/workflows/lib.json
18+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
19+
1820
jobs:
1921
compile-sketch:
2022
if: |
@@ -80,6 +82,13 @@ jobs:
8082
# Check out repository
8183
- name: Checkout repository
8284
uses: actions/checkout@v3
85+
with:
86+
token: ${{ env.GITHUB_TOKEN }}
87+
fetch-depth: '0'
88+
89+
- name: Switch branch
90+
run:
91+
git checkout remotes/origin/gh-pages
8392

8493
# This step is needed to get the size data produced by the compile jobs
8594
- name: Download sketches reports artifact
@@ -95,21 +104,17 @@ jobs:
95104
destination-file: ${{ env.RESULT_LIBRARY_TEST_FILE }}
96105

97106
- name: Append file with action URL
98-
uses: DamianReeves/write-file-action@master
99-
with:
100-
path: ${{ env.RESULT_LIBRARY_TEST_FILE }}
101-
contents: |
102-
/ [GitHub Action Link](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})
103-
write-mode: append
107+
run:
108+
echo "/ [GitHub Action Link](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})" >> ${{ env.RESULT_LIBRARY_TEST_FILE }}
104109

105110
- name: Push to github repo
106111
run: |
107112
git config user.name github-actions
108113
git config user.email [email protected]
109114
git add ${{ env.RESULT_LIBRARY_TEST_FILE }}
110115
git commit -m "Generated External Libraries Test Results"
111-
git push
112-
116+
git push origin HEAD:gh-pages
117+
113118
event_file:
114119
name: "Event File"
115120
if: |
@@ -121,4 +126,4 @@ jobs:
121126
uses: actions/upload-artifact@v2
122127
with:
123128
name: Event File
124-
path: ${{github.event_path}}
129+
path: ${{github.event_path}}

LIBRARIES_TEST.md

-1
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Finally, if you are sure no one else had the issue, follow the **Issue template*
5454

5555
### External libraries compilation test
5656

57-
We have set-up CI testing for external libraries for ESP32 Arduino core. You can check test results in the file [LIBRARIES_TEST](https://github.com/espressif/arduino-esp32/blob/master/LIBRARIES_TEST.md).
57+
We have set-up CI testing for external libraries for ESP32 Arduino core. You can check test results in the file [LIBRARIES_TEST](https://github.com/espressif/arduino-esp32/blob/gh-pages/LIBRARIES_TEST.md).
5858
For more information and how to add your library to the test see [external library testing](https://docs.espressif.com/projects/arduino-esp32/en/latest/external_libraries_test.html) in the documentation.
5959

6060
### Contributing

0 commit comments

Comments
 (0)