Skip to content

Commit 318ad6b

Browse files
committed
Merge branch 'master' of github.com:adafruit/ci-arduino
2 parents e0fdb88 + 875e429 commit 318ad6b

File tree

6 files changed

+88
-256
lines changed

6 files changed

+88
-256
lines changed

Diff for: .github/workflows/githubci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ jobs:
1616
run: bash ./actions_install.sh
1717
- name: test platforms
1818
run: |
19-
python3 build_platform.py uno leonardo mega2560 zero esp8266 esp32 pico_rp2040
19+
python3 build_platform.py uno leonardo mega2560 zero esp8266 esp32 pico_rp2040 feather_m4_express
2020

Diff for: README.md

+39-240
Original file line numberDiff line numberDiff line change
@@ -1,256 +1,55 @@
1-
# Travis CI Arduino Init Script [![Build Status](https://travis-ci.com/adafruit/travis-ci-arduino.svg?branch=master)](https://travis-ci.com/adafruit/travis-ci-arduino)
1+
# Arduino CI Scripts
22

3-
The purpose of this repo is to create a centrally managed dependency
4-
install script for all Adafruit Arduino Library Travis CI and Github Actions configs.
5-
This will allow us to easily update the install steps without
6-
having to manually or programmatically update 100+ `.travis.yml` files.
3+
This repos contains various scripts and tools related to running
4+
continuous integration (CI) checks on Arduino Library Repos.
75

8-
We have a guide that you can use to follow along to install both TravisCI and Doxygen generation here https://learn.adafruit.com/the-well-automated-arduino-library/
6+
There is an associated guide available here:
7+
https://learn.adafruit.com/the-well-automated-arduino-library/
98

10-
## Adding to Travis CI Configs
9+
## Adding GitHub Actions to Repo
1110

12-
You will need to source the script in the `before_install` step of your
13-
`.travis.yml` file.
11+
* Create a folder named `.github/worflows` in the root of the repo.
12+
* 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.
14+
* 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.
1416

15-
```sh
16-
source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
17-
```
18-
19-
If you only want to install and build on certain platforms, you can set the
20-
`INSTALL_PLATFORMS` environment variable to a comma-separated list of platforms.
21-
22-
**Example `.travis.yml`:**
23-
```yaml
24-
language: c
25-
sudo: false
26-
cache:
27-
directories:
28-
- ~/arduino_ide
29-
- ~/.arduino15/packages/
30-
git:
31-
depth: false
32-
quiet: true
33-
addons:
34-
apt:
35-
sources:
36-
- llvm-toolchain-trusty-5.0
37-
- key_url: 'http://apt.llvm.org/llvm-snapshot.gpg.key'
38-
packages:
39-
- clang-format-5.0
40-
env:
41-
global:
42-
# - ARDUINO_IDE_VERSION="1.8.10"
43-
- PRETTYNAME="Adafruit FT6206 Arduino Library"
44-
# Optional, will default to "$TRAVIS_BUILD_DIR/Doxyfile"
45-
# - DOXYFILE: $TRAVIS_BUILD_DIR/Doxyfile
17+
## Controlling Test Behavior
4618

47-
before_install:
48-
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
49-
- curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/run-clang-format.py > run-clang-format.py
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:
5025

51-
install:
52-
- arduino --install-library "Adafruit ILI9341","Adafruit GFX Library"
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).
5329

54-
script:
55-
- python run-clang-format.py -r .
56-
- build_main_platforms
57-
58-
# Generate and deploy documentation
59-
after_success:
60-
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh)
61-
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh)
62-
```
30+
Replace `YOUR_PLATFORM_HERE` in the name with exact text from `ALL_PLATFORMS`.
6331

64-
**Choosing Arduino IDE version**
32+
### Examples
6533

66-
You could use any version of IDE by setting `ARDUINO_IDE_VERSION` variable but we recommend keeping this variable unused because script gets updated and you then will not have to modify `.travis.yml` manually.
34+
* To **skip** testing on ESP8266, add a file named `.esp8266.test.skip`
35+
* To test **only** the Arduino UNO, add a file named `.uno.test.only`
36+
* To generate UF2s for PyPortal, add a file named `.pyportal.generate`
6737

68-
## Automated Example Verification Bash Functions
69-
70-
`build_platform` will build all `.ino` examples in the repo using the passed platform. The platforms
71-
are defined in the `MAIN_PLATFORMS` and `AUX_PLATFORMS` associative arrays at the top of the script.
72-
73-
All of the examples will be built with the platforms in `MAIN_PLATFORMS` if you call `build_main_platforms`,
74-
and `AUX_PLATFORMS` can be used to define other platforms that don't need to be verified for every repo.
75-
76-
Build the examples using the platforms in the MAIN_PLATFORMS array:
77-
```yaml
78-
script:
79-
- build_main_platforms
80-
```
38+
## Formatting Check with Clang
8139

82-
Build the examples only using the trinket:
83-
```yaml
84-
script:
85-
- build_platform trinket
40+
The `run-clang-format.py` script is used to run ClangFormat and check file formatting.
41+
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.
42+
Even a single extra white space can cause the CI to fail on formatting.
43+
You can typically just let clang do its thing and edit files in place using:
8644
```
87-
88-
### Skipping Platforms
89-
90-
If you would like to skip one of the main platforms when running `build_main_platforms`,
91-
you can commit a `.YOUR_PLATFORM_HERE.test.skip` file to the example sketch directory you
92-
wish to skip. You will need to use the array key defined in `MAIN_PLATFORMS` for the platform
93-
you wish to skip.
94-
95-
For example, if you would like to skip the `esp8266` platform for an example
96-
in your lib called `blink.ino`, you would need to do something like this in your library repo:
97-
98-
```sh
99-
$ touch examples/blink/.esp8266.test.skip
100-
$ git add -A
101-
$ git commit -a
102-
$ git push
45+
clang-format -i File_To_Format.cpp
10346
```
10447

105-
If you need an easy way to skip a platform, you can also add something like this to your `~/.bash_profile`:
106-
107-
```sh
108-
function travis_skip()
109-
{
110-
111-
local platform_key=$1
112-
113-
# grab all pde and ino example sketches
114-
local examples=$(find $PWD -name "*.pde" -o -name "*.ino")
115-
116-
# loop through example sketches
117-
for example in $examples; do
118-
119-
# store the full path to the example's sketch directory
120-
local example_dir=$(dirname $example)
48+
## Documentation with Doxygen
12149

122-
touch ${example_dir}/.${platform_key}.test.skip
123-
124-
done
125-
126-
}
127-
```
128-
129-
You will then be able to skip a platform for all examples by running the `travis_skip` function from your library repo.
130-
It will automatically add the `.YOUR_PLATFORM_HERE.test.skip` files to the examples.
131-
132-
```sh
133-
$ travis_skip esp8266
134-
```
135-
136-
## Using external libraries
137-
External libraries (which are not hosted by the Arduino library manager) can be installed using the following command:
138-
```sh
139-
- if [ ! -d "$HOME/arduino_ide/libraries/<Name>" ]; then git clone <URL> $HOME/arduino_ide/libraries/<Name>; fi
140-
```
141-
142-
## Deploying compiled artifacts
143-
If you need to get hold of the compiled sketches of your project, in order to release them or forward them to an
144-
deployment pipeline, you can find them in the `$ARDUINO_HEX_DIR` directory. Specifically, if `Foo` is the name
145-
of your project, you are compiling for an `Arduino Mega` and the primary sketch is called `Foo.ino`, the flashable
146-
`.hex` files will be found inside `$ARDUINO_HEX_DIR/mega2560/Foo` as `Foo.ino.hex` and `Foo.ino.with_bootloader.hex`.
147-
Similarly for the rest of the platforms.
148-
149-
For example, assuming you have a `Foo` project as outlined above, to create a release which includes the `.hex`
150-
files on GitHub, you could add this to your `.travis.yml` configuration:
151-
152-
```yaml
153-
deploy:
154-
provider: releases
155-
api_key:
156-
secure: YOUR_API_KEY_ENCRYPTED
157-
file:
158-
- $ARDUINO_HEX_DIR/mega2560/Foo/Foo.ino.hex
159-
- $ARDUINO_HEX_DIR/mega2560/Foo/Foo.ino.with_bootloader.hex
160-
skip_cleanup: true
161-
on:
162-
tags: true
163-
```
164-
165-
## Running build_platforms.py locally
166-
1. Install arduino-cli from here: https://arduino.github.io/arduino-cli/installation/
167-
2. Download ci-arduino
168-
* `git clone https://github.com/adafruit/ci-arduino`
169-
3. Put these lines at the end of your `.bashrc` or `.bash_profile` if you're on OSX. Make sure to fill in the path to where you installed ci-arduino and replacing USER with your username.
170-
```bash
171-
alias test-platforms='python3 ~/path/to/ci-arduino/build_platform.py'
172-
export HOME=/home/USER/
173-
```
174-
4. Run this at the top level of the library you want to test
175-
```bash
176-
adafruit@adafruit:~/Adafruit_BMP183_Library$ export GITHUB_WORKSPACE=$(pwd)
177-
```
178-
5. Remove everything in test library, and re-create it
179-
```bash
180-
adafruit@adafruit:~/Adafruit_BMP183_Library$ rm -rf ~/Arduino/libraries/Adafruit_Test_Library/; mkdir ~/Arduino/libraries/Adafruit_Test_Library
181-
```
182-
6. Still in the top-level directory of the library you'll be testing, copy the current library to Adafruit_Test_Library
183-
```bash
184-
adafruit@adafruit:~/Adafruit_BMP183_Library$ cp * ~/Arduino/libraries/Adafruit_Test_Library/
185-
```
186-
7. Grep for build_platform.py in githubci.yml to find out what boards to test.
187-
```bash
188-
adafruit@adafruit:~/Adafruit_BMP183_Library$ grep 'build_platform.py' .github/workflows/githubci.yml
189-
run: python3 ci/build_platform.py main_platforms
190-
```
191-
8. Run test-platforms. This may take a while, and tests for some boards sometimes run orders of magnitude slower than tests for other boards.
192-
```bash
193-
test-platforms main_platforms
194-
```
195-
OR, if githubci.yml specified other boards, let's say the metro m0 and pyportal, you'd run this:
196-
```bash
197-
test-platforms metro_m0 pyportal
198-
```
199-
200-
Here's what that returns
201-
```bash
202-
adafruit@adafruit:~/Adafruit_BMP183_Library$ test-platforms main_platforms
203-
build dir: /home/dherrada/Adafruit_BMP183_Library
204-
205-
########################################
206-
INSTALLING ARDUINO BOARDS
207-
########################################
208-
arduino-cli core update-index --additional-urls https://adafruit.github.io/arduino-board-index/package_adafruit_index.json,http://arduino.esp8266.com/stable/package_esp8266com_index.json,https://dl.espressif.com/dl/package_esp32_index.json,https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json > /dev/null
209-
210-
Installing Adafruit Unified Sensor
211-
arduino-cli lib install "Adafruit Unified Sensor" > /dev/null
212-
arduino-cli lib uninstall "Adafruit BMP183 Library"
213-
Library Adafruit BMP183 Library is not installed
214-
Libraries installed: ['/home/adafruit/Arduino/libraries/Adafruit_VL53L0X', '/home/adafruit/Arduino/libraries/RTClib', '/home/adafruit/Arduino/libraries/Adafruit-RGB-LCD-Shield-Library', '/home/adafruit/Arduino/libraries/readme.txt', '/home/adafruit/Arduino/libraries/Adafruit_Test_Library', '/home/adafruit/Arduino/libraries/Adafruit_Unified_Sensor']
215-
elif isinstance(platform, collections.Iterable):
216-
################################################################################
217-
SWITCHING TO arduino:avr:uno
218-
Installing arduino:avr ✓
219-
################################################################################
220-
BMP183test.ino ✓
221-
################################################################################
222-
SWITCHING TO arduino:avr:leonardo
223-
Installing arduino:avr ✓
224-
################################################################################
225-
BMP183test.ino ✓
226-
################################################################################
227-
SWITCHING TO arduino:avr:mega:cpu=atmega2560
228-
Installing arduino:avr ✓
229-
################################################################################
230-
BMP183test.ino ✓
231-
################################################################################
232-
SWITCHING TO arduino:samd:arduino_zero_native
233-
Installing arduino:samd ✓
234-
################################################################################
235-
BMP183test.ino ✓
236-
################################################################################
237-
SWITCHING TO esp8266:esp8266:huzzah:eesz=4M3M,xtal=80
238-
Installing esp8266:esp8266 ✓
239-
################################################################################
240-
BMP183test.ino ✓
241-
################################################################################
242-
SWITCHING TO esp32:esp32:featheresp32:FlashFreq=80
243-
Installing esp32:esp32 ✓
244-
################################################################################
245-
BMP183test.ino ✓
246-
################################################################################
247-
SWITCHING TO adafruit:samd:adafruit_metro_m4:speed=120
248-
Installing adafruit:samd ✓
249-
################################################################################
250-
BMP183test.ino ✓
251-
################################################################################
252-
SWITCHING TO adafruit:nrf52:feather52840:softdevice=s140v6,debug=l0
253-
Installing adafruit:nrf52 ✓
254-
################################################################################
255-
BMP183test.ino ✓
256-
```
50+
The `doxy_gen_and_deploy.sh` script uses Doxygen to generate and deploy documentation
51+
for the library. Any issues, like missing documentation, will cause the CI to fail.
52+
See the [the guide](https://learn.adafruit.com/the-well-automated-arduino-library/doxygen)
53+
for details on installing and running doxygen locally. The guide also has some
54+
[tips](https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips)
55+
on basic usage of doxygen markup within your code.

0 commit comments

Comments
 (0)