Skip to content

Commit d91c5b6

Browse files
authored
Merge pull request #98 from espressif/esp32-s3-support
minor changes
2 parents a00be36 + 6934595 commit d91c5b6

File tree

19 files changed

+465
-56
lines changed

19 files changed

+465
-56
lines changed

Diff for: .github/scripts/on-push.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -e
44

5+
export ARDUINO_BUILD_DIR="$HOME/.arduino/build.tmp"
6+
57
function build(){
68
local target=$1
79
local fqbn=$2
@@ -58,7 +60,7 @@ fi
5860

5961
SCRIPTS_DIR="./.github/scripts"
6062
if [ "$BUILD_PIO" -eq 0 ]; then
61-
source ./.github/scripts/install-arduino-ide.sh
63+
source ${SCRIPTS_DIR}/install-arduino-ide.sh
6264
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
6365

6466
FQBN_ESP32="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app"
@@ -82,7 +84,7 @@ if [ "$BUILD_PIO" -eq 0 ]; then
8284
build "esp32c3" $FQBN_ESP32C3 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32XX
8385
build "esp32" $FQBN_ESP32 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
8486
else
85-
source ./${SCRIPTS_DIR}/install-platformio-esp32.sh
87+
source ${SCRIPTS_DIR}/install-platformio-esp32.sh
8688
# PlatformIO ESP32 Test
8789
BOARD="esp32dev"
8890
OPTIONS="board_build.partitions = huge_app.csv"

Diff for: .github/scripts/sketch_utils.sh

+11-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <fqbn> <path-to-i
88
fi
99

1010
ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp"
11+
if [ -z "$ARDUINO_BUILD_DIR" ]; then
12+
build_dir="$(dirname $sketch)/build"
13+
else
14+
build_dir="$ARDUINO_BUILD_DIR"
15+
fi
1116
local ide_path=$1
1217
local usr_path=$2
1318
local fqbn=$3
1419
local sketch=$4
1520
local xtra_opts=$5
1621
local win_opts=$6
1722

18-
build_dir="$(dirname $sketch)/build"
23+
rm -rf "$build_dir"
1924
mkdir -p "$build_dir"
2025
mkdir -p "$ARDUINO_CACHE_DIR"
2126
$ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \
@@ -32,13 +37,13 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <fqbn> <path-to-i
3237
$win_opts $xtra_opts "$sketch"
3338
}
3439

35-
function count_sketches(){ # count_sketches <path> <target>
40+
function count_sketches(){ # count_sketches <path> [target]
3641
local path=$1
3742
local target=$2
3843

39-
if [ $# -lt 2 ]; then
44+
if [ $# -lt 1 ]; then
4045
echo "ERROR: Illegal number of parameters"
41-
echo "USAGE: ${0} count <path> <target>"
46+
echo "USAGE: ${0} count <path> [target]"
4247
fi
4348

4449
rm -rf sketches.txt
@@ -47,15 +52,15 @@ function count_sketches(){ # count_sketches <path> <target>
4752
return 0
4853
fi
4954

50-
local sketches=$(find $path -name *.ino)
55+
local sketches=$(find $path -name *.ino | sort)
5156
local sketchnum=0
5257
for sketch in $sketches; do
5358
local sketchdir=$(dirname $sketch)
5459
local sketchdirname=$(basename $sketchdir)
5560
local sketchname=$(basename $sketch)
5661
if [[ "$sketchdirname.ino" != "$sketchname" ]]; then
5762
continue
58-
elif [[ -f "$sketchdir/.skip.$target" ]]; then
63+
elif [[ -n $target ]] && [[ -f "$sketchdir/.skip.$target" ]]; then
5964
continue
6065
else
6166
echo $sketch >> sketches.txt

Diff for: .github/scripts/tests_build.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
SCRIPTS_DIR="./.github/scripts"
4+
BUILD_CMD=""
5+
6+
if [ $# -eq 3 ]; then
7+
chunk_build=1
8+
elif [ $# -eq 2 ]; then
9+
chunk_build=0
10+
else
11+
echo "ERROR: Illegal number of parameters"
12+
echo "USAGE:
13+
${0} <target> <sketch_dir>
14+
${0} <target> <chunk> <total_chunks>
15+
"
16+
exit 0
17+
fi
18+
19+
target=$1
20+
21+
case "$target" in
22+
"esp32") fqbn="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app"
23+
;;
24+
"esp32s2") fqbn="espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app"
25+
;;
26+
"esp32c3") fqbn="espressif:esp32:esp32c3:PartitionScheme=huge_app"
27+
;;
28+
"esp32s3") fqbn="espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app"
29+
;;
30+
esac
31+
32+
if [ -z $fqbn ]; then
33+
echo "Unvalid chip $1"
34+
exit 0
35+
fi
36+
37+
source ${SCRIPTS_DIR}/install-arduino-ide.sh
38+
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
39+
40+
args="$ARDUINO_IDE_PATH $ARDUINO_USR_PATH \"$fqbn\""
41+
42+
if [ $chunk_build -eq 1 ]; then
43+
chunk_index=$2
44+
chunk_max=$3
45+
46+
if [ "$chunk_index" -gt "$chunk_max" ] && [ "$chunk_max" -ge 2 ]; then
47+
chunk_index=$chunk_max
48+
fi
49+
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh chunk_build"
50+
args+=" $target $PWD/tests $chunk_index $chunk_max"
51+
else
52+
sketchdir=$2
53+
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh build"
54+
args+=" $PWD/tests/$sketchdir/$sketchdir.ino"
55+
fi
56+
57+
${BUILD_CMD} ${args}
58+

Diff for: .github/scripts/tests_run.sh

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
target=$1
4+
chunk_idex=$2
5+
chunks_num=$3
6+
7+
SCRIPTS_DIR="./.github/scripts"
8+
COUNT_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh count"
9+
10+
source ${SCRIPTS_DIR}/install-arduino-ide.sh
11+
12+
if [ "$chunks_num" -le 0 ]; then
13+
echo "ERROR: Chunks count must be positive number"
14+
return 1
15+
fi
16+
if [ "$chunk_idex" -ge "$chunks_num" ] && [ "$chunks_num" -ge 2 ]; then
17+
echo "ERROR: Chunk index must be less than chunks count"
18+
return 1
19+
fi
20+
21+
set +e
22+
${COUNT_SKETCHES} $PWD/tests $target
23+
sketchcount=$?
24+
set -e
25+
sketches=$(cat sketches.txt)
26+
rm -rf sketches.txt
27+
28+
chunk_size=$(( $sketchcount / $chunks_num ))
29+
all_chunks=$(( $chunks_num * $chunk_size ))
30+
if [ "$all_chunks" -lt "$sketchcount" ]; then
31+
chunk_size=$(( $chunk_size + 1 ))
32+
fi
33+
34+
start_index=0
35+
end_index=0
36+
if [ "$chunk_idex" -ge "$chunks_num" ]; then
37+
start_index=$chunk_idex
38+
end_index=$sketchcount
39+
else
40+
start_index=$(( $chunk_idex * $chunk_size ))
41+
if [ "$sketchcount" -le "$start_index" ]; then
42+
echo "Skipping job"
43+
return 0
44+
fi
45+
46+
end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
47+
if [ "$end_index" -gt "$sketchcount" ]; then
48+
end_index=$sketchcount
49+
fi
50+
fi
51+
52+
start_num=$(( $start_index + 1 ))
53+
sketchnum=0
54+
55+
for sketch in $sketches; do
56+
sketchdir=$(dirname $sketch)
57+
sketchdirname=$(basename $sketchdir)
58+
sketchname=$(basename $sketch)
59+
sketchnum=$(($sketchnum + 1))
60+
if [ "$sketchnum" -le "$start_index" ] \
61+
|| [ "$sketchnum" -gt "$end_index" ]; then
62+
continue
63+
fi
64+
echo ""
65+
echo "Test for Sketch Index $(($sketchnum - 1)) - $sketchdirname"
66+
pytest tests -k test_$sketchdirname --junit-xml=tests/$sketchdirname/$sketchdirname.xml
67+
result=$?
68+
if [ $result -ne 0 ]; then
69+
return $result
70+
fi
71+
done

Diff for: .github/workflows/hil.yml

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Run tests in hardware
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, labeled]
6+
7+
schedule:
8+
- cron: '0 2 * * *'
9+
10+
env:
11+
MAX_CHUNKS: 15
12+
13+
concurrency:
14+
group: hil-${{github.event.pull_request.number || github.ref}}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
gen_chunks:
19+
if: |
20+
contains(github.event.pull_request.labels.*.name, 'hil_test') ||
21+
github.event_name == 'schedule'
22+
name: Generate Chunks matrix
23+
runs-on: ubuntu-latest
24+
outputs:
25+
chunks: ${{ steps.gen-chunks.outputs.chunks }}
26+
steps:
27+
- name: Checkout Repository
28+
uses: actions/checkout@v2
29+
30+
- name: Generate Chunks matrix
31+
id: gen-chunks
32+
run: |
33+
set +e
34+
bash .github/scripts/sketch_utils.sh count tests
35+
sketches=$((? - 1))
36+
if [[ $sketches -gt ${{env.MAX_CHUNKS}} ]]; then
37+
$sketches=${{env.MAX_CHUNKS}}
38+
fi
39+
set -e
40+
rm sketches.txt
41+
CHUNKS=$(jq -c -n '$ARGS.positional' --args `seq 0 1 $sketches`)
42+
echo "::set-output name=chunks::${CHUNKS}"
43+
44+
Build:
45+
needs: gen_chunks
46+
name: ${{matrix.chip}}-Build#${{matrix.chunks}}
47+
runs-on: ubuntu-latest
48+
strategy:
49+
matrix:
50+
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3']
51+
chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}}
52+
53+
steps:
54+
- name: Checkout Repository
55+
uses: actions/checkout@v2
56+
57+
- name: Build sketches
58+
run: |
59+
bash .github/scripts/tests_build.sh ${{matrix.chip}} ${{matrix.chunks}} ${{env.MAX_CHUNKS}}
60+
- name: Upload ${{matrix.chip}}-${{matrix.chunks}} artifacts
61+
uses: actions/upload-artifact@v2
62+
with:
63+
name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts
64+
path: |
65+
tests/*/build/*.bin
66+
tests/*/build/*.json
67+
Test:
68+
needs: [gen_chunks, Build]
69+
name: ${{matrix.chip}}-Test#${{matrix.chunks}}
70+
runs-on: ESP32
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3']
75+
chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}}
76+
container:
77+
image: python:3.10.1-bullseye
78+
options: --privileged
79+
80+
steps:
81+
- name: Checkout repository
82+
uses: actions/checkout@v2
83+
84+
- name: Download ${{matrix.chip}}-${{matrix.chunks}} artifacts
85+
uses: actions/download-artifact@v2
86+
with:
87+
name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts
88+
path: tests/
89+
90+
- name: Check Artifacts
91+
run: |
92+
ls -R tests
93+
cat tests/*/build/build.options.json
94+
95+
- name: Install dependencies
96+
run: |
97+
pip install -U pip
98+
pip install -r tests/requirements.txt
99+
100+
- name: Run Tests
101+
run: |
102+
bash .github/scripts/tests_run.sh ${{matrix.chip}} ${{matrix.chunks}} ${{env.MAX_CHUNKS}}
103+
104+
- name: Upload test result artifacts
105+
uses: actions/upload-artifact@v2
106+
if: always()
107+
with:
108+
name: test_results-${{matrix.chip}}-${{matrix.chunks}}
109+
path: tests/*/*.xml
110+
111+
event_file:
112+
name: "Event File"
113+
if: ${{ always() }}
114+
needs: Test
115+
runs-on: ubuntu-latest
116+
steps:
117+
- name: Upload
118+
uses: actions/upload-artifact@v2
119+
with:
120+
name: Event File
121+
path: ${{github.event_path}}

Diff for: .github/workflows/publish.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Unit Test Results
2+
3+
on:
4+
workflow_run:
5+
workflows: [Run tests in hardware]
6+
7+
types:
8+
- completed
9+
10+
jobs:
11+
unit-test-results:
12+
name: Unit Test Results
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Download and Extract Artifacts
16+
env:
17+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
18+
run: |
19+
mkdir -p artifacts && cd artifacts
20+
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
21+
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
22+
do
23+
IFS=$'\t' read name url <<< "$artifact"
24+
gh api $url > "$name.zip"
25+
unzip -d "$name" "$name.zip"
26+
done
27+
- name: Publish Unit Test Results
28+
uses: EnricoMi/publish-unit-test-result-action@v1
29+
with:
30+
commit: ${{ github.event.workflow_run.head_sha }}
31+
event_file: artifacts/Event File/event.json
32+
event_name: ${{ github.event.workflow_run.event }}
33+
files: "artifacts/**/*.xml"

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ boards.sloeber.txt
2323
# Ignore docs build (Sphinx)
2424
docs/build
2525
docs/source/_build
26+
27+
# Test log files
28+
*.log

0 commit comments

Comments
 (0)