| # Copyright (c) 2020-2021 Project CHIP Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| name: Lint Code Base |
| on: |
| push: |
| pull_request: |
| workflow_dispatch: |
| |
| concurrency: |
| group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }} |
| cancel-in-progress: true |
| |
| jobs: |
| code-lints: |
| runs-on: ubuntu-latest |
| if: github.actor != 'restyled-io[bot]' |
| |
| container: |
| image: connectedhomeip/chip-build:0.6.32 |
| |
| steps: |
| - uses: Wandalen/wretry.action@v1.0.36 |
| if: ${{ !env.ACT }} |
| name: Checkout |
| with: |
| action: actions/checkout@v3 |
| with: | |
| token: ${{ github.token }} |
| attempt_limit: 3 |
| attempt_delay: 2000 |
| # To use act like: |
| # act -j code-lints |
| # |
| # Note you likely still need to have non submodules setup for the |
| # local machine, like: |
| # git submodule deinit --all |
| - uses: actions/checkout@v3 |
| if: ${{ env.ACT }} |
| name: Checkout (ACT for local build) |
| |
| # Bootstrap and checkout for internal scripts (like idl_lint) |
| # to run |
| - name: Checkout submodules |
| run: scripts/checkout_submodules.py --shallow --platform linux |
| - name: Bootstrap |
| timeout-minutes: 10 |
| run: scripts/build/gn_bootstrap.sh |
| |
| - name: Check for matter lint errors |
| if: always() |
| run: | |
| for idl_file in $(find . -name '*.matter'); do |
| # TODO: all these conformance failures should be fixed |
| # Issues exist for most of them: |
| # https://github.com/project-chip/connectedhomeip/issues/19180 |
| # https://github.com/project-chip/connectedhomeip/issues/19176 |
| # https://github.com/project-chip/connectedhomeip/issues/19175 |
| # https://github.com/project-chip/connectedhomeip/issues/19173 |
| # https://github.com/project-chip/connectedhomeip/issues/19169 |
| # https://github.com/project-chip/connectedhomeip/issues/22640 |
| if [ "$idl_file" = './examples/all-clusters-app/all-clusters-common/all-clusters-app.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/lighting-app/lighting-common/lighting-app.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/log-source-app/log-source-common/log-source-app.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/placeholder/linux/apps/app1/config.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/placeholder/linux/apps/app2/config.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/thermostat/thermostat-common/thermostat.matter' ]; then continue; fi |
| if [ "$idl_file" = './examples/window-app/common/window-app.matter' ]; then continue; fi |
| |
| # Test files are intentionally small and not spec-compilant, just parse-compliant |
| if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/cluster_struct_attribute.matter" ]; then continue; fi |
| if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/global_struct_attribute.matter" ]; then continue; fi |
| if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/optional_argument.matter" ]; then continue; fi |
| if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/several_clusters.matter" ]; then continue; fi |
| if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/simple_attribute.matter" ]; then continue; fi |
| if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/large_lighting_app.matter" ]; then continue; fi |
| if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/large_all_clusters_app.matter" ]; then continue; fi |
| |
| ./scripts/run_in_build_env.sh "./scripts/idl_lint.py --log-level warn $idl_file" >/dev/null || exit 1 |
| done |
| |
| - name: Check broken links |
| # On-push disabled until the job can run fully green |
| # At that point the step should be enabled. |
| if: github.event_name == 'workflow_dispatch' |
| uses: gaurav-nelson/github-action-markdown-link-check@v1 |
| |
| # git grep exits with 0 if it finds a match, but we want |
| # to fail (exit nonzero) on match. And we wasnt to exclude this file, |
| # to avoid our grep regexp matching itself. |
| - name: Check for incorrect error use in VerifyOrExit |
| if: always() |
| run: | |
| git grep -n "VerifyOrExit(.*, [A-Za-z]*_ERROR" -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 |
| |
| # git grep exits with 0 if it finds a match, but we want |
| # to fail (exit nonzero) on match. And we wasnt to exclude this file, |
| # to avoid our grep regexp matching itself. |
| - name: Check for use of PRI*8, which are not supported on some libcs. |
| if: always() |
| run: | |
| git grep -n "PRI.8" -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)third_party/lwip/repo/lwip/src/include/lwip/arch.h' && exit 1 || exit 0 |
| |
| # git grep exits with 0 if it finds a match, but we want |
| # to fail (exit nonzero) on match. And we wasnt to exclude this file, |
| # to avoid our grep regexp matching itself. |
| - name: Check for use of PRI*16, which are not supported on some libcs. |
| if: always() |
| run: | |
| git grep -n "PRI.16" -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)third_party/lwip/repo/lwip/src/include/lwip/arch.h' && exit 1 || exit 0 |
| |
| # git grep exits with 0 if it finds a match, but we want |
| # to fail (exit nonzero) on match. And we wasnt to exclude this file, |
| # to avoid our grep regexp matching itself. |
| - name: Check for use of %zu, which are not supported on some libcs. |
| if: always() |
| run: | |
| git grep -n "%zu" -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 |
| |
| # Comments like '{{! ... }}' should be used in zap files |
| - name: Do not allow TODO in generated files |
| if: always() |
| run: | |
| git grep -n 'TODO:' -- ./zzz_generated './*/zap-generated/*' && exit 1 || exit 0 |
| |
| - name: Check for disallowed include files |
| if: always() |
| run: scripts/tools/check_includes.sh |
| |
| - name: Check for zcl.json and extension sync status |
| if: always() |
| run: scripts/tools/check_zcl_file_sync.py . |
| |
| - name: Ensure all PICS are set for tests (to true or false) |
| if: always() |
| run: | |
| scripts/tools/check_test_pics.py src/app/tests/suites/certification/ci-pics-values src/app/tests/suites/certification/PICS.yaml |
| |
| # git grep exits with 0 if it finds a match, but we want |
| # to fail (exit nonzero) on match. And we wasnt to exclude this file, |
| # to avoid our grep regexp matching itself. |
| - name: Check for use of 0x%u and the like, which lead to misleading output. |
| if: always() |
| run: | |
| git grep -n '0x%[0-9l.-]*[^0-9lxX".-]' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 |
| |
| # git grep exits with 0 if it finds a match, but we want |
| # to fail (exit nonzero) on match. And we wasnt to exclude this file, |
| # to avoid our grep regexp matching itself. |
| - name: Check for use of '"0x" PRIu*' and the like, which lead to misleading output. |
| if: always() |
| run: | |
| git grep -n '0x%[0-9-]*" *PRI[^xX]' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 |