Skip to content

Commit e0d1a18

Browse files
committed
test
1 parent 2c02d96 commit e0d1a18

File tree

4 files changed

+99
-71
lines changed

4 files changed

+99
-71
lines changed

.github/scripts/set_push_chunks.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
build_all=false
2+
chunks_count=0
3+
4+
if [[ $CORE_CHANGED == 'true' ]] || [[ $IS_PR != 'true' ]]; then
5+
echo "Core files changed or not a PR. Building all."
6+
build_all=true
7+
chunks_count=$MAX_CHUNKS
8+
elif [[ $LIB_CHANGED == 'true' ]]; then
9+
echo "Libraries changed. Building only affected sketches."
10+
if [[ $NETWORKING_CHANGED == 'true' ]]; then
11+
echo "Networking libraries changed. Building networking related sketches."
12+
networking_sketches=$(find libraries/WiFi -name *.ino -printf '%f ')
13+
networking_sketches+="$(find libraries/ETH -name *.ino -printf '%f ')"
14+
networking_sketches+="$(find libraries/PPP -name *.ino -printf '%f ')"
15+
networking_sketches+="$(find libraries/NetworkClientSecure -name *.ino -printf '%f ')"
16+
networking_sketches+="$(find libraries/WebServer -name *.ino -printf '%f ')"
17+
fi
18+
if [[ $FS_CHANGED == 'true' ]]; then
19+
echo "FS libraries changed. Building FS related sketches."
20+
fs_sketches=$(find libraries/SD -name *.ino -printf '%f ')
21+
fs_sketches+="$(find libraries/SD_MMC -name *.ino -printf '%f ')"
22+
fs_sketches+="$(find libraries/SPIFFS -name *.ino -printf '%f ')"
23+
fs_sketches+="$(find libraries/LittleFS -name *.ino -printf '%f ')"
24+
fs_sketches+="$(find libraries/FFat -name *.ino -printf '%f ')"
25+
fi
26+
sketches="$networking_sketches $fs_sketches"
27+
for file in $LIB_FILES; do
28+
if [[ $file == *.ino ]]; then
29+
# If file ends with .ino, add it to the list of sketches
30+
echo "Sketch found: $file"
31+
sketches+="$file "
32+
elif [[ $(basename $(dirname $file)) == "src" ]]; then
33+
# If file is in a src directory, find all sketches in the parent/examples directory
34+
echo "Library src file found: $file"
35+
lib=$(dirname $(dirname $file))
36+
if [[ -d $lib/examples ]]; then
37+
lib_sketches=$(find $lib/examples -name *.ino -printf '%f ')
38+
sketches+="$lib_sketches"
39+
echo "Library sketches: $lib_sketches"
40+
fi
41+
else
42+
# If file is in a example folder but it is not a sketch, find all sketches in the current directory
43+
echo "File in example folder found: $file"
44+
sketch=$(find $(dirname $file) -name *.ino -printf '%f ')
45+
sketches+="$sketch"
46+
echo "Sketch in example folder: $sketch"
47+
fi
48+
echo ""
49+
done
50+
fi
51+
52+
if [[ -n $sketches ]]; then
53+
# Remove duplicates
54+
sketches=$(echo $sketches | tr ' ' '\n' | sort | uniq)
55+
for sketch in $sketches; do
56+
echo $sketch >> sketches_found.txt
57+
chunks_count=$((chunks_count+1))
58+
done
59+
echo "Number of sketches found: $chunks_count"
60+
echo "Sketches: $sketches"
61+
62+
if [[ $chunks_count -gt $MAX_CHUNKS ]]; then
63+
echo "More sketches than the allowed number of chunks found. Limiting to $MAX_CHUNKS chunks."
64+
chunks_count=$MAX_CHUNKS
65+
fi
66+
fi
67+
68+
chunks='["0"'
69+
for i in $(seq 1 $(( $chunks_count - 1 )) ); do
70+
chunks+=",\"$i\""
71+
done
72+
chunks+="]"
73+
74+
echo "build_all=$build_all" >> $GITHUB_OUTPUT
75+
echo "build_libraries=$build_libraries" >> $GITHUB_OUTPUT
76+
echo "build_static_sketches=$build_static_sketches" >> $GITHUB_OUTPUT
77+
echo "build_idf=$build_idf" >> $GITHUB_OUTPUT
78+
echo "build_platformio=$build_platformio" >> $GITHUB_OUTPUT
79+
echo "chunk_count=$chunks_count" >> $GITHUB_OUTPUT
80+
echo "chunks=$chunks" >> $GITHUB_OUTPUT

.github/scripts/sketch_utils.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [extra-options]
46
while [ ! -z "$1" ]; do
57
case "$1" in

.github/scripts/tests_run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
function run_test() {
46
local target=$1
57
local sketch=$2

.github/workflows/push.yml

Lines changed: 15 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ jobs:
7777
libraries:
7878
- 'libraries/**/examples/**'
7979
- 'libraries/**/src/**'
80+
networking:
81+
- 'libraries/Network/src/**'
82+
fs:
83+
- 'libraries/FS/src/**'
8084
static_sketeches:
8185
- 'libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino'
8286
- 'libraries/BLE/examples/Server/Server.ino'
@@ -97,78 +101,18 @@ jobs:
97101
id: set-chunks
98102
env:
99103
LIB_FILES: ${{ steps.changed-files.outputs.libraries_all_changed_files }}
104+
IS_PR: ${{ github.event_name == 'pull_request' }}
105+
MAX_CHUNKS: ${{ env.MAX_CHUNKS }}
106+
BUILD_PLATFORMIO: ${{ steps.changed-files.outputs.platformio_any_changed == 'true' }}
107+
BUILD_IDF: ${{ steps.changed-files.outputs.idf_any_changed == 'true' }}
108+
BUILD_LIBRARIES: ${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
109+
BUILD_STATIC_SKETCHES: ${{ steps.changed-files.outputs.static_sketeches_any_changed == 'true' }}
110+
FS_CHANGED: ${{ steps.changed-files.outputs.fs_any_changed == 'true' }}
111+
NETWORKING_CHANGED: ${{ steps.changed-files.outputs.networking_any_changed == 'true' }}
112+
CORE_CHANGED: ${{ steps.changed-files.outputs.core_any_changed == 'true' }}
113+
LIB_CHANGED: ${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
100114
run: |
101-
build_all=false
102-
chunks_count=0
103-
is_pr=${{ github.event_name == 'pull_request' }}
104-
105-
build_platformio=${{ steps.changed-files.outputs.platformio_any_changed == 'true' }}
106-
build_idf=${{ steps.changed-files.outputs.idf_any_changed == 'true' }}
107-
build_libraries=${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
108-
build_static_sketches=${{ steps.changed-files.outputs.static_sketeches_any_changed == 'true' }}
109-
110-
core_changed=${{ steps.changed-files.outputs.core_any_changed == 'true' }}
111-
lib_changed=${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
112-
113-
if [[ $core_changed == 'true' ]] || [[ $is_pr != 'true' ]]; then
114-
echo "Core files changed or not a PR. Building all."
115-
build_all=true
116-
chunks_count=${{ env.MAX_CHUNKS }}
117-
elif [[ $lib_changed == 'true' ]]; then
118-
echo "Libraries changed. Building only affected sketches."
119-
sketches=""
120-
for file in $LIB_FILES; do
121-
if [[ $file == *.ino ]]; then
122-
# If file ends with .ino, add it to the list of sketches
123-
echo "Sketch found: $file"
124-
sketches+="$file "
125-
elif [[ $(basename $(dirname $file)) == "src" ]]; then
126-
# If file is in a src directory, find all sketches in the parent/examples directory
127-
echo "Library src file found: $file"
128-
lib=$(dirname $(dirname $file))
129-
lib_sketches=$(find $lib/examples -name *.ino)
130-
sketches+="$lib_sketches "
131-
echo "Library sketches: $lib_sketches"
132-
else
133-
# If file is in a example folder but it is not a sketch, find all sketches in the current directory
134-
echo "File in example folder found: $file"
135-
sketch=$(find $(dirname $file) -name *.ino)
136-
sketches+="$sketch "
137-
echo "Sketch in example folder: $sketch"
138-
fi
139-
echo ""
140-
done
141-
fi
142-
143-
if [[ -n $sketches ]]; then
144-
# Remove duplicates
145-
sketches=$(echo $sketches | tr ' ' '\n' | sort | uniq)
146-
for sketch in $sketches; do
147-
echo $sketch >> sketches_found.txt
148-
chunks_count=$((chunks_count+1))
149-
done
150-
echo "Number of sketches found: $chunks_count"
151-
echo "Sketches: $sketches"
152-
153-
if [[ $chunks_count -gt ${{ env.MAX_CHUNKS }} ]]; then
154-
echo "More sketches than the allowed number of chunks found. Limiting to ${{ env.MAX_CHUNKS }} chunks."
155-
chunks_count=${{ env.MAX_CHUNKS }}
156-
fi
157-
fi
158-
159-
chunks='["0"'
160-
for i in $(seq 1 $(( $chunks_count - 1 )) ); do
161-
chunks+=",\"$i\""
162-
done
163-
chunks+="]"
164-
165-
echo "build_all=$build_all" >> $GITHUB_OUTPUT
166-
echo "build_libraries=$build_libraries" >> $GITHUB_OUTPUT
167-
echo "build_static_sketches=$build_static_sketches" >> $GITHUB_OUTPUT
168-
echo "build_idf=$build_idf" >> $GITHUB_OUTPUT
169-
echo "build_platformio=$build_platformio" >> $GITHUB_OUTPUT
170-
echo "chunk_count=$chunks_count" >> $GITHUB_OUTPUT
171-
echo "chunks=$chunks" >> $GITHUB_OUTPUT
115+
bash ./.github/scripts/set_push_chunks.sh
172116
173117
- name: Upload sketches found
174118
if: ${{ steps.set-chunks.outputs.build_all == 'false' && steps.set-chunks.outputs.build_libraries == 'true' }}

0 commit comments

Comments
 (0)