-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'adafruit:main' into boards-featherS2-initial
- Loading branch information
Showing
74 changed files
with
10,347 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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" | ||
|
@@ -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 | ||
|
@@ -131,7 +140,7 @@ jobs: | |
MIME_EXT="jpg" | ||
fi | ||
echo "❌ $FILE: expected .$MIME_EXT" | ||
echo "❌ $FILE: expected extension .$MIME_EXT" | ||
EXIT_VALUE=1 | ||
fi | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] | ||
} |
Oops, something went wrong.