-
Notifications
You must be signed in to change notification settings - Fork 89
409 lines (345 loc) · 15.2 KB
/
Build_Examples.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
###############################################################################
#
# Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
# Analog Devices, Inc.),
# Copyright (C) 2023-2024 Analog Devices, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
name: Build_Examples
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Build_Examples:
# The type of runner that the job will run on
runs-on:
- ubuntu-latest
env:
SOURCE_BRANCH: ${{github.ref_name}}
TARGET_BRANCH: ${{github.event.pull_request.base.ref}}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
# Update the submodules below, doing so here will convert ssh to https
submodules: false
fetch-depth: 0
ref: '${{ github.event.pull_request.head.ref }}'
repository: '${{ github.event.pull_request.head.repo.full_name }}'
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: |
**.c
**.h
**.S
**.s
**.a
**.cpp
**.mk
**/Makefile
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
echo ${ALL_CHANGED_FILES} > changed_files
cat changed_files
- name: Check watch files
id: check_watch
run: |
echo SOURCE_BRANCH = $SOURCE_BRANCH
echo TARGET_BRANCH = $TARGET_BRANCH
# Determine if we need to run the test
RUN_TEST=0
# Always run test if a workflow_dispatch
if [[ $GITHUB_EVENT_NAME == "workflow_dispatch" ]]; then
RUN_TEST=1
fi
if [[ $SOURCE_BRANCH == "main" ]]; then
echo "Pushed to main, running test"
RUN_TEST=1
fi
# Check for changes made to these files
WATCH_FILES="\
Build_Examples.yml \
.c \
.cpp \
.S \
.s \
.h \
.a \
.mk \
makefile \
Makefile"
if [[ -n $TARGET_BRANCH ]]; then
# We are in a PR. Need to check changes against the target branch.
echo "Comparing PR against target branch: $TARGET_BRANCH"
echo "Adding remote '$GITHUB_SERVER_URL/$GITHUB_REPOSITORY' as 'upstream'"
git remote add upstream $GITHUB_SERVER_URL/$GITHUB_REPOSITORY
echo "Fetching $TARGET_BRANCH"
git fetch upstream $TARGET_BRANCH
echo "diffing files"
CHANGE_FILES=$(git diff --ignore-submodules --name-only remotes/upstream/$TARGET_BRANCH)
fi
echo "Watching these locations and files"
echo $WATCH_FILES
echo "Checking the following changes"
echo $CHANGE_FILES
for watch_file in $WATCH_FILES; do
for change_file in $CHANGE_FILES; do
if [[ "${change_file,,}" == *"${watch_file,,}" ]]; then
echo "Match found. Watch type: $watch_file, File: $change_file"
RUN_TEST=1
fi
done
done
# End the test early if there wasn't a significant change
if [[ $RUN_TEST -eq 0 ]]; then
echo "Skipping Build"
else
echo "Running Build"
fi
echo "RUN_TEST=$RUN_TEST" >> $GITHUB_OUTPUT
- name: Install ARM GCC Toolchain (arm-none-eabi-gcc)
uses: carlosperate/arm-none-eabi-gcc-action@v1
id: arm-none-eabi-gcc-action
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
with:
release: '10.3-2021.10' # <-- The compiler release to use
- name: Install RISCV GCC Toolchain (riscv-none-embed-gcc)
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
run: |
# Install RISCV tools
npm install --global xpm@latest
TOOL_VER=10.2.0-1.2.1
xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@$TOOL_VER
cp -r /home/runner/.local/xPacks/@xpack-dev-tools/riscv-none-embed-gcc /home/runner/riscv-none-embed-gcc
# Add riscv tools to path
echo "/home/runner/riscv-none-embed-gcc/$TOOL_VER/.content/bin" >> $GITHUB_PATH
- name: Install RISCV GCC Toolchain (riscv-none-elf-gcc)
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
run: |
# Install RISCV tools (updated)
npm install --global xpm@latest
# https://www.npmjs.com/package/@xpack-dev-tools/riscv-none-elf-gcc
TOOL_VER=12.2.0-3.1
xpm install --global @xpack-dev-tools/riscv-none-elf-gcc@$TOOL_VER
cp -r /home/runner/.local/xPacks/@xpack-dev-tools/riscv-none-elf-gcc /home/runner/riscv-none-elf-gcc
# Add riscv tools to path
echo "/home/runner/riscv-none-elf-gcc/$TOOL_VER/.content/bin" >> $GITHUB_PATH
- name: Install ccache
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
run: |
# Install ccache
sudo apt install -y ccache
# Prepend ccache into the PATH
echo "/usr/bin" >> $GITHUB_PATH
echo "/usr/lib/ccache" >> $GITHUB_PATH
# Setup ccache links
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-addr2line
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-ar
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-as
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-c
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-c++filt
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-cpp
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-elfedit
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-g
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gcc
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gcc-10.2.1
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gcc-ar
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gcc-nm
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gcc-ranlib
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gcov
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gcov-dump
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gcov-tool
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gdb-add-index
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gdb-add-index-py
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gdb-py
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-gprof
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-ld
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-ld.bfd
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-lto-dump
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-nm
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-objcopy
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-objdump
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-ranlib
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-readelf
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-size
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-strings
sudo ln -s ../../bin/ccache /usr/bin/arm-none-eabi-strip
sudo ln -s ../../bin/ccache /usr/bin/riscv-none-embed-gcc
- name: Setup Python
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
uses: actions/[email protected]
with:
python-version: '3.10'
- name: Install packages
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
run: pip install -r .github/workflows/scripts/requirements.txt
# Runs a set of commands using the runners shell
- name: Build All Examples
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
run: |
# This environment variable is required for the SBTs.
# It must be set to the absolute path inside the Github repo.
export MAXIM_SBT_DIR=$(pwd)/Tools/SBT
# Set MAXIM_PATH to limit warnings
export MAXIM_PATH=$(pwd)
python .github/workflows/scripts/build.py --change_file changed_files
Regression_Test_Make_3_81:
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Update the submodules below, doing so here will convert ssh to https
submodules: false
fetch-depth: 0
ref: '${{ github.event.pull_request.head.ref }}'
repository: '${{ github.event.pull_request.head.repo.full_name }}'
- name: Install Make 3.81
run: |
# Build and install Make version 3.81.
cd $GITHUB_WORKSPACE
ls -la
wget https://ftp.gnu.org/gnu/make/make-3.81.tar.gz
tar -xvf make-3.81.tar.gz
cd make-3.81
# Note: This patch is necessary to get make to build on Ubuntu-22.04.
patch glob/glob.c $GITHUB_WORKSPACE/.github/workflows/patch/glob_patch.patch
./configure --prefix=$GITHUB_WORKSPACE/make-3.81
make
make install
# Pre-prend 3.81 to path
echo "$GITHUB_WORKSPACE/make-3.81/bin:$GITHUB_PATH" > $GITHUB_PATH
make --version
- name: Check Make Version
run: |
# If this fails, there is a setup issue with the workflow.
VERSION_CHECK=$(make --version | grep 3.81)
if [ ! "$VERSION_CHECK" ];then
exit 2
fi
- name: Check watch files
id: check_watch
run: |
echo SOURCE_BRANCH = $SOURCE_BRANCH
echo TARGET_BRANCH = $TARGET_BRANCH
# Determine if we need to run the test
RUN_TEST=0
# Always run test if a workflow_dispatch
if [[ $GITHUB_EVENT_NAME == "workflow_dispatch" ]]; then
RUN_TEST=1
fi
if [[ $SOURCE_BRANCH == "main" ]]; then
echo "Pushed to main, running test"
RUN_TEST=1
fi
# Check for changes made to these files
WATCH_FILES="\
Build_Examples.yml \
.c \
.cpp \
.S \
.s \
.h \
.a \
.mk \
makefile \
Makefile"
if [[ -n $TARGET_BRANCH ]]; then
# We are in a PR. Need to check changes against the target branch.
echo "Comparing PR against target branch: $TARGET_BRANCH"
echo "Adding remote '$GITHUB_SERVER_URL/$GITHUB_REPOSITORY' as 'upstream'"
git remote add upstream $GITHUB_SERVER_URL/$GITHUB_REPOSITORY
echo "Fetching $TARGET_BRANCH"
git fetch upstream $TARGET_BRANCH
echo "diffing files"
CHANGE_FILES=$(git diff --ignore-submodules --name-only remotes/upstream/$TARGET_BRANCH)
fi
echo "Watching these locations and files"
echo $WATCH_FILES
echo "Checking the following changes"
echo $CHANGE_FILES
for watch_file in $WATCH_FILES; do
for change_file in $CHANGE_FILES; do
if [[ "${change_file,,}" == *"${watch_file,,}" ]]; then
echo "Match found. Watch type: $watch_file, File: $change_file"
RUN_TEST=1
fi
done
done
# End the test early if there wasn't a significant change
if [[ $RUN_TEST -eq 0 ]]; then
echo "Skipping Build"
else
echo "Running Build"
fi
echo "RUN_TEST=$RUN_TEST" >> $GITHUB_OUTPUT
- name: Install ARM GCC Toolchain (arm-none-eabi-gcc)
uses: carlosperate/arm-none-eabi-gcc-action@v1
id: arm-none-eabi-gcc-action
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
with:
release: '10.3-2021.10' # <-- The compiler release to use
- name: Install RISCV GCC Toolchain (riscv-none-embed-gcc)
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
run: |
# Install RISCV tools
npm install --global xpm@latest
TOOL_VER=10.2.0-1.2.1
xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@$TOOL_VER
cp -r /home/runner/.local/xPacks/@xpack-dev-tools/riscv-none-embed-gcc /home/runner/riscv-none-embed-gcc
# Add riscv tools to path
echo "/home/runner/riscv-none-embed-gcc/$TOOL_VER/.content/bin" >> $GITHUB_PATH
- name: Install RISCV GCC Toolchain (riscv-none-elf-gcc)
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
run: |
# Install RISCV tools (updated)
npm install --global xpm@latest
# https://www.npmjs.com/package/@xpack-dev-tools/riscv-none-elf-gcc
TOOL_VER=12.2.0-3.1
xpm install --global @xpack-dev-tools/riscv-none-elf-gcc@$TOOL_VER
cp -r /home/runner/.local/xPacks/@xpack-dev-tools/riscv-none-elf-gcc /home/runner/riscv-none-elf-gcc
# Add riscv tools to path
echo "/home/runner/riscv-none-elf-gcc/$TOOL_VER/.content/bin" >> $GITHUB_PATH
- name: Setup Python
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
uses: actions/[email protected]
with:
python-version: '3.10'
- name: Install packages
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
run: pip install -r .github/workflows/scripts/requirements.txt
- name: Build PeriphDrivers and Hello_World
if: ${{ steps.check_watch.outputs.RUN_TEST == '1' }}
run: |
# This environment variable is required for the SBTs.
# It must be set to the absolute path inside the Github repo.
export MAXIM_SBT_DIR=$(pwd)/Tools/SBT
# Set MAXIM_PATH to limit warnings
export MAXIM_PATH=$(pwd)
python .github/workflows/scripts/build.py --projects Hello_World