Refactor workflow and outboards

- change "merge" option to "branches"
 - use first branch as base and merge rest
 - use "zmk" file instead of manifest
 - checkout to subdirectories
 - checkout zmk manually
 - use west just for zephyr
 - use absolute paths
 - handle simultaneous board and shield outboards
 - change outboard and directory names
This commit is contained in:
Manna Harbour 2022-04-07 10:19:04 +10:00
parent 5a0a9e1b8f
commit dab63d5540
46 changed files with 127 additions and 167 deletions

View File

@ -1,7 +1,7 @@
# Copyright 2022 Manna Harbour # Copyright 2022 Manna Harbour
# https://github.com/manna-harbour/miryoku # https://github.com/manna-harbour/miryoku
name: 'Build Example corne nice_nano mousekeyspr' name: 'Build Example mousekeyspr'
on: on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
@ -12,4 +12,4 @@ jobs:
shield: '["corne_left","corne_right"]' shield: '["corne_left","corne_right"]'
config: '["#define MIRYOKU_KLUDEGE_MOUSEKEYSPR"]' config: '["#define MIRYOKU_KLUDEGE_MOUSEKEYSPR"]'
kconfig: '["CONFIG_ZMK_MOUSE=y"]' kconfig: '["CONFIG_ZMK_MOUSE=y"]'
merge: '["=krikun98/zmk/mouse-pr"]' branches: '["zmkfirmware/zmk/main krikun98/zmk/mouse-pr","krikun98/zmk/mouse-pr"]'

View File

@ -40,7 +40,7 @@ on:
description: 'Kconfig' description: 'Kconfig'
required: false required: false
default: 'default' default: 'default'
merge: branches:
description: 'ZMK Branches' description: 'ZMK Branches'
required: false required: false
default: 'default' default: 'default'
@ -57,7 +57,7 @@ jobs:
mapping: ${{ steps.process-inputs.outputs.mapping }} mapping: ${{ steps.process-inputs.outputs.mapping }}
config: ${{ steps.process-inputs.outputs.config }} config: ${{ steps.process-inputs.outputs.config }}
kconfig: ${{ steps.process-inputs.outputs.kconfig }} kconfig: ${{ steps.process-inputs.outputs.kconfig }}
merge: ${{ steps.process-inputs.outputs.merge }} branches: ${{ steps.process-inputs.outputs.branches }}
steps: steps:
- name: Process inputs - name: Process inputs
id: process-inputs id: process-inputs
@ -76,7 +76,7 @@ jobs:
set-output "mapping" "${{ github.event.inputs.mapping }}" set-output "mapping" "${{ github.event.inputs.mapping }}"
set-output "config" "${{ github.event.inputs.config }}" set-output "config" "${{ github.event.inputs.config }}"
set-output "kconfig" "${{ github.event.inputs.kconfig }}" set-output "kconfig" "${{ github.event.inputs.kconfig }}"
set-output "merge" "${{ github.event.inputs.merge }}" set-output "branches" "${{ github.event.inputs.branches }}"
build: build:
uses: manna-harbour/zmk-config/.github/workflows/main.yml@31a649e5571b4572d7010561dd3f191922cd9410 uses: manna-harbour/zmk-config/.github/workflows/main.yml@31a649e5571b4572d7010561dd3f191922cd9410
needs: process-inputs needs: process-inputs
@ -90,4 +90,4 @@ jobs:
mapping: ${{ needs.process-inputs.outputs.mapping }} mapping: ${{ needs.process-inputs.outputs.mapping }}
config: ${{ needs.process-inputs.outputs.config }} config: ${{ needs.process-inputs.outputs.config }}
kconfig: ${{ needs.process-inputs.outputs.kconfig }} kconfig: ${{ needs.process-inputs.outputs.kconfig }}
merge: ${{ needs.process-inputs.outputs.merge }} branches: ${{ needs.process-inputs.outputs.branches }}

View File

@ -32,7 +32,7 @@ on:
kconfig: kconfig:
type: string type: string
default: '["default"]' default: '["default"]'
merge: branches:
type: string type: string
default: '["default"]' default: '["default"]'
@ -53,11 +53,13 @@ jobs:
mapping: ${{ fromJSON(inputs.mapping) }} mapping: ${{ fromJSON(inputs.mapping) }}
config: ${{ fromJSON(inputs.config) }} config: ${{ fromJSON(inputs.config) }}
kconfig: ${{ fromJSON(inputs.kconfig) }} kconfig: ${{ fromJSON(inputs.kconfig) }}
merge: ${{ fromJSON(inputs.merge) }} branches: ${{ fromJSON(inputs.branches) }}
steps: steps:
- name: Checkout - name: checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Process variables with:
path: 'miryoku_zmk'
- name: main
id: variables id: variables
run: | run: |
if [ -n "${{ matrix.shield }}" -a "${{ matrix.shield }}" != "default" ] if [ -n "${{ matrix.shield }}" -a "${{ matrix.shield }}" != "default" ]
@ -73,7 +75,7 @@ jobs:
keyboard_split="$keyboard" keyboard_split="$keyboard"
keyboard_base=`echo "$keyboard" | sed 's/_\(left\|right\)//'` keyboard_base=`echo "$keyboard" | sed 's/_\(left\|right\)//'`
configfile="${GITHUB_WORKSPACE}/miryoku/custom_config.h" configfile="${GITHUB_WORKSPACE}/miryoku_zmk/miryoku/custom_config.h"
echo "::set-output name=configfile::$configfile" echo "::set-output name=configfile::$configfile"
artifact_build_name="miryoku_zmk $shield ${{ matrix.board }}" artifact_build_name="miryoku_zmk $shield ${{ matrix.board }}"
@ -96,160 +98,119 @@ jobs:
esac esac
done done
artifacts_dir="artifacts" artifacts_dir="${GITHUB_WORKSPACE}/artifacts"
echo "::set-output name=artifact-dir::$artifacts_dir" echo "::set-output name=artifact-dir::$artifacts_dir"
mkdir "$artifacts_dir" mkdir "$artifacts_dir"
cp "$configfile" "$artifacts_dir" cp "$configfile" "$artifacts_dir"
cat "$configfile"
if [ -n "${{ matrix.kconfig }}" -a "${{ matrix.kconfig }}" != 'default' ] if [ -n "${{ matrix.kconfig }}" -a "${{ matrix.kconfig }}" != 'default' ]
then then
kconfig_file="config/$keyboard_split.conf" kconfig_file="${GITHUB_WORKSPACE}/miryoku_zmk/config/$keyboard_split.conf"
echo "${{ matrix.kconfig }}" >> "$kconfig_file" echo "${{ matrix.kconfig }}" >> "$kconfig_file"
cp "$kconfig_file" "$artifacts_dir" cp "$kconfig_file" "$artifacts_dir"
cat "$kconfig_file"
artifact_build_name="$artifact_build_name kconfig_"`echo "${{ matrix.kconfig }}" | md5sum | cut -d ' ' -f 1` artifact_build_name="$artifact_build_name kconfig_"`echo "${{ matrix.kconfig }}" | md5sum | cut -d ' ' -f 1`
fi fi
if [ -n "${{ matrix.merge }}" -a "${{ matrix.merge }}" != 'default' ] . "${GITHUB_WORKSPACE}/miryoku_zmk/.github/workflows/zmk"
then
artifact_build_name="$artifact_build_name merge_"`echo "${{ matrix.merge }}" | md5sum | cut -d ' ' -f 1`
for branch in ${{ matrix.merge }}
do
if [ `echo "$branch" | cut -c1` = '=' ]
then
zmk=`echo "$branch" | cut -c2-`
else
merge="$merge $branch"
fi
done
fi
echo "::set-output name=merge::$merge"
echo "::set-output name=zmk::$zmk"
outboard_dir=".github/workflows/outboards"
if [ -n "$shield" ] if [ -n "$shield" ]
then then
outboard_file="$outboard_dir/$keyboard_base.shield.outboard" outboards="shields/$keyboard_base boards/${{ matrix.board }}"
else else
outboard_file="$outboard_dir/$keyboard_base.board.outboard" outboards="boards/$keyboard_base"
fi fi
if [ ! -f "$outboard_file" ] for outboard in $outboards
do
outboard_file="${GITHUB_WORKSPACE}/miryoku_zmk/.github/workflows/outboards/$outboard"
if [ -f "$outboard_file" ]
then
cp "$outboard_file" "$artifacts_dir"
. "$outboard_file"
outboard_dir="${GITHUB_WORKSPACE}/outboards/$outboard"
if [ -n "$outboard_repository" -a -n "$outboard_ref" ]
then
git clone -b "$outboard_ref" --depth 1 "https://github.com/$outboard_repository.git" "$outboard_dir"
if [ -n "$outboard_from" -a -n "$outboard_to" ]
then
to="${GITHUB_WORKSPACE}/miryoku_zmk/config/$outboard_to"
mkdir -p `dirname "$to"`
ln -sr "$outboard_dir/$outboard_from" "$to"
fi
fi
outboard_repository=''
outboard_ref=''
outboard_from=''
outboard_to=''
fi
done
if [ -n "${{ matrix.branches }}" -a "${{ matrix.branches }}" != 'default' ]
then then
outboard_file="$outboard_dir/$keyboard_base.outboard" artifact_build_name="$artifact_build_name branches_"`echo "${{ matrix.branches }}" | md5sum | cut -d ' ' -f 1`
zmk=`echo "${{ matrix.branches }}" | cut -d ' ' -f 1`
merges=`echo "${{ matrix.branches }}" | cut -d ' ' -f 2- -s`
fi fi
if [ -f "$outboard_file" ]
then
grep -v '^#' "$outboard_file" >> $GITHUB_ENV
cat "$outboard_file"
cp "$outboard_file" "$artifacts_dir"
fi
echo "::set-output name=outboard_chekout_dir::outboard"
artifact_build_name=`echo $artifact_build_name | tr ' ' '-'` artifact_build_name=`echo $artifact_build_name | tr ' ' '-'`
echo "::set-output name=artifact-build-name::$artifact_build_name" echo "::set-output name=artifact-build-name::$artifact_build_name"
echo "::set-output name=artifact-generic-name::"`echo "$artifact_build_name" | sed 's/_\(left\|right\)//'` echo "::set-output name=artifact-generic-name::"`echo "$artifact_build_name" | sed 's/_\(left\|right\)//'`
- name: Checkout outboard user=`echo "$zmk" | cut -f 1 -d '/'`
if: ${{ env.outboard_repository != '' && env.outboard_ref != '' }} repo=`echo "$zmk" | cut -f 2 -d '/'`
uses: actions/checkout@v2 branch=`echo "$zmk" | cut -f 3- -d '/'`
with: git clone -b "$branch" --depth 1 "https://github.com/$user/$repo.git" 'zmk'
repository: ${{ env.outboard_repository }}
ref: ${{ env.outboard_ref }} if [ -n "$merges" ]
path: ${{ steps.variables.outputs.outboard_chekout_dir }} then
- name: Link outboard cd "${GITHUB_WORKSPACE}/zmk"
if: ${{ env.outboard_from != '' && env.outboard_to != '' }} git config user.name "${GITHUB_ACTOR}"
run: | git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
mkdir -p `dirname "config/${{ env.outboard_to }}"` git fetch --unshallow
ln -sr ${{ steps.variables.outputs.outboard_chekout_dir }}/${{ env.outboard_from }} config/${{ env.outboard_to }} for merge in "$merges"
- name: Generate manifest from outboard do
if: ${{ env.outboard_url_base != '' && env.outboard_revision != '' }} user=`echo "$merge" | cut -f 1 -d '/'`
run: | repo=`echo "$merge" | cut -f 2 -d '/'`
echo "manifest:\n remotes:\n - name: outboard\n url-base: ${{ env.outboard_url_base }}\n projects:\n - name: zmk\n remote: outboard\n revision: ${{ env.outboard_revision }}\n import: app/west.yml\n self:\n path: config" > config/west.yml branch=`echo "$merge" | cut -f 3- -d '/'`
cat config/west.yml remote="$user-$repo"
- name: Copy manifest from outboard git remote add "$remote" "https://github.com/$user/$repo.git"
if: ${{ env.outboard_manifest != '' }} git fetch "$remote" "$branch"
run: | git merge "$remote/$branch"
cp ${{ steps.variables.outputs.outboard_chekout_dir }}/${{ env.outboard_manifest }} config/west.yml git remote remove "$remote"
cat config/west.yml git status
- name: Generate manifest from merge field done
if: ${{ steps.variables.outputs.zmk != '' }} fi
run: | - name: cache
user=`echo ${{ steps.variables.outputs.zmk }} | cut -f 1 -d '/'`
repo=`echo ${{ steps.variables.outputs.zmk }} | cut -f 2 -d '/'`
branch=`echo ${{ steps.variables.outputs.zmk }} | cut -f 3- -d '/'`
remote="$user-$repo"
echo "manifest:\n remotes:\n - name: $remote\n url-base: https://github.com/$user\n projects:\n - name: zmk\n remote: $remote\n repo-path: $repo\n revision: $branch\n import: app/west.yml\n self:\n path: config" > config/west.yml
cat config/west.yml
- name: Cache zmk
if: true if: true
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: | path: |
zmk/ zmk/modules/
key: zmk ${{ hashFiles('config/west.yml') }} ${{ matrix.merge }} zmk/zephyr/
timeout-minutes: 2
continue-on-error: true
- name: West init
run: west init -l config
- name: West update zmk
run: west update zmk
- name: Merge branches
if: ${{ steps.variables.outputs.merge != '' }}
run: |
cd zmk
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
for merge in ${{ steps.variables.outputs.merge }}
do
user=`echo "$merge" | cut -f 1 -d '/'`
repo=`echo "$merge" | cut -f 2 -d '/'`
branch=`echo "$merge" | cut -f 3- -d '/'`
remote="$user-$repo"
git remote add "$remote" "https://github.com/$user/$repo.git"
git fetch "$remote" "$branch"
git merge "$remote/$branch"
git remote remove "$remote"
git status
done
cd ..
cp -a zmk zmk.merged
- name: Cache zephyr
if: true
uses: actions/cache@v3
with:
path: |
modules/
tools/
zephyr/
key: zephyr ${{ runner.os }} ${{ hashFiles('zmk/app/west.yml') }} key: zephyr ${{ runner.os }} ${{ hashFiles('zmk/app/west.yml') }}
timeout-minutes: 2 timeout-minutes: 2
continue-on-error: true continue-on-error: true
- name: West update - name: build
run: west update
- name: Restore merge
if: ${{ steps.variables.outputs.merge != '' }}
run: | run: |
mv zmk zmk.default cd "${GITHUB_WORKSPACE}/zmk"
mv zmk.merged zmk west init -l app
- name: Export Zephyr CMake package west update
run: west zephyr-export west zephyr-export
- name: Build
run: west build -s zmk/app -b ${{ matrix.board }} -- ${{ steps.variables.outputs.shield-arg }} -DZMK_CONFIG="${GITHUB_WORKSPACE}/config" cd "${GITHUB_WORKSPACE}/zmk/app"
- name: Prepare firmware artifacts west build -b ${{ matrix.board }} -- ${{ steps.variables.outputs.shield-arg }} -DZMK_CONFIG="${GITHUB_WORKSPACE}/miryoku_zmk/config"
run: |
for extension in "hex" "uf2" for extension in "uf2"
do do
file="build/zephyr/zmk.$extension" file="${GITHUB_WORKSPACE}/zmk/app/build/zephyr/zmk.$extension"
if [ -f "$file" ] if [ -f "$file" ]
then then
cp "$file" "${{ steps.variables.outputs.artifact-dir }}/${{ steps.variables.outputs.artifact-build-name }}.$extension" cp "$file" "${{ steps.variables.outputs.artifact-dir }}/${{ steps.variables.outputs.artifact-build-name }}.$extension"
fi fi
done done
- name: Archive artifacts - name: upload
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: ${{ steps.variables.outputs.artifact-generic-name }} name: ${{ steps.variables.outputs.artifact-generic-name }}
path: ${{ steps.variables.outputs.artifact-dir }} path: ${{ steps.variables.outputs.artifact-dir }}
continue-on-error: true

View File

@ -0,0 +1,4 @@
# Copyright 2022 Manna Harbour
# https://github.com/manna-harbour/miryoku
zmk=LOWPROKB/zmk/Board-Corne-ish-Zen-dedicated-work-queue

View File

@ -0,0 +1,4 @@
# Copyright 2022 Manna Harbour
# https://github.com/manna-harbour/miryoku
zmk=petejohanson/zmk/boards/ferris-02-bling-basics

View File

@ -0,0 +1,9 @@
# Copyright 2022 Manna Harbour
# https://github.com/manna-harbour/miryoku
# use with shield microdox_mod
outboard_repository=abondis/zmk-config
outboard_ref=main
outboard_from=config/boards/arm/sparkfun_nrf52840_mini
outboard_to=boards/arm/sparkfun_nrf52840_mini

View File

@ -1,8 +1,7 @@
# Copyright 2021 Manna Harbour # Copyright 2022 Manna Harbour
# https://github.com/manna-harbour/miryoku # https://github.com/manna-harbour/miryoku
outboard_repository=petejohanson/zaphod-config outboard_repository=petejohanson/zaphod-config
outboard_ref=main outboard_ref=main
outboard_from=boards/arm/zaphod outboard_from=boards/arm/zaphod
outboard_to=boards/arm/zaphod outboard_to=boards/arm/zaphod
outboard_manifest=west.yml

View File

@ -1,5 +0,0 @@
# Copyright 2021 Manna Harbour
# https://github.com/manna-harbour/miryoku
outboard_url_base=https://github.com/LOWPROKB
outboard_revision=Board-Corne-ish-Zen-dedicated-work-queue

View File

@ -1,5 +0,0 @@
# Copyright 2021 Manna Harbour
# https://github.com/manna-harbour/miryoku
outboard_url_base=https://github.com/petejohanson
outboard_revision=boards/ferris-02-bling-basics

View File

@ -1,9 +0,0 @@
# Copyright 2021 Manna Harbour
# https://github.com/manna-harbour/miryoku
# use with included board sparkfun_nrf52840_mini
outboard_repository=abondis/zmk-config
outboard_ref=main
outboard_from=config/boards
outboard_to=boards

View File

@ -0,0 +1,9 @@
# Copyright 2022 Manna Harbour
# https://github.com/manna-harbour/miryoku
# use with board sparkfun_nrf52840_mini
outboard_repository=abondis/zmk-config
outboard_ref=main
outboard_from=config/boards/shields/microdox_mod
outboard_to=boards/shields/microdox_mod

4
.github/workflows/zmk vendored Normal file
View File

@ -0,0 +1,4 @@
# Copyright 2022 Manna Harbour
# https://github.com/manna-harbour/miryoku
zmk=zmkfirmware/zmk/main

View File

@ -1,11 +0,0 @@
manifest:
remotes:
- name: zmkfirmware
url-base: https://github.com/zmkfirmware
projects:
- name: zmk
remote: zmkfirmware
revision: main
import: app/west.yml
self:
path: config

View File

@ -148,15 +148,15 @@ Appends to the [[#config-file][config]] file. Join multiple lines with ~\n~. F
Appends to [[#kconfig-configuration][Kconfig configuration]]. Join multiple lines with ~\n~. For no additonal config, leave as ~default~. Appends to [[#kconfig-configuration][Kconfig configuration]]. Join multiple lines with ~\n~. For no additonal config, leave as ~default~.
****** ZMK Branches / merge ****** ZMK Branches / branches
Used to select an alternative ZMK branch for building, and to merge branches into ZMK at build time. Used to select an alternative ZMK branch for building, and to merge branches into ZMK at build time.
An alternative ZMK branch for building is specified as ~=<user>/<repo>/<branch>~, i.e. with a leading ~=~. E.g. the default ZMK branch would be specified as ~=zmkfirmware/zmk/main~. Branches are specified in the form ~<user>/<repo>/<branch>~. E.g. the default ZMK branch would be specified as ~zmkfirmware/zmk/main~.
Branches for merging are specified as ~<user>/<repo>/<branch>~, i.e. with no leading ~=~. E.g. the default ZMK branch would be specified as ~zmkfirmware/zmk/main~. Multiple space separated branches can be specified. The first branch specified is used as an alternative ZMK branch for building. Any additional branches will be merged.
To specify multiple branches, separate with space. For no changes, leave as ~default~. For no changes, leave as ~default~.
** Supported Keyboards ** Supported Keyboards
@ -350,13 +350,13 @@ Add ~#define MIRYOKU_KLUDEGE_MOUSEKEYSPR~ to the [[#config-file][config file]].
Add ~CONFIG_ZMK_MOUSE=y~ to the [[#kconfig-configuration][Kconfig configuration]]. Add ~CONFIG_ZMK_MOUSE=y~ to the [[#kconfig-configuration][Kconfig configuration]].
[[#zmk-branches--merge][Merge or build]] from the mousekeys PR branch ~krikun98/zmk/mouse-pr~ [[#zmk-branches--branches][Merge or build]] from the mousekeys PR branch ~krikun98/zmk/mouse-pr~
For [[#workflow-builds][workflow builds]], the [[#build-inputs][Build Inputs]] workflow can be used, or for [[#build-examples][Build Examlpe]] workflows see the [[./github/workflows/build-example-corne-nice_nano-mousekeyspr.yml][Build Example corne nice_nano mousekeyspr]] workflow. For [[#workflow-builds][workflow builds]], the [[#build-inputs][Build Inputs]] workflow can be used, or for [[#build-examples][Build Examlpe]] workflows see the [[./github/workflows/build-example-mousekeyspr.yml][Build Example mousekeyspr]] workflow.
For local builds, make the changes to the local files. For local builds, make the changes to the local files.
If the PR hasn't been rebased recently the automatic merge may fail. In that case merge manually or build directly from the branch. If the PR hasn't been rebased recently the automatic merge may fail. In that case build directly from the branch or merge manually.
*** Key Emulation Combos *** Key Emulation Combos