commit
752ed8d758
2 changed files with 59 additions and 36 deletions
85
.github/workflows/protoc-wrapper-generation.yml
vendored
85
.github/workflows/protoc-wrapper-generation.yml
vendored
|
|
@ -2,10 +2,19 @@ name: Generate .proto Wrapper Files
|
|||
on:
|
||||
push:
|
||||
branches: master
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: write
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
# Setup
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
|
@ -13,10 +22,11 @@ jobs:
|
|||
uses: arduino/setup-protoc@v1
|
||||
with:
|
||||
version: '3.13.0'
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install Python dependencies
|
||||
run : |
|
||||
python -m pip install --upgrade pip
|
||||
pip install protobuf
|
||||
pip install protobuf setuptools
|
||||
- name: Self Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
|
|
@ -26,45 +36,22 @@ jobs:
|
|||
run: |
|
||||
git config --global user.name adafruitio
|
||||
git config --global user.email adafruitio@adafruit.com
|
||||
- name: Generate Python & JS Wrapper Files from .proto Files
|
||||
run: |
|
||||
mkdir ./python_out
|
||||
mkdir ./python_nanopb_out
|
||||
mkdir ./js_out
|
||||
protoc --proto_path=./protobuf-checkout/proto ./protobuf-checkout/proto/wippersnapper/*/*/*.proto --js_out=import_style=commonjs,binary:js_out --python_out=./python_out
|
||||
protoc ./protobuf-checkout/nanopb/generator/proto/nanopb.proto --js_out=import_style=commonjs,binary:js_out --python_out=./python_nanopb_out
|
||||
- name: Checkout Python Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/Adafruit_Wippersnapper_Python
|
||||
token: ${{ secrets.IO_BOT_PAT }}
|
||||
path: python-checkout
|
||||
- name: Copy Python Files
|
||||
run: |
|
||||
rm -rf ./python-checkout/adafruit_wippersnapper/proto/
|
||||
cp -r ./python_out/ ./python-checkout/adafruit_wippersnapper/proto/
|
||||
mkdir ./python-checkout/adafruit_wippersnapper/proto/nanopb
|
||||
mv ./python_nanopb_out/protobuf_checkout/nanopb/generator/proto/nanopb_pb2.py ./python-checkout/adafruit_wippersnapper/proto/nanopb
|
||||
- name: Open Python Pull Request
|
||||
env:
|
||||
GITHUB_USER: adafruitio
|
||||
GITHUB_TOKEN: ${{ secrets.IO_BOT_PAT }}
|
||||
PROTOBUF_BRANCH_NAME: protobuf-update
|
||||
run: |
|
||||
cd python-checkout
|
||||
git checkout -b $PROTOBUF_BRANCH_NAME-$GITHUB_SHA
|
||||
git add adafruit_wippersnapper
|
||||
git commit -m "Updating protobuf wrappers" || exit 0 # quit cleanly if nothing to commit
|
||||
hub push origin $PROTOBUF_BRANCH_NAME-$GITHUB_SHA
|
||||
hub pull-request --message ".proto file wrappers updated" --message "Auto-generated by [GitHub Actions on Protobuf Repo][1]" --message "[1]: https://github.com/adafruit/Wippersnapper_Protobuf/blob/master/.github/workflows/protoc-wrapper-generation.yml"
|
||||
|
||||
# Arduino wrappers for the microcontrollers
|
||||
- name: Generate Arduino files from .proto Files
|
||||
env:
|
||||
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python
|
||||
run: |
|
||||
mkdir ./arduino_out
|
||||
protoc --plugin=protobuf-checkout/nanopb/generator/protoc-gen-nanopb -Iprotobuf-checkout/nanopb/generator/proto --proto_path=./protobuf-checkout/proto ./protobuf-checkout/proto/wippersnapper/*/*/*.proto --nanopb_out=./arduino_out --nanopb_opt=-I./protobuf-checkout/proto --nanopb_opt=-t
|
||||
mkdir ./doc
|
||||
echo "Installing protobuf-gen-doc"
|
||||
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
|
||||
cp ~/go/bin/protoc-gen-doc .
|
||||
echo "Generating docs..."
|
||||
protoc --plugin=protobuf-checkout/nanopb/generator/protoc-gen-nanopb -Iprotobuf-checkout/nanopb/generator/proto --proto_path=./protobuf-checkout/proto ./protobuf-checkout/proto/wippersnapper/*/*/*.proto --nanopb_out=./arduino_out --nanopb_opt=-I./protobuf-checkout/proto --nanopb_opt=-t --plugin=protoc-gen-doc=./protoc-gen-doc --doc_out=./doc --doc_opt=html,index.html
|
||||
# Local (non-CI) build command:
|
||||
# protoc --plugin=nanopb/generator/protoc-gen-nanopb -Inanopb/generator/proto --proto_path=./proto ./proto/wippersnapper/*/*/*.proto --nanopb_out=./arduino_out --nanopb_opt=-I./proto --nanopb_opt=-t
|
||||
# protoc --plugin=nanopb/generator/protoc-gen-nanopb -Inanopb/generator/proto --proto_path=./proto ./proto/wippersnapper/*/*/*.proto --nanopb_out=./arduino_out --nanopb_opt=-I./proto --nanopb_opt=-t --plugin=protoc-gen-doc=./protoc-gen-doc --doc_out=./doc --doc_opt=html,index.html
|
||||
|
||||
- name: Checkout Arduino Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
|
|
@ -89,6 +76,13 @@ jobs:
|
|||
git commit -m "Updating protobuf wrappers" || exit 0 # quit cleanly if nothing to commit
|
||||
hub push origin $PROTOBUF_BRANCH_NAME-$GITHUB_SHA
|
||||
hub pull-request --base main --message ".proto file wrappers updated" --message "Auto-generated by [GitHub Actions on Protobuf Repo][1]" --message "[1]: https://github.com/adafruit/Wippersnapper_Protobuf/blob/master/.github/workflows/protoc-wrapper-generation.yml"
|
||||
|
||||
# NodeJS wrappers for the mqtt broker
|
||||
- name: Generate JS Wrapper Files from .proto Files
|
||||
run: |
|
||||
mkdir ./js_out
|
||||
protoc --proto_path=./protobuf-checkout/proto ./protobuf-checkout/proto/wippersnapper/*/*/*.proto --js_out=import_style=commonjs,binary:js_out
|
||||
protoc ./protobuf-checkout/nanopb/generator/proto/nanopb.proto --js_out=import_style=commonjs,binary:js_out
|
||||
- name: Checkout io-node Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
|
|
@ -115,3 +109,26 @@ jobs:
|
|||
git commit -m "Updating protobuf wrappers" || exit 0 # quit cleanly if nothing to commit
|
||||
hub push origin $PROTOBUF_BRANCH_NAME-$GITHUB_SHA
|
||||
hub pull-request --base main --message ".proto file wrappers updated" --message "Auto-generated by [GitHub Actions on Protobuf Repo][1]" --message "[1]: https://github.com/adafruit/Wippersnapper_Protobuf/blob/master/.github/workflows/protoc-wrapper-generation.yml"
|
||||
|
||||
# Docs
|
||||
- name: Checkout doc branch
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: gh-pages
|
||||
path: protobuf-docs-checkout
|
||||
- name: Commit and push generated HTML Docs file
|
||||
run: |
|
||||
cd protobuf-docs-checkout
|
||||
cp -r ../doc ./doc
|
||||
git add doc/
|
||||
git commit -m "Add generated HTML documentation for $GITHUB_SHA" || exit 0 # quit cleanly if nothing to commit
|
||||
git push
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v3
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v2
|
||||
with:
|
||||
path: 'protobuf-docs-checkout/doc'
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v2
|
||||
|
|
|
|||
10
.github/workflows/test-wrapper-arduino.yml
vendored
10
.github/workflows/test-wrapper-arduino.yml
vendored
|
|
@ -29,9 +29,15 @@ jobs:
|
|||
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python
|
||||
run: |
|
||||
mkdir ./arduino_out
|
||||
protoc --plugin=protobuf-checkout/nanopb/generator/protoc-gen-nanopb -Iprotobuf-checkout/nanopb/generator/proto --proto_path=./protobuf-checkout/proto ./protobuf-checkout/proto/wippersnapper/*/*/*.proto --nanopb_out=./arduino_out --nanopb_opt=-I./protobuf-checkout/proto --nanopb_opt=-t
|
||||
mkdir ./doc
|
||||
echo "Installing protobuf-gen-doc"
|
||||
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
|
||||
cp ~/go/bin/protoc-gen-doc .
|
||||
echo "Generating docs..."
|
||||
protoc --plugin=protobuf-checkout/nanopb/generator/protoc-gen-nanopb -Iprotobuf-checkout/nanopb/generator/proto --proto_path=./protobuf-checkout/proto ./protobuf-checkout/proto/wippersnapper/*/*/*.proto --nanopb_out=./arduino_out --nanopb_opt=-I./protobuf-checkout/proto --nanopb_opt=-t --plugin=protoc-gen-doc=./protoc-gen-doc --doc_out=./doc --doc_opt=html,index.html
|
||||
# Local (non-CI) build command:
|
||||
# protoc --plugin=nanopb/generator/protoc-gen-nanopb -Inanopb/generator/proto --proto_path=./proto ./proto/wippersnapper/*/*/*.proto --nanopb_out=./arduino_out --nanopb_opt=-I./proto --nanopb_opt=-t
|
||||
# protoc --plugin=nanopb/generator/protoc-gen-nanopb -Inanopb/generator/proto --proto_path=./proto ./proto/wippersnapper/*/*/*.proto --nanopb_out=./arduino_out --nanopb_opt=-I./proto --nanopb_opt=-t --plugin=protoc-gen-doc=./protoc-gen-doc --doc_out=./doc --doc_opt=html,index.html
|
||||
cp ./doc/index.html ./arduino_out
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: build-artifact-arduino-wrapper
|
||||
|
|
|
|||
Loading…
Reference in a new issue