diff options
author | Peter Johanson <[email protected]> | 2024-01-09 00:29:36 +0000 |
---|---|---|
committer | Pete Johanson <[email protected]> | 2024-01-14 10:42:04 -0800 |
commit | 50e473276f2e8d681c776fdf2fe6c6d2ac9a2ce7 (patch) | |
tree | b2b470c66f7705931eb2c1d7799c7e44fd626919 /.github/workflows/build.yml | |
parent | 466cf920296d74dc9f22ef02fbccb43024f14c81 (diff) | |
download | zmk-50e473276f2e8d681c776fdf2fe6c6d2ac9a2ce7.tar.gz zmk-50e473276f2e8d681c776fdf2fe6c6d2ac9a2ce7.zip |
chore(ci): Split build and upload into separate steps
* Treat build and upload as distinct steps during a build, and don't fail
a PR if only the upload portion fails.
Diffstat (limited to '.github/workflows/build.yml')
-rw-r--r-- | .github/workflows/build.yml | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a7d0560d04..3fcaee26ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,13 +54,12 @@ jobs: node-version: "14.x" - name: Install @actions/artifact run: npm install @actions/artifact - - name: Build and upload artifacts + - name: Build uses: actions/github-script@v7 id: boards-list with: script: | const fs = require('fs'); - const {default: artifact} = require('@actions/artifact'); const execSync = require('child_process').execSync; @@ -70,10 +69,39 @@ jobs: for (const shieldArgs of buildShieldArgs) { try { + console.log(`::group::${{ matrix.board}} ${shieldArgs.shield} Build`) + const output = execSync(`west build -s app -p -b ${{ matrix.board }} -- ${shieldArgs.shield ? '-DSHIELD="' + shieldArgs.shield + '"' : ''} ${shieldArgs['cmake-args'] || ''}`); - console.log(`::group::${{ matrix.board}} ${shieldArgs.shield} Build`) console.log(output.toString()); + } catch (e) { + console.error(`::error::Failed to build ${{ matrix.board }} ${shieldArgs.shield} ${shieldArgs['cmake-args']}`); + console.error(e); + error = true; + } finally { + console.log('::endgroup::'); + } + } + + if (error) { + throw new Error('Failed to build one or more configurations'); + } + - name: Upload artifacts + uses: actions/github-script@v7 + continue-on-error: github.event_name == 'pull_request' + id: boards-upload + with: + script: | + const fs = require('fs'); + const {default: artifact} = require('@actions/artifact'); + + const buildShieldArgs = JSON.parse(`${{ matrix.shieldArgs }}`); + + let error = false; + + for (const shieldArgs of buildShieldArgs) { + try { + console.log(`::group::${{ matrix.board}} ${shieldArgs.shield} Upload`) const fileExtensions = ["hex", "uf2"]; @@ -91,7 +119,7 @@ jobs: await artifact.uploadArtifact(artifactName, files, rootDirectory, options); } catch (e) { - console.error(`::error::Failed to build or upload ${{ matrix.board }} ${shieldArgs.shield} ${shieldArgs['cmake-args']}`); + console.error(`::error::Failed to upload ${{ matrix.board }} ${shieldArgs.shield} ${shieldArgs['cmake-args']}`); console.error(e); error = true; } finally { |