-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c90770
commit 691f1de
Showing
17 changed files
with
476 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#!/bin/bash | ||
|
||
# Function: Check version format | ||
# Input parameters: $1 The version number | ||
# Return value: 0 if the version numbers are correct, 1 if the first version is incorrect, | ||
check_version_format() { | ||
version_regex="^v[0-9]+\.[0-9]+\.[0-9]+$" | ||
|
||
if [[ ! $1 =~ $version_regex ]]; then | ||
return 1 | ||
fi | ||
|
||
return 0 | ||
} | ||
|
||
if [ $# -lt 1 ]; then | ||
latest_version="0.0.0" | ||
echo "Don't get the lastest version, use \"0.0.0\" as default" | ||
else | ||
# Get the first input parameter as the version to be compared | ||
latest_version="$1" | ||
# Check the version format | ||
check_version_format "${latest_version}" | ||
result=$? | ||
if [ ${result} -ne 0 ]; then | ||
echo "The latest release version (${latest_version}) format is incorrect." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Specify the directory path | ||
target_directory="./" | ||
|
||
echo "Checking directory: ${target_directory}" | ||
|
||
# Function: Check if a file exists | ||
# Input parameters: $1 The file to check | ||
# Return value: 0 if the file exists, 1 if the file does not exist | ||
check_file_exists() { | ||
if [ ! -f "$1" ]; then | ||
echo "File '$1' not found." | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
# Function: Compare version numbers | ||
# Input parameters: $1 The first version number, $2 The second version number | ||
# Return value: 0 if the version numbers are equal, 1 if the first version is greater, | ||
# 2 if the second version is greater, | ||
compare_versions() { | ||
version_regex="^v[0-9]+\.[0-9]+\.[0-9]+$" | ||
|
||
version1=$(echo "$1" | cut -c 2-) # Remove the 'v' at the beginning of the version number | ||
version2=$(echo "$2" | cut -c 2-) | ||
|
||
IFS='.' read -ra v1_parts <<< "$version1" | ||
IFS='.' read -ra v2_parts <<< "$version2" | ||
|
||
for ((i=0; i<${#v1_parts[@]}; i++)); do | ||
if [[ "${v1_parts[$i]}" -lt "${v2_parts[$i]}" ]]; then | ||
return 2 | ||
elif [[ "${v1_parts[$i]}" -gt "${v2_parts[$i]}" ]]; then | ||
return 1 | ||
fi | ||
done | ||
|
||
return 0 | ||
} | ||
|
||
echo "Checking file: library.properties" | ||
# Check if "library.properties" file exists | ||
check_file_exists "${target_directory}/library.properties" | ||
if [ $? -ne 0 ]; then | ||
exit 1 | ||
fi | ||
# Read the version information from the file | ||
arduino_version=v$(grep -E '^version=' "${target_directory}/library.properties" | cut -d '=' -f 2) | ||
echo "Get Arduino version: ${arduino_version}" | ||
# Check the version format | ||
check_version_format "${arduino_version}" | ||
result=$? | ||
if [ ${result} -ne 0 ]; then | ||
echo "Arduino version (${arduino_version}) format is incorrect." | ||
exit 1 | ||
fi | ||
|
||
# Compare Arduino Library version with the latest release version | ||
compare_versions "${arduino_version}" "${latest_version}" | ||
result=$? | ||
if [ ${result} -ne 1 ]; then | ||
if [ ${result} -eq 3 ]; then | ||
echo "Arduino version (${arduino_version}) is incorrect." | ||
else | ||
echo "Arduino version (${arduino_version}) is not greater than the latest release version (${latest_version})." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo "Checking file: idf_component.yml" | ||
# Check if "idf_component.yml" file exists | ||
check_file_exists "${target_directory}/idf_component.yml" | ||
if [ $? -eq 0 ]; then | ||
# Read the version information from the file | ||
idf_version=v$(grep -E '^version:' "${target_directory}/idf_component.yml" | awk -F'"' '{print $2}') | ||
echo "Get IDF component version: ${idf_version}" | ||
# Check the version format | ||
check_version_format "${idf_version}" | ||
result=$? | ||
if [ ${result} -ne 0 ]; then | ||
echo "IDF component (${idf_version}) format is incorrect." | ||
exit 1 | ||
fi | ||
# Compare IDF Component version with Arduino Library version | ||
compare_versions ${idf_version} ${arduino_version} | ||
result=$? | ||
if [ ${result} -ne 0 ]; then | ||
if [ ${result} -eq 3 ]; then | ||
echo "IDF component version (${idf_version}) is incorrect." | ||
else | ||
echo "IDF component version (${idf_version}) is not equal to the Arduino version (${arduino_version})." | ||
exit 1 | ||
fi | ||
fi | ||
# Compare IDF Component version with the latest release version | ||
compare_versions ${idf_version} ${latest_version} | ||
result=$? | ||
if [ ${result} -ne 1 ]; then | ||
if [ ${result} -eq 3 ]; then | ||
echo "IDF component version (${idf_version}) is incorrect." | ||
else | ||
echo "IDF component version (${idf_version}) is not greater than the latest release version (${latest_version})." | ||
exit 1 | ||
fi | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Arduino Lint Action | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: arduino/arduino-lint-action@v1 | ||
with: | ||
library-manager: update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Build Test Application | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
idf_ver: ["v4.4.5", "v5.0"] | ||
idf_target: ["esp32"] | ||
runs-on: ubuntu-20.04 | ||
container: espressif/idf:${{ matrix.idf_ver }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build ESP_Button Test Application | ||
env: | ||
IDF_TARGET: ${{ matrix.idf_target }} | ||
working-directory: test_apps | ||
shell: bash | ||
run: | | ||
. ${IDF_PATH}/export.sh | ||
export PEDANTIC_FLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function" | ||
export EXTRA_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes" | ||
export EXTRA_CXXFLAGS="${PEDANTIC_FLAGS}" | ||
idf.py build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Check Versions | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
check_versions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Get latest release info of repository | ||
id: last_release | ||
uses: InsonusK/[email protected] | ||
with: | ||
myToken: ${{ github.token }} | ||
exclude_types: "draft|prerelease" | ||
view_top: 1 | ||
- name: Print result | ||
run: | | ||
echo "id: ${{ steps.last_release.outputs.id }}" | ||
echo "name: ${{ steps.last_release.outputs.name }}" | ||
echo "tag_name: ${{ steps.last_release.outputs.tag_name }}" | ||
echo "created_at: ${{ steps.last_release.outputs.created_at }}" | ||
echo "draft: ${{ steps.last_release.outputs.draft }}" | ||
echo "prerelease: ${{ steps.last_release.outputs.prerelease }}" | ||
echo "url: ${{ steps.last_release.outputs.url }}" | ||
- name: Check & Compare versions | ||
run: bash ./.github/scripts/check_versions.sh ${{ steps.last_release.outputs.tag_name }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: pre-commit | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
- uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
repos: | ||
- repo: https://github.com/igrr/astyle_py.git | ||
rev: master | ||
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'] | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.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 | ||
|
||
- repo: https://github.com/espressif/check-copyright/ | ||
rev: v1.0.3 | ||
hooks: | ||
- id: check-copyright | ||
args: ['--config', 'check_copyright_config.yaml'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0") | ||
list(APPEND PRIVREQ esp_adc) | ||
else() | ||
list(APPEND PRIVREQ esp_adc_cal) | ||
endif() | ||
|
||
idf_component_register(SRCS "src/original/button_adc.c" | ||
"src/original/button_gpio.c" | ||
"src/original/button_matrix.c" | ||
"src/original/iot_button.c" | ||
# "src/original/adc_oneshot.c" | ||
"src/Button.cpp" | ||
INCLUDE_DIRS "src" | ||
REQUIRES driver ${PRIVREQ} | ||
PRIV_REQUIRES esp_timer) | ||
|
||
|
||
# set(PRIVREQ esp_timer) | ||
|
||
# if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0") | ||
# list(APPEND REQ esp_adc) | ||
# else() | ||
# list(APPEND REQ esp_adc_cal) | ||
# endif() | ||
|
||
# idf_component_register(SRCS "src/original/button_adc.c" | ||
# "src/original/button_gpio.c" | ||
# "src/original/button_matrix.c" | ||
# "src/original/iot_button.c" | ||
# "src/Button.cpp" | ||
# INCLUDE_DIRS "src" | ||
# REQUIRES driver ${REQ} | ||
# PRIV_REQUIRES ${PRIVREQ}) | ||
# # REQUIRES driver | ||
# # PRIV_REQUIRES esp_timer) | ||
|
||
# # include(package_manager) | ||
# # cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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' | ||
|
||
# You can create your own rules for files or group of files | ||
examples_and_unit_tests: | ||
include: | ||
- 'test_apps/' | ||
allowed_licenses: | ||
- Apache-2.0 | ||
- Unlicense | ||
- CC0-1.0 | ||
license_for_new_files: CC0-1.0 | ||
|
||
ignore: # You can also select ignoring files here | ||
perform_check: no # Don't check files from that block | ||
include: | ||
- 'examples/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.