Skip to content

Doc/update readme #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

repos:
- repo: https://github.com/fsfe/reuse-tool
rev: latest
rev: v0.14.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning behind changing this to v0.14.0? I may have missed some conversation about this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got an error when trying to use "latest" locally, so I instead pinned it to the latest version the libraries use, but I can double check to see if I misunderstood.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. What are the other repos doing for this?

Copy link
Member Author

@tekktrik tekktrik Jul 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other repos are pinning to this version (v0.14.0) of the reuse hook.

hooks:
- id: reuse
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
159 changes: 21 additions & 138 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,157 +4,40 @@ SPDX-FileCopyrightText: 2019 Adafruit Industries
SPDX-License-Identifier: MIT
-->

# Actions CI CircuitPython Init Script
# Actions CI CircuitPython Install Script

The purpose of this repo is to create a centrally managed dependency
install script for all Adafruit CircuitPython Library Github Actions and Travis CI configs.
install script for all Adafruit CircuitPython Library Github Actions.
This will allow us to easily update the install steps without
having to manually or programatically update 100+ `.travis.yml` files or github workflows.
having to manually or programatically update 200+ GitHub workflows.

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/
We have [a Learn guide](https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/testing-with-github-actions)
that you can use to follow along to using GitHub Actions.

## Adding to Github Actions Workflows
# Using in Workflow Files

This section should be added.
To use the install script in workflow files, you'll need to check out this
repository, followed by running the `install.sh` bash script.

## Adding to Travis CI Configs
You can clone and checkout this repo in a GitHub Actions workflow file using
`actions/checkout`:

You will need to source the script in the `before_install` step of your
`.travis.yml` file.

```sh
source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
```

If you only want to install and build on certain platforms, you can set the
`INSTALL_PLATFORMS` envionrment variable to a comma-seperated list of platforms.

**Example `.travis.yml`:**
```yaml
language: c
sudo: false
cache:
directories:
- ~/arduino_ide
- ~/.arduino15/packages/
git:
depth: false
quiet: true
env:
global:
# You can uncomment this to explicitly choose an (old) version of the Arduino IDE
#- ARDUINO_IDE_VERSION="1.8.10"
before_install:
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
install:
# Note that every library should be installed in a seperate command
- arduino --install-library "Adafruit SleepyDog Library"
- arduino --install-library "Adafruit FONA Library"
script:
- build_main_platforms
notifications:
email:
on_success: change
on_failure: change
- name: Checkout tools repo
uses: actions/checkout@v2
with:
repository: adafruit/actions-ci-circuitpython-libs
path: actions-ci
```

**Choosing Arduino IDE version**

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.
In the example above, the repo is now cloned as `actions-ci`.

## Automated Example Verification Bash Functions
The dependencies can then be downloaded using `install.sh`:

`build_platform` will build all `.ino` examples in the repo using the passed platform. The platforms
are defined in the `MAIN_PLATFORMS` and `AUX_PLATFORMS` associative arrays at the top of the script.

All of the examples will be built with the platforms in `MAIN_PLATFORMS` if you call `build_main_platforms`,
and `AUX_PLATFORMS` can be used to define other platforms that don't need to be verified for every repo.

Build the examples using the platforms in the MAIN_PLATFORMS array:
```yaml
script:
- build_main_platforms
```

Build the examples only using the trinket:
```yaml
script:
- build_platform trinket
```

### Skipping Platforms

If you would like to skip one of the main platforms when running `build_main_platforms`,
you can commit a `.YOUR_PLATFORM_HERE.test.skip` file to the example sketch directory you
wish to skip. You will need to use the array key defined in `MAIN_PLATFORMS` for the platform
you wish to skip.

For example, if you would like to skip the `esp8266` platform for an example
in your lib called `blink.ino`, you would need to do something like this in your library repo:

```sh
$ touch examples/blink/.esp8266.test.skip
$ git add -A
$ git commit -a
$ git push
```

If you need an easy way to skip a platform, you can also add something like this to your `~/.bash_profile`:

```sh
function travis_skip()
{

local platform_key=$1

# grab all pde and ino example sketches
local examples=$(find $PWD -name "*.pde" -o -name "*.ino")

# loop through example sketches
for example in $examples; do

# store the full path to the example's sketch directory
local example_dir=$(dirname $example)

touch ${example_dir}/.${platform_key}.test.skip

done

}
- name: Install dependencies
run: |
source action-ci/install.sh
```

You will then be able to skip a platform for all examples by running the `travis_skip` function from your library repo.
It will automatically add the `.YOUR_PLATFORM_HERE.test.skip` files to the examples.

```sh
$ travis_skip esp8266
```

## Using external libraries
External libraries (which are not hosted by the Arduino library manager) can be installed using the following command:
```sh
- if [ ! -d "$HOME/arduino_ide/libraries/<Name>" ]; then git clone <URL> $HOME/arduino_ide/libraries/<Name>; fi
```

## Deploying compiled artifacts
If you need to get hold of the compiled sketches of your project, in order to release them or forward them to an
deployment pipeline, you can find them in the `$ARDUINO_HEX_DIR` directory. Specifically, if `Foo` is the name
of your project, you are compiling for an `Arduino Mega` and the primary sketch is called `Foo.ino`, the flashable
`.hex` files will be found inside `$ARDUINO_HEX_DIR/mega2560/Foo` as `Foo.ino.hex` and `Foo.ino.with_bootloader.hex`.
Similarly for the rest of the platforms.

For example, assuming you have a `Foo` project as outlined above, to create a release which includes the `.hex`
files on GitHub, you could add this to your `.travis.yml` configuration:

```yaml
deploy:
provider: releases
api_key:
secure: YOUR_API_KEY_ENCRYPTED
file:
- $ARDUINO_HEX_DIR/mega2560/Foo/Foo.ino.hex
- $ARDUINO_HEX_DIR/mega2560/Foo/Foo.ino.with_bootloader.hex
skip_cleanup: true
on:
tags: true
```
This will handle installing all the needed dependencies for the given library.