Skip to content

Commit 317c7cc

Browse files
committed
Merge branch 'master' into separate-platform-definiton
2 parents c784122 + b066942 commit 317c7cc

File tree

5 files changed

+84
-27
lines changed

5 files changed

+84
-27
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
.idea

README.md

+43-21
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,78 @@
11
# Arduino CI Scripts
22

3-
This repos contains various scripts and tools related to running
4-
continuous integration (CI) checks on Arduino Library Repos.
3+
This repos contains various scripts and tools related to running continuous integration (CI) checks on Arduino Library Repos. The operations include:
4+
5+
* checking formatting using using [clang-format](https://clang.llvm.org/docs/ClangFormat.html),
6+
* generating documentation from source comments using using [Doxygen](https://www.doxygen.nl/), and
7+
* building each example in the library for selected targets.
58

69
There is an associated guide available here:
710
https://learn.adafruit.com/the-well-automated-arduino-library/
811

912
## Adding GitHub Actions to Repo
1013

14+
To run these continuous integration checks on each push, pull-request or [repository dispatch](https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#create-a-repository-dispatch-event) using [GitHub actions](https://github.com/features/actions):
15+
1116
* Create a folder named `.github/worflows` in the root of the repo.
1217
* Copy `example_actions.yml` into the above directory and rename it `githubci.yml`.
13-
* Edit `githubci.yml` and change `PRETTYNAME` to the library repo name.
18+
* Edit `githubci.yml` and change `PRETTYNAME` to the library repo name. Optionally, delete or comment out steps (using the `#` character), you don't want to include.
1419
* Here's an example: [Adafruit_BME280_Library](https://github.com/adafruit/Adafruit_BME280_Library/blob/master/.github/workflows/githubci.yml)
15-
* These actions will now run automatically on any pull, push, or dispatch.
1620

1721
## Controlling Test Behavior
1822

19-
The `build_platform.py` script is used to test each `.ino` example in the repo for the
20-
selected build platforms. The `ALL_PLATFORMS` dictionary contains a listing of all
21-
available platforms. By default, `main_platforms` is used. Additionally, UF2 files
22-
of the compiled sketches can be generated for supported platforms. The behavior
23-
can be controlled using special hidden filenames. These are just empty files
24-
placed in the root folder:
23+
The `build_platform.py` script is used to test each `.ino` example in the repo for selected build platforms. The [`ALL_PLATFORMS`](ci-arduino/blob/master/build_platform.py#L54) dictionary contains a listing of all available platforms and selected platform groups. By default, `main_platforms` is used. To select a specific platform or group, replace `main_platforms` in [`githubci.yml`](`example_actions.yml`) with the group or platform name.
24+
25+
Additionally, [UF2 files](https://github.com/microsoft/uf2) of the compiled sketches can be generated for supported platforms.
26+
27+
### Fine tuning test selection
2528

26-
* `.YOUR_PLATFORM_HERE.test.skip` - Skip the specified platform. All others are tested.
27-
* `.YOUR_PLATFORM_HERE.test.only` - Test only the specfied platform. All others are skipped.
28-
* `.YOUR_PLATFORM_HERE.generate` - Generate UF2 of sketch for specified platform (if supported).
29+
The script behavior can be controlled using special filenames:
2930

30-
Replace `YOUR_PLATFORM_HERE` in the name with exact text from `ALL_PLATFORMS`.
31+
* `.PLATFORM_ID.test.skip` - Skip the specified platform. All others are tested.
32+
* `.PLATFORM_ID.test.only` - Test the specified platform. All others are skipped.
33+
* `.PLATFORM_ID.generate` - Generate UF2 of sketch for specified platform (if supported).
34+
35+
These are just empty files placed in an example folder. Replace `PLATFORM_ID` in the name with the key from [`ALL_PLATFORMS`](ci-arduino/blob/master/build_platform.py#L54). `metro_m0` from the following line in `build_platform.py`, for example:
36+
37+
```python
38+
"metro_m0" : ["adafruit:samd:adafruit_metro_m0", "0x68ed2b88", None],
39+
```
3140

32-
### Examples
41+
You can use several `.PLATFORM_ID.test.skip` or `.PLATFORM_ID.test.only` to exclude or include multiple platforms. For example:
3342

3443
* To **skip** testing on ESP8266, add a file named `.esp8266.test.skip`
3544
* To test **only** the Arduino UNO, add a file named `.uno.test.only`
3645
* To skip all and test **nothing**, add a file named `.none.test.only`
3746
* To generate UF2s for PyPortal, add a file named `.pyportal.generate`
3847

48+
### Dependencies
49+
50+
Any library dependencies included in the [`library.properties`](https://arduino.github.io/arduino-cli/0.19/library-specification/#libraryproperties-file-format) are automatically installed before the tests are started. To install additional dependencies (e.g., those required for some examples but not the library itself) using [`arduino-cli`](https://arduino.github.io/arduino-cli/0.19/commands/arduino-cli_lib_install/), you could add additional steps to the `githubci.yml` file. For example:
51+
52+
```yaml
53+
- name: Set configuration
54+
run: arduino-cli config set library.enable_unsafe_install true
55+
56+
- name: Install test dependencies
57+
run: arduino-cli lib install --git-url https://github.com/arduino-libraries/Servo --git-url https://github.com/arduino-libraries/Ethernet
58+
```
59+
60+
Note: you'll only need to enable the [`enable_unsafe_install`](https://arduino.github.io/arduino-cli/0.32/configuration/#configuration-keys) option if you want to identify libraries using urls. This isn't necessary when using the library name.
61+
3962
## Formatting Check with Clang
4063

41-
The `run-clang-format.py` script is used to run ClangFormat and check file formatting.
64+
The `run-clang-format.py` script is used to run [clang-format](https://clang.llvm.org/docs/ClangFormat.html) and check file formatting.
4265
See [the guide](https://learn.adafruit.com/the-well-automated-arduino-library/formatting-with-clang-format) for details on installing `clang-format` to run formatting locally.
4366
Even a single extra white space can cause the CI to fail on formatting.
4467
You can typically just let clang do its thing and edit files in place using:
68+
4569
```
4670
clang-format -i File_To_Format.cpp
4771
```
4872

4973
## Documentation with Doxygen
5074

51-
The `doxy_gen_and_deploy.sh` script uses Doxygen to generate and deploy documentation
75+
The `doxy_gen_and_deploy.sh` script uses [Doxygen](https://www.doxygen.nl/) to generate and deploy documentation
5276
for the library. Any issues, like missing documentation, will cause the CI to fail.
53-
See the [the guide](https://learn.adafruit.com/the-well-automated-arduino-library/doxygen)
54-
for details on installing and running doxygen locally. The guide also has some
55-
[tips](https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips)
56-
on basic usage of doxygen markup within your code.
77+
See the [the guide](https://learn.adafruit.com/the-well-automated-arduino-library/doxygen) for details on installing and running doxygen locally. The guide also has some
78+
[tips](https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips) on basic usage of doxygen markup within your code.

all_platforms.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
"qtpy_esp32s2" : ["esp32:esp32:adafruit_qtpy_esp32s2", "0xbfdd4eee", None],
1919
"feather_esp32s2" : ["esp32:esp32:adafruit_feather_esp32s2", "0xbfdd4eee", None],
2020
"feather_esp32s2_tft" : ["esp32:esp32:adafruit_feather_esp32s2_tft", "0xbfdd4eee", None],
21+
"feather_esp32s2_reverse_tft" : ["esp32:esp32:adafruit_feather_esp32s2_reversetft", "0xbfdd4eee", None],
2122
"feather_esp32s3" : ["esp32:esp32:adafruit_feather_esp32s3_nopsram", "0xc47e5767", None],
2223
"feather_esp32s3_4mbflash_2mbpsram" : ["esp32:esp32:adafruit_feather_esp32s3", "0xc47e5767", None],
2324
"feather_esp32s3_tft" : ["esp32:esp32:adafruit_feather_esp32s3_tft", "0xc47e5767", None],
25+
"feather_esp32s3_reverse_tft" : ["esp32:esp32:adafruit_feather_esp32s3_reversetft", "0xc47e5767", None],
26+
"matrixportal_s3" : ["esp32:esp32:adafruit_matrixportal_esp32s3", "0xc47e5767", None],
2427
"qtpy_esp32s3" : ["esp32:esp32:adafruit_qtpy_esp32s3_nopsram", "0xc47e5767", None],
28+
"qtpy_esp32s3_n4r2" : ["esp32:esp32:adafruit_qtpy_esp32s3_n4r2", "0xc47e5767", None],
2529
"qtpy_esp32" : ["esp32:esp32:adafruit_qtpy_esp32_pico", None, None],
2630
"qtpy_esp32c3" : ["esp32:esp32:adafruit_qtpy_esp32c3:FlashMode=qio", None, None],
2731
# Adafruit AVR
@@ -89,11 +93,19 @@
8993
"pico_rp2040" : ["rp2040:rp2040:rpipico:freq=125,flash=2097152_0", "0xe48bff56", None],
9094
"pico_rp2040_tinyusb" : ["rp2040:rp2040:rpipico:flash=2097152_0,freq=125,dbgport=Disabled,dbglvl=None,usbstack=tinyusb", "0xe48bff56", None],
9195
"picow_rp2040" : ["rp2040:rp2040:rpipicow:flash=2097152_0,freq=125", "0xe48bff56", None],
92-
"picow_rp2040_tinyusb" : ["rp2040:rp2040:rpipicow:flash=2097152_0,freq=133,dbgport=Disabled,dbglvl=None,usbstack=tinyusb", "0xe48bff56", None],
96+
"picow_rp2040_tinyusb" : ["rp2040:rp2040:rpipicow:flash=2097152_131072,freq=133,dbgport=Disabled,dbglvl=None,usbstack=tinyusb", "0xe48bff56", None],
9397
"feather_rp2040" : ["rp2040:rp2040:adafruit_feather:freq=125,flash=8388608_0", "0xe48bff56", None],
9498
"feather_rp2040_tinyusb" : ["rp2040:rp2040:adafruit_feather:flash=8388608_0,freq=125,dbgport=Disabled,dbglvl=None,usbstack=tinyusb", "0xe48bff56", None],
99+
"feather_rp2040_rfm" : ["rp2040:rp2040:adafruit_feather_rfm:freq=125,flash=8388608_0", "0xe48bff56", None],
100+
"feather_rp2040_rfm_tinyusb" : ["rp2040:rp2040:adafruit_feather_rfm:flash=8388608_0,freq=125,dbgport=Disabled,dbglvl=None,usbstack=tinyusb", "0xe48bff56", None],
101+
"feather_rp2040_dvi" : ["rp2040:rp2040:adafruit_feather_dvi:freq=125,flash=8388608_0", "0xe48bff56", None],
102+
"feather_rp2040_dvi_tinyusb" : ["rp2040:rp2040:adafruit_feather_dvi:flash=8388608_0,freq=125,dbgport=Disabled,dbglvl=None,usbstack=tinyusb", "0xe48bff56", None],
103+
"feather_rp2040_usbhost_tinyusb" : ["rp2040:rp2040:adafruit_feather_usb_host:flash=8388608_0,freq=120,dbgport=Disabled,dbglvl=None,usbstack=tinyusb", "0xe48bff56", None],
95104
"qt2040_trinkey" : ["rp2040:rp2040:adafruit_trinkeyrp2040qt:freq=125,flash=8388608_0", "0xe48bff56", None],
96105
"qt2040_trinkey_tinyusb" : ["rp2040:rp2040:adafruit_trinkeyrp2040qt:flash=8388608_0,freq=125,dbgport=Disabled,dbglvl=None,usbstack=tinyusb", "0xe48bff56", None],
106+
"qt_py_rp2040": ["rp2040:rp2040:adafruit_qtpy:freq=125,flash=8388608_0", "0xe48bff56", None],
107+
"qt_py_rp2040_tinyusb": ["rp2040:rp2040:adafruit_qtpy:flash=8388608_0,freq=125,dbgport=Disabled,dbglvl=None,usbstack=tinyusb", "0xe48bff56", None],
108+
97109
# Attiny8xy, 16xy, 32xy (SpenceKonde)
98110
"attiny3217" : ["megaTinyCore:megaavr:atxy7:chip=3217", None, None],
99111
"attiny3216" : ["megaTinyCore:megaavr:atxy6:chip=3216", None, None],

build_platform.py

+23-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
BUILD_WARN = False
2020
sys.argv.remove("--no_warn")
2121

22+
# optional timeout argument to extend build time
23+
# for larger sketches or firmware builds
24+
BUILD_TIMEOUT = False
25+
if "--build_timeout" in sys.argv:
26+
BUILD_TIMEOUT = True
27+
popen_timeout = int(sys.argv[sys.argv.index("--build_timeout") + 1])
28+
sys.argv.pop(sys.argv.index("--build_timeout") + 1)
29+
sys.argv.remove("--build_timeout")
30+
2231
# add user bin to path!
2332
BUILD_DIR = ''
2433
# add user bin to path!
@@ -150,6 +159,12 @@ def run_or_die(cmd, error):
150159

151160
run_or_die("arduino-cli core update-index --additional-urls "+BSP_URLS+
152161
" > /dev/null", "FAILED to update core indices")
162+
##### HACK !!!!!!!!!!!!!!!!!!!
163+
# manual fix for megatinycore URL truncation issue
164+
# see: https://github.com/arduino/arduino-cli/issues/2345
165+
# https://github.com/SpenceKonde/megaTinyCore/issues/1005
166+
os.system("mv ~/.arduino15/package_drazzy.json ~/.arduino15/package_drazzy.com_index.json")
167+
##### HACK !!!!!!!!!!!!!!!!!!!!
153168
print()
154169

155170
################################ Install dependencies
@@ -249,7 +264,10 @@ def generate_uf2(example_path):
249264
cmd = ['python3', 'uf2conv.py', input_file, '-c', '-f', family_id, '-b', "0x0000", '-o', output_file]
250265

251266
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
252-
r = proc.wait(timeout=60)
267+
if BUILD_TIMEOUT:
268+
r = proc.wait(timeout=popen_timeout)
269+
else:
270+
r = proc.wait(timeout=60)
253271
out = proc.stdout.read()
254272
err = proc.stderr.read()
255273
if r == 0 and not err:
@@ -335,7 +353,10 @@ def test_examples_in_folder(folderpath):
335353
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
336354
stderr=subprocess.PIPE)
337355
try:
338-
out, err = proc.communicate(timeout=120)
356+
if BUILD_TIMEOUT:
357+
out, err = proc.communicate(timeout=popen_timeout)
358+
else:
359+
out, err = proc.communicate(timeout=120)
339360
r = proc.returncode
340361
except:
341362
proc.kill()

example_actions.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/setup-python@v1
10+
- uses: actions/setup-python@v4
1111
with:
1212
python-version: '3.x'
13-
- uses: actions/checkout@v2
14-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v3
1515
with:
1616
repository: adafruit/ci-arduino
1717
path: ci

0 commit comments

Comments
 (0)