From 88e5edcf12092f7387073f62b586cdcb870a7cf5 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:35:14 -0300 Subject: [PATCH 1/3] ci(triggers): Improve workflow triggering and bump versions --- .github/workflows/pre-commit.yml | 14 +++++++++++--- .github/workflows/push.yml | 6 ++++-- tests/requirements.txt | 8 ++++---- tools/pre-commit/requirements.txt | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index c4ae017c229..8257e78c822 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -6,7 +6,7 @@ on: branches: - master pull_request: - types: [opened, reopened, synchronize, labeled, unlabeled] + types: [opened, reopened, synchronize, labeled] concurrency: group: pre-commit-${{github.event.pull_request.number || github.ref}} @@ -15,8 +15,10 @@ concurrency: jobs: lint: if: | + github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') || - github.event_name != 'pull_request' + contains(github.event.pull_request.labels.*.name, 'Re-trigger Pre-commit Hooks') + name: Check if fixes are needed runs-on: ubuntu-latest steps: @@ -25,6 +27,12 @@ jobs: with: fetch-depth: 2 + - name: Remove Label + if: contains(github.event.pull_request.labels.*.name, 'Re-trigger Pre-commit Hooks') + run: gh pr edit ${{ github.event.number }} --remove-label 'Re-trigger Pre-commit Hooks' + env: + GH_TOKEN: ${{ github.token }} + - name: Set up Python 3 uses: actions/setup-python@v5 with: @@ -65,7 +73,7 @@ jobs: key: ${{ steps.restore-cache.outputs.cache-primary-key }} - name: Push changes using pre-commit-ci-lite - uses: pre-commit-ci/lite-action@v1.0.2 + uses: pre-commit-ci/lite-action@v1.1.0 # Only push changes in PRs if: ${{ always() && github.event_name == 'pull_request' }} with: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 19e53b844f2..82159e1b8a4 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -5,7 +5,7 @@ on: push: branches: - master - - release/v2.x + - release/* pull_request: paths: - 'cores/**' @@ -47,6 +47,7 @@ jobs: cmake-check: name: Check cmake file runs-on: ubuntu-latest + if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/')) }} steps: - uses: actions/checkout@v4 - run: bash ./.github/scripts/check-cmakelists.sh @@ -54,6 +55,7 @@ jobs: gen-chunks: name: Generate chunks runs-on: ubuntu-latest + if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/')) }} outputs: build_all: ${{ steps.set-chunks.outputs.build_all }} build_libraries: ${{ steps.set-chunks.outputs.build_libraries }} @@ -307,7 +309,7 @@ jobs: #Upload PR number as artifact upload-pr-number: name: Upload PR number - if: github.event_name == 'pull_request' + if: ${{ github.event_name == 'pull_request' && !startsWith(github.head_ref, 'release/') }} runs-on: ubuntu-latest steps: - name: Save the PR number in an artifact diff --git a/tests/requirements.txt b/tests/requirements.txt index 63d204a96b0..a7df8928665 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,7 +1,7 @@ cryptography==43.0.1 --only-binary cryptography pytest-cov==5.0.0 -pytest-embedded-serial-esp==1.11.6 -pytest-embedded-arduino==1.11.6 -pytest-embedded-wokwi==1.11.6 -pytest-embedded-qemu==1.11.6 +pytest-embedded-serial-esp==1.11.8 +pytest-embedded-arduino==1.11.8 +pytest-embedded-wokwi==1.11.8 +pytest-embedded-qemu==1.11.8 diff --git a/tools/pre-commit/requirements.txt b/tools/pre-commit/requirements.txt index 7b88387b05b..aca4a61191f 100644 --- a/tools/pre-commit/requirements.txt +++ b/tools/pre-commit/requirements.txt @@ -1,2 +1,2 @@ -pre-commit==3.7.1 +pre-commit==4.0.1 docutils==0.16 From 343f568266937e8fda4ee604d0c8bea2957c55e8 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Fri, 1 Nov 2024 17:31:29 -0300 Subject: [PATCH 2/3] ci(runtime): Improve runtime tests triggers --- .github/workflows/tests.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ab8baa6d14c..f57a1925c1c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,10 +26,9 @@ on: - '!.github/scripts/upload_py_tools.sh' - 'tests/**' - 'cores/**' - - 'libraries/**' - - '!libraries/**.md' - - '!libraries/**.txt' - - '!libraries/**.properties' + - 'libraries/*/src/**.cpp' + - 'libraries/*/src/**.h' + - 'libraries/*/src/**.c' - 'package/**' schedule: - cron: '0 2 * * *' From 352337ba6847bc7069c03f68b97a9d0bd1afa57a Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:07:38 -0300 Subject: [PATCH 3/3] fix(push): Fix push chunks script indentation and lib detection --- .github/scripts/set_push_chunks.sh | 116 ++++++++++++++--------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/.github/scripts/set_push_chunks.sh b/.github/scripts/set_push_chunks.sh index 472205f0c38..11a93a7159d 100644 --- a/.github/scripts/set_push_chunks.sh +++ b/.github/scripts/set_push_chunks.sh @@ -4,73 +4,73 @@ 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 + 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 + 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 + lib=$(echo $file | awk -F "/" '{print $1"/"$2}') + if [[ "$file" == *.ino ]]; then + # If file ends with .ino, add it to the list of sketches + echo "Sketch found: $file" + sketches+="$file " + elif [[ "$file" == "$lib/src/"* ]]; then + # If file is inside the src directory, find all sketches in the lib/examples directory + echo "Library src file found: $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" + # 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 + 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\"" + chunks+=",\"$i\"" done chunks+="]"