diff options
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/build.yml | 144 | ||||
| -rw-r--r-- | .github/workflows/build_util.yml | 34 | ||||
| -rwxr-xr-x | .github/workflows/ci_set_matrix.py | 24 | ||||
| -rw-r--r-- | .github/workflows/metrics_comment.yml | 38 |
4 files changed, 147 insertions, 93 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f1b134b8a..c062aca46 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,12 +56,12 @@ jobs: echo "hil_matrix=$HIL_MATRIX_JSON" echo "hil_matrix=$HIL_MATRIX_JSON" >> $GITHUB_OUTPUT - # --------------------------------------- - # Build CMake: only build on push with one-per-family. - # Full built is done by CircleCI in PR - # --------------------------------------- + # ------------------------------------------------------------------------------ + # CMake build: only one board per family (first alphabetically). Full build is done by CircleCI in PR + # Note: + # For Make and IAR build: will be done on CircleCI only (one random per family as well) + # ------------------------------------------------------------------------------ cmake: - if: github.event_name == 'push' needs: set-matrix uses: ./.github/workflows/build_util.yml strategy: @@ -71,59 +71,84 @@ jobs: - 'aarch64-gcc' #- 'arm-clang' - 'arm-gcc' - - 'esp-idf' + #- 'esp-idf' - 'msp430-gcc' - 'riscv-gcc' with: build-system: 'cmake' toolchain: ${{ matrix.toolchain }} build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain]) }} - one-per-family: true + build-options: '--one-first' + upload-metrics: true - # --------------------------------------- - # Build Make: only build on push with one-per-family - # --------------------------------------- - make: - if: github.event_name == 'push' - needs: set-matrix - uses: ./.github/workflows/build_util.yml - strategy: - fail-fast: false - matrix: - toolchain: - - 'aarch64-gcc' - #- 'arm-clang' - - 'arm-gcc' - - 'msp430-gcc' - - 'riscv-gcc' - - 'rx-gcc' - with: - build-system: 'make' - toolchain: ${{ matrix.toolchain }} - build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain]) }} - one-per-family: true + code-metrics: + needs: cmake + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Checkout TinyUSB + uses: actions/checkout@v4 - # --------------------------------------- - # Build IAR - # Since IAR Token secret is not passed to forked PR, only build non-forked PR with make. - # cmake is built by circle-ci. Due to IAR limit capacity, only build oe per family - # --------------------------------------- - arm-iar: - if: false # disable for now since we got reach capacity limit too often - #if: github.event_name == 'push' && github.repository_owner == 'hathach' - needs: set-matrix - uses: ./.github/workflows/build_util.yml - secrets: inherit - strategy: - fail-fast: false - matrix: - build-system: - - 'make' - with: - build-system: ${{ matrix.build-system }} - toolchain: 'arm-iar' - build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)['arm-iar']) }} - one-per-family: true + - name: Download Artifacts + uses: actions/download-artifact@v5 + with: + pattern: metrics-* + path: cmake-build + merge-multiple: true + + - name: Aggregate Code Metrics + run: | + python tools/get_deps.py + python tools/metrics.py combine -j -m -f tinyusb/src cmake-build/*/metrics.json + + - name: Upload Metrics Artifact + if: github.event_name == 'push' + uses: actions/upload-artifact@v5 + with: + name: metrics-tinyusb + path: metrics.json + + - name: Download Base Branch Metrics + if: github.event_name != 'push' + uses: dawidd6/action-download-artifact@v11 + with: + workflow: build.yml + branch: ${{ github.base_ref }} + name: metrics-tinyusb + path: base-metrics + continue-on-error: true + + - name: Compare with Base Branch + if: github.event_name != 'push' + run: | + if [ -f base-metrics/metrics.json ]; then + python tools/metrics.py compare -m -f tinyusb/src base-metrics/metrics.json metrics.json + cat metrics_compare.md + else + echo "No base metrics found, skipping comparison" + cp metrics.md metrics_compare.md + fi + + - name: Save PR number + if: github.event_name == 'pull_request' + run: echo ${{ github.event.number }} > pr_number.txt + + - name: Upload Metrics Comment Artifact + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v5 + with: + name: metrics-comment + path: | + metrics_compare.md + pr_number.txt + + - name: Post Code Metrics as PR Comment + if: github.event_name != 'push' + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: code-metrics + path: metrics_compare.md # --------------------------------------- # Build Make/CMake on Windows/MacOS @@ -134,14 +159,13 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, macos-latest] - build-system: [ 'make', 'cmake' ] + os: [ windows-latest, macos-latest ] with: os: ${{ matrix.os }} - build-system: ${{ matrix.build-system }} + build-system: 'cmake-make' toolchain: 'arm-gcc-${{ matrix.os }}' build-args: '["stm32h7"]' - one-per-family: true + build-options: '--one-random' # --------------------------------------- # Zephyr @@ -184,7 +208,6 @@ jobs: build-system: 'cmake' toolchain: ${{ matrix.toolchain }} build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.hil_json)[matrix.toolchain]) }} - one-per-family: true upload-artifacts: true # --------------------------------------- @@ -192,11 +215,9 @@ jobs: # self-hosted on local VM, for attached hardware checkout HIL_JSON # --------------------------------------- hil-tinyusb: - if: | - github.repository_owner == 'hathach' && - (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch') + if: github.repository_owner == 'hathach' && github.event_name != 'push' needs: hil-build - runs-on: [self-hosted, X64, hathach, hardware-in-the-loop] + runs-on: [ self-hosted, X64, hathach, hardware-in-the-loop ] steps: - name: Get Skip Boards from previous run if: github.run_attempt != '1' @@ -221,6 +242,7 @@ jobs: - name: Download Artifacts uses: actions/download-artifact@v5 with: + pattern: binaries-* path: cmake-build merge-multiple: true @@ -237,8 +259,8 @@ jobs: if: | github.repository_owner == 'hathach' && github.event.pull_request.head.repo.fork == false && - (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch') - runs-on: [self-hosted, Linux, X64, hifiphile] + github.event_name != 'push' + runs-on: [ self-hosted, Linux, X64, hifiphile ] env: IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }} steps: diff --git a/.github/workflows/build_util.yml b/.github/workflows/build_util.yml index 55901b838..1cbd02f1b 100644 --- a/.github/workflows/build_util.yml +++ b/.github/workflows/build_util.yml @@ -12,11 +12,15 @@ on: build-args: required: true type: string - one-per-family: + build-options: + required: false + default: '' + type: string + upload-artifacts: required: false default: false type: boolean - upload-artifacts: + upload-metrics: required: false default: false type: boolean @@ -47,16 +51,6 @@ 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 env: IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }} @@ -64,16 +58,26 @@ jobs: run: | if [ "$TOOLCHAIN" == "esp-idf" ]; then docker run --rm -v $PWD:/project -w /project espressif/idf:tinyusb python tools/build.py ${{ matrix.arg }} + elif [ "${{ inputs.build-system }}" == "cmake-make" ] || [ "${{ inputs.build-system }}" == "make-cmake" ]; then + python tools/build.py -s make ${{ steps.setup-toolchain.outputs.build_option }} ${{ inputs.build-options }} ${{ matrix.arg }} + python tools/build.py -s cmake ${{ steps.setup-toolchain.outputs.build_option }} ${{ inputs.build-options }} ${{ matrix.arg }} else - python tools/build.py -s ${{ inputs.build-system }} ${{ steps.setup-toolchain.outputs.build_option }} ${{ steps.set-one-per-family.outputs.build_option }} ${{ matrix.arg }} + python tools/build.py -s ${{ inputs.build-system }} ${{ steps.setup-toolchain.outputs.build_option }} ${{ inputs.build-options }} ${{ matrix.arg }} fi shell: bash + - name: Upload Artifacts for Metrics + if: ${{ inputs.upload-metrics }} + uses: actions/upload-artifact@v5 + with: + name: metrics-${{ matrix.arg }} + path: cmake-build/cmake-build-*/metrics.json + - name: Upload Artifacts for Hardware Testing if: ${{ inputs.upload-artifacts }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: - name: ${{ matrix.arg }} + name: binaries-${{ matrix.arg }} path: | cmake-build/cmake-build-*/*/*/*.elf cmake-build/cmake-build-*/*/*/*.bin diff --git a/.github/workflows/ci_set_matrix.py b/.github/workflows/ci_set_matrix.py index 9d0e42c2e..933a8375f 100755 --- a/.github/workflows/ci_set_matrix.py +++ b/.github/workflows/ci_set_matrix.py @@ -15,39 +15,29 @@ toolchain_list = [ # family: [supported toolchain] family_list = { - "at32f402_405 at32f403a_407 at32f413 at32f415 at32f423 at32f425 at32f435_437": ["arm-gcc"], - "broadcom_32bit": ["arm-gcc"], + "at32f402_405 at32f403a_407 at32f413 at32f415 at32f423 at32f425 at32f435_437 broadcom_32bit da1469x": ["arm-gcc"], "broadcom_64bit": ["aarch64-gcc"], "ch32v10x ch32v20x ch32v30x fomu gd32vf103": ["riscv-gcc"], - "da1469x": ["arm-gcc"], "imxrt": ["arm-gcc", "arm-clang"], "kinetis_k kinetis_kl kinetis_k32l2": ["arm-gcc", "arm-clang"], - "lpc11 lpc13 lpc15": ["arm-gcc", "arm-clang"], - "lpc17 lpc18 lpc40 lpc43": ["arm-gcc", "arm-clang"], + "lpc11 lpc13 lpc15 lpc17 lpc18 lpc40 lpc43": ["arm-gcc", "arm-clang"], "lpc51 lpc54 lpc55": ["arm-gcc", "arm-clang"], - "maxim": ["arm-gcc"], - "mcx": ["arm-gcc"], - "mm32": ["arm-gcc"], + "maxim mcx mm32 msp432e4 tm4c": ["arm-gcc"], "msp430": ["msp430-gcc"], - "msp432e4 tm4c": ["arm-gcc"], "nrf": ["arm-gcc", "arm-clang"], - "nuc100_120 nuc121_125 nuc126 nuc505": ["arm-gcc"], + "nuc100_120 nuc121_125 nuc126 nuc505 xmc4000": ["arm-gcc"], "ra": ["arm-gcc"], "rp2040": ["arm-gcc"], "rx": ["rx-gcc"], - "samd11 samd2x_l2x": ["arm-gcc", "arm-clang"], - "samd5x_e5x samg": ["arm-gcc", "arm-clang"], + "samd11 samd2x_l2x samd5x_e5x samg": ["arm-gcc", "arm-clang"], "stm32c0 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"], - "stm32h7rs": ["arm-gcc", "arm-clang", "arm-iar"], - "stm32l0 stm32l4": ["arm-gcc", "arm-clang", "arm-iar"], + "stm32h7rs stm32l0 stm32l4": ["arm-gcc", "arm-clang", "arm-iar"], "stm32n6": ["arm-gcc"], - "stm32u0 stm32u5 stm32wb": ["arm-gcc", "arm-clang", "arm-iar"], - "stm32wba": ["arm-gcc", "arm-clang"], - "xmc4000": ["arm-gcc"], + "stm32u0 stm32u5 stm32wb stm32wba": ["arm-gcc", "arm-clang", "arm-iar"], "-bespressif_s2_devkitc": ["esp-idf"], # S3, P4 will be built by hil test # "-bespressif_s3_devkitm": ["esp-idf"], diff --git a/.github/workflows/metrics_comment.yml b/.github/workflows/metrics_comment.yml new file mode 100644 index 000000000..2f1b0d631 --- /dev/null +++ b/.github/workflows/metrics_comment.yml @@ -0,0 +1,38 @@ +name: Metrics Comment + +on: + workflow_run: + workflows: ["Build"] + types: + - completed + +jobs: + post-comment: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' + permissions: + pull-requests: write + steps: + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + name: metrics-comment + + - name: Read PR Number + id: pr_number + run: | + if [ -f pr_number.txt ]; then + echo "number=$(cat pr_number.txt)" >> $GITHUB_OUTPUT + fi + + - name: Post Code Metrics as PR Comment + if: steps.pr_number.outputs.number != '' + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: code-metrics + path: metrics_compare.md + number: ${{ steps.pr_number.outputs.number }} |
