Skip to content

Commit 745dc83

Browse files
committed
feat(ci): Extend CI and pre-commit hook
* Add publish/release scripts * Add pre-commit hooks
1 parent 4e54345 commit 745dc83

14 files changed

+550
-76
lines changed

.flake8

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
[flake8]
2+
3+
select =
4+
# Full lists are given in order to suppress all errors from other plugins
5+
# Full list of pyflakes error codes:
6+
F401, # module imported but unused
7+
F402, # import module from line N shadowed by loop variable
8+
F403, # 'from module import *' used; unable to detect undefined names
9+
F404, # future import(s) name after other statements
10+
F405, # name may be undefined, or defined from star imports: module
11+
F406, # 'from module import *' only allowed at module level
12+
F407, # an undefined __future__ feature name was imported
13+
F601, # dictionary key name repeated with different values
14+
F602, # dictionary key variable name repeated with different values
15+
F621, # too many expressions in an assignment with star-unpacking
16+
F622, # two or more starred expressions in an assignment (a, *b, *c = d)
17+
F631, # assertion test is a tuple, which are always True
18+
F701, # a break statement outside of a while or for loop
19+
F702, # a continue statement outside of a while or for loop
20+
F703, # a continue statement in a finally block in a loop
21+
F704, # a yield or yield from statement outside of a function
22+
F705, # a return statement with arguments inside a generator
23+
F706, # a return statement outside of a function/method
24+
F707, # an except: block as not the last exception handler
25+
F721, F722, # doctest syntax error syntax error in forward type annotation
26+
F811, # redefinition of unused name from line N
27+
F812, # list comprehension redefines name from line N
28+
F821, # undefined name name
29+
F822, # undefined name name in __all__
30+
F823, # local variable name referenced before assignment
31+
F831, # duplicate argument name in function definition
32+
F841, # local variable name is assigned to but never used
33+
F901, # raise NotImplemented should be raise NotImplementedError
34+
35+
# Full list of pycodestyle violations:
36+
E101, # indentation contains mixed spaces and tabs
37+
E111, # indentation is not a multiple of four
38+
E112, # expected an indented block
39+
E113, # unexpected indentation
40+
E114, # indentation is not a multiple of four (comment)
41+
E115, # expected an indented block (comment)
42+
E116, # unexpected indentation (comment)
43+
E121, # continuation line under-indented for hanging indent
44+
E122, # continuation line missing indentation or outdented
45+
E123, # closing bracket does not match indentation of opening bracket's line
46+
E124, # closing bracket does not match visual indentation
47+
E125, # continuation line with same indent as next logical line
48+
E126, # continuation line over-indented for hanging indent
49+
E127, # continuation line over-indented for visual indent
50+
E128, # continuation line under-indented for visual indent
51+
E129, # visually indented line with same indent as next logical line
52+
E131, # continuation line unaligned for hanging indent
53+
E133, # closing bracket is missing indentation
54+
E201, # whitespace after '('
55+
E202, # whitespace before ')'
56+
E203, # whitespace before ':'
57+
E211, # whitespace before '('
58+
E221, # multiple spaces before operator
59+
E222, # multiple spaces after operator
60+
E223, # tab before operator
61+
E224, # tab after operator
62+
E225, # missing whitespace around operator
63+
E226, # missing whitespace around arithmetic operator
64+
E227, # missing whitespace around bitwise or shift operator
65+
E228, # missing whitespace around modulo operator
66+
E231, # missing whitespace after ',', ';', or ':'
67+
E241, # multiple spaces after ','
68+
E242, # tab after ','
69+
E251, # unexpected spaces around keyword / parameter equals
70+
E261, # at least two spaces before inline comment
71+
E262, # inline comment should start with '# '
72+
E265, # block comment should start with '# '
73+
E266, # too many leading '#' for block comment
74+
E271, # multiple spaces after keyword
75+
E272, # multiple spaces before keyword
76+
E273, # tab after keyword
77+
E274, # tab before keyword
78+
E275, # missing whitespace after keyword
79+
E301, # expected 1 blank line, found 0
80+
E302, # expected 2 blank lines, found 0
81+
E303, # too many blank lines
82+
E304, # blank lines found after function decorator
83+
E305, # expected 2 blank lines after end of function or class
84+
E306, # expected 1 blank line before a nested definition
85+
E401, # multiple imports on one line
86+
E402, # module level import not at top of file
87+
E501, # line too long (82 > 79 characters)
88+
E502, # the backslash is redundant between brackets
89+
E701, # multiple statements on one line (colon)
90+
E702, # multiple statements on one line (semicolon)
91+
E703, # statement ends with a semicolon
92+
E704, # multiple statements on one line (def)
93+
E711, # comparison to None should be 'if cond is None:'
94+
E712, # comparison to True should be 'if cond is True:' or 'if cond:'
95+
E713, # test for membership should be 'not in'
96+
E714, # test for object identity should be 'is not'
97+
E721, # do not compare types, use 'isinstance()'
98+
E722, # do not use bare except, specify exception instead
99+
E731, # do not assign a lambda expression, use a def
100+
E741, # do not use variables named 'l', 'O', or 'I'
101+
E742, # do not define classes named 'l', 'O', or 'I'
102+
E743, # do not define functions named 'l', 'O', or 'I'
103+
E901, # SyntaxError or IndentationError
104+
E902, # IOError
105+
W191, # indentation contains tabs
106+
W291, # trailing whitespace
107+
W292, # no newline at end of file
108+
W293, # blank line contains whitespace
109+
W391, # blank line at end of file
110+
W503, # line break before binary operator
111+
W504, # line break after binary operator
112+
W505, # doc line too long (82 > 79 characters)
113+
W601, # .has_key() is deprecated, use 'in'
114+
W602, # deprecated form of raising exception
115+
W603, # '<>' is deprecated, use '!='
116+
W604, # backticks are deprecated, use 'repr()'
117+
W605, # invalid escape sequence 'x'
118+
W606, # 'async' and 'await' are reserved keywords starting with Python 3.7
119+
120+
# Full list of flake8 violations
121+
E999, # failed to compile a file into an Abstract Syntax Tree for the plugins that require it
122+
123+
# Full list of mccabe violations
124+
C901 # complexity value provided by the user
125+
126+
ignore =
127+
E221, # multiple spaces before operator
128+
E231, # missing whitespace after ',', ';', or ':'
129+
E241, # multiple spaces after ','
130+
W503, # line break before binary operator
131+
W504 # line break after binary operator
132+
133+
max-line-length = 160
134+
135+
show_source = True
136+
137+
statistics = True

.github/workflows/build.yml

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "esp_wifi_remote: build-tests"
1+
name: "Build"
22

33
on:
44
push:
@@ -8,25 +8,6 @@ on:
88
types: [opened, synchronize, reopened, labeled]
99

1010
jobs:
11-
wifi_remote_api_compat:
12-
name: Check API compatibility of WiFi Remote
13-
strategy:
14-
matrix:
15-
idf_ver: ["latest", "release-v5.3"]
16-
runs-on: ubuntu-20.04
17-
container: espressif/idf:${{ matrix.idf_ver }}
18-
steps:
19-
- name: Checkout code
20-
uses: actions/checkout@v3
21-
- name: Check that headers are the same as generated
22-
shell: bash
23-
run: |
24-
. ${IDF_PATH}/export.sh
25-
pip install idf-component-manager idf-build-apps --upgrade
26-
cp -r ./components/esp_wifi_remote ./components/esp_wifi_remote_base
27-
cd ./components/esp_wifi_remote/scripts
28-
python generate_and_check.py --base-dir ../../esp_wifi_remote_base
29-
3011
build_wifi_remote:
3112
name: Build WiFi Remote Test
3213
strategy:
@@ -94,35 +75,3 @@ jobs:
9475
. ${IDF_PATH}/export.sh
9576
pip install idf-component-manager idf-build-apps --upgrade
9677
python $GITHUB_WORKSPACE/protocols/ci/build_apps.py ./components/esp_wifi_remote/${{matrix.example.path}} -vv --preserve-all
97-
98-
build_idf_examples_with_wifi_remote:
99-
name: Build IDF examples with WiFi Remote
100-
strategy:
101-
matrix:
102-
idf_ver: ["latest", "release-v5.3"]
103-
idf_target: ["esp32p4", "esp32h2", "esp32s3"]
104-
test: [ { app: idf_mqtt_example, path: "examples/protocols/mqtt/tcp" }]
105-
runs-on: ubuntu-20.04
106-
container: espressif/idf:${{ matrix.idf_ver }}
107-
steps:
108-
- name: Checkout code
109-
uses: actions/checkout@v3
110-
- name: ccache
111-
uses: hendrikmuhs/[email protected]
112-
with:
113-
key: ${{ matrix.idf_ver }}
114-
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
115-
shell: bash
116-
run: |
117-
. ${IDF_PATH}/export.sh
118-
pip install idf-component-manager idf-build-apps --upgrade
119-
export OVERRIDE_PATH=`pwd`/components/esp_wifi_remote
120-
echo ${OVERRIDE_PATH}
121-
sed -i '/espressif\/esp_wifi_remote:/a \ \ \ \ override_path: "${OVERRIDE_PATH}"' ${IDF_PATH}/${{matrix.test.path}}/main/idf_component.yml
122-
cat ${IDF_PATH}/${{matrix.test.path}}/main/idf_component.yml
123-
export PEDANTIC_FLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function"
124-
export EXTRA_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes"
125-
export EXTRA_CXXFLAGS="${PEDANTIC_FLAGS}"
126-
cd ${IDF_PATH}/${{matrix.test.path}}
127-
idf-build-apps find --config sdkconfig.ci* -vv --target ${{ matrix.idf_target }}
128-
idf-build-apps build --config sdkconfig.ci* -vv --target ${{ matrix.idf_target }}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Check pre-commit rules
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
pre_commit_check:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.base_ref }}
18+
fetch-depth: 20
19+
- name: Fetch head and base refs
20+
# This is necessary for pre-commit to check the changes in the PR branch (and to set origin/HEAD and HEAD refs)
21+
run: |
22+
git fetch origin ${{ github.event.pull_request.head.sha }}:pr_ref
23+
git checkout pr_ref
24+
git remote set-head origin --auto
25+
git merge-base origin/HEAD HEAD || ( echo "Your PR is far behind origin/HEAD, please rebase" && exit 1 )
26+
- name: Set up Python environment
27+
uses: actions/setup-python@master
28+
with:
29+
python-version: v3.8
30+
- name: Install python packages
31+
run: |
32+
pip install pre-commit
33+
pre-commit install-hooks
34+
- name: Run pre-commit and check for any changes
35+
run: |
36+
echo "Commits being checked:"
37+
git log --oneline --no-decorate origin/HEAD..HEAD
38+
echo ""
39+
if ! pre-commit run --from-ref origin/HEAD --to-ref HEAD --hook-stage manual --show-diff-on-failure ; then
40+
echo ""
41+
echo "::notice::It looks like the commits in this PR have been made without having pre-commit hooks installed."
42+
echo "::notice::Please see https://github.com/espressif/esp-wifi-remote/CONTRIBUTING.md for instructions."
43+
echo ""
44+
exit 1
45+
fi

.github/workflows/publish.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Publish esp-wifi-remote
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build", "Compat checks"]
6+
branches: [main]
7+
types:
8+
- completed
9+
10+
jobs:
11+
publish:
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
13+
name: Publishes Tag, Release, and Uploads Component
14+
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
persist-credentials: false
20+
fetch-depth: 0
21+
token: "${{ secrets.GITHUB_TOKEN }}"
22+
- name: Checkout protocols
23+
uses: actions/checkout@v4
24+
with:
25+
repository: espressif/esp-protocols
26+
ref: wifi_remote-v0.4.0
27+
sparse-checkout: |
28+
ci/detect_component_bump
29+
sparse-checkout-cone-mode: false
30+
path: protocols
31+
32+
- name: Check for version update
33+
shell: bash
34+
run: $GITHUB_WORKSPACE/protocols/ci/detect_component_bump
35+
36+
- name: Tag merge commit
37+
if: env.BUMP_VERSION != ''
38+
uses: anothrNick/[email protected]
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
CUSTOM_TAG: ${{ env.BUMP_TAG }}
42+
43+
- name: Create Release
44+
if: env.BUMP_VERSION != ''
45+
uses: softprops/action-gh-release@v1
46+
with:
47+
body_path: "release_notes.md"
48+
tag_name: ${{ env.BUMP_TAG }}
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Upload esp_wifi_remote to IDF Component Registry
53+
uses: espressif/upload-components-ci-action@v1
54+
with:
55+
directories: >
56+
components/esp_wifi_remote;
57+
namespace: "espressif"
58+
api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }}

.github/workflows/smoke_compat.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: "Compat checks"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened, labeled]
9+
10+
jobs:
11+
wifi_remote_api_compat:
12+
name: Check API compatibility of WiFi Remote
13+
strategy:
14+
matrix:
15+
idf_ver: ["latest", "release-v5.3"]
16+
runs-on: ubuntu-20.04
17+
container: espressif/idf:${{ matrix.idf_ver }}
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
- name: Check that headers are the same as generated
22+
shell: bash
23+
run: |
24+
. ${IDF_PATH}/export.sh
25+
pip install idf-component-manager idf-build-apps --upgrade
26+
cp -r ./components/esp_wifi_remote ./components/esp_wifi_remote_base
27+
cd ./components/esp_wifi_remote/scripts
28+
python generate_and_check.py --base-dir ../../esp_wifi_remote_base
29+
30+
build_idf_examples_with_wifi_remote:
31+
name: Build IDF examples with WiFi Remote
32+
strategy:
33+
matrix:
34+
idf_ver: ["latest", "release-v5.3"]
35+
idf_target: ["esp32p4", "esp32h2", "esp32s3"]
36+
test: [ { app: idf_mqtt_example, path: "examples/protocols/mqtt/tcp" }]
37+
runs-on: ubuntu-20.04
38+
container: espressif/idf:${{ matrix.idf_ver }}
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v3
42+
- name: ccache
43+
uses: hendrikmuhs/[email protected]
44+
with:
45+
key: ${{ matrix.idf_ver }}
46+
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
47+
shell: bash
48+
run: |
49+
. ${IDF_PATH}/export.sh
50+
pip install idf-component-manager idf-build-apps --upgrade
51+
export OVERRIDE_PATH=`pwd`/components/esp_wifi_remote
52+
echo ${OVERRIDE_PATH}
53+
sed -i '/espressif\/esp_wifi_remote:/a \ \ \ \ override_path: "${OVERRIDE_PATH}"' ${IDF_PATH}/${{matrix.test.path}}/main/idf_component.yml
54+
cat ${IDF_PATH}/${{matrix.test.path}}/main/idf_component.yml
55+
export PEDANTIC_FLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function"
56+
export EXTRA_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes"
57+
export EXTRA_CXXFLAGS="${PEDANTIC_FLAGS}"
58+
cd ${IDF_PATH}/${{matrix.test.path}}
59+
idf-build-apps find --config sdkconfig.ci* -vv --target ${{ matrix.idf_target }}
60+
idf-build-apps build --config sdkconfig.ci* -vv --target ${{ matrix.idf_target }}

.github/workflows/upload_component.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)