Skip to content

Commit aa67ce7

Browse files
authored
Create BuildTest.yml
1 parent aa4a859 commit aa67ce7

File tree

1 file changed

+252
-0
lines changed

1 file changed

+252
-0
lines changed

.github/workflows/BuildTest.yml

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
# This is a basic workflow to help you get started with Actions
2+
name: Test for ESP-IDF v4.3.1
3+
# on:
4+
# push:
5+
# branches:
6+
# - '**4.3'
7+
8+
jobs:
9+
bootstrap:
10+
name: Preparation
11+
container:
12+
image: sle118/squeezelite-esp32-idfv43
13+
outputs:
14+
build_number: ${{ steps.buildnumber.outputs.build_number }}
15+
ui_build: ${{ steps.build_flags.outputs.ui_build }}
16+
release_flag: ${{ steps.build_flags.outputs.release_flag }}
17+
mock: ${{ steps.build_flags.outputs.mock }}
18+
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 15
22+
submodules: true
23+
- name: Generate common build number
24+
id: buildnumber
25+
uses: einaregilsson/build-number@v3
26+
with:
27+
token: ${{secrets.github_token}}
28+
- name: Set build flags
29+
id: build_flags
30+
run: |
31+
. /opt/esp/python_env/idf4.3_py3.8_env/bin/activate
32+
# build_flags support the following options
33+
# --mock - to mock the compilation part - this is to be used for testing only
34+
# --force - to force a release build even if the last commit message doesn't contain the word "release"
35+
# --ui_build - to force a ui_build even if the last commit message doesn't contain "[ui-build]"
36+
build_tools.py build_flags --ui_build
37+
38+
preparation:
39+
name: Preparation
40+
needs: bootstrap
41+
container:
42+
image: sle118/squeezelite-esp32-idfv43
43+
steps:
44+
- name: Show Build Flags
45+
run: |
46+
echo "Running with the following options"
47+
echo "Web Build Flag=${{needs.bootstrap.outputs.ui_build}}"
48+
echo "Mock flag=${{needs.bootstrap.outputs.mock}}"
49+
echo "Release Flag=${{needs.bootstrap.outputs.release_flag}}"
50+
- uses: actions/checkout@v2
51+
with:
52+
fetch-depth: 15
53+
submodules: true
54+
- name: Pull latest
55+
run: |
56+
git pull
57+
git submodule update
58+
- name: Refresh certificates
59+
run: |
60+
git update-index --chmod=+x ./server_certs/getcert.sh
61+
cd server_certs;./getcert.sh;cat github.pem;cd ..
62+
- name: Setup Node.js dependencies
63+
if: ${{ !env.ACT }}
64+
uses: actions/setup-node@v3
65+
with:
66+
node-version: 16
67+
cache: 'npm'
68+
cache-dependency-path: components/wifi-manager/webapp/package.json
69+
- name: Build Web Application
70+
if: ${{ needs.bootstrap.outputs.ui_build == 1 }}
71+
run: |
72+
cd components/wifi-manager/webapp/
73+
npm install
74+
npm run-script build
75+
- name: Update repository with prebuilt items
76+
if: ${{ needs.bootstrap.outputs.ui_build == 1 || needs.bootstrap.outputs.release_flag == 1 }}
77+
run: |
78+
git fetch
79+
git config user.name github-actions
80+
git config user.email [email protected]
81+
git add server_certs
82+
git add components/wifi-manager/webapp/*.h
83+
git add components/wifi-manager/webapp/*.c
84+
git add components/wifi-manager/webapp/*.cmake
85+
git add components/wifi-manager/webapp/dist/*
86+
git commit -m "Update prebuilt objects [skip actions]"
87+
git push https://${{secrets.github_token}}@github.com/sle118/squeezelite-esp32.git
88+
- name: Locally store commonly built objects
89+
uses: actions/upload-artifact@v3
90+
with:
91+
name: prebuilt_objects
92+
path: |
93+
server_certs
94+
components/wifi-manager/webapp/*.h
95+
components/wifi-manager/webapp/*.c
96+
components/wifi-manager/webapp/dist/*
97+
components/wifi-manager/webapp/*.cmake
98+
build:
99+
container:
100+
image: sle118/squeezelite-esp32-idfv43
101+
needs: [preparation,bootstrap]
102+
strategy:
103+
max-parallel: 3
104+
matrix:
105+
#node: [I2S-4MFlash, SqueezeAmp, Muse]
106+
#depth: [16, 32]
107+
node: [I2S-4MFlash]
108+
depth: [16]
109+
exclude:
110+
- node: Muse
111+
depth: 32
112+
- node: bootstrap
113+
depth: 32
114+
steps:
115+
- uses: actions/checkout@v2
116+
with:
117+
fetch-depth: 15
118+
submodules: true
119+
- name: Show Build Flags
120+
run: |
121+
echo "Running with the following options"
122+
echo "Web Build Flag=${{needs.bootstrap.outputs.ui_build}}"
123+
echo "Mock flag=${{needs.bootstrap.outputs.mock}}"
124+
echo "Release Flag=${{needs.bootstrap.outputs.release_flag}}"
125+
echo Environment File name: $GITHUB_ENV
126+
- name: Set build parameters
127+
run: |
128+
. /opt/esp/python_env/idf4.3_py3.8_env/bin/activate
129+
build_tools.py environment --build ${{ needs.bootstrap.outputs.build_number }} --env_file "$GITHUB_ENV" --node "${{matrix.node}}" --depth ${{matrix.depth}} --major 2 --docker sle118/squeezelite-esp32-idfv43
130+
131+
- uses: actions/download-artifact@master
132+
name: Restore common objects
133+
with:
134+
name: prebuilt_objects
135+
- name: Build the firmware
136+
if: ${{ needs.bootstrap.outputs.mock == 0 }}
137+
run: |
138+
. ${IDF_PYTHON_ENV_PATH}/bin/activate
139+
chmod +x ./components/spotify/cspot/bell/nanopb/generator/protoc
140+
chmod +x ./components/spotify/cspot/bell/nanopb/generator/protoc-gen-nanopb
141+
chmod +x ./components/spotify/cspot/bell/nanopb/generator/*.py
142+
chmod +x ./components/spotify/cspot/bell/nanopb/generator/*.py2
143+
chmod +x ./components/spotify/cspot/bell/nanopb/generator/proto/*.py
144+
echo "Copying target sdkconfig"
145+
cp build-scripts/${TARGET_BUILD_NAME}-sdkconfig.defaults sdkconfig
146+
echo "Building project"
147+
idf.py build -DDEPTH=${DEPTH} -DBUILD_NUMBER=${BUILD_NUMBER}-${DEPTH}
148+
- name: Build Mock firmware
149+
if: ${{ needs.bootstrap.outputs.mock == 1 }}
150+
run: |
151+
mkdir -p build
152+
cd build
153+
mkdir -p partition_table
154+
mkdir -p bootloader
155+
echo \\"mock content\\"> ./squeezelite.bin
156+
echo \"mock content\"> ./recovery.bin
157+
echo \"mock content\"> ./bootloader/bootloader.bin
158+
echo \"mock content\"> ./partition_table/partition-table.bin
159+
echo \"mock content\"> ./ota_data_initial.bin
160+
echo \"mock content\"> ./flash_project_args
161+
echo \"mock content\"> ./size_comp1.txt
162+
echo \"mock content\"> ./size_comp2.txt
163+
echo \"mock content\"> ./partitions.csv
164+
echo { \"write_flash_args\" : [ \"--flash_mode\", \"dio\", \"--flash_size\", \"detect\", \"--flash_freq\", \"80m\" ], \"flash_settings\" : { \"flash_mode\": \"dio\", \"flash_size\": \"detect\", \"flash_freq\": \"80m\" }, \"flash_files\" : { \"0x8000\" : \"partition_table/partition-table.bin\", \"0xd000\" : \"ota_data_initial.bin\", \"0x1000\" : \"bootloader/bootloader.bin\", \"0x10000\" : \"recovery.bin\", \"0x150000\" : \"squeezelite.bin\" }, \"partition_table\" : { \"offset\" : \"0x8000\", \"file\" : \"partition_table/partition-table.bin\" }, \"otadata\" : { \"offset\" : \"0xd000\", \"file\" : \"ota_data_initial.bin\" }, \"bootloader\" : { \"offset\" : \"0x1000\", \"file\" : \"bootloader/bootloader.bin\" }, \"app\" : { \"offset\" : \"0x10000\", \"file\" : \"recovery.bin\" }, \"squeezelite\" : { \"offset\" : \"0x150000\", \"file\" : \"squeezelite.bin\" }, \"extra_esptool_args\" : { \"after\" : \"hard_reset\", \"before\" : \"default_reset\" } } > ./flasher_args.json
165+
- name: Create Release Artifact Zip
166+
if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
167+
run: |
168+
if [ -z "${artifact_file_name}" ]
169+
then
170+
echo "No artifact file name set. Will not generate zip file."
171+
else
172+
echo "Generating build artifact zip file"
173+
zip -r build_output.zip build
174+
zip build/${artifact_file_name} partitions*.csv components/ build/*.bin build/bootloader/bootloader.bin build/partition_table/partition-table.bin build/flash_project_args build/size_*.txt
175+
fi
176+
- name: Upload Artifacts
177+
uses: actions/upload-artifact@v3
178+
if: ${{ needs.bootstrap.outputs.mock == 0 }}
179+
with:
180+
name: ${{ env.artifact_prefix }}
181+
path: |
182+
build/flash_project_args
183+
build/size_comp1.txt
184+
build/size_comp2.txt
185+
partitions.csv
186+
sdkconfig
187+
server_certs/github.pem
188+
build_output.zip
189+
- name: Save Last Build
190+
if: ${{ needs.bootstrap.outputs.mock == 0 }}
191+
uses: actions/upload-artifact@v3
192+
with:
193+
name: build_parms
194+
path: |
195+
build/flash_project_args
196+
build/flasher_args.json
197+
partitions.csv
198+
sdkconfig
199+
- name: Create Release
200+
if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
201+
id: create_release
202+
uses: actions/create-release@v1
203+
env:
204+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
205+
with:
206+
tag_name: ${{ env.tag }}
207+
release_name: ${{ env.name }}
208+
body: ${{ env.description }}
209+
draft: false
210+
prerelease: true
211+
- name: Upload Release Asset - Squeezelite binary file
212+
if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
213+
id: upload-release-asset
214+
uses: actions/upload-release-asset@v1
215+
env:
216+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
217+
with:
218+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
219+
asset_path: build/squeezelite.bin
220+
asset_name: ${{ env.artifact_bin_file_name }}
221+
asset_content_type: application/octet-stream
222+
- name: Upload Release Asset - Zip file
223+
if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
224+
id: upload-release-asset-zip
225+
uses: actions/upload-release-asset@v1
226+
env:
227+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
228+
with:
229+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
230+
asset_path: build/${{ env.artifact_file_name }}
231+
asset_name: ${{ env.artifact_file_name }}
232+
asset_content_type: application/octet-stream
233+
update_web_installer:
234+
name: Web Installer
235+
if: ${{ needs.bootstrap.outputs.release_flag == 1 && needs.bootstrap.outputs.mock == 0 }}
236+
needs: [build, preparation,bootstrap]
237+
container:
238+
image: sle118/squeezelite-esp32-idfv43
239+
steps:
240+
- uses: actions/checkout@v2
241+
with:
242+
fetch-depth: 15
243+
submodules: true
244+
- uses: actions/download-artifact@master
245+
name: Restore last build
246+
with:
247+
name: build_parms
248+
- name: Update Web Installer Project
249+
run: |
250+
. /opt/esp/python_env/idf4.3_py3.8_env/bin/activate
251+
build_tools.py manifest --flash_file "./build/flasher_args.json" --outdir "./bin_files" --manif_name "manifest" --max_count 3
252+
build_tools.py pushinstaller --source "./bin_files" --manif_name "manifest" --target "web-installer" --url "https://github.com/sle118/squeezelite-esp32-installer.git" --artifacts "artifacts" --web_installer_branch "main" --token "${{secrets.github_token}}"

0 commit comments

Comments
 (0)