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
This commit is contained in:
parent
e5b7a094da
commit
e9a69a0c6b
|
|
@ -25,6 +25,14 @@ executors:
|
||||||
GOFLAGS: -p=8
|
GOFLAGS: -p=8
|
||||||
|
|
||||||
commands:
|
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:
|
test-go:
|
||||||
parameters:
|
parameters:
|
||||||
goarch:
|
goarch:
|
||||||
|
|
@ -32,6 +40,7 @@ commands:
|
||||||
default: "amd64"
|
default: "amd64"
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
- check-changed-files-or-halt
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: '/go'
|
at: '/go'
|
||||||
- run: 'GOARCH=<< parameters.goarch >> make'
|
- run: 'GOARCH=<< parameters.goarch >> make'
|
||||||
|
|
@ -45,6 +54,7 @@ commands:
|
||||||
default: false
|
default: false
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
- check-changed-files-or-halt
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: '/go'
|
at: '/go'
|
||||||
- when:
|
- when:
|
||||||
|
|
@ -70,6 +80,7 @@ jobs:
|
||||||
- checkout
|
- checkout
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: go-mod-v1-{{ checksum "go.sum" }}
|
key: go-mod-v1-{{ checksum "go.sum" }}
|
||||||
|
- check-changed-files-or-halt
|
||||||
- run: 'make deps'
|
- run: 'make deps'
|
||||||
- run: 'make tidy'
|
- run: 'make tidy'
|
||||||
- save_cache:
|
- save_cache:
|
||||||
|
|
@ -105,6 +116,7 @@ jobs:
|
||||||
- checkout
|
- checkout
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: mac-go-mod-v0-{{ checksum "go.sum" }}
|
key: mac-go-mod-v0-{{ checksum "go.sum" }}
|
||||||
|
- check-changed-files-or-halt
|
||||||
- run: 'sh ./scripts/mac_installgo.sh'
|
- run: 'sh ./scripts/mac_installgo.sh'
|
||||||
- save_cache:
|
- save_cache:
|
||||||
name: 'Saving cache'
|
name: 'Saving cache'
|
||||||
|
|
@ -124,6 +136,7 @@ jobs:
|
||||||
shell: powershell.exe
|
shell: powershell.exe
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
- check-changed-files-or-halt-windows
|
||||||
- run: choco upgrade golang --version=1.16.2
|
- run: choco upgrade golang --version=1.16.2
|
||||||
- run: choco install make
|
- run: choco install make
|
||||||
- run: git config --system core.longpaths true
|
- run: git config --system core.longpaths true
|
||||||
|
|
@ -148,6 +161,7 @@ jobs:
|
||||||
shell: powershell.exe
|
shell: powershell.exe
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
- check-changed-files-or-halt
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: '/build'
|
at: '/build'
|
||||||
- run:
|
- run:
|
||||||
|
|
@ -172,6 +186,7 @@ jobs:
|
||||||
shell: /bin/bash --login -o pipefail
|
shell: /bin/bash --login -o pipefail
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
- check-changed-files-or-halt
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: '.'
|
at: '.'
|
||||||
- run:
|
- run:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue