From 736066fc4073a6e9ba000c3f15a72798457797e9 Mon Sep 17 00:00:00 2001 From: Soren Ptak Date: Tue, 5 Sep 2023 17:55:17 -0400 Subject: [PATCH] CI-CD Updates (#76) * Use new version of CI-CD Actions, checkout@v3 instead of checkout@v2 on all jobs * Use cSpell spell check, and use ubuntu-20.04 for formatting check * Add in bot formatting action --- .github/.cSpellWords.txt | 23 ++++ .github/workflows/ci.yml | 58 ++++++--- .github/workflows/formatting.yml | 23 ++++ .github/workflows/release.yml | 4 +- README.md | 111 +++++++++++------- cspell.config.yaml | 31 +++++ lexicon.txt | 100 ---------------- test/cbmc/proofs/Defender_GetTopic/README.md | 2 +- .../cbmc/proofs/Defender_MatchTopic/README.md | 2 +- 9 files changed, 193 insertions(+), 161 deletions(-) create mode 100644 .github/.cSpellWords.txt create mode 100644 .github/workflows/formatting.yml create mode 100644 cspell.config.yaml delete mode 100644 lexicon.txt diff --git a/.github/.cSpellWords.txt b/.github/.cSpellWords.txt new file mode 100644 index 0000000..6d8e1f3 --- /dev/null +++ b/.github/.cSpellWords.txt @@ -0,0 +1,23 @@ +CBMC +CBOR +CMOCK +CMock +Cmock +Coverity +DDISABLE +DNDEBUG +DUNITY +MISRA +MQTT +Misra +Wunused +cbmc +cbor +cmet +cmock +coverity +ctest +lcov +misra +sinclude +utest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d1f1d4..47f3c71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone This Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build run: | sudo apt-get install -y lcov @@ -34,12 +34,12 @@ jobs: - name: Check Coverage uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main with: - path: ./build/coverage.info + coverage-file: ./build/coverage.info build-with-default-config: runs-on: ubuntu-latest steps: - name: Clone This Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build run: | cmake -S test -B build/ \ @@ -50,7 +50,7 @@ jobs: complexity: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Check complexity uses: FreeRTOS/CI-CD-Github-Actions/complexity@main with: @@ -58,7 +58,7 @@ jobs: doxygen: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run doxygen build uses: FreeRTOS/CI-CD-Github-Actions/doxygen@main with: @@ -67,15 +67,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone This Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run spellings check uses: FreeRTOS/CI-CD-Github-Actions/spellings@main with: path: ./ formatting: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Check formatting uses: FreeRTOS/CI-CD-Github-Actions/formatting@main with: @@ -83,9 +83,9 @@ jobs: git-secrets: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Checkout awslabs/git-secrets - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: awslabs/git-secrets ref: master @@ -99,19 +99,43 @@ jobs: memory_statistics: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: - submodules: 'recursive' + submodules: "recursive" - name: Install Python3 - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: - python-version: '3.11.0' + python-version: "3.11.0" - name: Measure sizes uses: FreeRTOS/CI-CD-Github-Actions/memory_statistics@main with: - config: .github/memory_statistics_config.json - check_against: docs/doxygen/include/size_table.md + config: .github/memory_statistics_config.json + check_against: docs/doxygen/include/size_table.md + link-verifier: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Check Links + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: FreeRTOS/CI-CD-Github-Actions/link-verifier@main + + verify-manifest: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Run manifest verifier + uses: FreeRTOS/CI-CD-GitHub-Actions/manifest-verifier@main + with: + path: ./ + fail-on-incorrect-version: true + proof_ci: + if: ${{ github.event.pull_request }} runs-on: cbmc_ubuntu-latest_16-core steps: - name: Set up CBMC runner @@ -119,4 +143,4 @@ jobs: - name: Run CBMC uses: FreeRTOS/CI-CD-Github-Actions/run_cbmc@main with: - proofs_dir: test/cbmc/proofs + proofs_dir: test/cbmc/proofs \ No newline at end of file diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml new file mode 100644 index 0000000..8257add --- /dev/null +++ b/.github/workflows/formatting.yml @@ -0,0 +1,23 @@ +name: Format Pull Request Files + +on: + issue_comment: + types: [created] + +env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + +jobs: + Formatting: + name: Run Formatting Check + if: ${{ github.event.issue.pull_request }} && + ( ( github.event.comment.body == '/bot run uncrustify' ) || + ( github.event.comment.body == '/bot run formatting' ) ) + runs-on: ubuntu-20.04 + steps: + - name: Apply Formatting Fix + uses: FreeRTOS/CI-CD-Github-Actions/formatting-bot@main + id: check-formatting diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d5024d7..0589bad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.event.inputs.commit_id }} - name: Configure git identity @@ -53,7 +53,7 @@ jobs: - name: Install ZIP tools run: sudo apt-get install zip unzip - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.event.inputs.commit_id }} path: Device-Defender-for-AWS-IoT-embedded-sdk diff --git a/README.md b/README.md index 395901d..a90dcb8 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,50 @@ # AWS IoT Device Defender Library -The Device Defender library enables you to send device metrics to the [AWS IoT Device Defender Service](https://aws.amazon.com/iot-device-defender/). -This library also supports custom metrics, a feature that helps you monitor operational health metrics that are unique to your fleet or use case. For example, you can define a new metric to monitor the memory usage or CPU usage on your devices. -This library has no dependencies on any additional libraries other than the -standard C library, and therefore, can be used with any MQTT client library. -This library is distributed under the [MIT Open Source License](LICENSE). +**[API Documentation Pages for current and previous releases of this library can be found here](https://aws.github.io/Device-Defender-for-AWS-IoT-embedded-sdk/)** + +The Device Defender library enables you to send device metrics to the +[AWS IoT Device Defender Service](https://aws.amazon.com/iot-device-defender/). +This library also supports custom metrics, a feature that helps you monitor +operational health metrics that are unique to your fleet or use case. For +example, you can define a new metric to monitor the memory usage or CPU usage on +your devices. This library has no dependencies on any additional libraries other +than the standard C library, and therefore, can be used with any MQTT client +library. This library is distributed under the +[MIT Open Source License](LICENSE). This library has gone through code quality checks including verification that no -function has a [GNU Complexity](https://www.gnu.org/software/complexity/manual/complexity.html) +function has a +[GNU Complexity](https://www.gnu.org/software/complexity/manual/complexity.html) score over 8, and checks against deviations from mandatory rules in the -[MISRA coding standard](https://www.misra.org.uk). -Deviations from the MISRA C:2012 guidelines are documented under [MISRA Deviations](MISRA.md). -This library has also undergone static code analysis using [Coverity static analysis](https://scan.coverity.com/), -and validation of memory safety through the [CBMC automated reasoning tool](https://www.cprover.org/cbmc/). - -See memory requirements for this library [here](./docs/doxygen/include/size_table.md). - -**AWS IoT Device Defender v1.3.0 [source code](https://github.com/aws/Device-Defender-for-AWS-IoT-embedded-sdk/tree/v1.3.0/source) is part of the [FreeRTOS 202210.00 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202210.00-LTS) release.** - -**AWS IoT Device Defender v1.1.0 [source code](https://github.com/aws/Device-Defender-for-AWS-IoT-embedded-sdk/tree/v1.1.0/source) is part of the [FreeRTOS 202012.01 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202012.01-LTS) release.** +[MISRA coding standard](https://www.misra.org.uk). Deviations from the MISRA +C:2012 guidelines are documented under [MISRA Deviations](MISRA.md). This +library has also undergone static code analysis using +[Coverity static analysis](https://scan.coverity.com/), and validation of memory +safety through the +[CBMC automated reasoning tool](https://www.cprover.org/cbmc/). + +See memory requirements for this library +[here](./docs/doxygen/include/size_table.md). + +**AWS IoT Device Defender v1.3.0 +[source code](https://github.com/aws/Device-Defender-for-AWS-IoT-embedded-sdk/tree/v1.3.0/source) +is part of the +[FreeRTOS 202210.00 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202210.00-LTS) +release.** + +**AWS IoT Device Defender v1.1.0 +[source code](https://github.com/aws/Device-Defender-for-AWS-IoT-embedded-sdk/tree/v1.1.0/source) +is part of the +[FreeRTOS 202012.01 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202012.01-LTS) +release.** ## AWS IoT Device Defender Client Config File The AWS IoT Device Defender Client Library exposes build configuration macros that are required for building the library. A list of all the configurations and their default values are defined in -[defender_config_defaults.h](source/include/defender_config_defaults.h). -To provide custom values for the configuration macros, a config file named +[defender_config_defaults.h](source/include/defender_config_defaults.h). To +provide custom values for the configuration macros, a config file named `defender_config.h` can be provided by the application to the library. By default, a `defender_config.h` config file is required to build the library. @@ -35,13 +53,14 @@ values, provide `DEFENDER_DO_NOT_USE_CUSTOM_CONFIG` as a compile time preprocessor macro. **Thus, the Device Defender client library can be built by either**: -* Defining a `defender_config.h` file in the application, and adding it to the -include directories list of the library. + +- Defining a `defender_config.h` file in the application, and adding it to the + include directories list of the library. **OR** -* Defining the `DEFENDER_DO_NOT_USE_CUSTOM_CONFIG` preprocessor macro for the -library build. +- Defining the `DEFENDER_DO_NOT_USE_CUSTOM_CONFIG` preprocessor macro for the + library build. ## Building the Library @@ -49,9 +68,9 @@ The [defenderFilePaths.cmake](defenderFilePaths.cmake) file contains the information of all source files and the header include paths required to build the Device Defender client library. -As mentioned in the previous section, either a custom config file -(i.e. `defender_config.h`) or `DEFENDER_DO_NOT_USE_CUSTOM_CONFIG` macro needs to -be provided to build the Device Defender client library. +As mentioned in the previous section, either a custom config file (i.e. +`defender_config.h`) or `DEFENDER_DO_NOT_USE_CUSTOM_CONFIG` macro needs to be +provided to build the Device Defender client library. For a CMake example of building the Device Defender client library with the `defenderFilePaths.cmake` file, refer to the `coverity_analysis` library target @@ -62,16 +81,19 @@ in [test/CMakeLists.txt](test/CMakeLists.txt) file. ### Platform Prerequisites - For running unit tests: - - **C90 compiler** like gcc. - - **CMake 3.13.0 or later**. - - **Ruby 2.0.0 or later** is additionally required for the CMock test framework (that we use). -- For running the coverage target, **gcov** and **lcov** are additionally required. + - **C90 compiler** like gcc. + - **CMake 3.13.0 or later**. + - **Ruby 2.0.0 or later** is additionally required for the CMock test + framework (that we use). +- For running the coverage target, **gcov** and **lcov** are additionally + required. ### Steps to build **Unit Tests** 1. Go to the root directory of this repository. -1. Run the *cmake* command: `cmake -S test -B build -DBUILD_CLONE_SUBMODULES=ON`. +1. Run the _cmake_ command: + `cmake -S test -B build -DBUILD_CLONE_SUBMODULES=ON`. 1. Run this command to build the library and unit tests: `make -C build all`. @@ -81,34 +103,42 @@ in [test/CMakeLists.txt](test/CMakeLists.txt) file. ## CBMC -To learn more about CBMC and proofs specifically, review the training material [here](https://model-checking.github.io/cbmc-training). +To learn more about CBMC and proofs specifically, review the training material +[here](https://model-checking.github.io/cbmc-training). The `test/cbmc/proofs` directory contains CBMC proofs. -In order to run these proofs you will need to install CBMC and other tools by following the instructions [here](https://model-checking.github.io/cbmc-training/installation.html). +In order to run these proofs you will need to install CBMC and other tools by +following the instructions +[here](https://model-checking.github.io/cbmc-training/installation.html). ## Reference examples The AWS IoT Embedded C-SDK repository contains a demo showing the use of AWS IoT -Device Defender Client Library [here](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/main/demos/defender/defender_demo_json) +Device Defender Client Library +[here](https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/main/demos/defender/defender_demo_json) on a POSIX platform. ## Documentation ### Existing documentation -For pre-generated documentation, please see the documentation linked in the locations below: -| Location | -| :-: | -| [AWS IoT Device SDK for Embedded C](https://github.com/aws/aws-iot-device-sdk-embedded-C#releases-and-documentation) | +For pre-generated documentation, please see the documentation linked in the +locations below: + +| Location | +| :-------------------------------------------------------------------------------------------------------------------------------------: | +| [AWS IoT Device SDK for Embedded C](https://github.com/aws/aws-iot-device-sdk-embedded-C#releases-and-documentation) | | [FreeRTOS.org](https://freertos.org/Documentation/api-ref/device-defender-for-aws-iot-embedded-sdk/docs/doxygen/output/html/index.html) | -Note that the latest included version of the AWS IoT Device Defender library may differ across repositories. +Note that the latest included version of the AWS IoT Device Defender library may +differ across repositories. ### Generating documentation The Doxygen references were created using Doxygen version 1.9.2. To generate the -Doxygen pages, please run the following command from the root of this repository: +Doxygen pages, please run the following command from the root of this +repository: ```shell doxygen docs/doxygen/config.doxyfile @@ -116,4 +146,5 @@ doxygen docs/doxygen/config.doxyfile ## Contributing -See [CONTRIBUTING.md](./.github/CONTRIBUTING.md) for information on contributing. +See [CONTRIBUTING.md](./.github/CONTRIBUTING.md) for information on +contributing. diff --git a/cspell.config.yaml b/cspell.config.yaml new file mode 100644 index 0000000..911ce1d --- /dev/null +++ b/cspell.config.yaml @@ -0,0 +1,31 @@ +--- +$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json +version: '0.2' +# Allows things like stringLength +allowCompoundWords: true + +# Read files not to spell check from the git ignore +useGitignore: true + +# Language settings for C +languageSettings: + - caseSensitive: false + enabled: true + languageId: c + locale: "*" + +# Add a dictionary, and the path to the word list +dictionaryDefinitions: + - name: freertos-words + path: '.github/.cSpellWords.txt' + addWords: true + +dictionaries: + - freertos-words + +# Paths and files to ignore +ignorePaths: + - 'dependency' + - 'docs' + - 'ThirdParty' + - 'History.txt' diff --git a/lexicon.txt b/lexicon.txt deleted file mode 100644 index af0febd..0000000 --- a/lexicon.txt +++ /dev/null @@ -1,100 +0,0 @@ -addr -api -apis -aws -bi -bo -br -bufferlength -cbor -colspan -com -cond -config -configpagestyle -const -copydoc -css -defenderapi -defenderbadparameter -defenderbuffertoosmall -defendercborreportaccepted -defendercborreportpublish -defendercborreportrejected -defendererror -defenderinvalidtopic -defenderjsonreportaccepted -defenderjsonreportpublish -defenderjsonreportrejected -defendernomatch -defenderstatus -defendersuccess -defendertopic -defgroup -developerguide -doesn -doxygen -endcode -endcond -endif -enum -gcc -getdeviceserialnumber -gettopic -github -hed -html -https -inc -ingroup -iot -iso -json -logdebug -logerror -loginfo -logwarn -mainpage -matchapi -matchtopic -md -mdash -memcpy -misra -mit -mqtt -noninfringement -ns -os -param -pbuffer -png -po -posix -poutapi -poutlength -poutthingnamelength -ppoutthingname -pre -premainingtopic -pthingname -ptopic -remainingtopiclength -remediate -rm -sdk -spdx -strlen -sublicense -tcp -td -thingname -thingnamelength -toolchain -topicbuffer -topiclength -tr -udp -uint -utest -xa diff --git a/test/cbmc/proofs/Defender_GetTopic/README.md b/test/cbmc/proofs/Defender_GetTopic/README.md index 56f00c2..f4c13ea 100644 --- a/test/cbmc/proofs/Defender_GetTopic/README.md +++ b/test/cbmc/proofs/Defender_GetTopic/README.md @@ -11,7 +11,7 @@ To run the proof. * Run "make". * Open html/index.html in a web browser. -To use [`arpa`](https://github.com/awslabs/aws-proof-build-assistant) to simplify writing Makefiles. +To use [`arpa`](https://awslabs.github.io/aws-proof-build-assistant) to simplify writing Makefiles. ------------- * Run "make arpa" to generate a Makefile.arpa that contains relevant build information for the proof. diff --git a/test/cbmc/proofs/Defender_MatchTopic/README.md b/test/cbmc/proofs/Defender_MatchTopic/README.md index c095d85..08fbf79 100644 --- a/test/cbmc/proofs/Defender_MatchTopic/README.md +++ b/test/cbmc/proofs/Defender_MatchTopic/README.md @@ -11,7 +11,7 @@ To run the proof. * Run "make". * Open html/index.html in a web browser. -To use [`arpa`](https://github.com/awslabs/aws-proof-build-assistant) to simplify writing Makefiles. +To use [`arpa`](https://awslabs.github.io/aws-proof-build-assistant) to simplify writing Makefiles. ------------- * Run "make arpa" to generate a Makefile.arpa that contains relevant build information for the proof.