Skip to content

Commit 9e64ade

Browse files
committed
Merge branch 'test_ci'
2 parents 5d9cd9a + 711cce5 commit 9e64ade

File tree

9 files changed

+136
-52
lines changed

9 files changed

+136
-52
lines changed

.github/workflows/build_tests.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,29 @@ jobs:
4747
4848
echo "enabled=$enabled" >> $GITHUB_OUTPUT
4949
50-
- name: Checkout Repository
51-
uses: actions/checkout@v4
50+
- name: Checkout base repository
5251
if: ${{ steps.check-build.outputs.enabled == 'true' }}
52+
uses: actions/checkout@v4
5353
with:
5454
ref: ${{ github.event.pull_request.head.sha || github.sha }}
55+
persist-credentials: false
56+
sparse-checkout-cone-mode: false
57+
sparse-checkout: |
58+
/*
59+
!.github
60+
61+
- name: Checkout Scripts
62+
if: ${{ steps.check-build.outputs.enabled == 'true' }}
63+
uses: actions/checkout@v4
64+
with:
65+
persist-credentials: false
66+
sparse-checkout-cone-mode: false
67+
sparse-checkout: .github/*
68+
69+
- name: Cat scripts
70+
if: ${{ steps.check-build.outputs.enabled == 'true' }}
71+
run: |
72+
cat .github/scripts/tests_build.sh
5573
5674
- name: Get libs cache
5775
uses: actions/cache@v4

.github/workflows/hw.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,32 @@ jobs:
4949
5050
echo "enabled=$enabled" >> $GITHUB_OUTPUT
5151
52-
- name: Checkout repository
52+
- name: Checkout base repository
5353
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
5454
uses: actions/checkout@v4
5555
with:
5656
ref: ${{ github.event.pull_request.head.sha || github.sha }}
57+
persist-credentials: false
58+
sparse-checkout-cone-mode: false
59+
sparse-checkout: |
60+
/*
61+
!.github
5762
58-
- uses: actions/setup-python@v5
59-
if: steps.check-tests.outputs.enabled == 'true'
63+
- name: Checkout Scripts
64+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
65+
uses: actions/checkout@v4
6066
with:
61-
cache-dependency-path: tests/requirements.txt
62-
cache: 'pip'
63-
python-version: '3.10.1'
67+
persist-credentials: false
68+
sparse-checkout-cone-mode: false
69+
sparse-checkout: .github/*
70+
71+
# setup-python currently only works on ubuntu images
72+
# - uses: actions/setup-python@v5
73+
# if: steps.check-tests.outputs.enabled == 'true'
74+
# with:
75+
# cache-dependency-path: tests/requirements.txt
76+
# cache: 'pip'
77+
# python-version: '3.10.1'
6478

6579
- name: Install dependencies
6680
if: ${{ steps.check-tests.outputs.enabled == 'true' }}

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
- name: Set up Python 3
2929
uses: actions/setup-python@v5
3030
with:
31+
cache-dependency-path: tools/pre-commit/requirements.txt
32+
cache: 'pip'
3133
python-version: "3.x"
3234

3335
- name: Get Python version hash
@@ -41,11 +43,10 @@ jobs:
4143
with:
4244
path: |
4345
~/.cache/pre-commit
44-
~/.cache/pip
45-
key: pre-commit|${{ env.PY_HASH }}|${{ hashFiles('.pre-commit-config.yaml', '.github/workflows/pre-commit.yml') }}
46+
key: pre-commit-${{ env.PY_HASH }}-${{ hashFiles('.pre-commit-config.yaml', '.github/workflows/pre-commit.yml', 'tools/pre-commit/requirements.txt') }}
4647

4748
- name: Install python dependencies
48-
run: python -m pip install pre-commit docutils
49+
run: python -m pip install -r tools/pre-commit/requirements.txt
4950

5051
- name: Get changed files
5152
id: changed-files
@@ -61,7 +62,6 @@ jobs:
6162
with:
6263
path: |
6364
~/.cache/pre-commit
64-
~/.cache/pip
6565
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
6666

6767
- name: Push changes using pre-commit-ci-lite

.github/workflows/push.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
runs-on: ubuntu-latest
4949
outputs:
5050
build_all: ${{ steps.set-chunks.outputs.build_all }}
51+
build_libraries: ${{ steps.set-chunks.outputs.build_libraries }}
5152
build_static_sketches: ${{ steps.set-chunks.outputs.build_static_sketches }}
5253
build_idf: ${{ steps.set-chunks.outputs.build_idf }}
5354
build_platformio: ${{ steps.set-chunks.outputs.build_platformio }}
@@ -103,6 +104,7 @@ jobs:
103104
104105
build_platformio=${{ steps.changed-files.outputs.platformio_any_changed == 'true' }}
105106
build_idf=${{ steps.changed-files.outputs.idf_any_changed == 'true' }}
107+
build_libraries=${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
106108
build_static_sketches=${{ steps.changed-files.outputs.static_sketeches_any_changed == 'true' }}
107109
108110
core_changed=${{ steps.changed-files.outputs.core_any_changed == 'true' }}
@@ -164,6 +166,7 @@ jobs:
164166
chunks+="]"
165167
166168
echo "build_all=$build_all" >> $GITHUB_OUTPUT
169+
echo "build_libraries=$build_libraries" >> $GITHUB_OUTPUT
167170
echo "build_static_sketches=$build_static_sketches" >> $GITHUB_OUTPUT
168171
echo "build_idf=$build_idf" >> $GITHUB_OUTPUT
169172
echo "build_platformio=$build_platformio" >> $GITHUB_OUTPUT
@@ -274,7 +277,10 @@ jobs:
274277
build-esp-idf-component:
275278
name: Build with ESP-IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
276279
needs: gen-chunks
277-
if: ${{ needs.gen-chunks.outputs.build_all == 'true' || needs.gen-chunks.outputs.build_idf == 'true' }}
280+
if: |
281+
needs.gen-chunks.outputs.build_all == 'true' ||
282+
needs.gen-chunks.outputs.build_libraries == 'true' ||
283+
needs.gen-chunks.outputs.build_idf == 'true'
278284
runs-on: ubuntu-20.04
279285
strategy:
280286
fail-fast: false

.github/workflows/qemu.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,24 @@ jobs:
4545
4646
echo "enabled=$enabled" >> $GITHUB_OUTPUT
4747
48-
- name: Checkout repository
48+
- name: Checkout base repository
49+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
4950
uses: actions/checkout@v4
50-
if: steps.check-tests.outputs.enabled == 'true'
5151
with:
5252
ref: ${{ github.event.pull_request.head.sha || github.sha }}
53+
persist-credentials: false
54+
sparse-checkout-cone-mode: false
55+
sparse-checkout: |
56+
/*
57+
!.github
58+
59+
- name: Checkout Scripts
60+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
61+
uses: actions/checkout@v4
62+
with:
63+
persist-credentials: false
64+
sparse-checkout-cone-mode: false
65+
sparse-checkout: .github/*
5366

5467
- uses: actions/setup-python@v5
5568
if: steps.check-tests.outputs.enabled == 'true'

.github/workflows/tests.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
6868
call-build-tests:
6969
name: Build
70-
uses: espressif/arduino-esp32/.github/workflows/build_tests.yml@master
70+
uses: ./.github/workflows/build_tests.yml
7171
needs: gen-matrix
7272
if: github.event.action != 'closed'
7373
strategy:
@@ -80,7 +80,7 @@ jobs:
8080

8181
call-hardware-tests:
8282
name: Hardware
83-
uses: espressif/arduino-esp32/.github/workflows/hw.yml@master
83+
uses: ./.github/workflows/hw.yml
8484
needs: [gen-matrix, call-build-tests]
8585
if: |
8686
github.repository == 'espressif/arduino-esp32' &&
@@ -97,7 +97,7 @@ jobs:
9797

9898
call-wokwi-tests:
9999
name: Wokwi
100-
uses: espressif/arduino-esp32/.github/workflows/wokwi.yml@master
100+
uses: ./.github/workflows/wokwi.yml
101101
needs: [gen-matrix, call-build-tests]
102102
if: github.event.action != 'closed'
103103
strategy:
@@ -114,7 +114,7 @@ jobs:
114114
# This job is disabled for now
115115
call-qemu-tests:
116116
name: QEMU
117-
uses: espressif/arduino-esp32/.github/workflows/qemu.yml@master
117+
uses: ./.github/workflows/qemu.yml
118118
needs: [gen-matrix, call-build-tests]
119119
if: false
120120
strategy:
@@ -167,7 +167,7 @@ jobs:
167167
clean:
168168
name: Clean objects
169169
needs: unit-test-results
170-
if: always() && ${{ github.event_name }} == 'pull_request_target' && ${{ github.event.action }} != 'closed'
170+
if: always()
171171
permissions:
172172
actions: write
173173
runs-on: ubuntu-latest
@@ -179,6 +179,11 @@ jobs:
179179
const ref = '${{ github.event.pull_request.number || github.ref }}';
180180
const key_prefix = 'tests-' + ref + '-';
181181
182+
if ('${{ github.event_name }}' == 'pull_request_target' && '${{ github.event.action }}' != 'closed') {
183+
console.log('Skipping cache cleanup for open PR');
184+
return;
185+
}
186+
182187
await github.paginate(github.rest.actions.getActionsCacheList, {
183188
owner: context.repo.owner,
184189
repo: context.repo.repo,

.github/workflows/wokwi.yml

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@ jobs:
3030
id: ${{ github.event.pull_request.number || github.ref }}-${{ github.event.pull_request.head.sha || github.sha }}-${{ inputs.chip }}-${{ inputs.type }}
3131
runs-on: ubuntu-latest
3232
steps:
33-
# Disabled as Wokwi infrastrucutre is not stable (so we can re-trigger the tests manually)
34-
# - name: Check if already run
35-
# if: ${{ github.event.pull_request.number != null }}
36-
# id: get-cache-results
37-
# uses: actions/cache/restore@v4
38-
# with:
39-
# key: tests-${{ env.id }}-results-wokwi
40-
# path: |
41-
# tests/**/*.xml
42-
# tests/**/result_*.json
33+
- name: Check if already run
34+
if: ${{ github.event.pull_request.number != null }}
35+
id: get-cache-results
36+
uses: actions/cache/restore@v4
37+
with:
38+
key: tests-${{ env.id }}-results-wokwi
39+
path: |
40+
tests/**/*.xml
41+
tests/**/result_*.json
4342
4443
- name: Evaluate if tests should be run
4544
id: check-tests
@@ -54,11 +53,24 @@ jobs:
5453
5554
echo "enabled=$enabled" >> $GITHUB_OUTPUT
5655
57-
- name: Checkout Repository
56+
- name: Checkout base repository
57+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
5858
uses: actions/checkout@v4
59-
if: steps.check-tests.outputs.enabled == 'true'
6059
with:
6160
ref: ${{ github.event.pull_request.head.sha || github.sha }}
61+
persist-credentials: false
62+
sparse-checkout-cone-mode: false
63+
sparse-checkout: |
64+
/*
65+
!.github
66+
67+
- name: Checkout Scripts
68+
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
69+
uses: actions/checkout@v4
70+
with:
71+
persist-credentials: false
72+
sparse-checkout-cone-mode: false
73+
sparse-checkout: .github/*
6274

6375
- uses: actions/setup-python@v5
6476
if: steps.check-tests.outputs.enabled == 'true'
@@ -100,15 +112,14 @@ jobs:
100112
run: |
101113
bash .github/scripts/tests_run.sh -c -type ${{ inputs.type }} -t ${{inputs.chip}} -i 0 -m 1 -W ${{env.WOKWI_TIMEOUT}}
102114
103-
# Disabled as Wokwi infrastrucutre is not stable (so we can re-trigger the tests manually)
104-
# - name: Upload ${{ inputs.chip }} ${{ inputs.type }} Wokwi results as cache
105-
# uses: actions/cache/save@v4
106-
# if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
107-
# with:
108-
# key: tests-${{ env.id }}-results-wokwi
109-
# path: |
110-
# tests/**/*.xml
111-
# tests/**/result_*.json
115+
- name: Upload ${{ inputs.chip }} ${{ inputs.type }} Wokwi results as cache
116+
uses: actions/cache/save@v4
117+
if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
118+
with:
119+
key: tests-${{ env.id }}-results-wokwi
120+
path: |
121+
tests/**/*.xml
122+
tests/**/result_*.json
112123
113124
- name: Upload ${{ inputs.chip }} ${{ inputs.type }} Wokwi results as artifacts
114125
uses: actions/upload-artifact@v4

tools/get.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ def verify_files(filename, destination, rename_to):
107107
for i, zipped_file in enumerate(archive.namelist(), 1):
108108
local_path = os.path.join(extracted_dir_path, zipped_file.replace(first_dir, rename_to, 1))
109109
if not os.path.exists(local_path):
110-
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
111-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
110+
if verbose:
111+
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
112+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
112113
return False
113114
print_verification_progress(total_files, i, t1)
114115
except zipfile.BadZipFile:
115-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
116+
if verbose:
117+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
116118
return False
117119
elif filename.endswith(".tar.gz"):
118120
try:
@@ -122,12 +124,14 @@ def verify_files(filename, destination, rename_to):
122124
for i, zipped_file in enumerate(archive.getnames(), 1):
123125
local_path = os.path.join(extracted_dir_path, zipped_file.replace(first_dir, rename_to, 1))
124126
if not os.path.exists(local_path):
125-
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
126-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
127+
if verbose:
128+
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
129+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
127130
return False
128131
print_verification_progress(total_files, i, t1)
129132
except tarfile.ReadError:
130-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
133+
if verbose:
134+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
131135
return False
132136
elif filename.endswith(".tar.xz"):
133137
try:
@@ -137,12 +141,14 @@ def verify_files(filename, destination, rename_to):
137141
for i, zipped_file in enumerate(archive.getnames(), 1):
138142
local_path = os.path.join(extracted_dir_path, zipped_file.replace(first_dir, rename_to, 1))
139143
if not os.path.exists(local_path):
140-
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
141-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
144+
if verbose:
145+
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
146+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
142147
return False
143148
print_verification_progress(total_files, i, t1)
144149
except tarfile.ReadError:
145-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
150+
if verbose:
151+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
146152
return False
147153
else:
148154
raise NotImplementedError("Unsupported archive type")
@@ -231,7 +237,12 @@ def unpack(filename, destination, force_extract): # noqa: C901
231237
shutil.rmtree(rename_to)
232238
shutil.move(dirname, rename_to)
233239

234-
return True
240+
if verify_files(filename, destination, rename_to):
241+
print(" Files extracted successfully.")
242+
return True
243+
else:
244+
print(" Failed to extract files.")
245+
return False
235246

236247

237248
def download_file_with_progress(url, filename, start_time):
@@ -291,6 +302,7 @@ def get_tool(tool, force_download, force_extract):
291302
local_path = dist_dir + archive_name
292303
url = tool["url"]
293304
start_time = time.time()
305+
print("")
294306
if not os.path.isfile(local_path) or force_download:
295307
if verbose:
296308
print("Downloading '" + archive_name + "' to '" + local_path + "'")
@@ -421,6 +433,9 @@ def identify_platform():
421433
current_dir + "/../package/package_esp32_index.template.json", identified_platform
422434
)
423435
mkdir_p(dist_dir)
436+
437+
print("\nDownloading and extracting tools...")
438+
424439
for tool in tools_to_download:
425440
if is_test:
426441
print("Would install: {0}".format(tool["archiveFileName"]))
@@ -432,4 +447,4 @@ def identify_platform():
432447
print(f"Tool {tool['archiveFileName']} was corrupted, but re-downloading did not help!\n")
433448
sys.exit(1)
434449

435-
print("Platform Tools Installed")
450+
print("\nPlatform Tools Installed")

tools/pre-commit/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pre-commit==3.7.1
2+
docutils==0.21.2

0 commit comments

Comments
 (0)