All,
Some of my CI has been having intermittent build failures that I think are due to a combination of parallel make and limited memory. Now I could move to a larger resource class, but that would double my cost for about a 10% speed improvement by my testing (well, not counting the fact I might have to press the “re-run tests” again).
So, I thought about using when: on_fail
for my setup to re-run a build in case of failure (since then it might work).
Currently I like to use commands and my config looks like:
build-GEOSgcm:
parameters:
compiler:
type: string
executor: << parameters.compiler >>
working_directory: /root/project
steps:
- checkout_fixture:
repo: GEOSgcm
- mepoclone:
repo: GEOSgcm
- mepodevelop:
repo: GEOSgcm
- checkout_mapl_branch:
repo: GEOSgcm
- cmake:
repo: GEOSgcm
compiler: << parameters.compiler >>
- buildinstall:
repo: GEOSgcm
- compress_artifacts
- store_artifacts:
path: /logfiles
And I thought, great I’ll just make a new command and do:
...
- buildinstall:
repo: GEOSgcm
- retrybuild:
repo: GEOSgcm
when: on_fail
- compress_artifacts
- store_artifacts:
path: /logfiles
But that failed:
❯ circleci config validate
Error: Error calling workflow: 'build-and-test'
Error calling job: 'build-GEOSgcm'
Error calling command: 'retrybuild'
Unexpected argument(s): when
as I figured once I looked at the docs.
So for now, in my buildinstall
command, I have an extra run:
step with a when: on_fail
trigger:
buildinstall:
description: "Build and install"
parameters:
repo:
type: string
default: ""
steps:
- run:
name: "Build and install"
command: |
cd ${CIRCLE_WORKING_DIRECTORY}/workspace/build-<< parameters.repo >>
make -j"$(nproc)" install |& tee /logfiles/make.log
- run:
name: "Retry build and install after failure"
command: |
cd ${CIRCLE_WORKING_DIRECTORY}/workspace/build-<< parameters.repo >>
make -j"$(nproc)" install |& tee /logfiles/make-retry.log
when: on_fail
That validates and, well, now I’m waiting to see if the failure is helped by this.
But I had a question: is there a way to do what I wanted with the command in steps syntax? Or is just that steps
have no when
?
Thanks,
Matt
PS: Soon I’ll be thinking about using orbs since the commands in that fragment you see up there are used in a few repos. I think orbs would let me share these commands easily…right?