Build per board

This commit is contained in:
Nick Winans 2021-11-28 17:08:20 -06:00
parent 10f755d121
commit d64d795336

View file

@ -48,32 +48,60 @@ jobs:
run: west update run: west update
- name: Export Zephyr CMake package (west zephyr-export) - name: Export Zephyr CMake package (west zephyr-export)
run: west zephyr-export run: west zephyr-export
- name: Prepare variables - name: Use Node.js
id: variables uses: actions/setup-node@v2
run: |
SHIELD_ARG=
ARTIFACT_NAME="${{ matrix.board }}"
if [ -n "${{ matrix.shield }}" ]; then
SHIELD_ARG="-DSHIELD=${{ matrix.shield }}"
ARTIFACT_NAME="${ARTIFACT_NAME}-${{ matrix.shield }}"
fi
ARTIFACT_NAME="${ARTIFACT_NAME}-zmk"
echo ::set-output name=shield-arg::${SHIELD_ARG}
echo ::set-output name=artifact-name::${ARTIFACT_NAME}
- name: Build (west build)
run: west build -s app -b ${{ matrix.board }} -- ${{ steps.variables.outputs.shield-arg }} ${{ matrix.cmake-args }}
- name: Archive artifacts
if: ${{ !matrix.skip-archive }}
uses: actions/upload-artifact@v2
with: with:
name: "${{ steps.variables.outputs.artifact-name }}" node-version: '14.x'
path: | - name: Install @actions/artifact
build/zephyr/zmk.hex run: npm install @actions/artifact
build/zephyr/zmk.uf2 - name: Build and upload artifacts
continue-on-error: true uses: actions/github-script@v4
id: boards-list
with:
script: |
const fs = require('fs');
const artifact = require('@actions/artifact');
const artifactClient = artifact.create();
const execSync = require('child_process').execSync;
const buildShieldArgs = JSON.parse(`${{ matrix.shieldArgs }}`);
let error = false;
for (const shieldArgs of buildShieldArgs) {
try {
const output = execSync(`west build -s app -p -b ${{ matrix.board }} -- ${shieldArgs.shield ? '-DSHIELD=' + shieldArgs.shield : ''} ${shieldArgs['cmake-args'] || ''}`);
console.log(output.toString());
const fileExtensions = ['hex', 'uf2'];
let files = [];
for (const extension of fileExtensions) {
const path = 'build/zephyr/zmk.' + extension;
if (fs.existsSync(path)) {
files.push(path);
}
}
const rootDirectory = 'build/zephyr';
const options = {
continueOnError: true
}
const artifactName = `${{ matrix.board }}${shieldArgs.shield ? '-' + shieldArgs.shield : ''}-zmk`;
await artifactClient.uploadArtifact(artifactName, files, rootDirectory, options);
} catch (e) {
console.error(`Failed to build or upload ${{ matrix.board }} ${shieldArgs.shield} ${shieldArgs['cmake-args']}`);
console.error(e);
error = true;
}
}
if (error) {
throw new Error('Failed to build one or more configurations');
}
compile-matrix: compile-matrix:
if: ${{ always() }} if: ${{ always() }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -96,8 +124,30 @@ jobs:
const nightlyArray = nightly ? JSON.parse(nightly) : []; const nightlyArray = nightly ? JSON.parse(nightly) : [];
const combined = [...coreCoverageArray, ...boardChangesArray, ...nightlyArray]; const combined = [...coreCoverageArray, ...boardChangesArray, ...nightlyArray];
const combinedUnique = [...new Map(combined.map(el => [JSON.stringify(el), el])).values()];
return [...new Map(combined.map(el => [JSON.stringify(el), el])).values()]; const perBoard = {};
for (const configuration of combinedUnique) {
if (!perBoard[configuration.board])
perBoard[configuration.board] = [];
perBoard[configuration.board].push({
shield: configuration.shield,
'cmake-args': configuration['cmake-args']
})
}
const includeList = [];
for (const [board, shieldArgs] of Object.entries(perBoard)) {
includeList.push({
board,
shieldArgs: JSON.stringify(shieldArgs)
});
}
return includeList;
core-coverage: core-coverage:
if: ${{ needs.get-changed-files.outputs.core-changes == 'true' }} if: ${{ needs.get-changed-files.outputs.core-changes == 'true' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest