Skip to content

Commit

Permalink
Merge branch 'adafruit:main' into boards-featherS2-initial
Browse files Browse the repository at this point in the history
  • Loading branch information
MakeItYourself85 authored May 25, 2024
2 parents 1e4c302 + 127e81f commit 9a339b9
Show file tree
Hide file tree
Showing 74 changed files with 10,347 additions and 294 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/auto_import.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Automatically import JSON

on:
workflow_dispatch:
pull_request:
types:
- closed

jobs:
alert-not-merged:
name: Alert No Merge
runs-on: ubuntu-latest
if: github.event.pull_request.merged != true && github.event_name != 'workflow_dispatch'
steps:
- run: echo "PR closed but not merged, do nothing."

call-import-webhook:
name: Call Webhook
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: wget and wait for response
env:
SIGNING_TOKEN: ${{ secrets.AUTO_IMPORT_TOKEN }}
run: |
# early out if we can't access the signing token
if [[ -z $SIGNING_TOKEN ]]; then
echo "❌ Board Definition cannot auto-import for this merge. Ask a repo admin to trigger it manually."
exit 1
fi
# build the post body
JSON_POST_BODY='{"commit_sha":"'"$GITHUB_SHA"'"}'
# sign it
SIGNATURE=$(echo -n "$JSON_POST_BODY" | openssl sha256 -hmac "$SIGNING_TOKEN")
# post the json body to the webhook with headers for signature and json content type, save the http status
HTTP_STATUS=$(wget -S --header="X-HUB-SIGNATURE-256: $SIGNATURE" --header="Content-Type: application/json" --method=POST --body-data="$JSON_POST_BODY" https://io.adafruit.com/api/github/boards/refresh 2>&1 | awk '/^ HTTP/{print $2}')
if [[ $HTTP_STATUS != 204 ]]; then
echo "❌ Board Definition Import Failed: Got status $HTTP_STATUS. Retry the import manually to see the error messages"
exit 1
fi
echo "✅ Board Definition Import Successful"
51 changes: 30 additions & 21 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,41 @@ on: [pull_request]

jobs:
validate-definition-files:
name: Validate Definition Files
name: Validate JSON Schemas
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# Schema Docs: https://ajv.js.org/json-schema.html#json-data-type
- name: Validate Board JSON
uses: nhalstead/validate-json-action@0.1.3
uses: lorennorman/validate-json-action@master
with:
# Schema Docs: https://ajv.js.org/json-schema.html#json-data-type
schema: /boards/schema.json
jsons: boards/*/definition.json

- name: Validate Magic JSON
uses: lorennorman/validate-json-action@master
with:
schema: /boards/magic_schema.json
jsons: boards/*/magic.json

check-user-permissions:
name: Check Write Permission
runs-on: ubuntu-latest
outputs:
# Extract the permission for later jobs to use
has-write-permission: ${{ steps.check.outputs.has-permission }}
has-write-permission: ${{ steps.set-permission.outputs.has-permission }}
steps:
- name: Check user permission
id: check
uses: scherermichael-oss/action-has-permission@master
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: octokit/[email protected]
id: fetch-permissions
with:
route: GET /repos/${{ github.repository }}/collaborators/${{ github.actor }}/permission
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- id: set-permission
if: fromJson(steps.fetch-permissions.outputs.data).permission == 'admin' || fromJson(steps.fetch-permissions.outputs.data).permission == 'write'
run: echo "has-permission=true" >> "$GITHUB_OUTPUT"

changed-files:
name: List Changed Files
Expand All @@ -43,9 +51,7 @@ jobs:
- uses: actions/checkout@v3
- name: List Changed Board Files
id: list-changed-files
uses: tj-actions/changed-files@v21
with:
files: boards/**/*
uses: tj-actions/changed-files@v37

validate-expected-filenames:
name: Validate Filenames
Expand All @@ -63,11 +69,13 @@ jobs:
run: |
EXIT_VALUE=0
# TODO: break these regexes up into modular chunks that check specific things for readability and composability
# external contributors can modify some files
EXTERNAL_REGEX="^boards\/.*\/(definition\.json|((image|images\/(boot-(drive|loader)|drag-drop|reset|usb))\.(png|jpe?g|gif|svg)))$"
EXTERNAL_REGEX="^boards\/.*\/(definition\.json|magic\.json|((image|images\/(boot-(drive|loader)|drag-drop|reset|usb))\.(png|jpe?g|gif|svg)))$"
# folks with write access to the repo (Adafruit team) can change more sensitive files
INTERNAL_REGEX="^boards\/(schema.json|.*\/(definition\.json|((image|images\/(boot-(drive|loader)|drag-drop|reset|usb))\.(png|jpe?g|gif|svg))))$"
INTERNAL_REGEX="^(README.md|\.github\/.*|boards\/(schema.json|magic_schema.json|.*\/(definition\.json|magic\.json|((image|images\/(boot-(drive|loader)|drag-drop|reset|usb))\.(png|jpe?g|gif|svg)))))$"
# apply the appropriate regex based on permissions of the user
if [[ $CAN_WRITE_TO_REPO ]]; then
Expand All @@ -76,6 +84,7 @@ jobs:
board_definition_regex=$EXTERNAL_REGEX
fi
echo $FILES
for FILE in $FILES; do
if [[ $FILE =~ $board_definition_regex ]]; then
echo "✅ $FILE"
Expand All @@ -102,7 +111,7 @@ jobs:
EXIT_VALUE=0
for FILE in $FILES; do
if [[ $FILE == *.json ]]; then
if ! [[ $FILE =~ \.(svg|jpe?g|png)$ ]]; then
continue # non-image file
fi
Expand Down Expand Up @@ -131,7 +140,7 @@ jobs:
MIME_EXT="jpg"
fi
echo "❌ $FILE: expected .$MIME_EXT"
echo "❌ $FILE: expected extension .$MIME_EXT"
EXIT_VALUE=1
fi
Expand All @@ -153,7 +162,7 @@ jobs:
FILES: ${{ needs.changed-files.outputs.files }}
steps:
- uses: actions/checkout@v3
- uses: mfinelli/setup-imagemagick@v1
- uses: mfinelli/setup-imagemagick@v2
- name: Validate Image Dimensions
run: |
EXIT_VALUE=0
Expand All @@ -162,7 +171,7 @@ jobs:
MAX_HEIGHT=2000
for FILE in $FILES; do
if [[ $FILE == *.json ]]; then
if ! [[ $FILE =~ \.(svg|jpe?g|png)$ ]]; then
continue # non-image file
fi
Expand Down Expand Up @@ -221,7 +230,7 @@ jobs:
MAX_ANIGIF_FILESIZE=$((1000*1024)) # 1MB
for FILE in $FILES; do
if [[ $FILE == *.json ]]; then
if ! [[ $FILE =~ \.(svg|jpe?g|png)$ ]]; then
continue # non-image file
fi
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Information related to the hardware including the hardware's name, description a
| mcuRefVoltage | Yes | Float | Microcontroller's maximum voltage reference, in Volts. |
| displayName | Yes | String | Adafruit IO Device name |
| description | No | String | Device description |
| productPageURL | Yes | String | Link to board's homepage. |
| productURL | Yes | String | Link to board's homepage. |
| documentationURL | Yes | String | Link to board's documentation. |


Expand Down Expand Up @@ -79,4 +79,4 @@ The following HDM snippet defines an I2C interface on port 0 with a `SDA` GPIO p
Example hardware descriptions can be found in the `boards/` directory.

# Limitations
* The Adafruit IO WipperSnapper Firmware currently supports the following microcontrollers with a WiFi network interface: ESP8266, ESP32, ESP32-S2, ESP32-S3, SAMD51, SAMD21.
* The Adafruit IO WipperSnapper Firmware currently supports the following microcontrollers with a WiFi network interface: ESP8266, ESP32, ESP32-S2, ESP32-S3, SAMD51, SAMD21.
83 changes: 72 additions & 11 deletions boards/feather-esp32-v2/definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"mcuRefVoltage": 3.3,
"displayName":"Adafruit Feather ESP32 V2",
"vendor":"Adafruit",
"productPageURL":"https://www.adafruit.com/product/5400",
"productURL":"https://www.adafruit.com/product/5400",
"documentationURL":"https://learn.adafruit.com/adafruit-esp32-feather-v2",
"installMethod":"web",
"esptool": {
Expand All @@ -26,6 +26,18 @@
"displayName":"D0 (NeoPixel)",
"dataType":"bool"
},
{
"name":"D7",
"displayName":"D7 (UART RX)",
"dataType":"bool",
"uartRx": true
},
{
"name":"D8",
"displayName":"D8 (UART TX)",
"dataType":"bool",
"uartTx": true
},
{
"name":"D13",
"displayName":"D13 (LED BUILT-IN)",
Expand Down Expand Up @@ -76,18 +88,67 @@
},
{
"name":"D26",
"displayName":"D26",
"displayName":"D26 (A0)",
"dataType":"bool",
"hasPWM":true,
"hasServo":true
},
{
"name":"D25",
"displayName":"D25",
"displayName":"D25 (A1)",
"dataType":"bool",
"hasPWM":true,
"hasServo":true
},
{
"name":"D34",
"displayName":"D34 (A2)",
"dataType":"bool",
"hasPWM":true,
"hasServo":true
},
{
"name":"D39",
"displayName":"D39 (A3)",
"dataType":"bool",
"hasPWM":true,
"hasServo":true
},
{
"name":"D36",
"displayName":"D36 (A4)",
"dataType":"bool",
"hasPWM":true,
"hasServo":true
},
{
"name":"D4",
"displayName":"D4 (A5)",
"dataType":"bool",
"hasPWM":true,
"hasServo":true
},
{
"name":"D5",
"displayName":"D5 (SCK)",
"dataType":"bool",
"hasPWM":true,
"hasServo":true
},
{
"name":"D19",
"displayName":"D19 (MOSI)",
"dataType":"bool",
"hasPWM":true,
"hasServo":true
},
{
"name":"D21",
"displayName":"D21 (MISO)",
"dataType":"bool",
"hasPWM":true,
"hasServo":true
},
{
"name":"D37",
"displayName":"D37",
Expand All @@ -102,42 +163,42 @@
],
"analogPins": [
{
"name":"A0",
"name":"A26",
"displayName":"A0",
"dataType":"int16",
"hasPWM":true
},
{
"name":"A1",
"name":"A25",
"displayName":"A1",
"dataType":"int16",
"hasPWM":true
},
{
"name":"A2",
"name":"A34",
"displayName":"A2",
"dataType":"int16"
},
{
"name":"A3",
"name":"A39",
"displayName":"A3",
"dataType":"int16"
},
{
"name":"A4",
"name":"A36",
"displayName":"A4",
"dataType":"int16"
},
{
"name":"A5",
"name":"A4",
"displayName":"A5",
"dataType":"int16",
"hasPWM":true,
"hasServo":true
},
{
"name":"A13",
"displayName":"A13 (VBat Monitor)",
"name":"A35",
"displayName":"VBat Monitor",
"dataType":"int16"
}
],
Expand Down
51 changes: 51 additions & 0 deletions boards/feather-esp32-v2/magic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"exportVersion": "1.0.0",
"exportedBy": "Adafruit",
"exportedAt": "2023-11-13T19:41:29.465Z",
"exportedFromDevice": {
"board": "feather-esp32-v2",
"firmwareVersion": "1.0.0-beta.73"
},
"components": [
{
"name": "Button (D0/Boot)",
"pinName": "D38",
"type": "push_button",
"mode": "DIGITAL",
"direction": "INPUT",
"period": 0,
"isPin": true,
"pull": "UP"
},
{
"name": "Dimmable LED",
"type": "dimmable_led",
"pwmSetting": "fixedFrequency",
"frequency": 5000,
"resolution": 12,
"pinName": "D13",
"isPWM": true,
"selected": false
},
{
"name": "NeoPixel",
"pixelNumber": 1,
"pixelsOrder": "GRB",
"pixelBrightness": 255,
"pinName": "D0",
"type": "neopixel",
"pixelsType": "NEOPIXEL",
"isPixel": true
},
{
"name": "Battery ADC",
"pinName": "A35",
"type": "analog_pin",
"mode": "ANALOG",
"direction": "INPUT",
"analogReadMode": "PIN_VOLTAGE",
"period": 30,
"isPin": true
}
]
}
Loading

0 comments on commit 9a339b9

Please sign in to comment.