Skip to content

Commit

Permalink
[ci] Adapt example paths in CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Apr 6, 2024
1 parent 552fed5 commit 3125e63
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 55 deletions.
36 changes: 12 additions & 24 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,11 @@ jobs:
- name: Examples SAMD Devices
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py feather_m4 samd samd21_xplained_pro)
(cd examples && ../tools/scripts/examples_compile.py feather_m4 samd)
- name: Examples SAMG Devices
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py samg55_xplained_pro)
- name: Examples SAME5x Devices
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py same54_xplained_pro)
- name: Examples SAME70 Devices
if: always()
run: |
Expand All @@ -112,7 +108,7 @@ jobs:
- name: Examples RP20 Devices
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py feather_rp2040 rp_pico thingplus_rp2040)
(cd examples && ../tools/scripts/examples_compile.py rp_pico)
- name: Execute Python Scripts
if: always()
run: |
Expand All @@ -138,51 +134,43 @@ jobs:
- name: Examples STM32F0 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py stm32f0_discovery stm32f072_discovery nucleo_f031k6 nucleo_f072rb nucleo_f091rc nucleo_f042k6 stm32f030f4p6_demo_board)
(cd examples && ../tools/scripts/examples_compile.py stm32f0_discovery stm32f072_discovery nucleo_f072rb nucleo_f042k6 stm32f030f4p6_demo_board)
- name: Examples STM32F1 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py stm32f1_discovery nucleo_f103rb olimexino_stm32 blue_pill_f103 black_pill_f103)
(cd examples && ../tools/scripts/examples_compile.py stm32f1_discovery nucleo_f103rb blue_pill_f103)
- name: Examples STM32F3 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py stm32f3_discovery nucleo_f303k8 nucleo_f303re nucleo_f334r8)
(cd examples && ../tools/scripts/examples_compile.py stm32f3_discovery nucleo_f303re)
- name: Examples STM32F7 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py stm32f746g_discovery stm32f769i_discovery nucleo_f746zg nucleo_f767zi)
(cd examples && ../tools/scripts/examples_compile.py stm32f746g_discovery stm32f769i_discovery nucleo_f767zi)
- name: Examples STM32G0 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_g070rb nucleo_g071rb)
- name: Examples STM32L0 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_l031k6 nucleo_l053r8)
- name: Examples STM32L1 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_l152re stm32l1_discovery)
(cd examples && ../tools/scripts/examples_compile.py nucleo_l031k6)
- name: Examples STM32L4 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py stm32l476_discovery nucleo_l476rg nucleo_l432kc nucleo_l452re nucleo_l496zg-p)
(cd examples && ../tools/scripts/examples_compile.py nucleo_l476rg nucleo_l432kc nucleo_l452re)
- name: Examples STM32L5 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_l552ze-q)
- name: Examples STM32U5 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_u575zi-q)
- name: Examples STM32G4 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_g474re nucleo_g431rb nucleo_g431kb)
(cd examples && ../tools/scripts/examples_compile.py nucleo_g474re)
- name: Examples STM32H7 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_h743zi nucleo_h723zg stm32h750vbt6_devebox)
(cd examples && ../tools/scripts/examples_compile.py nucleo_h723zg)
stm32f4-examples-1:
runs-on: ubuntu-22.04
Expand All @@ -202,7 +190,7 @@ jobs:
- name: Examples STM32F4 Only Discovery Board
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py stm32f4_discovery stm32f429_discovery stm32f469_discovery stm32f401_discovery)
(cd examples && ../tools/scripts/examples_compile.py stm32f4_discovery stm32f469_discovery stm32f401_discovery)
stm32f4-examples-2:
runs-on: ubuntu-22.04
Expand All @@ -225,7 +213,7 @@ jobs:
- name: Examples STM32F4 Without Discovery Board
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_f401re nucleo_f411re nucleo_f429zi nucleo_f446re nucleo_f446ze nucleo_f439zi black_pill_f401 black_pill_f411 stm32f407vet6_devebox stm32_f4ve)
(cd examples && ../tools/scripts/examples_compile.py nucleo_f401re nucleo_f411re nucleo_f429zi nucleo_f446re nucleo_f446ze nucleo_f439zi stm32f407vet6_devebox stm32_f4ve)
avr-examples:
runs-on: ubuntu-22.04
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,18 @@ jobs:
run: |
(cd examples && ../tools/scripts/examples_compile.py linux)
- name: Compile STM32 Examples
- name: Generic Examples
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_f031k6 nucleo_f103rb nucleo_f303re nucleo_f411re nucleo_f746zg)
(cd examples && ../tools/scripts/examples_compile.py nucleo_g071rb nucleo_l031k6 nucleo_l152re nucleo_l476rg nucleo_g474re)
(cd examples && ../tools/scripts/examples_compile.py generic)
- name: Compile STM32 Discovery Examples
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py stm32f0_discovery stm32f072_discovery stm32f1_discovery stm32f3_discovery stm32f4_discovery)
(cd examples && ../tools/scripts/examples_compile.py stm32f401_discovery stm32f469_discovery stm32f746g_discovery stm32f769i_discovery)
- name: Compile AVR Examples
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py avr)
(cd examples && ../tools/scripts/examples_compile.py avr arduino_nano arduino_uno srxe)
20 changes: 12 additions & 8 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,28 @@ jobs:
with:
submodules: 'recursive'

- name: Hosted Examples
- name: Hosted Unittests
if: always()
shell: bash
run: |
(cd examples && python ../tools/scripts/examples_compile.py linux/assert linux/block_device/ram linux/build_info linux/git linux/logger linux/printf linux/etl linux/fiber)
(cd test && make run-hosted-windows)
- name: Hosted Unittests
- name: Hosted Examples
if: always()
shell: bash
run: |
(cd test && make run-hosted-windows)
(cd examples && python ../tools/scripts/examples_compile.py linux)
- name: Compile STM32 Examples
- name: Generic Examples
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py generic)
- name: Compile STM32 Discovery Examples
if: always()
shell: bash
run: |
(cd examples && python ../tools/scripts/examples_compile.py nucleo_f031k6 nucleo_f103rb nucleo_f303re nucleo_f411re nucleo_f746zg)
(cd examples && python ../tools/scripts/examples_compile.py nucleo_g071rb nucleo_l031k6 nucleo_l152re nucleo_l476rg nucleo_g474re)
(cd examples && ../tools/scripts/examples_compile.py stm32f0_discovery stm32f072_discovery stm32f1_discovery stm32f3_discovery stm32f4_discovery)
(cd examples && ../tools/scripts/examples_compile.py stm32f401_discovery stm32f469_discovery stm32f746g_discovery stm32f769i_discovery)
- name: Compile AVR Examples
if: always()
Expand Down
44 changes: 25 additions & 19 deletions tools/scripts/examples_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,39 @@ def check_builds_paths(projects):

return result

def _get_paths_from_ci(files):
paths = set()
for file in files:
matches = re.findall(r"examples_compile.py (.*?)\)", file.read_text())
paths |= set(m for match in matches for m in match.split(" "))
return paths
def check_ci_workflows(folders):
def _check(path, missing=None):
path = ".github/workflows/" + path
matches = re.findall(r"examples_compile.py (.*?)\)", repopath(path).read_text())
paths = set(m for match in matches for m in match.split(" "))

def check_is_part_of_ci(projects):
folders = set(p.relative_to(repopath("examples")).parts[0] for p in projects)
result = 0
# Linux files
paths = _get_paths_from_ci([repopath(".github/workflows/linux.yml")])
paths = folders - paths
if paths:
print("\nLinux CI is missing examples: '{}'"
.format("', '".join(sorted(list(paths)))), file=sys.stderr)
print(" Please add these example folders to the appropriate CI job in\n"
" '.github/workflows/linux.yml'!")
if nonexistant_paths := paths - folders:
print("\nThe CI is trying to build examples that don't exist:\n\n- " +
"\n- ".join(sorted(list(nonexistant_paths))) +
"\n\n Please remove these example folders from the CI configuration:"
f"\n '{path}'!", file=sys.stderr)

if missing is not None and (missing_paths := folders - paths - missing):
print("\nThe CI is missing examples:\n\n- " +
"\n- ".join(sorted(list(missing_paths))) +
"\n\n Please add these example folders to the appropriate CI job in"
f"\n '{path}'!", file=sys.stderr)
return len(missing_paths) + len(nonexistant_paths)

return len(paths)
return len(nonexistant_paths)

errors = _check("linux.yml", {'rpi'})
errors += _check("macos.yml")
errors += _check("windows.yml")
return errors

if __name__ == "__main__":
# Find all project files
projects = list(repopath("examples").rglob("*/project.xml"))
folders = set(p.relative_to(repopath("examples")).parts[0] for p in projects)
# Run a bunch of checks on them
result = check_builds_paths(projects)
result += check_is_part_of_ci(projects)
result += check_ci_workflows(folders)
# Return code if any
exit(result)

Expand Down

0 comments on commit 3125e63

Please sign in to comment.