diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a42042..743be18 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,19 +24,9 @@ variables: V: "0" IDF_CI_BUILD: "1" -before_script: - # add gitlab ssh key - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - - echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64 - - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa - - chmod 600 ~/.ssh/id_rsa - - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config - - git --version - - git submodule update --init --recursive --force - include: + - '.gitlab/ci/danger.yml' - '.gitlab/ci/rules.yml' - '.gitlab/ci/pre_check.yml' - '.gitlab/ci/build.yml' - - '.gitlab/ci/deploy.yml' \ No newline at end of file + - '.gitlab/ci/deploy.yml' diff --git a/.gitlab/ci/danger.yml b/.gitlab/ci/danger.yml new file mode 100644 index 0000000..e874190 --- /dev/null +++ b/.gitlab/ci/danger.yml @@ -0,0 +1,10 @@ +# External DangerJS +include: + - project: espressif/shared-ci-dangerjs + ref: master + file: danger.yaml + +run-danger-mr-linter: + stage: pre_check + tags: + - dangerjs diff --git a/.gitlab/ci/pre_check.yml b/.gitlab/ci/pre_check.yml index b0b6923..85ad140 100644 --- a/.gitlab/ci/pre_check.yml +++ b/.gitlab/ci/pre_check.yml @@ -1,19 +1,45 @@ -check_readme_links: - extends: - - .rules:pre_check:readme +.pre_check_template: stage: pre_check image: python:3.9 tags: ["build", "amd64", "internet"] + dependencies: [] + +check_readme_links: + extends: + - .pre_check_template + - .rules:pre_check:readme allow_failure: false script: - python ${CI_PROJECT_DIR}/tools/ci/check_readme_links.py check_copyright: - stage: pre_check - image: python:3.9 - tags: ["build", "amd64", "internet"] + extends: + - .pre_check_template allow_failure: false before_script: - pip install git+https://github.com/espressif/check-copyright.git@master script: - - python -m check_copyright --verbose --dry-run --ignore tools/ci/ignore_list_copyright.txt --config tools/ci/check_copyright_config.yaml . \ No newline at end of file + - python -m check_copyright --verbose --dry-run --ignore tools/ci/ignore_list_copyright.txt --config tools/ci/check_copyright_config.yaml . + +check_pre_commit: + extends: + - .pre_check_template + before_script: + - pip install pre-commit + script: + - | + # merged results pipelines, by default + if [[ -n $CI_MERGE_REQUEST_SOURCE_BRANCH_SHA ]]; then + MODIFIED_FILES=$(git diff --name-only $CI_MERGE_REQUEST_DIFF_BASE_SHA $CI_MERGE_REQUEST_SOURCE_BRANCH_SHA) + # merge request pipelines, when the mr got conflicts + elif [[ -n $CI_MERGE_REQUEST_DIFF_BASE_SHA ]]; then + MODIFIED_FILES=$(git diff --name-only $CI_MERGE_REQUEST_DIFF_BASE_SHA $CI_COMMIT_SHA) + # other pipelines, like the protected branches pipelines + else + MODIFIED_FILES=$(git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA) + fi + # print the MODIFIED_FILES + echo "MODIFIED_FILES: $MODIFIED_FILES" + - pre-commit install --allow-missing-config -t pre-commit -t commit-msg + - export SKIP=check-copyright # copyrights has been checked in separate job + - pre-commit run --files $MODIFIED_FILES diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 26f9bb5..b619804 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,25 +1,70 @@ +--- +minimum_pre_commit_version: 3.3.0 +default_install_hook_types: [pre-commit,commit-msg] + repos: -- repo: https://github.com/igrr/astyle_py.git + - repo: https://github.com/espressif/check-copyright/ + rev: v1.0.3 + hooks: + - id: check-copyright + args: ['--config', 'tools/ci/check_copyright_config.yaml', '--ignore', 'tools/ci/check_copyright_ignore.txt'] + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: file-contents-sorter + files: 'tools\/ci\/(executable-list\.txt|check_copyright_ignore\.txt)' + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + # note: whitespace exclusions use multiline regex, see https://pre-commit.com/#regular-expressions + # items are: + # 1 - some file extensions + # 2 - any file matching *test*/*expected* (for host tests, if possible use this naming pattern always) + # 3 - any file with known-warnings in the name + # 4 - any directory named 'testdata' + # 5 - protobuf auto-generated files + exclude: &whitespace_excludes | + (?x)^( + .+\.(md|rst|map|bin)| + .+test.*\/.*expected.*| + .+known-warnings.*| + .+\/testdata\/.+| + .*_pb2.py| + .*.pb-c.h| + .*.pb-c.c| + .*.yuv + )$ + - id: end-of-file-fixer + exclude: *whitespace_excludes + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: mixed-line-ending + args: ['-f=lf'] + - id: double-quote-string-fixer + - id: no-commit-to-branch + name: Do not use more than one slash in the branch name + args: ['--pattern', '^[^/]*/[^/]*/'] + - id: no-commit-to-branch + name: Do not use uppercase letters in the branch name + args: ['--pattern', '^[^A-Z]*[A-Z]'] + - 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'] + - id: astyle_py + # If you are modifying astyle version, update tools/format.sh as well + args: ['--astyle-version=3.4.7', '--rules=tools/ci/astyle-rules.yml'] -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + - repo: https://github.com/espressif/conventional-precommit-linter + rev: v1.8.0 hooks: - - id: trailing-whitespace - types_or: [c, c++] - - id: end-of-file-fixer - types_or: [c, c++] - - id: check-merge-conflict - - id: mixed-line-ending - types_or: [c, c++] - args: ['--fix=lf'] - description: Forces to replace line ending by the UNIX 'lf' character + - id: conventional-precommit-linter + stages: [commit-msg] -- repo: https://github.com/espressif/check-copyright/ - rev: v1.0.3 - hooks: - - id: check-copyright - args: ['--config', 'tools/ci/check_copyright_config.yaml', '--ignore', 'tools/ci/ignore_list_copyright.txt'] + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + args: [-w, "--ignore-words=codespell-ignore-list"] diff --git a/codespell-ignore-list b/codespell-ignore-list new file mode 100644 index 0000000..bc6e5ef --- /dev/null +++ b/codespell-ignore-list @@ -0,0 +1,18 @@ +ALS +ALS +ANS +ans +co-ordinate +co-ordinates +compresed +DOUT +dout +ERRO +ges +gien +MOT +regist +ser +TE +uncompressible +wHeigh diff --git a/components/bsp/idf_component.yml b/components/bsp/idf_component.yml index 3797f38..3962ff3 100644 --- a/components/bsp/idf_component.yml +++ b/components/bsp/idf_component.yml @@ -1,14 +1,18 @@ ## IDF Component Manager Manifest File dependencies: + esp_codec_dev: + public: true + version: "1.1.0" + espressif/esp-box: - version: "3.*" + version: "3.0.*" require: "no" espressif/esp-box-lite: - version: "2.*" + version: "2.0.*" require: "no" espressif/esp-box-3: - version: "1.*" + version: "1.1.*" require: "no" diff --git a/launch.toml b/launch.toml deleted file mode 100644 index 0a61f65..0000000 --- a/launch.toml +++ /dev/null @@ -1,119 +0,0 @@ -esp_toml_version = 1.0 -firmware_images_url = "https://dl.espressif.com/AE/esp-box/" - -supported_apps = [ - "ESP-BOX-3_Demo_V1_2_3", - "ESP-BOX-3_ChatGPT_Demo_V1_1", - "ESP-BOX-3_USB_Headset_V0_0_1", - "ESP-BOX-3_USB_Camera_V0_0_1", - "ESP-BOX-3_MATTER_SWITCH_Demo_V1_0", - - "ESP-BOX_Demo_CN_V0_3_0", - "ESP-BOX_Demo_EN_V0_3_0", - "ESP-BOX_Demo_EN_V0_5_0", - "ESP-BOX_Demo_CN_V0_5_0", - "ESP-BOX_ChatGPT_Demo_V1_1", - "ESP-BOX_USB_Headset_V0_0_1", - "ESP-BOX_MATTER_SWITCH_Demo_V1_0", - - "ESP-BOX-Lite_Demo_EN_V0_5_0", - "ESP-BOX-Lite_Demo_CN_V0_5_0", - "ESP-BOX-Lite_ChatGPT_Demo_V1_1", - "ESP-BOX-Lite_MATTER_SWITCH_Demo_V1_0" -] - -[ESP-BOX_Demo_EN_V0_3_0] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX_Demo_EN_V0.3.0.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX_Demo_CN_V0_3_0] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX_Demo_CN_V0.3.0.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX_USB_Headset_V0_0_1] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX_USB_Headset_V0.0.1.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX_ChatGPT_Demo_V1_1] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX_ChatGPT_Demo_V1.1.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX-Lite_ChatGPT_Demo_V1_1] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX_Lite_ChatGPT_Demo_V1.1.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX-3_ChatGPT_Demo_V1_1] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX-3_ChatGPT_Demo_V1_1.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX_Demo_CN_V0_5_0] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX_Demo_CN_V0.5.0.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX_Demo_EN_V0_5_0] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX_Demo_EN_V0.5.0.bin.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX-Lite_Demo_CN_V0_5_0] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX-Lite_Demo_CN_V0.5.0.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX-Lite_Demo_EN_V0_5_0] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX-Lite_Demo_EN_V0.5.0.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX-3_Demo_V1_2_3] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX-3_Demo_V1.2.3.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX_MATTER_SWITCH_Demo_V1_0] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX_MATTER_SWITCH_Demo_V1.0.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX-Lite_MATTER_SWITCH_Demo_V1_0] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX_Lite_MATTER_SWITCH_Demo_V1.0.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX-3_MATTER_SWITCH_Demo_V1_0] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX-3_MATTER_SWITCH_Demo_V1.0.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX-3_USB_Headset_V0_0_1] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX-3-usb-headset.bin" -android_app_url = "" -ios_app_url = "" - -[ESP-BOX-3_USB_Camera_V0_0_1] -chipsets = ["ESP32-S3"] -image.esp32-s3 = "ESP-BOX-3-usb-camera.bin" -android_app_url = "" -ios_app_url = "" diff --git a/tools/ci/astyle-rules.yml b/tools/ci/astyle-rules.yml new file mode 100644 index 0000000..8daf60a --- /dev/null +++ b/tools/ci/astyle-rules.yml @@ -0,0 +1,33 @@ +DEFAULT: + # These formatting options will be used by default. + # If you are modifying this, update tools/format.sh as well! + options: "--style=otbs --attach-namespaces --attach-classes --indent=spaces=4 --convert-tabs --align-reference=name --keep-one-line-statements --pad-header --pad-oper --unpad-paren --max-continuation-indent=120" + +# not_formatted_temporary: +# # Formatting in these folder or files aren't checked yet. +# # For each of these, decide whether it should be formatted or not. +# # 1. If yes, format the code and remove the component from the exclude list. +# # Add special rules for upstream source files, if necessary. +# # To reformat the files: +# # - Remove the directory from this exclude list +# # - Run 'git add .astyle-rules.yml' +# # - Run 'pre-commit run --all-files' +# # 2. If no, move it to 'not_formatted_permanent' section below. +# check: false +# include: + +not_formatted_permanent: + # Files which are not supposed to be formatted. + # Typically, these are: + # - Upstream source code we don't want to modify + # - Generated files + check: false + include: + - "components/audio/dac_audio/test/wave_1ch_16bits.c" + +docs: + # Docs directory contains some .inc files, which are not C include files + # and should not be formatted + check: false + include: + - "/docs/**/*.inc"