From 5fdfb8848b443f2915be5c84e5ca3ecd7996decb Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Fri, 27 Sep 2019 15:51:01 +0300 Subject: [PATCH] Update cron.yml --- .github/workflows/cron.yml | 10 ++--- .github/workflows/push.yml | 2 +- .github/workflows/repository_dispatch.yml | 6 ++- build.sh | 2 + tools/archive-build.sh | 17 ++++---- tools/config.sh | 2 +- tools/cron.sh | 7 +--- tools/install-esp-idf.sh | 40 ++++++++++++++++-- tools/prepare-libs.sh | 2 +- tools/push-to-arduino.sh | 35 +--------------- tools/repository_dispatch.sh | 40 +++++++++--------- tools/update-components.sh | 50 ++++++++++++++--------- 12 files changed, 114 insertions(+), 99 deletions(-) diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index b60fe5d..d158f88 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -32,8 +32,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }} IDF_BRANCH: ${{ matrix.idf_branch }} run: bash ./tools/cron.sh -# - name: Upload archive -# uses: actions/upload-artifact@v1 -# with: -# name: arduino-libs -# path: dist + - name: Upload archive + uses: actions/upload-artifact@v1 + with: + name: artifacts + path: dist diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index cb9d84a..299c789 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -23,5 +23,5 @@ jobs: - name: Upload archive uses: actions/upload-artifact@v1 with: - name: arduino-libs + name: artifacts path: dist diff --git a/.github/workflows/repository_dispatch.yml b/.github/workflows/repository_dispatch.yml index 37fbab5..5a8b072 100644 --- a/.github/workflows/repository_dispatch.yml +++ b/.github/workflows/repository_dispatch.yml @@ -6,7 +6,6 @@ jobs: run: name: Dispatch Event runs-on: ubuntu-latest - steps: - uses: actions/checkout@v1 - name: Install dependencies @@ -17,3 +16,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }} run: bash ./tools/repository_dispatch.sh + - name: Upload archive + uses: actions/upload-artifact@v1 + with: + name: artifacts + path: dist diff --git a/build.sh b/build.sh index 8081c2a..aea6f7b 100755 --- a/build.sh +++ b/build.sh @@ -35,6 +35,8 @@ if ! [ -x "$(command -v stat)" ]; then exit 1 fi +mkdir -p dist + # update components from git ./tools/update-components.sh if [ $? -ne 0 ]; then exit 1; fi diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 7e108f0..d6682ff 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -1,13 +1,16 @@ #!/bin/bash -IDF_COMMIT=$(git -C $IDF_PATH rev-parse --short HEAD) -IDF_BRANCH=$(git -C $IDF_PATH symbolic-ref --short HEAD) +IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) +IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD) idf_version_string=${IDF_BRANCH//\//_}"-$IDF_COMMIT" archive_path="dist/arduino-esp32-libs-$idf_version_string.tar.gz" +build_archive_path="dist/arduino-esp32-build-$idf_version_string.tar.gz" -mkdir -p dist && \ -rm -rf $archive_path && \ -cd out && \ -tar zcf ../$archive_path * \ -&& cd .. +mkdir -p dist && rm -rf "$archive_path" "$build_archive_path" +if [ -d "out" ]; then + cd out && tar zcf "../$archive_path" * && cd .. +fi +if [ -d "build" ]; then + cd build && tar zcf "../$build_archive_path" * && cd .. +fi diff --git a/tools/config.sh b/tools/config.sh index 478e465..02c7932 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -13,7 +13,7 @@ if [ -z $IDF_BRANCH ]; then fi # Owner of the target ESP32 Arduino repository -AR_USER="me-no-dev" +AR_USER="espressif" # The full name of the repository AR_REPO="$AR_USER/arduino-esp32" diff --git a/tools/cron.sh b/tools/cron.sh index 874200c..6122b1e 100644 --- a/tools/cron.sh +++ b/tools/cron.sh @@ -1,15 +1,10 @@ #!/bin/bash -if [ ! $GITHUB_EVENT_NAME == "schedule" ]; then +if [ ! "$GITHUB_EVENT_NAME" == "schedule" ]; then echo "Wrong event '$GITHUB_EVENT_NAME'!" exit 1 fi -echo "Event: $GITHUB_EVENT_NAME, Repo: $GITHUB_REPOSITORY, Path: $GITHUB_WORKSPACE, Ref: $GITHUB_REF" - git checkout "$IDF_BRANCH" #local branches should match what the matrix wants to build - source ./build.sh - bash ./tools/push-to-arduino.sh -#bash ./tools/archive-build.sh diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 68b1038..ad62e71 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -7,6 +7,10 @@ if ! [ -x "$(command -v $SED)" ]; then exit 1 fi +# +# CLONE ESP-IDF +# + if [ -z "$IDF_PATH" ]; then echo "ESP-IDF is not installed! Installing local copy" idf_was_installed="1" @@ -17,12 +21,16 @@ if [ -z "$IDF_PATH" ]; then fi if [ "$IDF_COMMIT" ]; then - git -C $IDF_PATH checkout $IDF_COMMIT + git -C "$IDF_PATH" checkout "$IDF_COMMIT" commit_predefined="1" fi -export IDF_COMMIT=$(git -C $IDF_PATH rev-parse --short HEAD) -export IDF_BRANCH=$(git -C $IDF_PATH symbolic-ref --short HEAD) +export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) +export IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD) + +# +# SETUP ARDUINO DEPLOY +# if [ "$GITHUB_EVENT_NAME" == "schedule" ] || [ "$GITHUB_EVENT_NAME" == "repository_dispatch" -a "$GITHUB_EVENT_ACTION" == "deploy" ]; then # format new branch name and pr title @@ -53,6 +61,24 @@ if [ "$GITHUB_EVENT_NAME" == "schedule" ] || [ "$GITHUB_EVENT_NAME" == "reposito echo "PR '$AR_NEW_PR_TITLE' Already Exists" fi + # setup git for pushing + git config --global github.user "$GITHUB_ACTOR" + git config --global user.name "$GITHUB_ACTOR" + git config --global user.email "$GITHUB_ACTOR@github.com" + + # create or checkout the branch + if [ ! $AR_HAS_BRANCH == "0" ]; then + echo "Switching to arduino branch '$AR_NEW_BRANCH_NAME'..." + git -C "$AR_COMPS/arduino" checkout $AR_NEW_BRANCH_NAME + else + echo "Creating arduino branch '$AR_NEW_BRANCH_NAME'..." + git -C "$AR_COMPS/arduino" checkout -b $AR_NEW_BRANCH_NAME + fi + if [ $? -ne 0 ]; then + echo "ERROR: Checkout of branch '$AR_NEW_BRANCH_NAME' failed" + exit 1 + fi + export AR_NEW_BRANCH_NAME export AR_NEW_COMMIT_MESSAGE export AR_NEW_PR_TITLE @@ -62,6 +88,10 @@ if [ "$GITHUB_EVENT_NAME" == "schedule" ] || [ "$GITHUB_EVENT_NAME" == "reposito export AR_HAS_PR fi +# +# UPDATE IDF MODULES +# + if [ -x $idf_was_installed ]; then git -C $IDF_PATH fetch origin && git -C $IDF_PATH pull origin $IDF_BRANCH git -C $IDF_PATH submodule update --init --recursive @@ -70,6 +100,10 @@ else cd $IDF_PATH && python -m pip install -r requirements.txt && cd "$AR_ROOT" fi +# +# INSTALL TOOLCHAIN +# + if ! [ -x "$(command -v $IDF_TOOLCHAIN-gcc)" ]; then echo "GCC toolchain is not installed! Installing local copy" diff --git a/tools/prepare-libs.sh b/tools/prepare-libs.sh index 064e48e..65390ec 100755 --- a/tools/prepare-libs.sh +++ b/tools/prepare-libs.sh @@ -16,7 +16,7 @@ cat pio_start.txt > "$AR_PLATFORMIO_PY" rm pio_end.txt 1pio_start.txt 2pio_start.txt pio_start.txt # include dirs -AR_INC="-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DHAVE_CONFIG_H \"-I{compiler.sdk.path}/include/config\"" +AR_INC="-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DHAVE_CONFIG_H -DGCC_NOT_5_2_0=0 -DWITH_POSIX \"-I{compiler.sdk.path}/include/config\"" echo " CPPPATH=[" >> "$AR_PLATFORMIO_PY" && echo " join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"include\", \"config\")," >> "$AR_PLATFORMIO_PY" while [ "$1" != "" ]; do cpath=$1 diff --git a/tools/push-to-arduino.sh b/tools/push-to-arduino.sh index b4c9967..7ebb077 100755 --- a/tools/push-to-arduino.sh +++ b/tools/push-to-arduino.sh @@ -11,46 +11,13 @@ if ! [ -d "$AR_COMPS/arduino" ]; then exit 1 fi -# # format new branch name and pr title -# if [ -x $1 ]; then #commit was not specified at build time -# AR_NEW_BRANCH_NAME="idf-$IDF_BRANCH" -# AR_NEW_COMMIT_MESSAGE="IDF $IDF_BRANCH $IDF_COMMIT" -# AR_NEW_PR_TITLE="IDF $IDF_BRANCH" -# else -# AR_NEW_BRANCH_NAME="idf-$IDF_COMMIT" -# AR_NEW_COMMIT_MESSAGE="IDF $IDF_COMMIT" -# AR_NEW_PR_TITLE="$AR_NEW_COMMIT_MESSAGE" -# fi - -# AR_HAS_COMMIT=`git_commit_exists "$AR_COMPS/arduino" "$AR_NEW_COMMIT_MESSAGE"` -# AR_HAS_BRANCH=`git_branch_exists "$AR_COMPS/arduino" "$AR_NEW_BRANCH_NAME"` -# AR_HAS_PR=`git_pr_exists "$AR_NEW_BRANCH_NAME"` - # -# CREATE/UPDATE BRANCH +# UPDATE FILES # if [ $AR_HAS_COMMIT == "0" ]; then cd $AR_COMPS/arduino - # setup git for pushing - git config --global github.user "$GITHUB_ACTOR" - git config --global user.name "$GITHUB_ACTOR" - git config --global user.email "$GITHUB_ACTOR@github.com" - - # create or checkout the branch - if [ ! $AR_HAS_BRANCH == "0" ]; then - echo "Switching to branch '$AR_NEW_BRANCH_NAME'..." - git checkout $AR_NEW_BRANCH_NAME - else - echo "Creating branch '$AR_NEW_BRANCH_NAME'..." - git checkout -b $AR_NEW_BRANCH_NAME - fi - if [ $? -ne 0 ]; then - echo "ERROR: Checkour of branch '$AR_NEW_BRANCH_NAME' failed" - exit 1 - fi - # make changes to the files echo "Patching files in branch '$AR_NEW_BRANCH_NAME'..." rm -rf $AR_COMPS/arduino/tools/sdk diff --git a/tools/repository_dispatch.sh b/tools/repository_dispatch.sh index c90ecd7..2fdce4a 100644 --- a/tools/repository_dispatch.sh +++ b/tools/repository_dispatch.sh @@ -1,41 +1,41 @@ #!/bin/bash -if [ ! $GITHUB_EVENT_NAME == "repository_dispatch" ]; then +if [ ! "$GITHUB_EVENT_NAME" == "repository_dispatch" ]; then echo "Wrong event '$GITHUB_EVENT_NAME'!" exit 1 fi -#echo "Event: $GITHUB_EVENT_NAME, Repo: $GITHUB_REPOSITORY, Path: $GITHUB_WORKSPACE, Ref: $GITHUB_REF" +EVENT_JSON=`cat "$GITHUB_EVENT_PATH"` +action=`echo "$EVENT_JSON" | jq -r '.action'` +payload=`echo "$EVENT_JSON" | jq -r '.client_payload'` +branch=`echo "$payload" | jq -r '.branch'` +commit=`echo "$payload" | jq -r '.commit'` +builder=`echo "$payload" | jq -r '.builder'` -EVENT_JSON=`cat $GITHUB_EVENT_PATH` -action=`echo $EVENT_JSON | jq -r '.action'` -payload=`echo $EVENT_JSON | jq -r '.client_payload'` -branch=`echo $payload | jq -r '.branch'` -commit=`echo $payload | jq -r '.commit'` +echo "Action: $action, Branch: $branch, Commit: $commit, Builder: $builder" -echo "Action: $action, Branch: $branch, Commit: $commit" - -if [ ! $action == "deploy" ] && [ ! $action == "build" ]; then +if [ ! "$action" == "deploy" ] && [ ! "$action" == "build" ]; then echo "Bad Action $action" exit 1 fi export GITHUB_EVENT_ACTION="$action" -if [ ! $commit == "" ] && [ ! $commit == "null" ]; then +if [ ! "$commit" == "" ] && [ ! "$commit" == "null" ]; then export IDF_COMMIT="$commit" else - commit="" - if [ ! $branch == "" ] && [ ! $branch == "null" ]; then - export IDF_BRANCH="$branch" - git checkout "$IDF_BRANCH" #local branches should match what the matrix wants to build - fi + commit="" + if [ ! "$branch" == "" ] && [ ! "$branch" == "null" ]; then + export IDF_BRANCH="$branch" + fi +fi + +if [ ! "$builder" == "" ] && [ ! "$builder" == "null" ]; then + git checkout "$builder" fi source ./build.sh -#bash ./tools/archive-build.sh - -if [ $action == "deploy" ]; then - bash ./tools/push-to-arduino.sh $commit +if [ "$action" == "deploy" ]; then + bash ./tools/push-to-arduino.sh fi diff --git a/tools/update-components.sh b/tools/update-components.sh index ffe6494..7cae8c1 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -2,29 +2,39 @@ source ./tools/config.sh -cd "$AR_COMPS" +# +# CLONE/UPDATE ARDUINO +# -if [ ! -d "arduino" ]; then - git clone $AR_REPO_URL arduino +if [ ! -d "$AR_COMPS/arduino" ]; then + git clone $AR_REPO_URL "$AR_COMPS/arduino" +else + git -C "$AR_COMPS/arduino" fetch origin && \ + git -C "$AR_COMPS/arduino" pull origin master fi +if [ $? -ne 0 ]; then exit 1; fi +git -C "$AR_COMPS/arduino" submodule update --init --recursive -if [ ! -d "esp32-camera" ]; then - git clone --depth 1 $CAMERA_REPO_URL +# +# CLONE/UPDATE ESP32-CAMERA +# + +if [ ! -d "$AR_COMPS/esp32-camera" ]; then + git clone $CAMERA_REPO_URL "$AR_COMPS/esp32-camera" +else + git -C "$AR_COMPS/esp32-camera" fetch origin && \ + git -C "$AR_COMPS/esp32-camera" pull origin master fi +if [ $? -ne 0 ]; then exit 1; fi -if [ ! -d "esp-face" ]; then - git clone --depth 1 $FACE_REPO_URL +# +# CLONE/UPDATE ESP-FACE +# + +if [ ! -d "$AR_COMPS/esp-face" ]; then + git clone $FACE_REPO_URL "$AR_COMPS/esp-face" +else + git -C "$AR_COMPS/esp-face" fetch origin && \ + git -C "$AR_COMPS/esp-face" pull origin master fi - -cd "$AR_ROOT" - -for component in `ls components`; do - cd "$AR_COMPS/$component" - if [ -d ".git" ]; then - git fetch origin && git pull origin master - fi -done - -cd "$AR_COMPS/arduino" -git submodule update --init --recursive -cd "$AR_ROOT" +if [ $? -ne 0 ]; then exit 1; fi