Skip to content

Commit

Permalink
Add debug mode and more error messages to workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
manna-harbour committed Jun 2, 2022
1 parent 4620b91 commit d44283d
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-example-corne-ish_zen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-example-mousekeyspr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on: workflow_dispatch
jobs:
build:
uses: ./.github/workflows/main.yml
secrets: inherit
with:
board: '["nice_nano"]'
shield: '["corne_left"]'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-example-tbkmini-nice_nano_v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
1 change: 1 addition & 0 deletions .github/workflows/build-inputs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
57 changes: 43 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" ]
Expand Down Expand Up @@ -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"
Expand All @@ -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" ]
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-all-boards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-all-configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-all-promicro-controllers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
build:
if: github.repository_owner == 'manna-harbour'
uses: ./.github/workflows/main.yml
secrets: inherit
with:
board: '[
"bluemicro840_v1",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-all-promicro-shields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-all-xiao-controllers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
build:
if: github.repository_owner == 'manna-harbour'
uses: ./.github/workflows/main.yml
secrets: inherit
with:
board: '[
"seeeduino_xiao",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-all-xiao-shields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
build:
if: github.repository_owner == 'manna-harbour'
uses: ./.github/workflows/main.yml
secrets: inherit
with:
board: '["seeeduino_xiao"]'
shield: '[
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
2 changes: 2 additions & 0 deletions readme.org
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d44283d

Please sign in to comment.