Ignore (but succeed) some builds

github
circle.yml

#1

Our setup has a merge gate to master in GitHub, which only opens when a build succeeds. Unfortunately, we cannot use [ci-skip] because it’ll fail the gate, so we must build every time.

Can you please include another flag to “successfully skip” the build? Something like [ci-succeed]

Here’s the workaround we have with skipping builds on *.md files:

# prints the hash of the last commit in a branch
function last_commit_in_branch () {
    git fetch && git log ${1} | grep commit | head -1 | awk '{ print $2 }'
}

# prints the list of files changed between the head of one branch ($1) and another ($2) (in that order for git diff)
function files_changed_between_branches () {
    git diff --name-only $(last_commit_in_branch $1) $(last_commit_in_branch $2)
}

# prints the files changed between HEAD and origin/master
function files_changed_from_master () {
    files_changed_between_branches HEAD origin/master
}

function non_markdown_files () {
    grep -v '.*\.md'
}

# returns true if only readmes (*.md) changed since master and false otherwise
function only_readme_changes () {
    local FUNCTIONAL_CHANGES_EXIST=$(files_changed_from_master | non_markdown_files)
    if [[ -z ${FUNCTIONAL_CHANGES_EXIST} ]]; then
        echo "true"
    else
        echo "false"
    fi
}

And in circle.yml:

environment:
    DO_NOT_BUILD: $(source utils/git-utils.sh && only_readme_changes)

And then for each command:
- $DO_NOT_BUILD ||

This is very clunky but necessary for our lengthy builds.


#2