Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz committed Jul 18, 2024
1 parent a32cf3e commit 6073bf8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cron_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
ar_new_pr_title: ${{ steps.check.outputs.ar_new_pr_title }}
ar_has_commit: ${{ steps.check.outputs.ar_has_commit }}
ar_has_branch: ${{ steps.check.outputs.ar_has_branch }}
ar_pr_number: ${{ steps.check.outputs.ar_pr_number }}
ar_has_pr: ${{ steps.check.outputs.ar_has_pr }}
libs_release_tag: ${{ steps.check.outputs.libs_release_tag }}
libs_version: ${{ steps.check.outputs.libs_version }}
Expand Down Expand Up @@ -144,6 +145,7 @@ jobs:
AR_NEW_PR_TITLE: ${{ needs.check-if-needed.outputs.ar_new_pr_title }}
AR_HAS_COMMIT: ${{ needs.check-if-needed.outputs.ar_has_commit }}
AR_HAS_BRANCH: ${{ needs.check-if-needed.outputs.ar_has_branch }}
AR_PR_NUMBER: ${{ needs.check-if-needed.outputs.ar_pr_number }}
AR_HAS_PR: ${{ needs.check-if-needed.outputs.ar_has_pr }}
LIBS_RELEASE_TAG: ${{ needs.check-if-needed.outputs.libs_release_tag }}
LIBS_VERSION: ${{ needs.check-if-needed.outputs.libs_version }}
Expand Down
7 changes: 6 additions & 1 deletion tools/check-deploy-needed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ if [ "$AR_HAS_BRANCH" == "1" ]; then
else
AR_HAS_COMMIT=`github_commit_exists "$AR_REPO" "$AR_BRANCH" "$IDF_COMMIT"`
fi
AR_HAS_PR=`github_pr_exists "$AR_REPO" "$AR_NEW_BRANCH_NAME"`

AR_PR_NUMBER=`github_pr_number "$AR_REPO" "$AR_NEW_BRANCH_NAME"`
AR_HAS_PR=`if [ -n "$AR_PR_NUMBER" ]; then echo "1"; else echo "0"; fi`

LIBS_RELEASE_ID=`github_release_id "$AR_LIBS_REPO" "$LIBS_RELEASE_TAG"`
LIBS_HAS_RELEASE=`if [ -n "$LIBS_RELEASE_ID" ]; then echo "1"; else echo "0"; fi`
Expand All @@ -60,6 +62,7 @@ export AR_NEW_PR_TITLE

export AR_HAS_COMMIT
export AR_HAS_BRANCH
export AR_PR_NUMBER
export AR_HAS_PR

export LIBS_RELEASE_TAG
Expand Down Expand Up @@ -89,6 +92,7 @@ echo "AR_NEW_BRANCH_NAME: $AR_NEW_BRANCH_NAME"
echo "AR_NEW_PR_TITLE: $AR_NEW_PR_TITLE"
echo "AR_HAS_COMMIT: $AR_HAS_COMMIT"
echo "AR_HAS_BRANCH: $AR_HAS_BRANCH"
echo "AR_PR_NUMBER: $AR_PR_NUMBER"
echo "AR_HAS_PR: $AR_HAS_PR"
echo "LIBS_RELEASE_TAG: $LIBS_RELEASE_TAG"
echo "LIBS_VERSION: $LIBS_VERSION"
Expand All @@ -106,6 +110,7 @@ if [ ! -x $GITHUB_OUTPUT ]; then
echo "ar_new_pr_title=$AR_NEW_PR_TITLE" >> "$GITHUB_OUTPUT"
echo "ar_has_commit=$AR_HAS_COMMIT" >> "$GITHUB_OUTPUT"
echo "ar_has_branch=$AR_HAS_BRANCH" >> "$GITHUB_OUTPUT"
echo "ar_pr_number=$AR_PR_NUMBER" >> "$GITHUB_OUTPUT"
echo "ar_has_pr=$AR_HAS_PR" >> "$GITHUB_OUTPUT"
echo "libs_release_tag=$LIBS_RELEASE_TAG" >> "$GITHUB_OUTPUT"
echo "libs_version=$LIBS_VERSION" >> "$GITHUB_OUTPUT"
Expand Down
3 changes: 2 additions & 1 deletion tools/combine-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ done
awk -i inplace '!seen[$0]++' $libs_folder/versions_full.txt
mv -f $libs_folder/versions_full.txt $libs_folder/versions.txt

cd out/tools && zip -X -q -r ../../dist/esp32-arduino-libs.zip * && cd ../..
echo "Creating zip file"
cd out/tools && zip -X -D -q -r ../../dist/esp32-arduino-libs.zip * && cd ../..
16 changes: 13 additions & 3 deletions tools/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ function github_branch_exists(){ # github_branch_exists <repo-path> <branch-name
if [ "$branch" == "$branch_name" ]; then echo 1; else echo 0; fi
}

function github_pr_exists(){ # github_pr_exists <repo-path> <branch-name>
function github_pr_number(){ # github_pr_number <repo-path> <branch-name>
local repo_path="$1"
local branch_name="$2"
local pr_num=`curl -s -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$repo_path/pulls?head=$AR_USER:$branch_name&state=open" | jq -r '.[].number'`
if [ ! "$pr_num" == "" ] && [ ! "$pr_num" == "null" ]; then echo 1; else echo 0; fi
if [ ! "$pr_num" == "" ] && [ ! "$pr_num" == "null" ]; then echo "$pr_num"; else echo ""; fi
}

function github_release_id(){ # github_release_id <repo-path> <release-tag>
Expand Down Expand Up @@ -178,7 +178,7 @@ function git_commit_exists(){ #git_commit_exists <repo-path> <commit-message>
if [ -n "$commits_found" ]; then echo 1; else echo 0; fi
}

function git_create_pr(){ # git_create_pr <branch> <title>
function git_create_pr(){ # git_create_pr <branch> <title> <target>
local pr_branch="$1"
local pr_title="$2"
local pr_target="$3"
Expand All @@ -191,3 +191,13 @@ function git_create_pr(){ # git_create_pr <branch> <title>
if [ ! "$done_pr" == "" ] && [ ! "$done_pr" == "null" ]; then echo 1; else echo 0; fi
}

function git_update_pr(){ # git_update_pr <number>
local pr_number="$1"
local pr_body="\`\`\`\r\n"
while read -r line; do pr_body+=$line"\r\n"; done < "$AR_TOOLS/esp32-arduino-libs/versions.txt"
pr_body+="\`\`\`\r\n"
local pr_data="{\"body\": \"$pr_body\"}"
git_update_pr_res=`echo "$pr_data" | curl -k -X PATCH -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" --data @- "https://api.github.com/repos/$AR_REPO/pulls/$pr_number"`
local done_pr=`echo "$git_update_pr_res" | jq -r '.title'`
if [ ! "$done_pr" == "" ] && [ ! "$done_pr" == "null" ]; then echo 1; else echo 0; fi
}
9 changes: 7 additions & 2 deletions tools/push-to-arduino.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fi
# esp32-arduino
#

if [ $AR_HAS_COMMIT == "0" ]; then
if [ $AR_HAS_COMMIT == "0" ] || [ $LIBS_HAS_ASSET == "0" ]; then
cd "$AR_ROOT"
# create or checkout the branch
if [ ! $AR_HAS_BRANCH == "0" ]; then
Expand Down Expand Up @@ -164,7 +164,12 @@ if [ $AR_HAS_COMMIT == "0" ]; then
exit 1
fi
else
echo "PR '$AR_NEW_PR_TITLE' Already Exists"
echo "Updating PR $AR_PR_NUMBER..."
pr_updated=`git_update_pr "$AR_PR_NUMBER"`
if [ $pr_updated == "0" ]; then
echo "ERROR: Failed to update PR '$AR_NEW_PR_TITLE': "`echo "$git_update_pr_res" | jq -r '.message'`": "`echo "$git_update_pr_res" | jq -r '.errors[].message'`
exit 1
fi
fi
fi

Expand Down

0 comments on commit 6073bf8

Please sign in to comment.