Skip to content

Commit 764ca0b

Browse files
Merge pull request #6 from espressif/fix/small-updates-wokwi-integration
Configuration Updates for Wokwi and Hardware Testing Integration
2 parents 5558515 + dbdaf1d commit 764ca0b

File tree

13 files changed

+182
-82
lines changed

13 files changed

+182
-82
lines changed

.github/workflows/build_esp_app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
espidf_target:
14+
espidf_target:
1515
- esp32
1616
- esp32c3
1717
- esp32c6

.github/workflows/dangerjs.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: DangerJS Pull Request linter
2+
on:
3+
pull_request_target:
4+
types: [opened, edited, reopened, synchronize]
5+
permissions:
6+
pull-requests: write
7+
contents: write
8+
jobs:
9+
pull-request-style-linter:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out PR head
13+
uses: actions/checkout@v4
14+
with:
15+
ref: ${{ github.event.pull_request.head.sha }}
16+
- name: DangerJS pull request linter
17+
uses: espressif/shared-github-dangerjs@v1
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pre-commit.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Check pre-commit
2+
on:
3+
pull_request:
4+
jobs:
5+
check-pre-commit:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
with:
10+
fetch-depth: 0
11+
- uses: actions/setup-python@v5
12+
- uses: pre-commit/[email protected]

.github/workflows/test_esp_app.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
espidf_target: ["esp32", "esp32c3", "esp32s2", "esp32s3"] # <--- Specify a list of Espressif chips connected to your runner
16+
espidf_target: # <--- Specify a list of Espressif chips connected to your runner
17+
- esp32
18+
- esp32c3
19+
- esp32s2
20+
- esp32s3
1721
steps:
1822
- name: Checkout repository
1923
uses: actions/checkout@v4
@@ -27,22 +31,19 @@ jobs:
2731
PIP_PREFER_BINARY: true
2832
PIP_INDEX_URL: "https://dl.espressif.com/pypi/"
2933
PIP_EXTRA_INDEX_URL: "https://pypi.org/simple"
30-
run: |
31-
pip install \
32-
pytest-embedded \
33-
pytest-embedded-serial-esp \
34-
pytest-embedded-idf
34+
run: pip install -r test_app/requirements.txt
3535
- name: Run Test App on target
3636
working-directory: test_app
3737
run: |
3838
pytest \
3939
--junit-xml=./test_app_results_${{ matrix.espidf_target }}.xml \
40+
--embedded-services esp,idf \
4041
--target=${{ matrix.espidf_target }}
4142
- name: Upload test results for publish-results job
4243
uses: actions/upload-artifact@v4
4344
if: always()
4445
with:
45-
name: test_app_results_${{ matrix.espidf_target }}
46+
name: test_app_results_hw${{ matrix.espidf_target }}
4647
path: test_app/*.xml
4748
publish-results:
4849
name: Publish Test App results

.github/workflows/test_in_wokwi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
espidf_target:
16+
espidf_target:
1717
- esp32
1818
- esp32c3
1919
- esp32c6
@@ -50,7 +50,7 @@ jobs:
5050
uses: actions/upload-artifact@v4
5151
if: always()
5252
with:
53-
name: test_app_results_${{ matrix.espidf_target }}
53+
name: test_app_results_wokwi${{ matrix.espidf_target }}
5454
path: test_app/*.xml
5555
publish-results:
5656
name: Publish Test App results

.pre-commit-config.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Run `pre-commit autoupdate` to update to the latest pre-commit hooks version.
2+
3+
minimum_pre_commit_version: 3.3.0 # Specifies the minimum version of pre-commit required for this configuration
4+
default_install_hook_types: [pre-commit, commit-msg] # Default hook types to install if not specified in individual hooks
5+
default_stages: [commit]
6+
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v4.6.0
9+
hooks:
10+
- id: trailing-whitespace # Removes trailing whitespaces from lines
11+
- id: end-of-file-fixer # Ensures files end with a newline
12+
- id: check-executables-have-shebangs # Checks executables have a proper shebang
13+
- id: check-shebang-scripts-are-executable # Checks that scripts with shebangs are executable.
14+
- id: check-case-conflict # Check conflict on a case-insensitive filesystem (MacOS HFS+/Windows FAT).
15+
- id: mixed-line-ending # Detects mixed line endings (CRLF/LF)
16+
args: ["-f=lf"] # Forces files to use LF line endings
17+
18+
- repo: https://github.com/espressif/astyle_py.git
19+
rev: v1.0.5
20+
hooks:
21+
- id: astyle_py # C code linter/formatter
22+
args:
23+
- --astyle-version=3.4.7
24+
- --style=linux
25+
26+
- repo: https://github.com/Yelp/detect-secrets
27+
rev: v1.5.0
28+
hooks:
29+
- id: detect-secrets # Detection of unwanted commit secrets and tokes
30+
args:
31+
- --base64-limit=4 # Level of entropy for base64 type strings
32+
- --hex-limit=3 # Level of entropy for hex strings
33+
34+
- repo: https://github.com/executablebooks/mdformat
35+
rev: 0.7.17
36+
hooks:
37+
- id: mdformat
38+
args: [--number] # Keep numbering for ordered lists
39+
additional_dependencies:
40+
- mdformat-gfm # Support for GitHub Flavored Markdown (GFM), including tables, task lists, strikethroughs, and autolinks.
41+
- mdformat-simple-breaks # Ensures that single line breaks in Markdown are converted to `<br>` t
42+
43+
- repo: https://github.com/codespell-project/codespell
44+
rev: v2.3.0
45+
hooks:
46+
- id: codespell # Spell checker
47+
args: ["--write-changes"]
48+
additional_dependencies: [tomli]
49+
exclude: '\.svg$'
50+
51+
- repo: https://github.com/espressif/conventional-precommit-linter
52+
rev: v1.10.0
53+
hooks:
54+
- id: conventional-precommit-linter # Lints commit messages for conventional format
55+
stages: [commit-msg]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ express Statement of Purpose.
118118
Work.
119119
d. Affirmer understands and acknowledges that Creative Commons is not a
120120
party to this document and has no duty or obligation with respect to
121-
this CC0 or use of the Work.
121+
this CC0 or use of the Work.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The purpose of this project is to provide a good **starting point for customers
88

99
*You can fork and update this project according to your specific needs.*
1010

11-
> Note: As default, the hardware testing job is `disabled`. To enable it, please see the **How to setup (HW)** documents.
11+
> Note: As default, the hardware testing job is `disabled`. To enable it, please see the **How to setup (HW)** documents.
1212
1313
## How to setup (Wokwi simulation)
1414

components/testable/mean.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "testable.h"
66

7-
87
int testable_mean(const int* values, int count)
98
{
109
if (count == 0) {

docs/ghub_action_workflow.md

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,34 @@ Here you will find a brief description of how to configure and customize the bui
77
This repository follows the project layout as described in detail in [Build System](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html) section of ESP-IDF Programming Guide.
88

99
**See as example layout of this repository:**
10-
1. Application code is in the [components](../components/) and [main](../main) directories (example of a real application)
11-
```sh
12-
├── /.github
13-
├── /components # <--- (Components of user app)
14-
├── /main # <--- (Main component of user app)
15-
├── /test_app # <--- (Test application)
16-
└── CMakeLists.txt # <--- (User app CMakeLists.txt)
17-
```
18-
You can have multiple apps in a GitHub repository and add them all to the testing process by specifying their paths in the `test_app/CMakeLists.txt` file (see the following text).
19-
20-
2. In the file ` test_app/CMakeLists.txt` specify the path to your testable components (components that contain unit tests):
21-
```sh
22-
├── components
23-
├── /test_app
24-
│ ├── CMakeLists.txt # <--- (define paths for the build system)
25-
26-
```
27-
```cmake
28-
...
29-
# Specify the path to testable components
30-
set(EXTRA_COMPONENT_DIRS ../components) # <--- (these components will be built and tested)
31-
...
32-
```
10+
11+
1. Application code is in the [components](../components/) and [main](../main) directories (example of a real application)
12+
13+
```sh
14+
├── /.github
15+
├── /components # <--- (Components of user app)
16+
├── /main # <--- (Main component of user app)
17+
├── /test_app # <--- (Test application)
18+
└── CMakeLists.txt # <--- (User app CMakeLists.txt)
19+
```
20+
21+
You can have multiple apps in a GitHub repository and add them all to the testing process by specifying their paths in the `test_app/CMakeLists.txt` file (see the following text).
22+
23+
2. In the file ` test_app/CMakeLists.txt` specify the path to your testable components (components that contain unit tests):
24+
25+
```sh
26+
├── components
27+
├── /test_app
28+
│ ├── CMakeLists.txt # <--- (define paths for the build system)
29+
30+
```
31+
32+
```cmake
33+
...
34+
# Specify the path to testable components
35+
set(EXTRA_COMPONENT_DIRS ../components) # <--- (these components will be built and tested)
36+
...
37+
```
3338

3439
## GitHub Action Workflow File (`ci_workflow.yml`)
3540

@@ -39,9 +44,9 @@ In this file, you will define the workflow triggers, jobs, and dependencies.
3944

4045
The workflow with build and tests is triggered in three ways:
4146

42-
- Schedule - automatically once per day at midnight
43-
- Pull Requests
44-
- Manually from GitHub Action UI
47+
- Schedule - automatically once per day at midnight
48+
- Pull Requests
49+
- Manually from GitHub Action UI
4550

4651
GitHub Action workflow file `.github/workflows/ci_workflow.yml`:
4752

@@ -50,7 +55,7 @@ name: Build and Run Test Application Workflow
5055

5156
on:
5257
schedule:
53-
- cron: '0 0 * * *' # (scheduled - once per day at midnight)
58+
- cron: '0 0 * * *' # (scheduled - once per day at midnight)
5459
pull_request: # (for every push to Pull Request)
5560
types: [opened, reopened, synchronize]
5661
workflow_dispatch: # (to start the workflow manually)
@@ -69,7 +74,7 @@ jobs:
6974
7075
### Jobs
7176
72-
In this file, you will see two `jobs` defined as follows:
77+
In this file, you will see two `jobs` defined as follows:
7378

7479
#### Job build_project
7580

@@ -79,7 +84,7 @@ This job will call the build workflow, defined by the file `.github/workflows/bu
7984

8085
This job will call the test workflow, defined by the file `.github/workflows/test_esp_app.yml`.
8186

82-
As default, this workflow is disabled if the namespace is different from `espressif`. To enable, please set the `if: ${{ github.repository_owner == 'espressif' }}` to your namespace or remove this line.
87+
As default, this workflow is disabled if the namespace is different from `espressif`. To enable, please set the `if: ${{ github.repository_owner == 'espressif' }}` to your namespace or remove this line.
8388

8489
```yml
8590
test_project:
@@ -92,7 +97,7 @@ As default, this workflow is disabled if the namespace is different from `espres
9297

9398
## Project Build Workflow (`build_esp_app.yml`)
9499

95-
### Build Binaries (`build` Job)
100+
### Build Binaries (`build` Job)
96101

97102
First, the binaries must be built with respect to each Espressif chip (`esp-idf target`). Using the GitHub action [matrix strategy](https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs), you can build for several targets (chip types) in parallel.
98103

@@ -125,13 +130,13 @@ Here you can customize the ESI-IDF version, the target (see the previous step),
125130
- name: Build Test Application with ESP-IDF
126131
uses: espressif/esp-idf-ci-action@v1
127132
with:
128-
esp_idf_version: "latest" # latest is the default version
133+
esp_idf_version: "latest" # latest is the default version
129134
target: ${{ matrix.espidf_target }}
130135
path: 'test_app'
131136
...
132137
```
133138

134-
To set the ESP-IDF version, you can use the release tag name in the `esp_idf_version` field.
139+
To set the ESP-IDF version, you can use the release tag name in the `esp_idf_version` field.
135140

136141
**Example**
137142

@@ -145,27 +150,28 @@ To see the full release tag list, please see the [project release list](https://
145150

146151
## Test on Hardware Workflow (`test_esp_app.yml`)
147152

148-
Binaries built in the `build` job are downloaded via GH Action artifact and used in this job,
153+
Binaries built in the `build` job are downloaded via GH Action artifact and used in this job,
149154
which is running on your self-hosted runner with connected Espressif boards.
150155

151-
- binaries are flashed to boards
152-
- tests are performed
153-
- results are gathered for the final report
156+
- binaries are flashed to boards
157+
- tests are performed
158+
- results are gathered for the final report
154159

155160
GitHub needs to know which of your self-hosted runner it should use for the test. It is a good practice to tag self-hosted runners in the same format as targets in `esp-idf`.
156161

157-
For example, the runner tag `esp32c3` is also the `IDF_TARGET` target. By defining this value in [matrix](https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs), the same value can be used as a `IDF_TARGET` for the `build` job and as a runner tag for the `run-target` job.
162+
For example, the runner tag `esp32c3` is also the `IDF_TARGET` target. By defining this value in [matrix](https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs), the same value can be used as a `IDF_TARGET` for the `build` job and as a runner tag for the `run-target` job.
158163

159164
### Tests in Docker Containers
160165

161166
We recommend running all tests in Docker containers because
162-
- you always start with a clean and identical test environment
163-
- there is no need to clean up after testing
164-
- no risk of permanent unwanted system changes on runner machines
165167

166-
The Docker container must have **access to the computer's USB ports** - set the `--privileged` option in the job container definition:
168+
- you always start with a clean and identical test environment
169+
- there is no need to clean up after testing
170+
- no risk of permanent unwanted system changes on runner machines
171+
172+
The Docker container must have **access to the computer's USB ports** - set the `--privileged` option in the job container definition:
167173

168-
Since the testing framework uses Python (`pytest`), it is a good idea to have a base image for a container with Python already included, e.g. `python:3.7-buster` (based on Debian, with Python 3).
174+
Since the testing framework uses Python (`pytest`), it is a good idea to have a base image for a container with Python already included, e.g. `python:3.7-buster` (based on Debian, with Python 3).
169175

170176
```yml
171177
run-target:

0 commit comments

Comments
 (0)