Skip to content

Commit 180d659

Browse files
committed
Merge branch 'ci/cron_optimization'
2 parents 28f5e7e + 97e27fd commit 180d659

10 files changed

+343
-259
lines changed

.github/workflows/cron.yml

+13-123
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: Cron Build
1+
name: Cron Deploy
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
# * * * * *
@@ -18,127 +18,17 @@ defaults:
1818
shell: bash
1919

2020
jobs:
21-
run:
21+
build-libs:
2222
name: Build with IDF ${{ matrix.idf_branch }}
23-
runs-on: ubuntu-latest
24-
23+
uses: ./.github/workflows/cron_build.yml
24+
with:
25+
idf_branch: ${{ matrix.idf_branch }}
26+
lib_builder_branch: ${{ matrix.lib_builder_branch }}
27+
targets: ${{ matrix.targets }}
2528
strategy:
2629
fail-fast: false
2730
matrix:
28-
idf_branch: [release/v5.1, release/v4.4] #, release/v3.3]
29-
steps:
30-
- uses: actions/checkout@v4
31-
with:
32-
fetch-depth: 0
33-
- name: Install dependencies
34-
run: bash ./tools/prepare-ci.sh
35-
- name: Build
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
38-
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
39-
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
40-
IDF_BRANCH: ${{ matrix.idf_branch }}
41-
run: |
42-
git checkout ${{ matrix.idf_branch }} || echo "Using master branch"
43-
bash ./tools/cron.sh
44-
- name: Upload build
45-
if: failure()
46-
uses: actions/upload-artifact@v4
47-
with:
48-
name: build
49-
path: build
50-
- name: Upload archive
51-
uses: actions/upload-artifact@v4
52-
with:
53-
name: artifacts
54-
path: dist
55-
56-
57-
# check:
58-
# name: Check if result should be deployed
59-
# runs-on: ubuntu-latest
60-
# strategy:
61-
# matrix:
62-
# branch: [release/v5.1, release/v4.4] #, release/v3.3]
63-
# outputs:
64-
# idf_branch: ${{ steps.check.outputs.idf_branch }}
65-
# idf_commit: ${{ steps.check.outputs.idf_commit }}
66-
# ar_branch: ${{ steps.check.outputs.ar_branch }}
67-
# ar_new_commit_message: ${{ steps.check.outputs.ar_new_commit_message }}
68-
# ar_new_branch_name: ${{ steps.check.outputs.ar_new_branch_name }}
69-
# ar_new_pr_title: ${{ steps.check.outputs.ar_new_pr_title }}
70-
# ar_has_commit: ${{ steps.check.outputs.ar_has_commit }}
71-
# ar_has_branch: ${{ steps.check.outputs.ar_has_branch }}
72-
# ar_has_pr: ${{ steps.check.outputs.ar_has_pr }}
73-
# libs_version: ${{ steps.check.outputs.libs_version }}
74-
# libs_has_commit: ${{ steps.check.outputs.libs_has_commit }}
75-
# libs_has_branch: ${{ steps.check.outputs.libs_has_branch }}
76-
# steps:
77-
# - uses: actions/checkout@v3
78-
# - id: check
79-
# env:
80-
# GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
81-
# GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
82-
# GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
83-
# IDF_BRANCH: ${{ matrix.idf_branch }}
84-
# run: bash ./tools/check-deploy-needed.sh
85-
86-
# build:
87-
# name: Build Libs for ${{ matrix.target }}
88-
# runs-on: ubuntu-latest
89-
# needs: check
90-
# if: needs.check.outputs.libs_has_commit == '0' || needs.check.outputs.ar_has_commit == '0'
91-
# strategy:
92-
# matrix:
93-
# target: [esp32, esp32s2, esp32s3, esp32c3, esp32c6, esp32h2]
94-
# fail-fast: false
95-
# steps:
96-
# - uses: actions/checkout@v3
97-
# # - name: Install dependencies
98-
# # run: bash ./tools/prepare-ci.sh
99-
# - shell: bash
100-
# name: Build Libs for ${{ matrix.target }}
101-
# run: echo ${{ matrix.target }}
102-
# # run: bash ./build.sh -t ${{ matrix.target }}
103-
# # - name: Upload archive
104-
# # uses: actions/upload-artifact@v3
105-
# # with:
106-
# # name: artifacts
107-
# # path: dist
108-
109-
# deploy:
110-
# name: Deploy build
111-
# runs-on: ubuntu-latest
112-
# needs: [check, build]
113-
# steps:
114-
# - uses: actions/checkout@v3
115-
# - shell: bash
116-
# env:
117-
# GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
118-
# GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
119-
# GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
120-
# IDF_BRANCH: ${{ needs.check.outputs.idf_branch }}
121-
# IDF_COMMIT: ${{ needs.check.outputs.idf_commit }}
122-
# AR_BRANCH: ${{ needs.check.outputs.ar_branch }}
123-
# AR_NEW_COMMIT_MESSAGE: ${{ needs.check.outputs.ar_new_commit_message }}
124-
# AR_NEW_BRANCH_NAME: ${{ needs.check.outputs.ar_new_branch_name }}
125-
# AR_NEW_PR_TITLE: ${{ needs.check.outputs.ar_new_pr_title }}
126-
# AR_HAS_COMMIT: ${{ needs.check.outputs.ar_has_commit }}
127-
# AR_HAS_BRANCH: ${{ needs.check.outputs.ar_has_branch }}
128-
# AR_HAS_PR: ${{ needs.check.outputs.ar_has_pr }}
129-
# LIBS_VERSION: ${{ needs.check.outputs.libs_version }}
130-
# LIBS_HAS_COMMIT: ${{ needs.check.outputs.libs_has_commit }}
131-
# LIBS_HAS_BRANCH: ${{ needs.check.outputs.libs_has_branch }}
132-
# run: |
133-
# echo "IDF_COMMIT: $IDF_COMMIT"
134-
# echo "AR_BRANCH: $AR_BRANCH"
135-
# echo "AR_NEW_COMMIT_MESSAGE: $AR_NEW_COMMIT_MESSAGE"
136-
# echo "AR_NEW_BRANCH_NAME: $AR_NEW_BRANCH_NAME"
137-
# echo "AR_NEW_PR_TITLE: $AR_NEW_PR_TITLE"
138-
# echo "AR_HAS_COMMIT: $AR_HAS_COMMIT"
139-
# echo "AR_HAS_BRANCH: $AR_HAS_BRANCH"
140-
# echo "AR_HAS_PR: $AR_HAS_PR"
141-
# echo "LIBS_VERSION: $LIBS_VERSION"
142-
# echo "LIBS_HAS_COMMIT: $LIBS_HAS_COMMIT"
143-
# echo "LIBS_HAS_BRANCH: $LIBS_HAS_BRANCH"
144-
31+
include:
32+
- idf_branch: "release/v5.1"
33+
lib_builder_branch: "master"
34+
targets: "esp32,esp32s2,esp32s3,esp32c3,esp32c6,esp32h2"

.github/workflows/cron_build.yml

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: Cron Build Matrix
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
idf_branch:
7+
type: string
8+
required: true
9+
description: 'IDF branch to build'
10+
lib_builder_branch:
11+
type: string
12+
required: true
13+
description: 'Branch of the lib-builder to use'
14+
targets:
15+
type: string
16+
required: true
17+
description: 'Targets to build'
18+
19+
env:
20+
IDF_BRANCH: ${{ inputs.idf_branch }}
21+
22+
jobs:
23+
check-if-needed:
24+
name: Check if deploy is needed for ${{ inputs.idf_branch }}
25+
runs-on: ubuntu-latest
26+
outputs:
27+
idf_commit: ${{ steps.check.outputs.idf_commit }}
28+
ar_branch: ${{ steps.check.outputs.ar_branch }}
29+
ar_new_commit_message: ${{ steps.check.outputs.ar_new_commit_message }}
30+
ar_new_branch_name: ${{ steps.check.outputs.ar_new_branch_name }}
31+
ar_new_pr_title: ${{ steps.check.outputs.ar_new_pr_title }}
32+
ar_has_commit: ${{ steps.check.outputs.ar_has_commit }}
33+
ar_has_branch: ${{ steps.check.outputs.ar_has_branch }}
34+
ar_has_pr: ${{ steps.check.outputs.ar_has_pr }}
35+
libs_release_tag: ${{ steps.check.outputs.libs_release_tag }}
36+
libs_version: ${{ steps.check.outputs.libs_version }}
37+
libs_release_id: ${{ steps.check.outputs.libs_release_id }}
38+
libs_has_release: ${{ steps.check.outputs.libs_has_release }}
39+
libs_asset_id: ${{ steps.check.outputs.libs_asset_id }}
40+
libs_has_asset: ${{ steps.check.outputs.libs_has_asset }}
41+
deploy_needed: ${{ steps.check.outputs.deploy_needed }}
42+
targets_list: ${{ steps.check.outputs.targets_list }}
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
ref: ${{ inputs.lib_builder_branch }}
47+
48+
- name: Check deploy and generate variables
49+
id: check
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
run: |
53+
source ./tools/check-deploy-needed.sh
54+
targets_list=$(echo "${{ inputs.targets }}" | sed 's/ *, */,/g' | sed 's/^/["/' | sed 's/$/"]/' | sed 's/,/","/g')
55+
echo "Targets list: $targets_list"
56+
echo "deploy_needed=$DEPLOY_NEEDED" >> $GITHUB_OUTPUT
57+
echo "targets_list=$targets_list" >> $GITHUB_OUTPUT
58+
59+
build-libs:
60+
name: Build for ${{ matrix.target }} (${{ inputs.idf_branch }})
61+
runs-on: ubuntu-latest
62+
if: needs.check-if-needed.outputs.deploy_needed == '1'
63+
needs: check-if-needed
64+
strategy:
65+
fail-fast: false
66+
matrix:
67+
target: ${{ fromJson(needs.check-if-needed.outputs.targets_list) }}
68+
steps:
69+
- uses: actions/checkout@v4
70+
with:
71+
ref: ${{ inputs.lib_builder_branch }}
72+
73+
- name: Install dependencies
74+
run: bash ./tools/prepare-ci.sh
75+
76+
- name: Build
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN || secrets.GITHUB_TOKEN }}
79+
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
80+
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
81+
TARGET: ${{ matrix.target }}
82+
run: |
83+
bash ./tools/cron.sh
84+
85+
- name: Replace invalid characters in the artifact name
86+
run: |
87+
branch=${{ inputs.idf_branch }}
88+
echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV
89+
90+
- name: Upload build
91+
if: failure()
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: build-${{ env.libs_branch }}-${{ matrix.target }}
95+
path: build
96+
97+
- name: Upload library files
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: libs-${{ env.libs_branch }}-${{ matrix.target }}
101+
path: dist
102+
103+
combine-artifacts:
104+
name: Combine artifacts for IDF ${{ inputs.idf_branch }}
105+
runs-on: ubuntu-latest
106+
needs: [check-if-needed, build-libs]
107+
if: needs.check-if-needed.outputs.deploy_needed == '1'
108+
steps:
109+
- uses: actions/checkout@v4
110+
with:
111+
ref: ${{ inputs.lib_builder_branch }}
112+
113+
- name: Replace invalid characters in the artifact name
114+
run: |
115+
branch=${{ inputs.idf_branch }}
116+
echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV
117+
118+
- name: Download artifacts
119+
uses: actions/download-artifact@v4
120+
with:
121+
path: dist
122+
pattern: libs-${{ env.libs_branch }}-*
123+
merge-multiple: true
124+
125+
- name: Combine artifacts
126+
run: bash ./tools/combine-artifacts.sh
127+
128+
- name: Upload full esp32-arduino-libs archive
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: esp32-arduino-libs-${{ env.libs_branch }}
132+
path: dist/esp32-arduino-libs.zip
133+
134+
- name: Push changes
135+
env:
136+
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
137+
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
138+
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
139+
IDF_COMMIT: ${{ needs.check-if-needed.outputs.idf_commit }}
140+
AR_BRANCH: ${{ needs.check-if-needed.outputs.ar_branch }}
141+
AR_NEW_COMMIT_MESSAGE: ${{ needs.check-if-needed.outputs.ar_new_commit_message }}
142+
AR_NEW_BRANCH_NAME: ${{ needs.check-if-needed.outputs.ar_new_branch_name }}
143+
AR_NEW_PR_TITLE: ${{ needs.check-if-needed.outputs.ar_new_pr_title }}
144+
AR_HAS_COMMIT: ${{ needs.check-if-needed.outputs.ar_has_commit }}
145+
AR_HAS_BRANCH: ${{ needs.check-if-needed.outputs.ar_has_branch }}
146+
AR_HAS_PR: ${{ needs.check-if-needed.outputs.ar_has_pr }}
147+
LIBS_RELEASE_TAG: ${{ needs.check-if-needed.outputs.libs_release_tag }}
148+
LIBS_VERSION: ${{ needs.check-if-needed.outputs.libs_version }}
149+
LIBS_RELEASE_ID: ${{ needs.check-if-needed.outputs.libs_release_id }}
150+
LIBS_HAS_RELEASE: ${{ needs.check-if-needed.outputs.libs_has_release }}
151+
LIBS_ASSET_ID: ${{ needs.check-if-needed.outputs.libs_asset_id }}
152+
LIBS_HAS_ASSET: ${{ needs.check-if-needed.outputs.libs_has_asset }}
153+
run: |
154+
bash ./tools/push-to-arduino.sh
155+
156+
- name: Upload package_esp32_index.template.json
157+
uses: actions/upload-artifact@v4
158+
with:
159+
name: package-esp32-index-json-${{ env.libs_branch }}
160+
path: out/package_esp32_index.template.json

build.sh

+5
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)