Skip to content

Commit

Permalink
fix(ci): Fix boards test
Browse files Browse the repository at this point in the history
more logs

more logs

more logs
  • Loading branch information
P-R-O-C-H-Y committed Oct 23, 2024
1 parent 2ad1804 commit 2909b2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
40 changes: 11 additions & 29 deletions .github/scripts/find_new_boards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=""

Expand All @@ -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[@]}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/boards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2909b2c

Please sign in to comment.