From 269622170e99bbffdc25e663c50600c6b32786fd Mon Sep 17 00:00:00 2001 From: Abhik Roy Date: Tue, 17 Oct 2023 12:13:45 +0200 Subject: [PATCH] fix(common): Fix pytest exclusion, gitignore, and changelog checks --- components/esp_modem/.gitignore => .gitignore | 0 CONTRIBUTING.md | 36 +++++++ ci/bump | 2 +- ci/changelog.py | 10 ++ components/esp_websocket_client/.gitignore | 93 ------------------- pytest.ini | 3 + 6 files changed, 50 insertions(+), 94 deletions(-) rename components/esp_modem/.gitignore => .gitignore (100%) delete mode 100644 components/esp_websocket_client/.gitignore diff --git a/components/esp_modem/.gitignore b/.gitignore similarity index 100% rename from components/esp_modem/.gitignore rename to .gitignore diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5813cc5a1e..f117a5ca58 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,11 @@ Contributions in the form of pull requests, issue reports, and feature requests are welcome! +## Common Terminology: +* [Type]: Examples include feat (for new features), fix (for bug fixes), ci (for continuous integration), bump (for version updates), etc. You can find a comprehensive list of types in .pre-commit-config.yaml on line 65. +* [Scope]: Refers to specific sections or areas within the project, such as mdns, modem, common, console, etc. You can discover additional scopes in .pre-commit-config.yaml on line 65. +* [Component]: This is the name of the component, and it should match the directory name where the component code is located. + ## Submitting a PR - [ ] Fork the [esp-protocols repository on GitHub](https://github.com/espressif/esp-protocols) to start making your changes. @@ -14,6 +19,37 @@ For quick merging, the contribution should be short, and concentrated on a singl Please follow the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) rule when writing commit messages. +A typical commit message title template: + +Template: +`[type]([scope]): Message` + +e.g. +`feat(console): Added fully operational ifconfig command` + + +## Creating a new component + +Steps: +1. Add a file named .cz.yaml to the root of the component. + +The template for .cz.yaml should look like this: +``` +--- +commitizen: + bump_message: 'bump([scope]): $current_version -> $new_version' + pre_bump_hooks: python ../../ci/changelog.py [component] + tag_format: [component]-v$version + version: 0.0.0 + version_files: + - idf_component.yml +``` +2. Run the following command to bump the version of the component: + +`ci/bump [component] [version] --bump-message "bump([scope]): First version [version]"` + +Replace [component], [version] and [scope] with the specific component name, version and scope you are working with. This command will help you bump the version of the component with the provided details. + ## Release process When releasing a new component version we have to: diff --git a/ci/bump b/ci/bump index 3af9b1883e..901966cb16 100755 --- a/ci/bump +++ b/ci/bump @@ -14,7 +14,7 @@ if ! cz bump --dry-run; then fi cz_bump_out=`cz bump --files-only "$@"` -commit_title=`echo "${cz_bump_out}" | head -1` +commit_title=`echo "${cz_bump_out}" | grep "bump(" | head -1` commit_body=`cat ../../release_notes.txt` git add -u . diff --git a/ci/changelog.py b/ci/changelog.py index f5091c2ce7..d3e6767ba0 100644 --- a/ci/changelog.py +++ b/ci/changelog.py @@ -31,6 +31,11 @@ def main(): 'breaking': 'Breaking changes', 'major': 'Major changes' } + + res = git('show-ref', '--tags', _tty_out=False) + if old_ref not in res: + old_ref = git('rev-list', '--max-parents=0', 'HEAD', _tty_out=False).strip() + brief_log = git.log('--oneline', '{}..HEAD'.format(old_ref), '--', 'components/' + component, _tty_out=False) for oneline in brief_log.splitlines(): [commit, brief_msg] = oneline.split(' ', 1) @@ -80,6 +85,11 @@ def main(): changelog += '- {}\n'.format(it) changelog += '\n' filename = os.path.join(root_path, 'components', component, 'CHANGELOG.md') + # Check if the changelog file exists. + if not os.path.exists(filename): + # File does not exist, create it + with open(filename, 'w') as file: + file.write('# Changelog\n\n') # insert the actual changelog to the beginning of the file, just after the title (2nd line) with open(filename, 'r') as orig_changelog: changelog_title = orig_changelog.readline( diff --git a/components/esp_websocket_client/.gitignore b/components/esp_websocket_client/.gitignore deleted file mode 100644 index 8d681ae3ec..0000000000 --- a/components/esp_websocket_client/.gitignore +++ /dev/null @@ -1,93 +0,0 @@ -.config -*.o -*.pyc - -# gtags -GTAGS -GRTAGS -GPATH - -# emacs -.dir-locals.el - -# emacs temp file suffixes -*~ -.#* -\#*# - -# eclipse setting -.settings - -# MacOS directory files -.DS_Store - -# Components Unit Test Apps files -components/**/build -components/**/sdkconfig -components/**/sdkconfig.old - -# Example project files -examples/**/sdkconfig -examples/**/sdkconfig.old -examples/**/build - -# Doc build artifacts -docs/_build/ -docs/doxygen_sqlite3.db - -# Downloaded font files -docs/_static/DejaVuSans.ttf -docs/_static/NotoSansSC-Regular.otf - -# Unit test app files -tools/unit-test-app/sdkconfig -tools/unit-test-app/sdkconfig.old -tools/unit-test-app/build -tools/unit-test-app/builds -tools/unit-test-app/output -tools/unit-test-app/test_configs - -# Unit Test CMake compile log folder -log_ut_cmake - -# test application build files -test/**/build -test/**/sdkconfig -test/**/sdkconfig.old - -# IDF monitor test -tools/test_idf_monitor/outputs - -TEST_LOGS - -# gcov coverage reports -*.gcda -*.gcno -coverage.info -coverage_report/ - -test_multi_heap_host - -# VS Code Settings -.vscode/ - -# VIM files -*.swp -*.swo - -# Clion IDE CMake build & config -.idea/ -cmake-build-*/ - -# Results for the checking of the Python coding style and static analysis -.mypy_cache -flake8_output.txt - -# ESP-IDF default build directory name -build - -# lock files for examples and components -dependencies.lock - -# ignore generated docs -docs/html diff --git a/pytest.ini b/pytest.ini index 3705d704f8..7d368d6fdc 100644 --- a/pytest.ini +++ b/pytest.ini @@ -23,3 +23,6 @@ log_file = test.log log_file_level = INFO log_file_format = %(asctime)s %(levelname)s %(message)s log_file_date_format = %Y-%m-%d %H:%M:%S + +# Directory patterns to avoid for recursion +norecursedirs = "managed_components"