Skip to content

Commit

Permalink
Ci tweak3 (#2643)
Browse files Browse the repository at this point in the history
- enable --one-per-family to build 1 board per family, also skip family if board specified in -b also present
- minimize ci run for push event
  - only build one board per family
  - skip hil test on both pi4 and hfp
- full build will be runn for PR event
- IAR always build 1 board per family regardless of event 
- update build.py to optimize make
- remove all setup python since we don't really need it
  • Loading branch information
hathach committed May 13, 2024
1 parent 6f47746 commit 7cf1bdd
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 164 deletions.
3 changes: 3 additions & 0 deletions .github/actions/setup_toolchain/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ runs:
- name: Download Toolchain
if: >-
inputs.toolchain != 'arm-gcc' &&
inputs.toolchain != 'arm-iar' &&
inputs.toolchain != 'esp-idf'
uses: ./.github/actions/setup_toolchain/download
with:
Expand All @@ -44,6 +45,8 @@ runs:
BUILD_OPTION=""
if [[ "${{ inputs.toolchain }}" == *"clang"* ]]; then
BUILD_OPTION="--toolchain clang"
elif [[ "${{ inputs.toolchain }}" == "arm-iar" ]]; then
BUILD_OPTION="--toolchain iar"
fi
echo "build_option=$BUILD_OPTION"
echo "build_option=$BUILD_OPTION" >> $GITHUB_OUTPUT
Expand Down
50 changes: 36 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ jobs:
outputs:
json: ${{ steps.set-matrix-json.outputs.matrix }}
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Checkout TinyUSB
uses: actions/checkout@v4

Expand All @@ -63,27 +58,22 @@ jobs:
matrix:
toolchain:
- 'aarch64-gcc'
- 'arm-clang'
# - 'arm-clang'
- 'arm-gcc'
- 'msp430-gcc'
- 'riscv-gcc'
if: >-
matrix.toolchain != 'arm-clang' ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && github.ref == 'refs/heads/master')
with:
build-system: 'cmake'
toolchain: ${{ matrix.toolchain }}
toolchain_url: ${{ fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].toolchain_url }}
build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].family) }}
one-per-family: ${{ github.event_name != 'pull_request' }}

# ---------------------------------------
# Build Make
# ---------------------------------------
make:
if: >-
github.event_name == 'pull_request' ||
(github.event_name == 'push' && github.ref == 'refs/heads/master')
#if: github.event_name == 'pull_request'
needs: set-matrix
uses: ./.github/workflows/build_util.yml
strategy:
Expand All @@ -100,6 +90,7 @@ jobs:
toolchain: ${{ matrix.toolchain }}
toolchain_url: ${{ fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].toolchain_url }}
build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].family) }}
one-per-family: ${{ github.event_name != 'pull_request' }}

# ---------------------------------------
# Build Make on Windows/MacOS
Expand All @@ -114,7 +105,8 @@ jobs:
os: ${{ matrix.os }}
build-system: 'make'
toolchain: 'arm-gcc'
build-args: '["-bstm32f411disco"]'
build-args: '["stm32h7"]'
one-per-family: true

# ---------------------------------------
# Build Espressif
Expand All @@ -134,3 +126,33 @@ jobs:
toolchain: 'esp-idf'
toolchain_url: 'v5.1.1'
build-args: '["-b${{ matrix.board }}"]'

# ---------------------------------------
# Build IAR on HFP self-hosted
# ---------------------------------------
arm-iar:
if: github.repository_owner == 'hathach'
needs: set-matrix
runs-on: [self-hosted, Linux, X64, hifiphile]
env:
BUILD_ARGS: ${{ join(fromJSON(needs.set-matrix.outputs.json)['arm-iar'].family, ' ') }}
steps:
- name: Clean workspace
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
- name: Checkout TinyUSB
uses: actions/checkout@v4

- name: Get Dependencies
run: python3 tools/get_deps.py $BUILD_ARGS

- name: Build
run: python3 tools/build.py --one-per-family --toolchain iar $BUILD_ARGS

- name: Test on actual hardware (hardware in the loop)
if: github.event_name == 'pull_request'
run: |
python3 test/hil/hil_test.py hfp.json
50 changes: 0 additions & 50 deletions .github/workflows/build_iar.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .github/workflows/build_renesas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ jobs:
# Alphabetical order
- 'rx'
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Checkout TinyUSB
uses: actions/checkout@v4

Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/build_util.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
build-args:
required: true
type: string
one-per-family:
required: false
default: false
type: boolean
os:
required: false
type: string
Expand All @@ -31,11 +35,6 @@ jobs:
- name: Checkout TinyUSB
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Setup Toolchain
id: setup-toolchain
uses: ./.github/actions/setup_toolchain
Expand All @@ -48,10 +47,20 @@ jobs:
with:
arg: ${{ matrix.arg }}

- name: Set build one-per-family option
id: set-one-per-family
run: |
if [[ "${{ inputs.one-per-family }}" == "true" ]]; then
BUILD_OPTION="--one-per-family"
fi
echo "build_option=$BUILD_OPTION"
echo "build_option=$BUILD_OPTION" >> $GITHUB_OUTPUT
shell: bash

- name: Build
if: inputs.toolchain != 'esp-idf'
run: |
python tools/build.py -s ${{ inputs.build-system }} ${{ steps.setup-toolchain.outputs.build_option }} ${{ matrix.arg }}
python tools/build.py -s ${{ inputs.build-system }} ${{ steps.setup-toolchain.outputs.build_option }} ${{ steps.set-one-per-family.outputs.build_option }} ${{ matrix.arg }}
- name: Build using ESP-IDF docker
if: inputs.toolchain == 'esp-idf'
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/ci_set_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
toolchain_list = {
"aarch64-gcc": "https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz",
"arm-clang": "https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-17.0.1/LLVMEmbeddedToolchainForArm-17.0.1-Linux-x86_64.tar.xz",
"arm-iar": "",
"arm-gcc": "",
"msp430-gcc": "http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2",
"riscv-gcc": "https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.1.0-1.1/xpack-riscv-none-embed-gcc-10.1.0-1.1-linux-x64.tar.gz",
Expand All @@ -28,12 +29,12 @@
"rp2040": ["arm-gcc"],
"samd11 samd21 saml2x": ["arm-gcc", "arm-clang"],
"samd5x_e5x samg": ["arm-gcc", "arm-clang"],
"stm32f0 stm32f1 stm32f2 stm32f3": ["arm-gcc", "arm-clang"],
"stm32f4": ["arm-gcc", "arm-clang"],
"stm32f7": ["arm-gcc", "arm-clang"],
"stm32g0 stm32g4 stm32h5": ["arm-gcc", "arm-clang"],
"stm32h7": ["arm-gcc", "arm-clang"],
"stm32l4 stm32u5 stm32wb": ["arm-gcc", "arm-clang"],
"stm32f0 stm32f1 stm32f2 stm32f3": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32f4": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32f7": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32g0 stm32g4 stm32h5": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32h7": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32l4 stm32u5 stm32wb": ["arm-gcc", "arm-clang", "arm-iar"],
"xmc4000": ["arm-gcc"],
}

Expand All @@ -43,7 +44,16 @@ def set_matrix_json():
for toolchain in toolchain_list.keys():
filtered_families = [family for family, supported_toolchain in family_list.items() if
toolchain in supported_toolchain]

# always add board in hfp.json for arm-iar
if toolchain == 'arm-iar':
with open('test/hil/hfp.json') as f:
hfp_data = json.load(f)
hfp_boards = [f"-b{board['name']}" for board in hfp_data['boards']]
filtered_families = filtered_families + hfp_boards

matrix[toolchain] = {"family": filtered_families, "toolchain_url": toolchain_list[toolchain]}

print(json.dumps(matrix))


Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/hil_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ jobs:
- name: Checkout TinyUSB
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Parse HIL json
id: parse_hil_json
run: |
Expand Down Expand Up @@ -78,11 +73,6 @@ jobs:
- name: Checkout TinyUSB
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Parse HIL json
id: parse_hil_json
run: |
Expand Down Expand Up @@ -131,7 +121,7 @@ jobs:
- build-esp
runs-on: [self-hosted, rp2040, nrf52840, esp32s3, hardware-in-the-loop]
env:
BOARDS_LIST: "${{ needs.build.outputs.BOARDS_LIST }} ${{ needs.build-esp.outputs.BOARDS_LIST }}"
BOARDS_LIST: "${{ needs.build.outputs.BOARDS_LIST }} ${{ needs.build-esp.outputs.BOARDS_LIST }}"
steps:
- name: Clean workspace
run: |
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion hw/bsp/stm32f0/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void board_init(void) {
//--------------------------------------------------------------------+

void board_led_write(bool state) {
GPIO_PinState pin_state = (GPIO_PinState)(state ? LED_STATE_ON : (1 - LED_STATE_ON));
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
}

Expand Down
2 changes: 1 addition & 1 deletion hw/bsp/stm32f1/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void board_init(void) {
//--------------------------------------------------------------------+

void board_led_write(bool state) {
GPIO_PinState pin_state = (GPIO_PinState)(state ? LED_STATE_ON : (1 - LED_STATE_ON));
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
}

Expand Down
3 changes: 2 additions & 1 deletion hw/bsp/stm32f2/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ void board_init(void) {
//--------------------------------------------------------------------+

void board_led_write(bool state) {
HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
}

uint32_t board_button_read(void) {
Expand Down
5 changes: 3 additions & 2 deletions hw/bsp/stm32f3/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ void board_init(void) {
//--------------------------------------------------------------------+

void board_led_write(bool state) {
HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
}

uint32_t board_button_read(void) {
Expand Down Expand Up @@ -142,7 +143,7 @@ uint32_t board_millis(void) {
#endif

void HardFault_Handler(void) {
asm("bkpt");
asm("bkpt 0");
}

// Required by __libc_init_array in startup code if we are compiling using
Expand Down
3 changes: 2 additions & 1 deletion hw/bsp/stm32u5/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ void board_init(void) {
//--------------------------------------------------------------------+

void board_led_write(bool state) {
HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
}

uint32_t board_button_read(void) {
Expand Down
5 changes: 3 additions & 2 deletions hw/bsp/stm32wb/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ void board_init(void) {
//--------------------------------------------------------------------+

void board_led_write(bool state) {
HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
}

uint32_t board_button_read(void) {
Expand Down Expand Up @@ -174,7 +175,7 @@ uint32_t board_millis(void) {
#endif

void HardFault_Handler(void) {
asm("bkpt");
asm("bkpt 1");
}

// Required by __libc_init_array in startup code if we are compiling using
Expand Down
Loading

0 comments on commit 7cf1bdd

Please sign in to comment.