From fec35cfe5e0ba56056d7a591b6608b7f1692f97f Mon Sep 17 00:00:00 2001 From: Qinghao Shi Date: Tue, 7 Sep 2021 17:31:58 +0100 Subject: [PATCH 1/4] migrate TravisCI to GHA --- .github/workflows/snippets_checks.yml | 43 +++++++++++ .travis.yml | 106 -------------------------- 2 files changed, 43 insertions(+), 106 deletions(-) create mode 100644 .github/workflows/snippets_checks.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/snippets_checks.yml b/.github/workflows/snippets_checks.yml new file mode 100644 index 0000000000..0fbcbc4662 --- /dev/null +++ b/.github/workflows/snippets_checks.yml @@ -0,0 +1,43 @@ +# This workflow performs the checks like license check, +# doxygen, unit tests etc. +name: Snippets Checks + +on: + pull_request: + workflow_dispatch: + push: + branches: + - development + +jobs: + Snippets-check: + runs-on: ubuntu-latest + container: + image: ghcr.io/armmbed/mbed-os-env:master-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v2 + + - name: clone mbed-os + run: git clone https://github.com/armmbed/mbed-os.git + + - name: add mbed_app.json + run: | + echo '{ "target_overrides": { "K64F": { "target.features_add": ["BLE"] } } }' > mbed_app.json + + - name: validate code snippets + run: ./check_tools/find_bad_code_snippets.sh + + - name: find remaining TODOs + run: | + TODO_COUNT=0 + for f in $(find -name mbed-os -prune -o -name '*.md' -print) + do + for l in $(sed -n '/```.*TODO/I=' $f) + do + echo "TODO in $f line $l" + TODO_COUNT=$(expr $TODO_COUNT + 1) + done + done + echo "Total number of TODOs: $TODO_COUNT" \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 449df051c1..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,106 +0,0 @@ -# Language and cache settings -language: python -python: 3.8 -cache: - pip: true - directories: - - $HOME/.cache/apt - -# Common install step -install: - # Make sure pipefail - - set -o pipefail - # Set up apt to cache - - mkdir -p $HOME/.cache/apt/partial - - sudo rm -rf /var/cache/apt/archives - - sudo ln -s $HOME/.cache/apt /var/cache/apt/archives - # Set up ppa to make sure arm-none-eabi-gcc is the correct version - - sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa - # Fix for "The following signatures were invalid: KEYEXPIRED 1515625755" failed". See https://github.com/travis-ci/travis-ci/issues/9037 - - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 - # Loop until update succeeds (timeouts can occur) - - travis_retry $(! sudo apt-get update 2>&1 | grep Failed) - # Finally install gcc-arm-embedded - - sudo apt-get install gcc-arm-embedded - # Get mbed-os - - git clone https://github.com/armmbed/mbed-os.git - # Install python dependencies - - pip install -r mbed-os/requirements.txt - -# CI matrix -jobs: - include: - # native testing - - stage: test - env: - - NAME=code-snippets - script: - # Run script to validate code snippets - - ./check_tools/find_bad_code_snippets.sh - # Grep to find remaining TODOs - - | - TODO_COUNT=0 - for f in $(find -name mbed-os -prune -o -name '*.md' -print) - do - for l in $(sed -n '/```.*TODO/I=' $f) - do - echo "TODO in $f line $l" - TODO_COUNT=$(expr $TODO_COUNT + 1) - done - done - echo "Total number of TODOs: $TODO_COUNT" - # Update status with number of found TODOs if we passed testing - - | - if [ "$TRAVIS_TEST_RESULT" -eq 0 ] - then - CURR=$TODO_COUNT - PREV=$(curl -u "$MBED_BOT" https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \ - | jq -re "select(.sha != \"$TRAVIS_COMMIT\") - | .statuses[] | select(.context == \"$STAGE/$NAME\").description - | capture(\"(?[0-9]+) TODOs\").count" \ - || echo 0) - STATUS="Passed, ${CURR} TODOs" - if [ "$PREV" -ne 0 ] - then - STATUS="$STATUS ($(python -c "print '%+d' % ($CURR-$PREV)") TODOs)" - fi - fi - -# Manage statuses -before_install: - - | - curl -u "$MBED_BOT" -X POST \ - https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \ - -d "{ - \"context\": \"travis-ci/$NAME\", - \"state\": \"pending\", - \"description\": \"${STATUS:-In progress}\", - \"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\" - }" - -after_failure: - - | - curl -u "$MBED_BOT" -X POST \ - https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \ - -d "{ - \"context\": \"travis-ci/$NAME\", - \"state\": \"failure\", - \"description\": \"${STATUS:-Failed}\", - \"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\" - }" - -after_success: - - | - curl -u "$MBED_BOT" -X POST \ - https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \ - -d "{ - \"context\": \"travis-ci/$NAME\", - \"state\": \"success\", - \"description\": \"${STATUS:-Passed}\", - \"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\" - }" - -# Job control -stages: - - name: test - From c85fc65f888ddab31d34cfd2212c8652cb4b2e00 Mon Sep 17 00:00:00 2001 From: Qinghao Shi Date: Tue, 7 Sep 2021 17:32:53 +0100 Subject: [PATCH 2/4] Fix code snippet to be cpp rather than c --- docs/api/connectivity/bluetooth/BLE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/connectivity/bluetooth/BLE.md b/docs/api/connectivity/bluetooth/BLE.md index 3d9bfd8a05..2e338e4ddb 100644 --- a/docs/api/connectivity/bluetooth/BLE.md +++ b/docs/api/connectivity/bluetooth/BLE.md @@ -47,7 +47,7 @@ the events (methods) you are interested in, the others will inherit the do-nothi All BLE operations are executed on an instance of BLE accessible through a function in the header `ble/BLE.h`. -```c +```cpp #include "ble/BLE.h" BLE& mydevicename = BLE::Instance(); From 56a1e31c5541b2bce231431f5ed4a79fa6ec2908 Mon Sep 17 00:00:00 2001 From: Qinghao Shi Date: Tue, 7 Sep 2021 17:39:06 +0100 Subject: [PATCH 3/4] update snippets make the compile job pass --- docs/api/drivers/driver_interfaces.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api/drivers/driver_interfaces.md b/docs/api/drivers/driver_interfaces.md index d4d1df77e0..ad2c9981e9 100644 --- a/docs/api/drivers/driver_interfaces.md +++ b/docs/api/drivers/driver_interfaces.md @@ -72,7 +72,7 @@ class LEDAnimator { } LEDAnimator(mbed::interface::DigitalOut *red, mbed::interface::DigitalOut *green, mbed::interface::DigitalOut *blue) : _red(red), _green(green), _blue(blue), _internally_created(false) { - ... + } ~LEDAnimator() { @@ -90,7 +90,7 @@ private: mbed::interface::DigitalOut *_blue; bool _internally_created; -} +}; ``` Now it is possible for your existing library to use the external GPIO expander without any knowledge that it is external. As long as your `my_company::I2CExpander::DigitalOut` class implements the `mbed::interface::DigitalOut` interface properly, your code will work as it did before. You can even have some of the GPIO be internal or external if your design calls for it! @@ -103,7 +103,7 @@ The inheritance of a driver from the new driver interface is conditional upon `F When `FEATURE_EXPERIMENTAL_API` is disabled, the following type alias is made instead: -```c++ +``` using mbed::interface::DigitalOut = mbed::DigitalOut; ``` From 2d5733b0db97b93d582a7e8f2b6b9acf8287ad2c Mon Sep 17 00:00:00 2001 From: Qinghao Shi Date: Fri, 17 Sep 2021 12:36:54 +0100 Subject: [PATCH 4/4] add comment --- docs/api/drivers/driver_interfaces.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/drivers/driver_interfaces.md b/docs/api/drivers/driver_interfaces.md index ad2c9981e9..f9ae35c2e1 100644 --- a/docs/api/drivers/driver_interfaces.md +++ b/docs/api/drivers/driver_interfaces.md @@ -72,7 +72,7 @@ class LEDAnimator { } LEDAnimator(mbed::interface::DigitalOut *red, mbed::interface::DigitalOut *green, mbed::interface::DigitalOut *blue) : _red(red), _green(green), _blue(blue), _internally_created(false) { - + // do something } ~LEDAnimator() {