Unverified Commit a31a5fca authored by Lucas Saavedra Vaz's avatar Lucas Saavedra Vaz Committed by GitHub

fix(ci): Fix issues found in workflows (#9829)

* ci(tests): Swap cache to artifacts to avoid errors between OSes

* ci(push): Fix chunk generation for compilation

* ci(tests): Fix error code propagation

* ci(push): Add shebang to new script

* ci(push): Fix sizes upload if there is no changes

* ci(bot): Fix GitHub actions bot commit info
parent e382746b
...@@ -108,7 +108,7 @@ if [ "$BUILD_PIO" -eq 0 ]; then ...@@ -108,7 +108,7 @@ if [ "$BUILD_PIO" -eq 0 ]; then
if [ "$BUILD_LOG" -eq 1 ]; then if [ "$BUILD_LOG" -eq 1 ]; then
#remove last comma from the last JSON object #remove last comma from the last JSON object
sed -i '$ s/.$//' "$sizes_file" sed -i '$ s/,$//' "$sizes_file"
#echo end of JSON array #echo end of JSON array
echo "]}" >> $sizes_file echo "]}" >> $sizes_file
fi fi
......
#!/bin/bash
build_all=false
chunks_count=0
if [[ $CORE_CHANGED == 'true' ]] || [[ $IS_PR != 'true' ]]; then
echo "Core files changed or not a PR. Building all."
build_all=true
chunks_count=$MAX_CHUNKS
elif [[ $LIB_CHANGED == 'true' ]]; then
echo "Libraries changed. Building only affected sketches."
if [[ $NETWORKING_CHANGED == 'true' ]]; then
echo "Networking libraries changed. Building networking related sketches."
networking_sketches="$(find libraries/WiFi -name *.ino) "
networking_sketches+="$(find libraries/Ethernet -name *.ino) "
networking_sketches+="$(find libraries/PPP -name *.ino) "
networking_sketches+="$(find libraries/NetworkClientSecure -name *.ino) "
networking_sketches+="$(find libraries/WebServer -name *.ino) "
fi
if [[ $FS_CHANGED == 'true' ]]; then
echo "FS libraries changed. Building FS related sketches."
fs_sketches="$(find libraries/SD -name *.ino) "
fs_sketches+="$(find libraries/SD_MMC -name *.ino) "
fs_sketches+="$(find libraries/SPIFFS -name *.ino) "
fs_sketches+="$(find libraries/LittleFS -name *.ino) "
fs_sketches+="$(find libraries/FFat -name *.ino) "
fi
sketches="$networking_sketches $fs_sketches"
for file in $LIB_FILES; do
if [[ $file == *.ino ]]; then
# If file ends with .ino, add it to the list of sketches
echo "Sketch found: $file"
sketches+="$file "
elif [[ $(basename $(dirname $file)) == "src" ]]; then
# If file is in a src directory, find all sketches in the parent/examples directory
echo "Library src file found: $file"
lib=$(dirname $(dirname $file))
if [[ -d $lib/examples ]]; then
lib_sketches=$(find $lib/examples -name *.ino)
sketches+="$lib_sketches "
echo "Library sketches: $lib_sketches"
fi
else
# If file is in a example folder but it is not a sketch, find all sketches in the current directory
echo "File in example folder found: $file"
sketch=$(find $(dirname $file) -name *.ino)
sketches+="$sketch "
echo "Sketch in example folder: $sketch"
fi
echo ""
done
fi
if [[ -n $sketches ]]; then
# Remove duplicates
sketches=$(echo $sketches | tr ' ' '\n' | sort | uniq)
for sketch in $sketches; do
echo $sketch >> sketches_found.txt
chunks_count=$((chunks_count+1))
done
echo "Number of sketches found: $chunks_count"
echo "Sketches:"
echo "$sketches"
if [[ $chunks_count -gt $MAX_CHUNKS ]]; then
echo "More sketches than the allowed number of chunks found. Limiting to $MAX_CHUNKS chunks."
chunks_count=$MAX_CHUNKS
fi
fi
chunks='["0"'
for i in $(seq 1 $(( $chunks_count - 1 )) ); do
chunks+=",\"$i\""
done
chunks+="]"
echo "build_all=$build_all" >> $GITHUB_OUTPUT
echo "build_libraries=$BUILD_LIBRARIES" >> $GITHUB_OUTPUT
echo "build_static_sketches=$BUILD_STATIC_SKETCHES" >> $GITHUB_OUTPUT
echo "build_idf=$BUILD_IDF" >> $GITHUB_OUTPUT
echo "build_platformio=$BUILD_PLATFORMIO" >> $GITHUB_OUTPUT
echo "chunk_count=$chunks_count" >> $GITHUB_OUTPUT
echo "chunks=$chunks" >> $GITHUB_OUTPUT
...@@ -192,7 +192,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex ...@@ -192,7 +192,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
exit_status=$? exit_status=$?
if [ $exit_status -ne 0 ]; then if [ $exit_status -ne 0 ]; then
echo ""ERROR: Compilation failed with error code $exit_status"" echo "ERROR: Compilation failed with error code $exit_status"
exit $exit_status exit $exit_status
fi fi
...@@ -236,7 +236,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex ...@@ -236,7 +236,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
exit_status=$? exit_status=$?
if [ $exit_status -ne 0 ]; then if [ $exit_status -ne 0 ]; then
echo ""ERROR: Compilation failed with error code $exit_status"" echo "ERROR: Compilation failed with error code $exit_status"
exit $exit_status exit $exit_status
fi fi
# $ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \ # $ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \
...@@ -398,6 +398,7 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat ...@@ -398,6 +398,7 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
else else
start_index=$(( $chunk_index * $chunk_size )) start_index=$(( $chunk_index * $chunk_size ))
if [ "$sketchcount" -le "$start_index" ]; then if [ "$sketchcount" -le "$start_index" ]; then
echo "No sketches to build for $target in this chunk"
return 0 return 0
fi fi
...@@ -437,7 +438,7 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat ...@@ -437,7 +438,7 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
continue continue
fi fi
echo "" echo ""
echo "Building Sketch Index $(($sketchnum - 1)) - $sketchdirname" echo "Building Sketch Index $sketchnum - $sketchdirname"
build_sketch $args -s $sketchdir $xtra_opts build_sketch $args -s $sketchdir $xtra_opts
local result=$? local result=$?
if [ $result -ne 0 ]; then if [ $result -ne 0 ]; then
......
...@@ -95,13 +95,12 @@ function run_test() { ...@@ -95,13 +95,12 @@ function run_test() {
printf "\033[95mpytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args\033[0m\n" printf "\033[95mpytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args\033[0m\n"
bash -c "set +e; pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args; exit \$?" || result=$? bash -c "set +e; pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args; exit \$?" || result=$?
printf "\n" printf "\n"
result=$?
if [ $result -ne 0 ]; then if [ $result -ne 0 ]; then
printf "\033[91mFailed test: $sketchname -- Config: $i\033[0m\n\n"
error=$result error=$result
fi fi
fi fi
done done
printf "Test return code: $error\n"
return $error return $error
} }
...@@ -250,7 +249,6 @@ else ...@@ -250,7 +249,6 @@ else
exit_code=0 exit_code=0
run_test $target $sketch $options $erase || exit_code=$? run_test $target $sketch $options $erase || exit_code=$?
echo "Sketch $sketch exit code: $exit_code"
if [ $exit_code -ne 0 ]; then if [ $exit_code -ne 0 ]; then
error=$exit_code error=$exit_code
fi fi
......
...@@ -77,18 +77,16 @@ jobs: ...@@ -77,18 +77,16 @@ jobs:
run: | run: |
pip install -U pip pip install -U pip
pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi
apt update
apt install -y jq
- name: Get binaries - name: Get binaries
id: cache-build-binaries
uses: actions/cache/restore@v4
if: ${{ steps.check-tests.outputs.enabled == 'true' }} if: ${{ steps.check-tests.outputs.enabled == 'true' }}
uses: actions/download-artifact@v4
with: with:
fail-on-cache-miss: true name: tests-bin-${{ inputs.chip }}-${{ inputs.type }}
key: tests-${{ env.id }}-bin
path: | path: |
~/.arduino/tests/**/build*.tmp/*.bin ~/.arduino/tests
~/.arduino/tests/**/build*.tmp/*.elf
~/.arduino/tests/**/build*.tmp/*.json
- name: Run Tests - name: Run Tests
if: ${{ steps.check-tests.outputs.enabled == 'true' }} if: ${{ steps.check-tests.outputs.enabled == 'true' }}
......
...@@ -120,8 +120,8 @@ jobs: ...@@ -120,8 +120,8 @@ jobs:
- name: Push to github repo - name: Push to github repo
run: | run: |
git config user.name github-actions git config user.name "github-actions[bot]"
git config user.email github-actions@github.com git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add ${{ env.RESULT_LIBRARY_TEST_FILE }} git add ${{ env.RESULT_LIBRARY_TEST_FILE }}
git commit -m "Generated External Libraries Test Results" git commit -m "Generated External Libraries Test Results"
git push origin HEAD:gh-pages git push origin HEAD:gh-pages
......
...@@ -32,22 +32,22 @@ jobs: ...@@ -32,22 +32,22 @@ jobs:
run: | run: |
mv master_cli_compile/*.json artifacts/sizes-report/pr/ mv master_cli_compile/*.json artifacts/sizes-report/pr/
mv v2.x_cli_compile/*.json artifacts/sizes-report/master/ mv v2.x_cli_compile/*.json artifacts/sizes-report/master/
- name: Report results - name: Report results
uses: P-R-O-C-H-Y/report-size-deltas@sizes_v2 uses: P-R-O-C-H-Y/report-size-deltas@sizes_v2
with: with:
sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }} sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}
github-token: ${{ env.GITHUB_TOKEN }} github-token: ${{ env.GITHUB_TOKEN }}
destination-file: ${{ env.RESULT_SIZES_TEST_FILE }} destination-file: ${{ env.RESULT_SIZES_TEST_FILE }}
- name: Append file with action URL - name: Append file with action URL
run: run:
echo "/ [GitHub Action Link](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})" >> ${{ env.RESULT_SIZES_TEST_FILE }} echo "/ [GitHub Action Link](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})" >> ${{ env.RESULT_SIZES_TEST_FILE }}
- name: Push to github repo - name: Push to github repo
run: | run: |
git config user.name github-actions git config user.name "github-actions[bot]"
git config user.email github-actions@github.com git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add ${{ env.RESULT_SIZES_TEST_FILE }} git add ${{ env.RESULT_SIZES_TEST_FILE }}
git commit -m "Generated Sizes Results (master-v2.x)" git commit -m "Generated Sizes Results (master-v2.x)"
git push origin HEAD:gh-pages git push origin HEAD:gh-pages
...@@ -77,6 +77,10 @@ jobs: ...@@ -77,6 +77,10 @@ jobs:
libraries: libraries:
- 'libraries/**/examples/**' - 'libraries/**/examples/**'
- 'libraries/**/src/**' - 'libraries/**/src/**'
networking:
- 'libraries/Network/src/**'
fs:
- 'libraries/FS/src/**'
static_sketeches: static_sketeches:
- 'libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino' - 'libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino'
- 'libraries/BLE/examples/Server/Server.ino' - 'libraries/BLE/examples/Server/Server.ino'
...@@ -97,78 +101,18 @@ jobs: ...@@ -97,78 +101,18 @@ jobs:
id: set-chunks id: set-chunks
env: env:
LIB_FILES: ${{ steps.changed-files.outputs.libraries_all_changed_files }} LIB_FILES: ${{ steps.changed-files.outputs.libraries_all_changed_files }}
IS_PR: ${{ github.event_name == 'pull_request' }}
MAX_CHUNKS: ${{ env.MAX_CHUNKS }}
BUILD_PLATFORMIO: ${{ steps.changed-files.outputs.platformio_any_changed == 'true' }}
BUILD_IDF: ${{ steps.changed-files.outputs.idf_any_changed == 'true' }}
BUILD_LIBRARIES: ${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
BUILD_STATIC_SKETCHES: ${{ steps.changed-files.outputs.static_sketeches_any_changed == 'true' }}
FS_CHANGED: ${{ steps.changed-files.outputs.fs_any_changed == 'true' }}
NETWORKING_CHANGED: ${{ steps.changed-files.outputs.networking_any_changed == 'true' }}
CORE_CHANGED: ${{ steps.changed-files.outputs.core_any_changed == 'true' }}
LIB_CHANGED: ${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
run: | run: |
build_all=false bash ./.github/scripts/set_push_chunks.sh
chunks_count=0
is_pr=${{ github.event_name == 'pull_request' }}
build_platformio=${{ steps.changed-files.outputs.platformio_any_changed == 'true' }}
build_idf=${{ steps.changed-files.outputs.idf_any_changed == 'true' }}
build_libraries=${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
build_static_sketches=${{ steps.changed-files.outputs.static_sketeches_any_changed == 'true' }}
core_changed=${{ steps.changed-files.outputs.core_any_changed == 'true' }}
lib_changed=${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
if [[ $core_changed == 'true' ]] || [[ $is_pr != 'true' ]]; then
echo "Core files changed or not a PR. Building all."
build_all=true
chunks_count=${{ env.MAX_CHUNKS }}
elif [[ $lib_changed == 'true' ]]; then
echo "Libraries changed. Building only affected sketches."
sketches=""
for file in $LIB_FILES; do
if [[ $file == *.ino ]]; then
# If file ends with .ino, add it to the list of sketches
echo "Sketch found: $file"
sketches+="$file "
elif [[ $(basename $(dirname $file)) == "src" ]]; then
# If file is in a src directory, find all sketches in the parent/examples directory
echo "Library src file found: $file"
lib=$(dirname $(dirname $file))
lib_sketches=$(find $lib/examples -name *.ino)
sketches+="$lib_sketches "
echo "Library sketches: $lib_sketches"
else
# If file is in a example folder but it is not a sketch, find all sketches in the current directory
echo "File in example folder found: $file"
sketch=$(find $(dirname $file) -name *.ino)
sketches+="$sketch "
echo "Sketch in example folder: $sketch"
fi
echo ""
done
fi
if [[ -n $sketches ]]; then
# Remove duplicates
sketches=$(echo $sketches | tr ' ' '\n' | sort | uniq)
for sketch in $sketches; do
echo $sketch >> sketches_found.txt
chunks_count=$((chunks_count+1))
done
echo "Number of sketches found: $chunks_count"
echo "Sketches: $sketches"
if [[ $chunks_count -gt ${{ env.MAX_CHUNKS }} ]]; then
echo "More sketches than the allowed number of chunks found. Limiting to ${{ env.MAX_CHUNKS }} chunks."
chunks_count=${{ env.MAX_CHUNKS }}
fi
fi
chunks='["0"'
for i in $(seq 1 $(( $chunks_count - 1 )) ); do
chunks+=",\"$i\""
done
chunks+="]"
echo "build_all=$build_all" >> $GITHUB_OUTPUT
echo "build_libraries=$build_libraries" >> $GITHUB_OUTPUT
echo "build_static_sketches=$build_static_sketches" >> $GITHUB_OUTPUT
echo "build_idf=$build_idf" >> $GITHUB_OUTPUT
echo "build_platformio=$build_platformio" >> $GITHUB_OUTPUT
echo "chunk_count=$chunks_count" >> $GITHUB_OUTPUT
echo "chunks=$chunks" >> $GITHUB_OUTPUT
- name: Upload sketches found - name: Upload sketches found
if: ${{ steps.set-chunks.outputs.build_all == 'false' && steps.set-chunks.outputs.build_libraries == 'true' }} if: ${{ steps.set-chunks.outputs.build_all == 'false' && steps.set-chunks.outputs.build_libraries == 'true' }}
...@@ -336,9 +280,10 @@ jobs: ...@@ -336,9 +280,10 @@ jobs:
- name: Commit json files to gh-pages if on master - name: Commit json files to gh-pages if on master
if: github.event_name == 'push' && github.ref == 'refs/heads/master' if: github.event_name == 'push' && github.ref == 'refs/heads/master'
continue-on-error: true
run: | run: |
git config user.name github-actions git config user.name "github-actions[bot]"
git config user.email github-actions@github.com git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add --all git add --all
git commit -m "Updated cli compile json files" git commit -m "Updated cli compile json files"
git push origin HEAD:gh-pages git push origin HEAD:gh-pages
......
...@@ -113,15 +113,11 @@ jobs: ...@@ -113,15 +113,11 @@ jobs:
- name: Get binaries - name: Get binaries
if: ${{ steps.check-tests.outputs.enabled == 'true' }} if: ${{ steps.check-tests.outputs.enabled == 'true' }}
id: cache-build-binaries uses: actions/download-artifact@v4
uses: actions/cache/restore@v4
with: with:
fail-on-cache-miss: true name: tests-bin-${{ inputs.chip }}-${{ inputs.type }}
key: tests-${{ env.id }}-bin
path: | path: |
~/.arduino/tests/**/build*.tmp/*.bin ~/.arduino/tests
~/.arduino/tests/**/build*.tmp/*.elf
~/.arduino/tests/**/build*.tmp/*.json
- name: Run Tests - name: Run Tests
if: ${{ steps.check-tests.outputs.enabled == 'true' }} if: ${{ steps.check-tests.outputs.enabled == 'true' }}
......
...@@ -91,15 +91,11 @@ jobs: ...@@ -91,15 +91,11 @@ jobs:
- name: Get binaries - name: Get binaries
if: ${{ steps.check-tests.outputs.enabled == 'true' }} if: ${{ steps.check-tests.outputs.enabled == 'true' }}
id: cache-build-binaries uses: actions/download-artifact@v4
uses: actions/cache/restore@v4
with: with:
fail-on-cache-miss: true name: tests-bin-${{ inputs.chip }}-${{ inputs.type }}
key: tests-${{ env.id }}-bin
path: | path: |
~/.arduino/tests/**/build*.tmp/*.bin ~/.arduino/tests
~/.arduino/tests/**/build*.tmp/*.elf
~/.arduino/tests/**/build*.tmp/*.json
- name: Run Tests - name: Run Tests
if: ${{ steps.check-tests.outputs.enabled == 'true' }} if: ${{ steps.check-tests.outputs.enabled == 'true' }}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment