From d44283d90f6c53dc1a51299025b051ab2441879e Mon Sep 17 00:00:00 2001 From: Manna Harbour <51143715+manna-harbour@users.noreply.github.com> Date: Thu, 26 May 2022 15:53:54 +1000 Subject: [PATCH] Add debug mode and more error messages to workflows --- .../workflows/build-example-corne-ish_zen.yml | 1 + .../build-example-corne-nice_nano-display.yml | 1 + .../workflows/build-example-mousekeyspr.yml | 1 + .../build-example-tbkmini-nice_nano_v2.yml | 1 + .github/workflows/build-inputs.yml | 1 + .github/workflows/main.yml | 57 ++++++++++++++----- .github/workflows/test-all-boards.yml | 1 + .github/workflows/test-all-configs.yml | 1 + .../test-all-promicro-controllers.yml | 1 + .../workflows/test-all-promicro-shields.yml | 1 + .../workflows/test-all-xiao-controllers.yml | 1 + .github/workflows/test-all-xiao-shields.yml | 1 + .github/workflows/test-build.yml | 1 + readme.org | 2 + 14 files changed, 57 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-example-corne-ish_zen.yml b/.github/workflows/build-example-corne-ish_zen.yml index cdeec2a..a392b04 100644 --- a/.github/workflows/build-example-corne-ish_zen.yml +++ b/.github/workflows/build-example-corne-ish_zen.yml @@ -6,5 +6,6 @@ on: workflow_dispatch jobs: build: uses: ./.github/workflows/main.yml + secrets: inherit with: board: '["corne-ish_zen_left","corne-ish_zen_right"]' diff --git a/.github/workflows/build-example-corne-nice_nano-display.yml b/.github/workflows/build-example-corne-nice_nano-display.yml index e696b22..791f7b8 100644 --- a/.github/workflows/build-example-corne-nice_nano-display.yml +++ b/.github/workflows/build-example-corne-nice_nano-display.yml @@ -6,6 +6,7 @@ on: workflow_dispatch jobs: build: uses: ./.github/workflows/main.yml + secrets: inherit with: board: '["nice_nano"]' shield: '["corne_left","corne_right"]' diff --git a/.github/workflows/build-example-mousekeyspr.yml b/.github/workflows/build-example-mousekeyspr.yml index 10a4911..86f4240 100644 --- a/.github/workflows/build-example-mousekeyspr.yml +++ b/.github/workflows/build-example-mousekeyspr.yml @@ -6,6 +6,7 @@ on: workflow_dispatch jobs: build: uses: ./.github/workflows/main.yml + secrets: inherit with: board: '["nice_nano"]' shield: '["corne_left"]' diff --git a/.github/workflows/build-example-tbkmini-nice_nano_v2.yml b/.github/workflows/build-example-tbkmini-nice_nano_v2.yml index 990ed1b..8950724 100644 --- a/.github/workflows/build-example-tbkmini-nice_nano_v2.yml +++ b/.github/workflows/build-example-tbkmini-nice_nano_v2.yml @@ -6,6 +6,7 @@ on: workflow_dispatch jobs: build: uses: ./.github/workflows/main.yml + secrets: inherit with: board: '["nice_nano_v2"]' shield: '["tbkmini_left","tbkmini_right"]' diff --git a/.github/workflows/build-inputs.yml b/.github/workflows/build-inputs.yml index 4bdb282..dcf6acf 100644 --- a/.github/workflows/build-inputs.yml +++ b/.github/workflows/build-inputs.yml @@ -79,6 +79,7 @@ jobs: set-output "branches" "${{ github.event.inputs.branches }}" build: uses: ./.github/workflows/main.yml + secrets: inherit needs: process-inputs with: board: ${{ needs.process-inputs.outputs.board }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 22f5a53..2a5f236 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,6 +54,8 @@ jobs: custom_config: ${{ fromJSON(inputs.custom_config) }} kconfig: ${{ fromJSON(inputs.kconfig) }} branches: ${{ fromJSON(inputs.branches) }} + env: + MIRYOKU_DEBUG: ${{ secrets.MIRYOKU_DEBUG }} steps: - name: checkout uses: actions/checkout@v3 @@ -62,6 +64,8 @@ jobs: - name: main id: variables run: | + test "$MIRYOKU_DEBUG" = 'MIRYOKU_DEBUG_TRUE' && set -x + echo "::group::variables" if [ -n "${{ matrix.shield }}" -a "${{ matrix.shield }}" != "default" ] @@ -110,15 +114,15 @@ jobs: echo "::set-output name=artifact-dir::$artifacts_dir" mkdir "$artifacts_dir" - cp "$configfile" "$artifacts_dir" + test "$MIRYOKU_DEBUG" = 'MIRYOKU_DEBUG_TRUE' && cp "$configfile" "$artifacts_dir" if [ -n "${{ matrix.kconfig }}" -a "${{ matrix.kconfig }}" != 'default' ] then kconfig_file="${GITHUB_WORKSPACE}/miryoku_zmk/config/$keyboard_split.conf" echo "${{ matrix.kconfig }}" >> "$kconfig_file" - cp "$kconfig_file" "$artifacts_dir" artifact_build_name="$artifact_build_name kconfig_"`echo "${{ matrix.kconfig }}" | md5sum | cut -d ' ' -f 1` fi + test "$MIRYOKU_DEBUG" = 'MIRYOKU_DEBUG_TRUE' && test -f "$kconfig_file" && cp "$kconfig_file" "$artifacts_dir" . "${GITHUB_WORKSPACE}/miryoku_zmk/.github/workflows/zmk" @@ -136,7 +140,7 @@ jobs: outboard_file="${GITHUB_WORKSPACE}/miryoku_zmk/.github/workflows/outboards/$outboard" if [ -f "$outboard_file" ] then - cp "$outboard_file" "$artifacts_dir" + test "$MIRYOKU_DEBUG" = 'MIRYOKU_DEBUG_TRUE' && cp "$outboard_file" "$artifacts_dir" . "$outboard_file" outboard_dir="${GITHUB_WORKSPACE}/outboards/$outboard" if [ -n "$outboard_repository" -a -n "$outboard_ref" ] @@ -208,42 +212,67 @@ jobs: continue-on-error: true - name: build run: | + if [ "$MIRYOKU_DEBUG" = 'MIRYOKU_DEBUG_TRUE' ] + then + set -x + #west_debug='-v' + #west_build_debug='-t rom_report -t ram_report' + fi + echo "::group::setup" cd "${GITHUB_WORKSPACE}/zmk" - west init -l app - west update - west zephyr-export + west $west_debug init -l app + west $west_debug update + west $west_debug zephyr-export echo "::endgroup::" echo "::group::build" log='build.log' - message='::error::Build failed with exit code' + build_failed_message='::error::Build failed with exit code' EX_UNAVAILABLE='69' + EX_DATAERR='65' cd "${GITHUB_WORKSPACE}/zmk/app" { - west build -b ${{ matrix.board }} -- ${{ steps.variables.outputs.shield-arg }} -DZMK_CONFIG="${GITHUB_WORKSPACE}/miryoku_zmk/config" || - echo "$message $?." ; + west $west_debug build -b ${{ matrix.board }} $west_build_debug -- ${{ steps.variables.outputs.shield-arg }} -DZMK_CONFIG="${GITHUB_WORKSPACE}/miryoku_zmk/config" || + echo "$build_failed_message $?." ; } 2>&1 | tee "$log" - if grep -q "$message" "$log" + if grep -q 'Invalid BOARD; see above.' "$log" then - false + echo '::error::Board not found. Unsupported or incorrect board.' + (exit "$EX_UNAVAILABLE") + fi + if grep -q 'Failed to locate keymap file!' "$log" + then + echo '::error::Keymap not found. Unsupported or incorrect keyboard.' + (exit "$EX_UNAVAILABLE") + fi + if grep -q 'Invalid SHIELD' "$log" + then + echo '::error::Keymap found but shield not found. Board used for shield.' + (exit "$EX_DATAERR") fi if ! grep -q 'Using keymap file: .*/config/[^/]*.keymap$' "$log" then - echo '::error::Miryoku keyboard keymap not found.' - exit "$EX_UNAVAILABLE" + echo '::error::Miryoku keyboard keymap not found. Unsupported or incorrect keyboard.' + (exit "$EX_UNAVAILABLE") + fi + if grep -q "$build_failed_message" "$log" + then + false fi echo "::endgroup::" echo "::group::copy" - for extension in "uf2" + for extension in 'uf2' 'bin' 'hex' do file="${GITHUB_WORKSPACE}/zmk/app/build/zephyr/zmk.$extension" if [ -f "$file" ] then cp "$file" "${{ steps.variables.outputs.artifact-dir }}/${{ steps.variables.outputs.artifact-build-name }}.$extension" + test "$MIRYOKU_DEBUG" = 'MIRYOKU_DEBUG_TRUE' || break fi done + test "$MIRYOKU_DEBUG" = 'MIRYOKU_DEBUG_TRUE' && cp "${GITHUB_WORKSPACE}/zmk/app/build/zephyr/.config" "${{ steps.variables.outputs.artifact-dir }}" echo "::endgroup::" - name: upload uses: actions/upload-artifact@v3 diff --git a/.github/workflows/test-all-boards.yml b/.github/workflows/test-all-boards.yml index 695fd26..8678242 100644 --- a/.github/workflows/test-all-boards.yml +++ b/.github/workflows/test-all-boards.yml @@ -7,6 +7,7 @@ jobs: build: if: github.repository_owner == 'manna-harbour' uses: ./.github/workflows/main.yml + secrets: inherit with: board: '[ "adv360_left","adv360_right", diff --git a/.github/workflows/test-all-configs.yml b/.github/workflows/test-all-configs.yml index 430cefe..f26ffcf 100644 --- a/.github/workflows/test-all-configs.yml +++ b/.github/workflows/test-all-configs.yml @@ -7,6 +7,7 @@ jobs: build: if: github.repository_owner == 'manna-harbour' uses: ./.github/workflows/main.yml + secrets: inherit with: board: '["nice_nano"]' shield: '["corne_left"]' diff --git a/.github/workflows/test-all-promicro-controllers.yml b/.github/workflows/test-all-promicro-controllers.yml index 286e0e6..97aa83a 100644 --- a/.github/workflows/test-all-promicro-controllers.yml +++ b/.github/workflows/test-all-promicro-controllers.yml @@ -7,6 +7,7 @@ jobs: build: if: github.repository_owner == 'manna-harbour' uses: ./.github/workflows/main.yml + secrets: inherit with: board: '[ "bluemicro840_v1", diff --git a/.github/workflows/test-all-promicro-shields.yml b/.github/workflows/test-all-promicro-shields.yml index 2a422d7..49d5989 100644 --- a/.github/workflows/test-all-promicro-shields.yml +++ b/.github/workflows/test-all-promicro-shields.yml @@ -7,6 +7,7 @@ jobs: build: if: github.repository_owner == 'manna-harbour' uses: ./.github/workflows/main.yml + secrets: inherit with: board: '["nice_nano_v2"]' shield: '[ diff --git a/.github/workflows/test-all-xiao-controllers.yml b/.github/workflows/test-all-xiao-controllers.yml index d35dda9..fcc130b 100644 --- a/.github/workflows/test-all-xiao-controllers.yml +++ b/.github/workflows/test-all-xiao-controllers.yml @@ -7,6 +7,7 @@ jobs: build: if: github.repository_owner == 'manna-harbour' uses: ./.github/workflows/main.yml + secrets: inherit with: board: '[ "seeeduino_xiao", diff --git a/.github/workflows/test-all-xiao-shields.yml b/.github/workflows/test-all-xiao-shields.yml index bde7a36..1bd46f4 100644 --- a/.github/workflows/test-all-xiao-shields.yml +++ b/.github/workflows/test-all-xiao-shields.yml @@ -7,6 +7,7 @@ jobs: build: if: github.repository_owner == 'manna-harbour' uses: ./.github/workflows/main.yml + secrets: inherit with: board: '["seeeduino_xiao"]' shield: '[ diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index c6f067a..24fb61c 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -10,6 +10,7 @@ jobs: build: if: github.repository_owner == 'manna-harbour' uses: ./.github/workflows/main.yml + secrets: inherit with: board: '["nice_nano"]' shield: '["corne_left"]' diff --git a/readme.org b/readme.org index fabba4f..bdc3729 100644 --- a/readme.org +++ b/readme.org @@ -44,6 +44,8 @@ See the [[docs/quickstart][Miryoku ZMK Quickstart Guide]] for step by step instr Workflow files are in [[.github/workflows]]. +To enable Miryoku ZMK workflow debugging, set the following [[https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository][secret]] in the repository: ~MIRYOKU_DEBUG~ to ~MIRYOKU_DEBUG_TRUE~. Optionally also [[https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging][enable step debugging]]. + **** Build Examples