-
Notifications
You must be signed in to change notification settings - Fork 195
283 lines (236 loc) · 11.9 KB
/
arduino.yml
File metadata and controls
283 lines (236 loc) · 11.9 KB
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
name: Arduino CI Build (3 of 4) Latest wolfSSL for Local Examples
#
# Test local Arduino examples with clone of LATEST github master branch wolfssl
#
# These 4 workflows across 3 repos are interdependent for the current $REPO_OWNER:
#
# Arduino CI Build 1: https://github.com/$REPO_OWNER/wolfssl # /.github/workflows/arduino.yml
# - Builds Arduino library from local clone of wolfssl master branch
# - Fetches examples from https://github.com/$REPO_OWNER/wolfssl-examples
#
# Arduino CI Build 2: https://github.com/$REPO_OWNER/wolfssl-examples # /.github/workflows/arduino-release.yml
# - Tests examples based on latest published release of Arduino library, NOT latest on wolfssl github.
# - Should be identical to Arduino CI Build 3 in every way but wolfssl install.
# - Copies only compile script from wolfssl-examples
# - Builds local examples
# - No other repos used
#
# THIS Arduino CI Build 3: https://github.com/$REPO_OWNER/wolfssl-examples # /.github/workflows/arduino.yml
# - Fetches current wolfSSL from https://github.com/$REPO_OWNER/wolfssl
# - Creates an updated Arduino library
# - Compiles local examples
# - Contains the source of `compile-all-examples.sh` and respective board-list.txt
#
# Arduino CI Build 4: https://github.com/$REPO_OWNER/Arduino-wolfssl # /.github/workflows/arduino.yml
# - Assembles and installs an updated Arduino wolfssl library from LOCAL wolfssl master source
# - Copies only compile script copied from wolfssl-examples
# - Builds local examples
# - No other repos used
#
#
# ** NOTE TO MAINTAINERS **
#
# Consider using winmerge or similar tool to keep the 4 arduino[-release].yml files in relative sync.
# Although there are some specific differences, most of the contents are otherwise identical.
#
# See https://github.com/wolfSSL/Arduino-wolfSSL
#
# To test locally:
# cd [your WOLFSSL_ROOT], e.g. cd /mnt/c/workspace/wolfssl-$USER
# [optional checkout] e.g. git checkout tags/v5.8.2-stable
# pushd ./IDE/ARDUINO
# export ARDUINO_ROOT="$HOME/Arduino/libraries"
# ./wolfssl-arduino.sh INSTALL
# cd [your WOLFSSL_EXAMPLES_ROOT] e.g. /mnt/c/workspace/wolfssl-examples-$USER
#
# START OF COMMON SECTION
on:
push:
branches: [ '**', 'master', 'main', 'release/**' ]
paths:
- 'Arduino/**'
- '!Arduino/sketches/board_list_v5.8.2.txt' # Not triggered on arduino-release.yml file. TODO remove this line after next Arduino wolfssl release
- '.github/workflows/arduino.yml'
pull_request:
branches: [ '**' ]
paths:
- 'Arduino/**'
- '!Arduino/sketches/board_list_v5.8.2.txt' # Not triggered on arduino-release.yml file. TODO remove this line after next Arduino wolfssl release
- '.github/workflows/arduino.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# END OF COMMON SECTION
jobs:
build:
# if: github.repository_owner == 'wolfssl'
runs-on: ubuntu-latest
env:
REPO_OWNER: ${{ github.repository_owner }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Arduino CLI
run: |
# Script to fetch and run install.sh from arduino/arduino-cli
# The install script will test to see if the recently installed apps in in the path
# So set it up in advance:
mkdir -p "${PWD}/bin"
echo "${PWD}/bin" >> $GITHUB_PATH
# Sets the install directory to a consistent path at the repo root.
ROOT_BIN="$GITHUB_WORKSPACE/bin"
# Ensures that BINDIR exists before the installer runs
mkdir -p "$ROOT_BIN"
# Save as a lobal environment variable
echo "$ROOT_BIN" >> "$GITHUB_PATH"
# Download and run install script from Arduino:
# -S show errors; -L follow redirects; -v Verbose
set +e # don't abort on error
set -o pipefail
curl -vSL --retry 5 --retry-delay 10 \
https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh \
| sh -x
rc=$?
c_rc=${PIPESTATUS[0]} # curl's exit code
s_rc=${PIPESTATUS[1]} # sh's exit code
set -e # restore default abort-on-error
# If there was a curl error, we have our own local copy that is more reliable and can add our own debugging
if [ "$rc" -ne 0 ]; then
echo "Primary install failed: curl=$c_rc, sh=$s_rc. Falling back..." >&2
echo "Using local copy of arduino_install.sh"
pushd ./Arduino/sketches
chmod +x ./arduino_install.sh
# Mimic curl install, does not use current directory:
BINDIR="$ROOT_BIN" sh -x ./arduino_install.sh
popd
else
echo "Alternative install script not needed."
fi
- name: Confirm Arduino CLI install
run: arduino-cli version
- name: Setup Arduino CLI
run: |
arduino-cli config init
arduino-cli core update-index
arduino-cli config add board_manager.additional_urls https://www.pjrc.com/teensy/package_teensy_index.json
arduino-cli core update-index
arduino-cli config add board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
arduino-cli core update-index
arduino-cli core install esp32:esp32 # ESP32
arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano
arduino-cli core install arduino:sam # Arduino Due
arduino-cli core install arduino:samd # Arduino Zero
arduino-cli core install teensy:avr # PJRC Teensy
arduino-cli core install esp8266:esp8266 # ESP8266
arduino-cli core install arduino:mbed_nano # nanorp2040connect
arduino-cli core install arduino:mbed_portenta # portenta_h7_m7
arduino-cli core install arduino:mbed_edge
# sudo "/home/$USER/.arduino15/packages/arduino/hardware/mbed_nano/4.2.4/post_install.sh"
arduino-cli core install arduino:renesas_uno
arduino-cli lib install "ArduinoJson" # Example dependency
arduino-cli lib install "WiFiNINA" # ARDUINO_SAMD_NANO_33_IOT
arduino-cli lib install "Ethernet" # Install Ethernet library
arduino-cli lib install "Bridge" # Pseudo-network for things like arduino:samd:tian
- name: Set job environment variables
run: |
# Script to assign some common environment variables after everything is installed
ICON_OK=$(printf "\xE2\x9C\x85")
ICON_FAIL=$(printf "\xE2\x9D\x8C")
echo "GITHUB_WORK=$(realpath "$GITHUB_WORKSPACE/../..")" >> "$GITHUB_ENV"
echo "ARDUINO_ROOT=$(realpath "$HOME/Arduino/libraries")" >> "$GITHUB_ENV"
# Show repo-specific location of examples:
echo "WOLFSSL_EXAMPLES_ROOT=$(realpath "./Arduino/sketches")" >> "$GITHUB_ENV"
# Show predefined summary:
echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE"
# Show assigned build:env values (e.g. "wolfssl", "gojimmpi" or other owners):
echo "REPO_OWNER = $REPO_OWNER"
# Show our custom values:
echo "GITHUB_WORK = $GITHUB_WORK"
echo "ARDUINO_ROOT = $ARDUINO_ROOT"
# WOLFSSL_EXAMPLES_ROOT is the report root, not example location
echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT"
- name: Show wolfssl-examples
run: |
# The examples are local in this wolfssl-example repo, but should have been copied to library, above
ls ./Arduino/sketches
# end Show wolfssl-examples
- name: Shallow clone wolfssl
run: |
# Clone the wolfssl to use for example build
# TODO remove after merge
REPO_OWNER=gojimmypi
# End TODO
git clone --depth 1 https://github.com/$REPO_OWNER/wolfssl.git
# Assign your PR branch for testing here:
THIS_PR_BRANCH=""
echo "REPO_OWNER=$REPO_OWNER"
# TODO remove after merge
# A user-specific branch assignment
if [[ "$REPO_OWNER" == "gojimmypi" ]]; then
THIS_PR_BRANCH="pr-arduino-testing"
else
echo "unexpected repo owner!"
fi
# END TODO
# If a branch is assigned for current repo user, checkout
if [ -z "$THIS_PR_BRANCH" ]; then
echo "Assign your PR branch name for testing"
else
# fetch open PR changes
pushd wolfssl
git remote add $REPO_OWNER https://github.com/$REPO_OWNER/wolfssl.git
git fetch --depth 1 "$REPO_OWNER" "$THIS_PR_BRANCH"
git checkout "$THIS_PR_BRANCH"
popd
fi
# end wolfssl source
- name: Install wolfSSL Arduino library
run: |
# Install wolfssl via wolfssl-arduino.sh install script
# Even though the examples are in this library, we'll test as installed for library publishing.
# When WOLFSSL_EXAMPLES_ROOT is set, the examples will be copied from that path to the published library.
# WOLFSSL_EXAMPLES_ROOT is the repo root, not example directory location (./Arduino/sketches) within.
export WOLFSSL_EXAMPLES_ROOT=$(realpath "./")
# Confirm ARDUINO_ROOT to install the wolfSSL library, see above "Set job environment variables"
echo "PWD = $PWD"
echo "ARDUINO_ROOT = $ARDUINO_ROOT"
echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT"
ls ./Arduino/sketches
if [ -z "$WOLFSSL_EXAMPLES_ROOT" ]; then
echo "$ICON_FAIL ERROR: Tests should be performed on in-place examples. WOLFSSL_EXAMPLES_ROOT is blank"
fi
# The install script is in the wolfssl repo, in /IDE/ARDUINO directory.
# Only explicit source code is copied to the Arduino library.
# Edit wolfssl-arduino.sh as needed for new examples.
pushd ./wolfssl/IDE/ARDUINO
chmod +x ./wolfssl-arduino.sh
bash ./wolfssl-arduino.sh INSTALL # Install wolfSSL as Arduino library in ARDUINO_ROOT
popd
echo "Examples installed in $ARDUINO_ROOT/wolfssl/examples"
ls "$ARDUINO_ROOT/wolfssl/examples" -al
# End Install wolfSSL Arduino library
- name: List installed Arduino libraries
run: arduino-cli lib list
# This will fail with Arduino published wolfSSL v5.7.6 and older
# as the examples moved. See https://github.com/wolfSSL/wolfssl/pull/8514
#
- name: Compile Arduino Sketches for Various Boards
run: |
# Call the compile-all-examples.sh script to compile all the examples for each of the fqbn names in the local copy of board_list.txt
echo "Current directory = $PWD"
echo "ARDUINO_ROOT = $ARDUINO_ROOT"
echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT"
pushd ./Arduino/sketches
chmod +x ./compile-all-examples.sh
# The script expects all the examples to be in the current directory.
# So copy from local directory to newly instlled wolfssl arduino library to compile there.
cp ./compile-all-examples.sh "$ARDUINO_ROOT/wolfssl/examples/compile-all-examples.sh"
cp ./board_list.txt "$ARDUINO_ROOT/wolfssl/examples/board_list.txt"
# Compile the Arduino library examples in-place
pushd "$ARDUINO_ROOT/wolfssl/examples/"
echo "PWD=$PWD"
./compile-all-examples.sh ./board_list.txt
popd
popd
# End Compile Arduino Sketches for Various Boards