Skip to content

Commit d2af3d0

Browse files
authored
Enforce arduino sketch folder naming and fix build path
- Update workflow to only compile .ino files where the filename matches the directory name. - Use --build-path instead of deprecated cache flags. - Ensure proper directory resolution for examples/SerialDemo/SerialDemo.ino structure.
1 parent 424593d commit d2af3d0

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

.github/workflows/compile-test.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,27 @@ jobs:
3030
3131
- name: Compile Examples
3232
run: |
33-
# Create the cache directory
34-
mkdir -p /tmp/arduino-cache
33+
# Create a dedicated build directory for caching
34+
mkdir -p /tmp/arduino-build
3535
36-
# Find every .ino file, get its directory, and compile with caching
37-
for example in $(find ./examples -name "*.ino"); do
36+
# Find all .ino files that are in a folder named exactly like the file
37+
# This avoids trying to compile parent directories
38+
find ./examples -name "*.ino" | while read -r example; do
3839
EXAMPLE_DIR=$(dirname "$example")
39-
echo "Compiling sketch in $EXAMPLE_DIR..."
40-
41-
$HOME/bin/arduino-cli compile \
42-
--fqbn rp2040:rp2040:rpipico \
43-
--build-cache-path /tmp/arduino-cache \
44-
"$EXAMPLE_DIR"
40+
SKETCH_NAME=$(basename "$example" .ino)
41+
PARENT_DIR_NAME=$(basename "$EXAMPLE_DIR")
42+
43+
if [ "$SKETCH_NAME" == "$PARENT_DIR_NAME" ]; then
44+
echo "----------------------------------------------------"
45+
echo "Compiling valid sketch: $EXAMPLE_DIR"
46+
echo "----------------------------------------------------"
47+
48+
$HOME/bin/arduino-cli compile \
49+
--fqbn rp2040:rp2040:rpipico \
50+
--build-path /tmp/arduino-build \
51+
"$EXAMPLE_DIR"
52+
else
53+
echo "Skipping $example: filename does not match folder name."
54+
fi
4555
done
4656

0 commit comments

Comments
 (0)