Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6ca98c3

Browse files
committedJun 26, 2024
Split cron jobs using matrix
1 parent 6683a0d commit 6ca98c3

File tree

5 files changed

+124
-23
lines changed

5 files changed

+124
-23
lines changed
 

‎.github/workflows/cron.yml

+111-7
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,49 @@
11
name: Cron Build
22

3-
on:
3+
on:
44
schedule:
55
# ┌───────────── minute (0 - 59)
66
# │ ┌───────────── hour (0 - 23)
77
# │ │ ┌───────────── day of the month (1 - 31)
88
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
99
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
10-
# │ │ │ │ │
10+
# │ │ │ │ │
1111
# │ │ │ │ │
1212
# │ │ │ │ │
1313
# * * * * *
1414
- cron: '0 */6 * * *'
15+
workflow_dispatch:
16+
inputs:
17+
idf_branch:
18+
description: 'IDF branch to build'
19+
required: true
20+
default: 'release/v5.1'
21+
target:
22+
description: 'Target to build'
23+
required: true
24+
default: 'all'
1525

1626
defaults:
1727
run:
1828
shell: bash
1929

2030
jobs:
21-
run:
22-
name: Build with IDF ${{ matrix.idf_branch }}
31+
build-libs:
32+
name: Build with IDF ${{ matrix.idf_branch }} for ${{ matrix.target }}
2333
runs-on: ubuntu-latest
24-
34+
if: github.event_name == 'schedule'
2535
strategy:
2636
fail-fast: false
2737
matrix:
2838
idf_branch: [release/v5.1, release/v4.4] #, release/v3.3]
39+
target: [esp32, esp32s2, esp32s3, esp32c3]
40+
include:
41+
- idf_branch: release/v5.1
42+
target: esp32c2
43+
- idf_branch: release/v5.1
44+
target: esp32c6
45+
- idf_branch: release/v5.1
46+
target: esp32h2
2947
steps:
3048
- uses: actions/checkout@v4
3149
with:
@@ -39,8 +57,94 @@ jobs:
3957
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
4058
IDF_BRANCH: ${{ matrix.idf_branch }}
4159
run: |
42-
git checkout ${{ matrix.idf_branch }} || echo "Using master branch"
43-
bash ./tools/cron.sh
60+
git checkout ${{ env.IDF_BRANCH }} || echo "Using master branch"
61+
if [ ! "$GITHUB_EVENT_NAME" == "schedule" ]; then
62+
echo "Wrong event '$GITHUB_EVENT_NAME'!"
63+
exit 1
64+
fi
65+
66+
bash ./build.sh -e -t ${{ matrix.target }}
67+
68+
- name: Upload build
69+
if: failure()
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: build-${{ matrix.idf_branch }}-${{ matrix.target }}
73+
path: build
74+
75+
- name: Upload library files
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: libs-${{ matrix.idf_branch }}-${{ matrix.target }}
79+
path: dist
80+
81+
combine-artifacts:
82+
name: Combine artifacts for IDF ${{ matrix.idf_branch }}
83+
runs-on: ubuntu-latest
84+
if: github.event_name == 'schedule'
85+
needs: build-libs
86+
strategy:
87+
fail-fast: false
88+
matrix:
89+
idf_branch: [release/v5.1, release/v4.4]
90+
steps:
91+
- name: Download artifacts
92+
uses: actions/download-artifact@v4
93+
with:
94+
path: dist
95+
pattern: libs-${{ matrix.idf_branch }}-*
96+
merge-multiple: true
97+
98+
- name: Combine artifacts
99+
shell: bash
100+
run: |
101+
set -e
102+
mkdir -p out
103+
find dist -name 'arduino-esp32-libs-esp*.tar.gz' -exec tar zxvf {} -C out \;
104+
for file in $files; do
105+
tar zxvf $file -C out
106+
cat out/tools/esp32-arduino-libs/versions.txt >> out/tools/esp32-arduino-libs/versions_full.txt
107+
done
108+
awk -i inplace '!seen[$0]++' out/tools/esp32-arduino-libs/versions_full.txt
109+
mv -f out/tools/esp32-arduino-libs/versions_full.txt out/tools/esp32-arduino-libs/versions.txt
110+
cd out/tools/esp32-arduino-libs && tar zcf ../../../dist/esp32-arduino-libs.tar.gz * && cd ../../..
111+
cp out/package_esp32_index.template.json dist/package_esp32_index.template.json
112+
113+
- name: Push changes
114+
if: ${{ github.repository == 'espressif/esp32-arduino-lib-builder' }}
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
117+
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
118+
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
119+
IDF_BRANCH: ${{ matrix.idf_branch }}
120+
run: |
121+
./tools/push-to-arduino.sh
122+
if [ $? -ne 0 ]; then exit 1; fi
123+
124+
build-libs-dispatch:
125+
name: Dispatch build with IDF ${{ inputs.idf_branch }}
126+
runs-on: ubuntu-latest
127+
if: github.event_name == 'workflow_dispatch'
128+
steps:
129+
- uses: actions/checkout@v4
130+
with:
131+
fetch-depth: 0
132+
- name: Install dependencies
133+
run: bash ./tools/prepare-ci.sh
134+
- name: Build
135+
env:
136+
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
137+
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
138+
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
139+
IDF_BRANCH: ${{ inputs.idf_branch }}
140+
run: |
141+
git checkout ${{ env.IDF_BRANCH }} || echo "Using master branch"
142+
if [ ! "$GITHUB_EVENT_NAME" == "schedule" ]; then
143+
echo "Wrong event '$GITHUB_EVENT_NAME'!"
144+
exit 1
145+
fi
146+
147+
bash ./build.sh -d -t ${{ inputs.target }}
44148
- name: Upload build
45149
if: failure()
46150
uses: actions/upload-artifact@v4

‎build.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ if [ "$BUILD_TYPE" != "all" ]; then
142142
# Skip building for targets that are not in the $TARGET array
143143
continue
144144
fi
145-
145+
146146
configs="configs/defconfig.common;configs/defconfig.$target;configs/defconfig.debug_$BUILD_DEBUG"
147147
for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do
148148
configs="$configs;configs/defconfig.$defconf"
@@ -187,7 +187,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
187187
continue
188188
fi
189189
fi
190-
190+
191191
# Skip chips that should not be a part of the final libs
192192
# WARNING!!! this logic needs to be updated when cron builds are split into jobs
193193
if [ "$TARGET" = "all" ] && [ $target_skip -eq 1 ]; then
@@ -299,13 +299,15 @@ done
299299

300300
# update package_esp32_index.template.json
301301
if [ "$BUILD_TYPE" = "all" ]; then
302+
echo "* Generating package_esp32_index.template.json..."
302303
python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -j "$AR_COMPS/arduino/package/package_esp32_index.template.json" -o "$AR_OUT/"
303304
python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -o "$TOOLS_JSON_OUT/"
304305
if [ $? -ne 0 ]; then exit 1; fi
305306
fi
306307

307308
# Generate PlatformIO manifest file
308309
if [ "$BUILD_TYPE" = "all" ]; then
310+
echo "* Generating PlatformIO manifest file..."
309311
pushd $IDF_PATH
310312
ibr=$(git describe --all 2>/dev/null)
311313
ic=$(git -C "$IDF_PATH" rev-parse --short HEAD)
@@ -316,18 +318,21 @@ fi
316318

317319
# copy everything to arduino-esp32 installation
318320
if [ $COPY_OUT -eq 1 ] && [ -d "$ESP32_ARDUINO" ]; then
321+
echo "* Copying to Arduino..."
319322
./tools/copy-to-arduino.sh
320323
if [ $? -ne 0 ]; then exit 1; fi
321324
fi
322325

323326
# push changes to esp32-arduino-libs and create pull request into arduino-esp32
324327
if [ $DEPLOY_OUT -eq 1 ]; then
328+
echo "* Pushing to Arduino..."
325329
./tools/push-to-arduino.sh
326330
if [ $? -ne 0 ]; then exit 1; fi
327331
fi
328332

329333
# archive the build
330334
if [ $ARCHIVE_OUT -eq 1 ]; then
335+
echo "* Archiving build..."
331336
./tools/archive-build.sh "$TARGET"
332337
if [ $? -ne 0 ]; then exit 1; fi
333338
fi

‎tools/cron.sh

-8
This file was deleted.

‎tools/install-esp-idf.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ source $IDF_PATH/export.sh
5151
# SETUP ARDUINO DEPLOY
5252
#
5353

54-
if [ "$GITHUB_EVENT_NAME" == "schedule" ] || [ "$GITHUB_EVENT_NAME" == "repository_dispatch" -a "$GITHUB_EVENT_ACTION" == "deploy" ]; then
54+
if [ "$GITHUB_EVENT_NAME" == "schedule" ] || [ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ] || [ "$GITHUB_EVENT_NAME" == "repository_dispatch" -a "$GITHUB_EVENT_ACTION" == "deploy" ]; then
5555
# format new branch name and pr title
5656
if [ -x $commit_predefined ]; then #commit was not specified at build time
5757
AR_NEW_BRANCH_NAME="idf-$IDF_BRANCH"

‎tools/push-to-arduino.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if [ $LIBS_HAS_COMMIT == "0" ] || [ $AR_HAS_COMMIT == "0" ]; then
4343
# make changes to the files
4444
echo "Patching files in esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'..."
4545
rm -rf $IDF_LIBS_DIR/* && cp -Rf $AR_TOOLS/esp32-arduino-libs/* $IDF_LIBS_DIR/
46-
46+
4747
cd $IDF_LIBS_DIR
4848
if [ -f "README.md" ]; then
4949
rm -rf "README.md"
@@ -52,9 +52,9 @@ if [ $LIBS_HAS_COMMIT == "0" ] || [ $AR_HAS_COMMIT == "0" ]; then
5252
# did any of the files change?
5353
if [ -n "$(git status --porcelain)" ]; then
5454
echo "Pushing changes to esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'..."
55-
git add . && git commit --message "$AR_NEW_COMMIT_MESSAGE" && git push -u origin $AR_NEW_BRANCH_NAME
55+
git add . && git commit --message "$AR_NEW_COMMIT_MESSAGE" && git push -u origin $AR_NEW_BRANCH_NAME
5656
if [ $? -ne 0 ]; then
57-
echo "ERROR: Pushing to branch '$AR_NEW_BRANCH_NAME' failed"
57+
echo "ERROR: Pushing to branch '$AR_NEW_BRANCH_NAME' failed"
5858
exit 1
5959
fi
6060
IDF_LIBS_COMMIT=`git rev-parse --verify HEAD`
@@ -122,13 +122,13 @@ if [ $AR_HAS_COMMIT == "0" ]; then
122122
# make changes to the files
123123
echo "Patching files in branch '$AR_NEW_BRANCH_NAME'..."
124124
rm -rf "$AR_COMPS/arduino/package/package_esp32_index.template.json" && cp -f "$AR_OUT/package_esp32_index.template.json" "$AR_COMPS/arduino/package/package_esp32_index.template.json"
125-
125+
126126
cd $AR_COMPS/arduino
127127

128128
# did any of the files change?
129129
if [ -n "$(git status --porcelain)" ]; then
130130
echo "Pushing changes to branch '$AR_NEW_BRANCH_NAME'..."
131-
git add . && git commit --message "$AR_NEW_COMMIT_MESSAGE" && git push -u origin $AR_NEW_BRANCH_NAME
131+
git add . && git commit --message "$AR_NEW_COMMIT_MESSAGE" && git push -u origin $AR_NEW_BRANCH_NAME
132132
if [ $? -ne 0 ]; then
133133
echo "ERROR: Pushing to branch '$AR_NEW_BRANCH_NAME' failed"
134134
exit 1

0 commit comments

Comments
 (0)
Please sign in to comment.