From 73e09784876e7397fa9ac621a4d8fef95e0109e8 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+Sporqist@users.noreply.github.com> Date: Tue, 18 Jul 2023 10:55:26 +0200 Subject: [PATCH] [CI] simplify things --- .gitea/workflows/build-user-config.yml | 120 ------------------------- .gitea/workflows/build.yml | 94 ++++++++++++++++++- 2 files changed, 92 insertions(+), 122 deletions(-) delete mode 100644 .gitea/workflows/build-user-config.yml diff --git a/.gitea/workflows/build-user-config.yml b/.gitea/workflows/build-user-config.yml deleted file mode 100644 index b183c41..0000000 --- a/.gitea/workflows/build-user-config.yml +++ /dev/null @@ -1,120 +0,0 @@ -# https://github.com/zmkfirmware/zmk/blob/main/.github/workflows/build-user-config.yml -name: Reusable user config build - - -on: - workflow_call: - inputs: - build_matrix_path: - description: "Path to the build matrix file" - default: "build.yaml" - required: false - type: string - config_path: - description: "Path to the config directory" - default: "config" - required: false - type: string - fallback_binary: - description: "Fallback binary format, if no *.uf2 file was built" - default: "bin" - required: false - type: string - archive_name: - description: "Archive output file name" - default: "firmware" - required: false - type: string - -jobs: - matrix: - runs-on: ubuntu-latest - name: Fetch Build Keyboards - outputs: - build_matrix: ${{ env.build_matrix }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install yaml2json - run: python3 -m pip install remarshal - - - name: Fetch Build Matrix - run: | - echo "build_matrix=$(yaml2json '${{ inputs.build_matrix_path }}' | jq -c .)" >> $GITHUB_ENV - yaml2json "${{ inputs.build_matrix_path }}" | jq - - build: - runs-on: ubuntu-latest - container: - image: zmkfirmware/zmk-build-arm:stable - needs: matrix - name: Build - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.matrix.outputs.build_matrix) }} - steps: - - name: Prepare variables - shell: sh -x {0} - env: - shield: ${{ matrix.shield }} - run: | - echo "zephyr_version=${ZEPHYR_VERSION}" >> $GITHUB_ENV - echo "extra_cmake_args=${shield:+-DSHIELD=\"$shield\"}" >> $GITHUB_ENV - echo "display_name=${shield:+$shield - }${{ matrix.board }}" >> $GITHUB_ENV - echo "artifact_name=${shield:+$shield-}${{ matrix.board }}-zmk" >> $GITHUB_ENV - - - name: Checkout - uses: actions/checkout@v3 - - - name: Cache west modules - uses: actions/cache@v3.0.11 - continue-on-error: true - env: - cache_name: cache-zephyr-${{ env.zephyr_version }}-modules - with: - path: | - modules/ - tools/ - zephyr/ - bootloader/ - zmk/ - key: ${{ runner.os }}-build-${{ env.cache_name }}-${{ hashFiles('**/west.yml', '**/build.yaml') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache_name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: West Init - run: west init -l "${{ inputs.config_path }}" - - - name: West Update - run: west update - - - name: West Zephyr export - run: west zephyr-export - - - name: West Build (${{ env.display_name }}) - shell: sh -x {0} - run: west build -s zmk/app -b "${{ matrix.board }}" -- -DZMK_CONFIG="${GITHUB_WORKSPACE}/${{ inputs.config_path }}" ${{ env.extra_cmake_args }} ${{ matrix.cmake-args }} - - - name: ${{ env.display_name }} Kconfig file - run: grep -v -e "^#" -e "^$" build/zephyr/.config | sort - - - name: Rename artifacts - shell: sh -x {0} - run: | - mkdir build/artifacts - if [ -f build/zephyr/zmk.uf2 ] - then - cp build/zephyr/zmk.uf2 "build/artifacts/${{ env.artifact_name }}.uf2" - elif [ -f build/zephyr/zmk.${{ inputs.fallback_binary }} ] - then - cp "build/zephyr/zmk.${{ inputs.fallback_binary }}" "build/artifacts/${{ env.artifact_name }}.${{ inputs.fallback_binary }}" - fi - - - name: Archive (${{ env.display_name }}) - uses: actions/upload-artifact@v3 - with: - name: ${{ inputs.archive_name }} - path: build/artifacts \ No newline at end of file diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index ad43cb4..359d8e9 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,7 +1,97 @@ +# https://github.com/idank/zmk-config/blob/main/.github/workflows/build.yml -name: Build on: [push, pull_request, workflow_dispatch] +name: Build + jobs: + matrix: + runs-on: ubuntu-latest + name: Fetch Build Keyboards + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install yaml2json + run: python3 -m pip install remarshal + - id: set-matrix + name: Fetch Build Matrix + run: | + matrix=$(yaml2json build.yaml | jq -c .) + yaml2json build.yaml + echo "::set-output name=matrix::${matrix}" build: - uses: sporq/zmk-config-corne/.gitea/workflows/build-user-config.yml@master \ No newline at end of file + runs-on: ubuntu-latest + container: + image: zmkfirmware/zmk-build-arm:2.5 + needs: matrix + name: Build + strategy: + fail-fast: false + matrix: ${{fromJson(needs.matrix.outputs.matrix)}} + steps: + - name: Prepare variables + id: variables + run: | + if [ -n "${{ matrix.shield }}" ]; then + EXTRA_CMAKE_ARGS="-DSHIELD=${{ matrix.shield }}" + ARTIFACT_NAME="${{ matrix.shield }}-${{ matrix.board }}-zmk" + DISPLAY_NAME="${{ matrix.shield }} - ${{ matrix.board }}" + else + EXTRA_CMAKE_ARGS= + DISPLAY_NAME="${{ matrix.board }}" + ARTIFACT_NAME="${{ matrix.board }}-zmk" + fi + echo ::set-output name=extra-cmake-args::${EXTRA_CMAKE_ARGS} + echo ::set-output name=artifact-name::${ARTIFACT_NAME} + echo ::set-output name=display-name::${DISPLAY_NAME} + - name: Checkout + uses: actions/checkout@v2 + - name: Cache west modules + uses: actions/cache@v2 + env: + cache-name: cache-zephyr-modules + with: + path: | + modules/ + tools/ + zephyr/ + bootloader/ + zmk/ + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('manifest-dir/west.yml') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: West Init + run: west init -l config + - name: West Update + run: west update + - name: West Zephyr export + run: west zephyr-export + - name: West Build (${{ steps.variables.outputs.display-name }}) + run: | + west build -s zmk/app -b ${{ matrix.board }} -- -DZMK_CONFIG=${GITHUB_WORKSPACE}/config ${{ steps.variables.outputs.extra-cmake-args }} ${{ matrix.cmake-args }} + - name: ${{ steps.variables.outputs.display-name }} DTS File + if: ${{ always() }} + run: | + if [ -f "build/zephyr/${{ matrix.board }}.dts.pre.tmp" ]; then cat -n build/zephyr/${{ matrix.board }}.dts.pre.tmp; fi + if [ -f "build/zephyr/zephyr.dts" ]; then cat -n build/zephyr/zephyr.dts; fi + - name: ${{ steps.variables.outputs.display-name }} Kconfig file + run: cat build/zephyr/.config | grep -v "^#" | grep -v "^$" + - name: Rename artifacts + run: | + mkdir build/artifacts + if [ -f build/zephyr/zmk.uf2 ] + then + cp build/zephyr/zmk.uf2 "build/artifacts/${{ steps.variables.outputs.artifact-name }}.uf2" + elif [ -f build/zephyr/zmk.hex ] + then + cp build/zephyr/zmk.hex "build/artifacts/${{ steps.variables.outputs.artifact-name }}.hex" + fi + - name: Archive (${{ steps.variables.outputs.display-name }}) + uses: actions/upload-artifact@v2 + with: + name: firmware + path: build/artifacts