From e9a69a0c6b94cb6a709d1aa8a9c8dd6dd1f48607 Mon Sep 17 00:00:00 2001 From: Sebastian Spaink <3441183+sspaink@users.noreply.github.com> Date: Fri, 16 Apr 2021 13:35:13 -0500 Subject: [PATCH] Only run CI for certain file changes (#9076) Updated circle-ci config to check for certain patterns in the latest commit to see if the jobs should run. Credit to this blog post for the idea: https://dev.to/acro5piano/exit-circleci-jobs-if-changed-files-do-not-match-specific-pattern-mel --- .circleci/config.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index f14fa48e0..efbb07f98 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,6 +25,14 @@ executors: GOFLAGS: -p=8 commands: + check-changed-files-or-halt: + steps: + - run: git diff master --name-only --no-color | egrep -e "^(\.circleci\/.*)|(.*\.(go|mod|sum))|Makefile$" || circleci step halt + check-changed-files-or-halt-windows: + steps: + - run: + command: git diff master --name-only --no-color | egrep -e "^(\.circleci\/.*)|(.*\.(go|mod|sum))|Makefile$" || circleci step halt + shell: bash.exe test-go: parameters: goarch: @@ -32,6 +40,7 @@ commands: default: "amd64" steps: - checkout + - check-changed-files-or-halt - attach_workspace: at: '/go' - run: 'GOARCH=<< parameters.goarch >> make' @@ -45,6 +54,7 @@ commands: default: false steps: - checkout + - check-changed-files-or-halt - attach_workspace: at: '/go' - when: @@ -70,6 +80,7 @@ jobs: - checkout - restore_cache: key: go-mod-v1-{{ checksum "go.sum" }} + - check-changed-files-or-halt - run: 'make deps' - run: 'make tidy' - save_cache: @@ -105,6 +116,7 @@ jobs: - checkout - restore_cache: key: mac-go-mod-v0-{{ checksum "go.sum" }} + - check-changed-files-or-halt - run: 'sh ./scripts/mac_installgo.sh' - save_cache: name: 'Saving cache' @@ -124,6 +136,7 @@ jobs: shell: powershell.exe steps: - checkout + - check-changed-files-or-halt-windows - run: choco upgrade golang --version=1.16.2 - run: choco install make - run: git config --system core.longpaths true @@ -148,6 +161,7 @@ jobs: shell: powershell.exe steps: - checkout + - check-changed-files-or-halt - attach_workspace: at: '/build' - run: @@ -172,6 +186,7 @@ jobs: shell: /bin/bash --login -o pipefail steps: - checkout + - check-changed-files-or-halt - attach_workspace: at: '.' - run: