Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: extend pre-commit checks, fix failing checks #394

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .astyle_rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
DEFAULT:
# These formatting options will be used by default.
options: "--style=otbs --attach-namespaces --attach-classes --indent=spaces=4 --convert-tabs --align-pointer=name --align-reference=name --keep-one-line-statements --pad-header --pad-oper"

proto-c:
check: false
include:
- "/network_provisioning/proto-c/"

thirdparty:
check: false
include:
- "/iqmath/"
- "/qrcode/qrcodegen.*"
- "/esp_jpeg/tjpgd/"
- "/jsmn/include/jsmn.h"
66 changes: 66 additions & 0 deletions .check_copyright_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
DEFAULT:
perform_check: yes # should the check be performed?
# Sections setting this to 'no' don't need to include any other options as they are ignored
# When a file is using a section with the option set to 'no', no checks are performed.

# what licenses (or license expressions) are allowed for files in this section
# when setting this option in a section, you need to list all the allowed licenses
allowed_licenses:
- Apache-2.0
license_for_new_files: Apache-2.0 # license to be used when inserting a new copyright notice
new_notice_c: | # notice for new C, CPP, H, HPP and LD files
/*
* SPDX-FileCopyrightText: {years} Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: {license}
*/
new_notice_python: | # notice for new python files
# SPDX-FileCopyrightText: {years} Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: {license}

# comment lines matching:
# SPDX-FileCopyrightText: year[-year] Espressif Systems
# or
# SPDX-FileContributor: year[-year] Espressif Systems
# are replaced with this template prefixed with the correct comment notation (# or // or *) and SPDX- notation
espressif_copyright: '{years} Espressif Systems (Shanghai) CO LTD'

# this section sets the default license for examples and unit tests of components
examples_and_tests:
include:
- '*/examples/**'
- '*/test*/**'
allowed_licenses:
- Apache-2.0
- Unlicense
- CC0-1.0
license_for_new_files: Unlicense OR CC0-1.0

thirdparty:
perform_check: no
include:
- 'iqmath/**'
- 'esp_jpeg/tjpgd/**'
- 'nghttp/port/**'
- 'jsmn/include/jsmn.h'
- 'qrcode/qrcodegen.*'
- 'coap/port/include/**'
- 'libpng/pnglibconf.h'

catch2:
allowed_licenses:
- BSL-1.0
- Apache-2.0
- Unlicense
- CC0-1.0
license_for_new_files: BSL-1.0
include:
- 'catch2/**'

generated:
perform_check: no
include:
- 'network_provisioning/python/*'
- 'network_provisioning/proto-c/*'
- 'esp_jpeg/test/test_logo*'
- 'expat/port/include/expat_config.h'
8 changes: 4 additions & 4 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ flowchart TD
build-all{Build all apps<br> label set?}
build-all --> |yes| changed-components
changed-components --> idf-build-apps-args
build-all --> |no| idf-build-apps-args
build-all --> |no| idf-build-apps-args
changed-components[Get changed components]
idf-build-apps-args[Prepare idf-build-apps arguments]
end
subgraph "Build apps"
idf-build-apps-args --> idf-build-apps-build
idf-build-apps-build[idf-build-apps build] -->
idf-build-apps-build[idf-build-apps build] -->
build-only
build-only{Build only<br>label set?}
build-only --> |no| upload-artifacts

upload-artifacts[Upload artifacts]

end
Expand All @@ -49,4 +49,4 @@ flowchart TD
build-only --> |yes| fin
generate-report -->fin
fin([Finish])
```
```
8 changes: 5 additions & 3 deletions .github/consistency_check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
# This script performs various consistency checks on the repository.
import argparse
import logging
Expand Down Expand Up @@ -43,7 +45,7 @@ def check_build_manifests_added_to_config(args):

missing = build_manifests_from_repo - build_manifests_from_config
if missing:
LOG.error(f"Missing build manifests in .idf_build_apps.toml: {missing}")
LOG.error(f"Missing build manifests in .idf_build_apps.toml: {missing}")
add_failure()


Expand Down Expand Up @@ -99,13 +101,13 @@ def load_toml(filepath) -> dict:
return toml.load(str(filepath))
except Exception as e:
raise ValueError(f"Failed to load {filepath}: {e}")


def load_yaml(filepath) -> dict:
with open(filepath, "r") as f:
return yaml.safe_load(f)


def get_component_dirs(args):
"""
Returns a list of component paths in this repository.
Expand Down
2 changes: 2 additions & 0 deletions .github/filter_sarif.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0

import argparse
import copy
Expand Down
6 changes: 4 additions & 2 deletions .github/get_idf_build_apps_args.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0

import argparse
import os
Expand All @@ -17,7 +19,7 @@ def main():
'--modified-files',
'"' + ';'.join(modified_files) + '"'
]

if args.verbose:
print('Modified files:')
for file in sorted(modified_files):
Expand All @@ -32,7 +34,7 @@ def main():
if not os.path.isdir(toplevel):
continue
modified_components.add(toplevel)

if modified_components:
idf_build_apps_args += [
'--modified-components',
Expand Down
3 changes: 2 additions & 1 deletion .github/get_pytest_args.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0

import argparse
import json
Expand Down Expand Up @@ -45,4 +47,3 @@ def main():

if __name__ == '__main__':
main()

4 changes: 2 additions & 2 deletions .github/workflows/build_and_run_apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
echo "build_only=$build_only" >> $GITHUB_OUTPUT
echo "test_all_apps=$test_all_apps"
echo "build_only=$build_only"

- name: Find changed files and components
id: find_changes
if: github.event_name == 'pull_request' && steps.get_labels.outputs.test_all_apps == '0'
Expand All @@ -71,7 +71,7 @@ jobs:
strategy:
fail-fast: false
matrix:
idf_ver:
idf_ver:
- "release-v5.0"
- "release-v5.1"
- "release-v5.2"
Expand Down
39 changes: 35 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
repos:
- repo: https://github.com/igrr/astyle_py.git
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
exclude: '\.pgm$'
- id: end-of-file-fixer
exclude: '\.pgm$'
- id: check-merge-conflict
- id: mixed-line-ending
exclude: '\.pgm$'
args: ['--fix=lf']
- id: check-yaml
- id: check-toml

- repo: https://github.com/espressif/astyle_py.git
rev: v1.0.5
hooks:
- id: astyle_py
args: ['--style=otbs', '--attach-namespaces', '--attach-classes', '--indent=spaces=4', '--convert-tabs', '--align-pointer=name', '--align-reference=name', '--keep-one-line-statements', '--pad-header', '--pad-oper']
exclude: 'network_provisioning/proto-c'
args: ['--astyle-version=3.4.7', '--rules=.astyle_rules.yml']

- repo: https://github.com/espressif/esp-idf-sbom.git
rev: v0.18.0
hooks:
- id: validate-sbom-manifest
stages: [post-commit]

- repo: https://github.com/espressif/check-copyright/
rev: v1.0.3
hooks:
- id: check-copyright
args: ['-r', '--config', '.check_copyright_config.yaml']

- repo: https://github.com/espressif/conventional-precommit-linter
rev: v1.10.0
hooks:
- id: conventional-precommit-linter
stages: [commit-msg]

- repo: local
hooks:
- id: consistency_check
Expand All @@ -15,4 +47,3 @@ repos:
additional_dependencies:
- "toml; python_version < '3.11'"
- pyyaml

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Espressif IDF Extra Components

This repository aims to store [ESP-IDF](https://github.com/espressif/esp-idf) extra components
This repository aims to store [ESP-IDF](https://github.com/espressif/esp-idf) extra components
which have been seperated and uploaded into [IDF Component Manager](https://components.espressif.com/).

## Important note
Expand Down
5 changes: 5 additions & 0 deletions bdc_motor/test_apps/main/bdc_motor_test.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>

void app_main(void)
Expand Down
2 changes: 1 addition & 1 deletion catch2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if(NOT target STREQUAL "linux")
endif()

# If console component is present in the build, include the console
# command feature.
# command feature.
idf_build_get_property(build_components BUILD_COMPONENTS)
if("console" IN_LIST build_components)
target_compile_definitions(${COMPONENT_LIB} PRIVATE WITH_CONSOLE)
Expand Down
1 change: 0 additions & 1 deletion catch2/examples/catch2-console/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS main)

project(catch2-console)

2 changes: 0 additions & 2 deletions catch2/examples/catch2-console/pytest_catch2_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ def test_catch2_console_example(dut: Dut) -> None:
dut.write('test\n')
dut.expect_exact('All tests passed')
dut.expect_exact('1 assertion in 1 test case')


1 change: 0 additions & 1 deletion catch2/examples/catch2-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS main)

project(catch2-test)

1 change: 0 additions & 1 deletion catch2/examples/catch2-test/pytest_catch2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
def test_catch2_example(dut: Dut) -> None:
dut.expect_exact('All tests passed')
dut.expect_exact('1 assertion in 1 test case')

1 change: 0 additions & 1 deletion cbor/examples/cbor/main/cbor_example_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ static CborError example_dump_cbor_buffer(CborValue *it, int nestingLevel)
return ret;
}


void app_main(void)
{
CborEncoder root_encoder;
Expand Down
10 changes: 5 additions & 5 deletions cbor/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: "0.6.0~1"
description: "CBOR: Concise Binary Object Representation Library"
url: https://github.com/espressif/idf-extra-components/tree/master/cbor
dependencies:
idf: ">=4.3"
version: "0.6.0~1"
description: "CBOR: Concise Binary Object Representation Library"
url: https://github.com/espressif/idf-extra-components/tree/master/cbor
dependencies:
idf: ">=4.3"
5 changes: 5 additions & 0 deletions cbor/port/include/cbor.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "../../tinycbor/src/cbor.h"
#include "../../tinycbor/src/cborjson.h"
1 change: 0 additions & 1 deletion ccomp_timer/ccomp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "esp_log.h"
#include "esp_intr_alloc.h"


esp_err_t ccomp_timer_start(void)
{
esp_err_t err = ESP_OK;
Expand Down
1 change: 0 additions & 1 deletion ccomp_timer/ccomp_timer_impl_xtensa.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ static void set_perfmon_interrupt(bool enable)
eri_write(ERI_PERFMON_PMCTRL0 + I_STALL_COUNTER_ID * sizeof(int32_t), i_pmctrl);
}


esp_err_t ccomp_timer_impl_init(void)
{
// Keep track of how many times each counter has overflowed.
Expand Down
1 change: 0 additions & 1 deletion ccomp_timer/test_apps/main/ccomp_timer_test_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include "sdkconfig.h"


#if CONFIG_IDF_TARGET_ESP32
#define CACHE_WAYS 2
#define CACHE_LINE_SIZE 32
Expand Down
2 changes: 2 additions & 0 deletions ccomp_timer/test_apps/pytest_ccomp_timer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import pytest


Expand Down
1 change: 0 additions & 1 deletion coap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
REQUIRES lwip mbedtls)
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")

6 changes: 5 additions & 1 deletion coap/examples/coap_client/main/coap_client_example_main.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
/* CoAP client Example

This example code is in the Public Domain (or CC0 licensed, at your option.)
Expand Down Expand Up @@ -33,7 +38,6 @@

#include "coap3/coap.h"


#ifndef CONFIG_COAP_CLIENT_SUPPORT
#error COAP_CLIENT_SUPPORT needs to be enabled
#endif /* COAP_CLIENT_SUPPORT */
Expand Down
2 changes: 1 addition & 1 deletion coap/examples/coap_client/sdkconfig.defaults.esp32h2
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CONFIG_EXAMPLE_CONNECT_WIFI=n
CONFIG_EXAMPLE_CONNECT_ETHERNET=y
CONFIG_EXAMPLE_CONNECT_ETHERNET=y
5 changes: 5 additions & 0 deletions coap/examples/coap_server/main/coap_server_example_main.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
/* CoAP server Example

This example code is in the Public Domain (or CC0 licensed, at your option.)
Expand Down
Loading
Loading