[feat] Skip stages when the commit is not important (Analysis,WaitApproval,Wait,ScriptRun)
t-kikuc opened this issue · comments
What would you like to be added
-
A new feature of skipping the
ANALYSIS
orWAIT_APPROVAL
stages when the commit diff is not important. -
The configurable conditions of skipping the stage:
- changed file path patterns (cf. GitHub Actions > paths)
- commit message (prefix)
Why is it needed
-
Some users would like to skip the
ANALYSIS
orWAIT_APPROVAL
stages for faster and automatic deployment when the commit diff does not deserve analysis or approval. -
use cases:
(a) When you modify only theHorizontalPodAutoscaler
of K8s resources in your config repo, skip theWAIT_APPROVAL
stage.
(b) When you modify onlygo.mod
dependencies in your source repo(not pipecd's config repo), skip theANALYSIS
stage.
(c) Skip theWAIT_APPROVAL
stage when the change in your source repo is small, but skip both theWAIT_APPROVAL
andANALYSIS
stages when the change is tiny.
How to realize it
- Add the
skip
configuration to app.pipecd.yaml.
spec:
pipeline:
stages:
# When changes are only `autoscaler.yaml` in any directory, skip this WAIT_APPROVAL.
- name: WAIT_APPROVAL
skip:
paths:
- "**/autoscaler.yaml"
# When the commit message starts with "[skip analysis]", skip this ANALYSIS.
- name: ANALYSIS
skip:
commitMessagePrefixes:
- "[skip analysis]"
Example1. How to realize the use case (b)
- Configure
eventWatcher
andpipeline
in your app.pipecd.yaml.
spec:
eventWatcher:
- matcher:
name: skip-analysis
handler:
type: GIT_UPDATE
config:
commitMessage: "[skip analysis] update xxx"
pipeline:
stages:
- name: ANALYSIS
skip:
commitMessagePrefixes:
- "[skip analysis]"
- Let your CI publish an event named
skip-analysis
if onlygo.mod
is changed.
Example2. How to realize the use case (c)
- Configure
eventWatcher
andpipeline
in your app.pipecd.yaml.
spec:
eventWatcher:
- matcher:
name: small-change
handler:
type: GIT_UPDATE
config:
commitMessage: "[small change] update xxx"
- matcher:
name: tiny-change
handler:
type: GIT_UPDATE
config:
commitMessage: "[tiny change] update yyy"
pipeline:
stages:
- name: WAIT_APPROVAL
skip:
commitMessagePrefixes:
- "[small change]"
- "[tiny change]"
- name: ANALYSIS
skip:
commitMessagePrefixes:
- "[tiny change]"
- Let your CI publish an event named
small-change
to skip onlyWAIT_APPROVAL
, andtiny-change
to skip bothWAIT_APPROVAL
andANALYSIS
.
Possible Extensions
- In addition to
commitMessagePrefixes
, it would be better to have other options like:skip.commitMessageOrBodyContains: []string
- It skips the stage when the title or body of the commit contains words you specify.
skip.commitMessageOrBodyContainsCommand: bool
- It skips the stage when the title or body of the commit contains specific commands like
[skip analysis]
,[skip stage]
, etc. - cf. GitHub Actions > Skipping workflow runs
- It skips the stage when the title or body of the commit contains specific commands like
[Acknowledgment]
I made this feature idea with @peaceiris, thanks!
I would like to add WAIT
stage to the supported list, since it similar with the above 2 stages.
I would like to add WAIT stage to the supported list, since it similar with the above 2 stages.
thanks, I agree with you and it's easily possible.
The SCRIPT_RUN
stage is also useful if supported.
In our case, we plan to trigger an e2e testing by a script run stage. The stage should be skipped for quick rollback.
I'll take this PR