From 25b7a8020412be10f0bfa7bb5f355bb0aa5c519b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Proch=C3=A1zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Mon, 21 Oct 2024 23:44:01 +0200 Subject: [PATCH 1/5] fix(ci): Chnage approach in listing the changed boards --- .github/scripts/find_new_boards.sh | 54 +++++++++--------------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/.github/scripts/find_new_boards.sh b/.github/scripts/find_new_boards.sh index 77c98877d2a..083f1448e83 100755 --- a/.github/scripts/find_new_boards.sh +++ b/.github/scripts/find_new_boards.sh @@ -8,53 +8,32 @@ url="https://api.github.com/repos/$owner_repository/pulls/$pr_number/files" echo $url # Get changes in boards.txt file from PR -Patch=$(curl $url | jq -r '.[] | select(.filename == "boards.txt") | .patch ') +Boards_modified_url=$(curl -s $url | jq -r '.[] | select(.filename == "boards.txt") | .raw_url') -# Extract only changed lines number and count -substring_patch=$(echo "$Patch" | grep -o '@@[^@]*@@') +# Echo the modified boards.txt file URL +echo "Modified boards.txt file URL:" +echo $Boards_modified_url -params_array=() +# Download the modified boards.txt file +curl -L -o boards_pr.txt $Boards_modified_url -IFS=$'\n' read -d '' -ra params <<< $(echo "$substring_patch" | grep -oE '[-+][0-9]+,[0-9]+') +# Compare boards.txt file in the repo with the modified file +diff=$(diff -u boards.txt boards_pr.txt) -for param in "${params[@]}" -do - echo "The parameter is $param" - params_array+=("$param") -done +# Extract added or modified lines (lines starting with '+' or '-') +modified_lines=$(echo "$diff" | grep -E '^[+-][^+-]') boards_array=() previous_board="" file="boards.txt" -# Loop through boards.txt file and extract all boards that were added -for (( c=0; c<${#params_array[@]}; c+=2 )) +# Extract board names from the modified lines, and add them to the boards_array +while read -r line do - deletion_count=$( echo "${params_array[c]}" | cut -d',' -f2 | cut -d' ' -f1 ) - addition_line=$( echo "${params_array[c+1]}" | cut -d'+' -f2 | cut -d',' -f1 ) - addition_count=$( echo "${params_array[c+1]}" | cut -d'+' -f2 | cut -d',' -f2 | cut -d' ' -f1 ) - addition_end=$(($addition_line+$addition_count)) - - addition_line=$(($addition_line + 3)) - addition_end=$(($addition_end - $deletion_count)) - - echo $addition_line - echo $addition_end - - i=0 - - while read -r line - do - i=$((i+1)) - if [ $i -lt $addition_line ] - then - continue - elif [ $i -gt $addition_end ] - then - break - fi board_name=$(echo "$line" | cut -d '.' -f1 | cut -d '#' -f1) - if [ "$board_name" != "" ] && [ "$board_name" != "esp32_family" ] + # remove + or - from the board name at the beginning + board_name=$(echo "$board_name" | sed 's/^[+-]//') + if [ "$board_name" != "" ] && [ "$board_name" != "+" ] && [ "$board_name" != "-" ] && [ "$board_name" != "esp32_family" ] then if [ "$board_name" != "$previous_board" ] then @@ -63,8 +42,7 @@ do echo "Added 'espressif:esp32:$board_name' to array" fi fi - done < "$file" -done +done <<< "$modified_lines" # Create JSON like string with all boards found and pass it to env variable board_count=${#boards_array[@]} From 02941056376bee84bd609faaed2214b26d36e35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Proch=C3=A1zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Wed, 23 Oct 2024 08:45:00 +0200 Subject: [PATCH 2/5] add test boards --- .github/scripts/find_new_boards.sh | 1 - boards.txt | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/scripts/find_new_boards.sh b/.github/scripts/find_new_boards.sh index 083f1448e83..8159abc833a 100755 --- a/.github/scripts/find_new_boards.sh +++ b/.github/scripts/find_new_boards.sh @@ -25,7 +25,6 @@ modified_lines=$(echo "$diff" | grep -E '^[+-][^+-]') boards_array=() previous_board="" -file="boards.txt" # Extract board names from the modified lines, and add them to the boards_array while read -r line diff --git a/boards.txt b/boards.txt index 74d709ec1e1..7c3604c41ef 100644 --- a/boards.txt +++ b/boards.txt @@ -44367,3 +44367,7 @@ cezerio_dev_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP cezerio_dev_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port ############################################################## + +test_1.build.board=TEST_1 +test_2.build.board=TEST_2 +test_3.build.board=TEST_3 From c3a8a1849e3e41e30507d1ba56fffd93eb142590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Proch=C3=A1zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Wed, 23 Oct 2024 08:48:26 +0200 Subject: [PATCH 3/5] add debug logs --- .github/scripts/find_new_boards.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/scripts/find_new_boards.sh b/.github/scripts/find_new_boards.sh index 8159abc833a..abc7ca0ac6a 100755 --- a/.github/scripts/find_new_boards.sh +++ b/.github/scripts/find_new_boards.sh @@ -23,6 +23,10 @@ diff=$(diff -u boards.txt boards_pr.txt) # Extract added or modified lines (lines starting with '+' or '-') modified_lines=$(echo "$diff" | grep -E '^[+-][^+-]') +# Print the modified lines +echo "Modified lines:" +echo "$modified_lines" + boards_array=() previous_board="" @@ -43,6 +47,13 @@ do fi done <<< "$modified_lines" +# Print all boards found +echo "Boards found:" +for board in ${boards_array[@]} +do + echo $board +done + # Create JSON like string with all boards found and pass it to env variable board_count=${#boards_array[@]} From 6c52de1b53db169d2a261806b2c84bfef81bf2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Proch=C3=A1zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Wed, 23 Oct 2024 08:49:54 +0200 Subject: [PATCH 4/5] add more debug --- .github/scripts/find_new_boards.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/scripts/find_new_boards.sh b/.github/scripts/find_new_boards.sh index abc7ca0ac6a..8f2f541244f 100755 --- a/.github/scripts/find_new_boards.sh +++ b/.github/scripts/find_new_boards.sh @@ -17,6 +17,13 @@ echo $Boards_modified_url # Download the modified boards.txt file curl -L -o boards_pr.txt $Boards_modified_url +# Check if the file is downloaded +if [ ! -f boards_pr.txt ] +then + echo "Error: boards.txt file not downloaded" + exit 1 +fi + # Compare boards.txt file in the repo with the modified file diff=$(diff -u boards.txt boards_pr.txt) From 2909b2c84a4aac39daf9d53a0f94e2d5c2871b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Proch=C3=A1zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Wed, 23 Oct 2024 08:51:07 +0200 Subject: [PATCH 5/5] fix(ci): Fix boards test more logs more logs more logs --- .github/scripts/find_new_boards.sh | 40 ++++++++---------------------- .github/workflows/boards.yml | 2 +- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/.github/scripts/find_new_boards.sh b/.github/scripts/find_new_boards.sh index c2db23d41c7..706676b4a4c 100755 --- a/.github/scripts/find_new_boards.sh +++ b/.github/scripts/find_new_boards.sh @@ -2,39 +2,29 @@ # Get inputs from command owner_repository=$1 -pr_number=$2 +base_ref=$2 -url="https://api.github.com/repos/$owner_repository/pulls/$pr_number/files" -echo $url +# Download the boards.txt file from the base branch +curl -L -o boards_base.txt https://raw.githubusercontent.com/$owner_repository/$base_ref/boards.txt -# Get changes in boards.txt file from PR -Boards_modified_url=$(curl -s $url | jq -r '.[] | select(.filename == "boards.txt") | .raw_url') +# Compare boards.txt file in the repo with the modified file from PR +diff=$(diff -u boards_base.txt boards.txt) -# Echo the modified boards.txt file URL -echo "Modified boards.txt file URL:" -echo $Boards_modified_url - -# Download the modified boards.txt file -curl -L -o boards_pr.txt $Boards_modified_url - -# Check if the file is downloaded -if [ ! -f boards_pr.txt ] +# Check if the diff is empty +if [ -z "$diff" ] then - echo "Error: boards.txt file not downloaded" - exit 1 + echo "No changes in boards.txt file" + echo "FQBNS=" + exit 0 fi -# Compare boards.txt file in the repo with the modified file -diff=$(diff -u boards.txt boards_pr.txt) - # Extract added or modified lines (lines starting with '+' or '-') modified_lines=$(echo "$diff" | grep -E '^[+-][^+-]') -# Print the modified lines +# Print the modified lines for debugging echo "Modified lines:" echo "$modified_lines" - boards_array=() previous_board="" @@ -55,14 +45,6 @@ do fi done <<< "$modified_lines" -# Print all boards found -echo "Boards found:" -for board in ${boards_array[@]} -do - echo $board -done - - # Create JSON like string with all boards found and pass it to env variable board_count=${#boards_array[@]} diff --git a/.github/workflows/boards.yml b/.github/workflows/boards.yml index 8d5868b083b..a14f57508c6 100644 --- a/.github/workflows/boards.yml +++ b/.github/workflows/boards.yml @@ -29,7 +29,7 @@ jobs: - name: Get board name run: - bash .github/scripts/find_new_boards.sh ${{ github.repository }} ${{github.event.number}} + bash .github/scripts/find_new_boards.sh ${{ github.repository }} ${{github.base_ref}} test-boards: needs: find-boards