diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..e69de29b diff --git a/404.html b/404.html new file mode 100644 index 00000000..7cdd28a2 --- /dev/null +++ b/404.html @@ -0,0 +1 @@ + gitStream Documentation
\ No newline at end of file diff --git a/CNAME b/CNAME new file mode 100644 index 00000000..c4b2a4d5 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +docs.gitstream.cm diff --git a/_config.yml b/_config.yml new file mode 100644 index 00000000..c7418817 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-slate \ No newline at end of file diff --git a/assets/ContinuousMerge3d.png b/assets/ContinuousMerge3d.png new file mode 100644 index 00000000..b2dbd0e8 Binary files /dev/null and b/assets/ContinuousMerge3d.png differ diff --git a/assets/ContinuousMerge3l.png b/assets/ContinuousMerge3l.png new file mode 100644 index 00000000..c503d067 Binary files /dev/null and b/assets/ContinuousMerge3l.png differ diff --git a/assets/change-deprecated-highlight.png b/assets/change-deprecated-highlight.png new file mode 100644 index 00000000..fe109a9a Binary files /dev/null and b/assets/change-deprecated-highlight.png differ diff --git a/assets/code-experts-highlight.png b/assets/code-experts-highlight.png new file mode 100644 index 00000000..5588fc9a Binary files /dev/null and b/assets/code-experts-highlight.png differ diff --git a/assets/etr-label-highlight.png b/assets/etr-label-highlight.png new file mode 100644 index 00000000..96592445 Binary files /dev/null and b/assets/etr-label-highlight.png differ diff --git a/assets/github_pr_check_fail.png b/assets/github_pr_check_fail.png new file mode 100644 index 00000000..1c583a61 Binary files /dev/null and b/assets/github_pr_check_fail.png differ diff --git a/assets/github_pr_check_neutral.png b/assets/github_pr_check_neutral.png new file mode 100644 index 00000000..a732fd5f Binary files /dev/null and b/assets/github_pr_check_neutral.png differ diff --git a/assets/github_pr_check_pass.png b/assets/github_pr_check_pass.png new file mode 100644 index 00000000..c1ec77f3 Binary files /dev/null and b/assets/github_pr_check_pass.png differ diff --git a/assets/gitstream-black.png b/assets/gitstream-black.png new file mode 100644 index 00000000..40d0b0e7 Binary files /dev/null and b/assets/gitstream-black.png differ diff --git a/assets/gitstream-w.webp b/assets/gitstream-w.webp new file mode 100644 index 00000000..e3d904c9 Binary files /dev/null and b/assets/gitstream-w.webp differ diff --git a/assets/gitstream-white.png b/assets/gitstream-white.png new file mode 100644 index 00000000..a27db46f Binary files /dev/null and b/assets/gitstream-white.png differ diff --git a/assets/images/favicon.png b/assets/images/favicon.png new file mode 100644 index 00000000..1cf13b9f Binary files /dev/null and b/assets/images/favicon.png differ diff --git a/assets/javascripts/bundle.ce72ebac.min.js b/assets/javascripts/bundle.ce72ebac.min.js new file mode 100644 index 00000000..baeb0319 --- /dev/null +++ b/assets/javascripts/bundle.ce72ebac.min.js @@ -0,0 +1,29 @@ +"use strict";(()=>{var Hi=Object.create;var xr=Object.defineProperty;var Pi=Object.getOwnPropertyDescriptor;var $i=Object.getOwnPropertyNames,Ht=Object.getOwnPropertySymbols,Ii=Object.getPrototypeOf,Er=Object.prototype.hasOwnProperty,an=Object.prototype.propertyIsEnumerable;var on=(e,t,r)=>t in e?xr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))Er.call(t,r)&&on(e,r,t[r]);if(Ht)for(var r of Ht(t))an.call(t,r)&&on(e,r,t[r]);return e};var sn=(e,t)=>{var r={};for(var n in e)Er.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ht)for(var n of Ht(e))t.indexOf(n)<0&&an.call(e,n)&&(r[n]=e[n]);return r};var Pt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Fi=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $i(t))!Er.call(e,o)&&o!==r&&xr(e,o,{get:()=>t[o],enumerable:!(n=Pi(t,o))||n.enumerable});return e};var yt=(e,t,r)=>(r=e!=null?Hi(Ii(e)):{},Fi(t||!e||!e.__esModule?xr(r,"default",{value:e,enumerable:!0}):r,e));var fn=Pt((wr,cn)=>{(function(e,t){typeof wr=="object"&&typeof cn!="undefined"?t():typeof define=="function"&&define.amd?define(t):t()})(wr,function(){"use strict";function e(r){var n=!0,o=!1,i=null,s={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function a(O){return!!(O&&O!==document&&O.nodeName!=="HTML"&&O.nodeName!=="BODY"&&"classList"in O&&"contains"in O.classList)}function f(O){var Ke=O.type,De=O.tagName;return!!(De==="INPUT"&&s[Ke]&&!O.readOnly||De==="TEXTAREA"&&!O.readOnly||O.isContentEditable)}function c(O){O.classList.contains("focus-visible")||(O.classList.add("focus-visible"),O.setAttribute("data-focus-visible-added",""))}function u(O){O.hasAttribute("data-focus-visible-added")&&(O.classList.remove("focus-visible"),O.removeAttribute("data-focus-visible-added"))}function p(O){O.metaKey||O.altKey||O.ctrlKey||(a(r.activeElement)&&c(r.activeElement),n=!0)}function m(O){n=!1}function d(O){a(O.target)&&(n||f(O.target))&&c(O.target)}function h(O){a(O.target)&&(O.target.classList.contains("focus-visible")||O.target.hasAttribute("data-focus-visible-added"))&&(o=!0,window.clearTimeout(i),i=window.setTimeout(function(){o=!1},100),u(O.target))}function v(O){document.visibilityState==="hidden"&&(o&&(n=!0),B())}function B(){document.addEventListener("mousemove",z),document.addEventListener("mousedown",z),document.addEventListener("mouseup",z),document.addEventListener("pointermove",z),document.addEventListener("pointerdown",z),document.addEventListener("pointerup",z),document.addEventListener("touchmove",z),document.addEventListener("touchstart",z),document.addEventListener("touchend",z)}function ne(){document.removeEventListener("mousemove",z),document.removeEventListener("mousedown",z),document.removeEventListener("mouseup",z),document.removeEventListener("pointermove",z),document.removeEventListener("pointerdown",z),document.removeEventListener("pointerup",z),document.removeEventListener("touchmove",z),document.removeEventListener("touchstart",z),document.removeEventListener("touchend",z)}function z(O){O.target.nodeName&&O.target.nodeName.toLowerCase()==="html"||(n=!1,ne())}document.addEventListener("keydown",p,!0),document.addEventListener("mousedown",m,!0),document.addEventListener("pointerdown",m,!0),document.addEventListener("touchstart",m,!0),document.addEventListener("visibilitychange",v,!0),B(),r.addEventListener("focus",d,!0),r.addEventListener("blur",h,!0),r.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&r.host?r.host.setAttribute("data-js-focus-visible",""):r.nodeType===Node.DOCUMENT_NODE&&(document.documentElement.classList.add("js-focus-visible"),document.documentElement.setAttribute("data-js-focus-visible",""))}if(typeof window!="undefined"&&typeof document!="undefined"){window.applyFocusVisiblePolyfill=e;var t;try{t=new CustomEvent("focus-visible-polyfill-ready")}catch(r){t=document.createEvent("CustomEvent"),t.initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(t)}typeof document!="undefined"&&e(document)})});var un=Pt(Sr=>{(function(e){var t=function(){try{return!!Symbol.iterator}catch(c){return!1}},r=t(),n=function(c){var u={next:function(){var p=c.shift();return{done:p===void 0,value:p}}};return r&&(u[Symbol.iterator]=function(){return u}),u},o=function(c){return encodeURIComponent(c).replace(/%20/g,"+")},i=function(c){return decodeURIComponent(String(c).replace(/\+/g," "))},s=function(){var c=function(p){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var m=typeof p;if(m!=="undefined")if(m==="string")p!==""&&this._fromString(p);else if(p instanceof c){var d=this;p.forEach(function(ne,z){d.append(z,ne)})}else if(p!==null&&m==="object")if(Object.prototype.toString.call(p)==="[object Array]")for(var h=0;hd[0]?1:0}),c._entries&&(c._entries={});for(var p=0;p1?i(d[1]):"")}})})(typeof global!="undefined"?global:typeof window!="undefined"?window:typeof self!="undefined"?self:Sr);(function(e){var t=function(){try{var o=new e.URL("b","http://a");return o.pathname="c d",o.href==="http://a/c%20d"&&o.searchParams}catch(i){return!1}},r=function(){var o=e.URL,i=function(f,c){typeof f!="string"&&(f=String(f)),c&&typeof c!="string"&&(c=String(c));var u=document,p;if(c&&(e.location===void 0||c!==e.location.href)){c=c.toLowerCase(),u=document.implementation.createHTMLDocument(""),p=u.createElement("base"),p.href=c,u.head.appendChild(p);try{if(p.href.indexOf(c)!==0)throw new Error(p.href)}catch(O){throw new Error("URL unable to set base "+c+" due to "+O)}}var m=u.createElement("a");m.href=f,p&&(u.body.appendChild(m),m.href=m.href);var d=u.createElement("input");if(d.type="url",d.value=f,m.protocol===":"||!/:/.test(m.href)||!d.checkValidity()&&!c)throw new TypeError("Invalid URL");Object.defineProperty(this,"_anchorElement",{value:m});var h=new e.URLSearchParams(this.search),v=!0,B=!0,ne=this;["append","delete","set"].forEach(function(O){var Ke=h[O];h[O]=function(){Ke.apply(h,arguments),v&&(B=!1,ne.search=h.toString(),B=!0)}}),Object.defineProperty(this,"searchParams",{value:h,enumerable:!0});var z=void 0;Object.defineProperty(this,"_updateSearchParams",{enumerable:!1,configurable:!1,writable:!1,value:function(){this.search!==z&&(z=this.search,B&&(v=!1,this.searchParams._fromString(this.search),v=!0))}})},s=i.prototype,a=function(f){Object.defineProperty(s,f,{get:function(){return this._anchorElement[f]},set:function(c){this._anchorElement[f]=c},enumerable:!0})};["hash","host","hostname","port","protocol"].forEach(function(f){a(f)}),Object.defineProperty(s,"search",{get:function(){return this._anchorElement.search},set:function(f){this._anchorElement.search=f,this._updateSearchParams()},enumerable:!0}),Object.defineProperties(s,{toString:{get:function(){var f=this;return function(){return f.href}}},href:{get:function(){return this._anchorElement.href.replace(/\?$/,"")},set:function(f){this._anchorElement.href=f,this._updateSearchParams()},enumerable:!0},pathname:{get:function(){return this._anchorElement.pathname.replace(/(^\/?)/,"/")},set:function(f){this._anchorElement.pathname=f},enumerable:!0},origin:{get:function(){var f={"http:":80,"https:":443,"ftp:":21}[this._anchorElement.protocol],c=this._anchorElement.port!=f&&this._anchorElement.port!=="";return this._anchorElement.protocol+"//"+this._anchorElement.hostname+(c?":"+this._anchorElement.port:"")},enumerable:!0},password:{get:function(){return""},set:function(f){},enumerable:!0},username:{get:function(){return""},set:function(f){},enumerable:!0}}),i.createObjectURL=function(f){return o.createObjectURL.apply(o,arguments)},i.revokeObjectURL=function(f){return o.revokeObjectURL.apply(o,arguments)},e.URL=i};if(t()||r(),e.location!==void 0&&!("origin"in e.location)){var n=function(){return e.location.protocol+"//"+e.location.hostname+(e.location.port?":"+e.location.port:"")};try{Object.defineProperty(e.location,"origin",{get:n,enumerable:!0})}catch(o){setInterval(function(){e.location.origin=n()},100)}}})(typeof global!="undefined"?global:typeof window!="undefined"?window:typeof self!="undefined"?self:Sr)});var Qr=Pt((Lt,Kr)=>{/*! + * clipboard.js v2.0.11 + * https://clipboardjs.com/ + * + * Licensed MIT © Zeno Rocha + */(function(t,r){typeof Lt=="object"&&typeof Kr=="object"?Kr.exports=r():typeof define=="function"&&define.amd?define([],r):typeof Lt=="object"?Lt.ClipboardJS=r():t.ClipboardJS=r()})(Lt,function(){return function(){var e={686:function(n,o,i){"use strict";i.d(o,{default:function(){return ki}});var s=i(279),a=i.n(s),f=i(370),c=i.n(f),u=i(817),p=i.n(u);function m(j){try{return document.execCommand(j)}catch(T){return!1}}var d=function(T){var w=p()(T);return m("cut"),w},h=d;function v(j){var T=document.documentElement.getAttribute("dir")==="rtl",w=document.createElement("textarea");w.style.fontSize="12pt",w.style.border="0",w.style.padding="0",w.style.margin="0",w.style.position="absolute",w.style[T?"right":"left"]="-9999px";var k=window.pageYOffset||document.documentElement.scrollTop;return w.style.top="".concat(k,"px"),w.setAttribute("readonly",""),w.value=j,w}var B=function(T,w){var k=v(T);w.container.appendChild(k);var F=p()(k);return m("copy"),k.remove(),F},ne=function(T){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},k="";return typeof T=="string"?k=B(T,w):T instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(T==null?void 0:T.type)?k=B(T.value,w):(k=p()(T),m("copy")),k},z=ne;function O(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?O=function(w){return typeof w}:O=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},O(j)}var Ke=function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},w=T.action,k=w===void 0?"copy":w,F=T.container,N=T.target,Le=T.text;if(k!=="copy"&&k!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(N!==void 0)if(N&&O(N)==="object"&&N.nodeType===1){if(k==="copy"&&N.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(k==="cut"&&(N.hasAttribute("readonly")||N.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(Le)return z(Le,{container:F});if(N)return k==="cut"?h(N):z(N,{container:F})},De=Ke;function Fe(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Fe=function(w){return typeof w}:Fe=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},Fe(j)}function Oi(j,T){if(!(j instanceof T))throw new TypeError("Cannot call a class as a function")}function nn(j,T){for(var w=0;w0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof F.action=="function"?F.action:this.defaultAction,this.target=typeof F.target=="function"?F.target:this.defaultTarget,this.text=typeof F.text=="function"?F.text:this.defaultText,this.container=Fe(F.container)==="object"?F.container:document.body}},{key:"listenClick",value:function(F){var N=this;this.listener=c()(F,"click",function(Le){return N.onClick(Le)})}},{key:"onClick",value:function(F){var N=F.delegateTarget||F.currentTarget,Le=this.action(N)||"copy",kt=De({action:Le,container:this.container,target:this.target(N),text:this.text(N)});this.emit(kt?"success":"error",{action:Le,text:kt,trigger:N,clearSelection:function(){N&&N.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(F){return yr("action",F)}},{key:"defaultTarget",value:function(F){var N=yr("target",F);if(N)return document.querySelector(N)}},{key:"defaultText",value:function(F){return yr("text",F)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(F){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return z(F,N)}},{key:"cut",value:function(F){return h(F)}},{key:"isSupported",value:function(){var F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],N=typeof F=="string"?[F]:F,Le=!!document.queryCommandSupported;return N.forEach(function(kt){Le=Le&&!!document.queryCommandSupported(kt)}),Le}}]),w}(a()),ki=Ri},828:function(n){var o=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var i=Element.prototype;i.matches=i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector}function s(a,f){for(;a&&a.nodeType!==o;){if(typeof a.matches=="function"&&a.matches(f))return a;a=a.parentNode}}n.exports=s},438:function(n,o,i){var s=i(828);function a(u,p,m,d,h){var v=c.apply(this,arguments);return u.addEventListener(m,v,h),{destroy:function(){u.removeEventListener(m,v,h)}}}function f(u,p,m,d,h){return typeof u.addEventListener=="function"?a.apply(null,arguments):typeof m=="function"?a.bind(null,document).apply(null,arguments):(typeof u=="string"&&(u=document.querySelectorAll(u)),Array.prototype.map.call(u,function(v){return a(v,p,m,d,h)}))}function c(u,p,m,d){return function(h){h.delegateTarget=s(h.target,p),h.delegateTarget&&d.call(u,h)}}n.exports=f},879:function(n,o){o.node=function(i){return i!==void 0&&i instanceof HTMLElement&&i.nodeType===1},o.nodeList=function(i){var s=Object.prototype.toString.call(i);return i!==void 0&&(s==="[object NodeList]"||s==="[object HTMLCollection]")&&"length"in i&&(i.length===0||o.node(i[0]))},o.string=function(i){return typeof i=="string"||i instanceof String},o.fn=function(i){var s=Object.prototype.toString.call(i);return s==="[object Function]"}},370:function(n,o,i){var s=i(879),a=i(438);function f(m,d,h){if(!m&&!d&&!h)throw new Error("Missing required arguments");if(!s.string(d))throw new TypeError("Second argument must be a String");if(!s.fn(h))throw new TypeError("Third argument must be a Function");if(s.node(m))return c(m,d,h);if(s.nodeList(m))return u(m,d,h);if(s.string(m))return p(m,d,h);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function c(m,d,h){return m.addEventListener(d,h),{destroy:function(){m.removeEventListener(d,h)}}}function u(m,d,h){return Array.prototype.forEach.call(m,function(v){v.addEventListener(d,h)}),{destroy:function(){Array.prototype.forEach.call(m,function(v){v.removeEventListener(d,h)})}}}function p(m,d,h){return a(document.body,m,d,h)}n.exports=f},817:function(n){function o(i){var s;if(i.nodeName==="SELECT")i.focus(),s=i.value;else if(i.nodeName==="INPUT"||i.nodeName==="TEXTAREA"){var a=i.hasAttribute("readonly");a||i.setAttribute("readonly",""),i.select(),i.setSelectionRange(0,i.value.length),a||i.removeAttribute("readonly"),s=i.value}else{i.hasAttribute("contenteditable")&&i.focus();var f=window.getSelection(),c=document.createRange();c.selectNodeContents(i),f.removeAllRanges(),f.addRange(c),s=f.toString()}return s}n.exports=o},279:function(n){function o(){}o.prototype={on:function(i,s,a){var f=this.e||(this.e={});return(f[i]||(f[i]=[])).push({fn:s,ctx:a}),this},once:function(i,s,a){var f=this;function c(){f.off(i,c),s.apply(a,arguments)}return c._=s,this.on(i,c,a)},emit:function(i){var s=[].slice.call(arguments,1),a=((this.e||(this.e={}))[i]||[]).slice(),f=0,c=a.length;for(f;f{"use strict";/*! + * escape-html + * Copyright(c) 2012-2013 TJ Holowaychuk + * Copyright(c) 2015 Andreas Lubbe + * Copyright(c) 2015 Tiancheng "Timothy" Gu + * MIT Licensed + */var is=/["'&<>]/;Jo.exports=as;function as(e){var t=""+e,r=is.exec(t);if(!r)return t;var n,o="",i=0,s=0;for(i=r.index;i0&&i[i.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function W(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i}function D(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,i;n1||a(m,d)})})}function a(m,d){try{f(n[m](d))}catch(h){p(i[0][3],h)}}function f(m){m.value instanceof Ze?Promise.resolve(m.value.v).then(c,u):p(i[0][2],m)}function c(m){a("next",m)}function u(m){a("throw",m)}function p(m,d){m(d),i.shift(),i.length&&a(i[0][0],i[0][1])}}function mn(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof xe=="function"?xe(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=e[i]&&function(s){return new Promise(function(a,f){s=e[i](s),o(a,f,s.done,s.value)})}}function o(i,s,a,f){Promise.resolve(f).then(function(c){i({value:c,done:a})},s)}}function A(e){return typeof e=="function"}function at(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var It=at(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription: +`+r.map(function(n,o){return o+1+") "+n.toString()}).join(` + `):"",this.name="UnsubscriptionError",this.errors=r}});function Ve(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var je=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=xe(s),f=a.next();!f.done;f=a.next()){var c=f.value;c.remove(this)}}catch(v){t={error:v}}finally{try{f&&!f.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}else s.remove(this);var u=this.initialTeardown;if(A(u))try{u()}catch(v){i=v instanceof It?v.errors:[v]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var m=xe(p),d=m.next();!d.done;d=m.next()){var h=d.value;try{dn(h)}catch(v){i=i!=null?i:[],v instanceof It?i=D(D([],W(i)),W(v.errors)):i.push(v)}}}catch(v){n={error:v}}finally{try{d&&!d.done&&(o=m.return)&&o.call(m)}finally{if(n)throw n.error}}}if(i)throw new It(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)dn(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&Ve(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&Ve(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}();var Tr=je.EMPTY;function Ft(e){return e instanceof je||e&&"closed"in e&&A(e.remove)&&A(e.add)&&A(e.unsubscribe)}function dn(e){A(e)?e():e.unsubscribe()}var Ae={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var st={setTimeout:function(e,t){for(var r=[],n=2;n0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,o=this,i=o.hasError,s=o.isStopped,a=o.observers;return i||s?Tr:(this.currentObservers=null,a.push(r),new je(function(){n.currentObservers=null,Ve(a,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,i=n.thrownError,s=n.isStopped;o?r.error(i):s&&r.complete()},t.prototype.asObservable=function(){var r=new U;return r.source=this,r},t.create=function(r,n){return new wn(r,n)},t}(U);var wn=function(e){ie(t,e);function t(r,n){var o=e.call(this)||this;return o.destination=r,o.source=n,o}return t.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},t.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:Tr},t}(E);var Et={now:function(){return(Et.delegate||Date).now()},delegate:void 0};var wt=function(e){ie(t,e);function t(r,n,o){r===void 0&&(r=1/0),n===void 0&&(n=1/0),o===void 0&&(o=Et);var i=e.call(this)||this;return i._bufferSize=r,i._windowTime=n,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,r),i._windowTime=Math.max(1,n),i}return t.prototype.next=function(r){var n=this,o=n.isStopped,i=n._buffer,s=n._infiniteTimeWindow,a=n._timestampProvider,f=n._windowTime;o||(i.push(r),!s&&i.push(a.now()+f)),this._trimBuffer(),e.prototype.next.call(this,r)},t.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),o=this,i=o._infiniteTimeWindow,s=o._buffer,a=s.slice(),f=0;f0?e.prototype.requestAsyncId.call(this,r,n,o):(r.actions.push(this),r._scheduled||(r._scheduled=ut.requestAnimationFrame(function(){return r.flush(void 0)})))},t.prototype.recycleAsyncId=function(r,n,o){var i;if(o===void 0&&(o=0),o!=null?o>0:this.delay>0)return e.prototype.recycleAsyncId.call(this,r,n,o);var s=r.actions;n!=null&&((i=s[s.length-1])===null||i===void 0?void 0:i.id)!==n&&(ut.cancelAnimationFrame(n),r._scheduled=void 0)},t}(Wt);var Tn=function(e){ie(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.flush=function(r){this._active=!0;var n=this._scheduled;this._scheduled=void 0;var o=this.actions,i;r=r||o.shift();do if(i=r.execute(r.state,r.delay))break;while((r=o[0])&&r.id===n&&o.shift());if(this._active=!1,i){for(;(r=o[0])&&r.id===n&&o.shift();)r.unsubscribe();throw i}},t}(Dt);var we=new Tn(On);var R=new U(function(e){return e.complete()});function Vt(e){return e&&A(e.schedule)}function kr(e){return e[e.length-1]}function Qe(e){return A(kr(e))?e.pop():void 0}function Se(e){return Vt(kr(e))?e.pop():void 0}function zt(e,t){return typeof kr(e)=="number"?e.pop():t}var pt=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Nt(e){return A(e==null?void 0:e.then)}function qt(e){return A(e[ft])}function Kt(e){return Symbol.asyncIterator&&A(e==null?void 0:e[Symbol.asyncIterator])}function Qt(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Ki(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Yt=Ki();function Gt(e){return A(e==null?void 0:e[Yt])}function Bt(e){return ln(this,arguments,function(){var r,n,o,i;return $t(this,function(s){switch(s.label){case 0:r=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,Ze(r.read())];case 3:return n=s.sent(),o=n.value,i=n.done,i?[4,Ze(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,Ze(o)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function Jt(e){return A(e==null?void 0:e.getReader)}function $(e){if(e instanceof U)return e;if(e!=null){if(qt(e))return Qi(e);if(pt(e))return Yi(e);if(Nt(e))return Gi(e);if(Kt(e))return _n(e);if(Gt(e))return Bi(e);if(Jt(e))return Ji(e)}throw Qt(e)}function Qi(e){return new U(function(t){var r=e[ft]();if(A(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Yi(e){return new U(function(t){for(var r=0;r=2;return function(n){return n.pipe(e?_(function(o,i){return e(o,i,n)}):de,Te(1),r?Pe(t):zn(function(){return new Zt}))}}function Nn(){for(var e=[],t=0;t=2,!0))}function ue(e){e===void 0&&(e={});var t=e.connector,r=t===void 0?function(){return new E}:t,n=e.resetOnError,o=n===void 0?!0:n,i=e.resetOnComplete,s=i===void 0?!0:i,a=e.resetOnRefCountZero,f=a===void 0?!0:a;return function(c){var u,p,m,d=0,h=!1,v=!1,B=function(){p==null||p.unsubscribe(),p=void 0},ne=function(){B(),u=m=void 0,h=v=!1},z=function(){var O=u;ne(),O==null||O.unsubscribe()};return g(function(O,Ke){d++,!v&&!h&&B();var De=m=m!=null?m:r();Ke.add(function(){d--,d===0&&!v&&!h&&(p=jr(z,f))}),De.subscribe(Ke),!u&&d>0&&(u=new tt({next:function(Fe){return De.next(Fe)},error:function(Fe){v=!0,B(),p=jr(ne,o,Fe),De.error(Fe)},complete:function(){h=!0,B(),p=jr(ne,s),De.complete()}}),$(O).subscribe(u))})(c)}}function jr(e,t){for(var r=[],n=2;ne.next(document)),e}function K(e,t=document){return Array.from(t.querySelectorAll(e))}function V(e,t=document){let r=ce(e,t);if(typeof r=="undefined")throw new ReferenceError(`Missing element: expected "${e}" to be present`);return r}function ce(e,t=document){return t.querySelector(e)||void 0}function _e(){return document.activeElement instanceof HTMLElement&&document.activeElement||void 0}function rr(e){return L(b(document.body,"focusin"),b(document.body,"focusout")).pipe(He(1),l(()=>{let t=_e();return typeof t!="undefined"?e.contains(t):!1}),q(e===_e()),G())}function Je(e){return{x:e.offsetLeft,y:e.offsetTop}}function Yn(e){return L(b(window,"load"),b(window,"resize")).pipe(Re(0,we),l(()=>Je(e)),q(Je(e)))}function nr(e){return{x:e.scrollLeft,y:e.scrollTop}}function dt(e){return L(b(e,"scroll"),b(window,"resize")).pipe(Re(0,we),l(()=>nr(e)),q(nr(e)))}var Bn=function(){if(typeof Map!="undefined")return Map;function e(t,r){var n=-1;return t.some(function(o,i){return o[0]===r?(n=i,!0):!1}),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(r){var n=e(this.__entries__,r),o=this.__entries__[n];return o&&o[1]},t.prototype.set=function(r,n){var o=e(this.__entries__,r);~o?this.__entries__[o][1]=n:this.__entries__.push([r,n])},t.prototype.delete=function(r){var n=this.__entries__,o=e(n,r);~o&&n.splice(o,1)},t.prototype.has=function(r){return!!~e(this.__entries__,r)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(r,n){n===void 0&&(n=null);for(var o=0,i=this.__entries__;o0},e.prototype.connect_=function(){!zr||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),xa?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!zr||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var r=t.propertyName,n=r===void 0?"":r,o=ya.some(function(i){return!!~n.indexOf(i)});o&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),Jn=function(e,t){for(var r=0,n=Object.keys(t);r0},e}(),Zn=typeof WeakMap!="undefined"?new WeakMap:new Bn,eo=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var r=Ea.getInstance(),n=new Ra(t,r,this);Zn.set(this,n)}return e}();["observe","unobserve","disconnect"].forEach(function(e){eo.prototype[e]=function(){var t;return(t=Zn.get(this))[e].apply(t,arguments)}});var ka=function(){return typeof or.ResizeObserver!="undefined"?or.ResizeObserver:eo}(),to=ka;var ro=new E,Ha=I(()=>H(new to(e=>{for(let t of e)ro.next(t)}))).pipe(x(e=>L(Oe,H(e)).pipe(C(()=>e.disconnect()))),J(1));function he(e){return{width:e.offsetWidth,height:e.offsetHeight}}function ge(e){return Ha.pipe(S(t=>t.observe(e)),x(t=>ro.pipe(_(({target:r})=>r===e),C(()=>t.unobserve(e)),l(()=>he(e)))),q(he(e)))}function bt(e){return{width:e.scrollWidth,height:e.scrollHeight}}function sr(e){let t=e.parentElement;for(;t&&(e.scrollWidth<=t.scrollWidth&&e.scrollHeight<=t.scrollHeight);)t=(e=t).parentElement;return t?e:void 0}var no=new E,Pa=I(()=>H(new IntersectionObserver(e=>{for(let t of e)no.next(t)},{threshold:0}))).pipe(x(e=>L(Oe,H(e)).pipe(C(()=>e.disconnect()))),J(1));function cr(e){return Pa.pipe(S(t=>t.observe(e)),x(t=>no.pipe(_(({target:r})=>r===e),C(()=>t.unobserve(e)),l(({isIntersecting:r})=>r))))}function oo(e,t=16){return dt(e).pipe(l(({y:r})=>{let n=he(e),o=bt(e);return r>=o.height-n.height-t}),G())}var fr={drawer:V("[data-md-toggle=drawer]"),search:V("[data-md-toggle=search]")};function io(e){return fr[e].checked}function qe(e,t){fr[e].checked!==t&&fr[e].click()}function Ue(e){let t=fr[e];return b(t,"change").pipe(l(()=>t.checked),q(t.checked))}function $a(e,t){switch(e.constructor){case HTMLInputElement:return e.type==="radio"?/^Arrow/.test(t):!0;case HTMLSelectElement:case HTMLTextAreaElement:return!0;default:return e.isContentEditable}}function Ia(){return L(b(window,"compositionstart").pipe(l(()=>!0)),b(window,"compositionend").pipe(l(()=>!1))).pipe(q(!1))}function ao(){let e=b(window,"keydown").pipe(_(t=>!(t.metaKey||t.ctrlKey)),l(t=>({mode:io("search")?"search":"global",type:t.key,claim(){t.preventDefault(),t.stopPropagation()}})),_(({mode:t,type:r})=>{if(t==="global"){let n=_e();if(typeof n!="undefined")return!$a(n,r)}return!0}),ue());return Ia().pipe(x(t=>t?R:e))}function Me(){return new URL(location.href)}function ot(e){location.href=e.href}function so(){return new E}function co(e,t){if(typeof t=="string"||typeof t=="number")e.innerHTML+=t.toString();else if(t instanceof Node)e.appendChild(t);else if(Array.isArray(t))for(let r of t)co(e,r)}function M(e,t,...r){let n=document.createElement(e);if(t)for(let o of Object.keys(t))typeof t[o]!="undefined"&&(typeof t[o]!="boolean"?n.setAttribute(o,t[o]):n.setAttribute(o,""));for(let o of r)co(n,o);return n}function ur(e){if(e>999){let t=+((e-950)%1e3>99);return`${((e+1e-6)/1e3).toFixed(t)}k`}else return e.toString()}function fo(){return location.hash.substring(1)}function uo(e){let t=M("a",{href:e});t.addEventListener("click",r=>r.stopPropagation()),t.click()}function Fa(){return b(window,"hashchange").pipe(l(fo),q(fo()),_(e=>e.length>0),J(1))}function po(){return Fa().pipe(l(e=>ce(`[id="${e}"]`)),_(e=>typeof e!="undefined"))}function Nr(e){let t=matchMedia(e);return er(r=>t.addListener(()=>r(t.matches))).pipe(q(t.matches))}function lo(){let e=matchMedia("print");return L(b(window,"beforeprint").pipe(l(()=>!0)),b(window,"afterprint").pipe(l(()=>!1))).pipe(q(e.matches))}function qr(e,t){return e.pipe(x(r=>r?t():R))}function pr(e,t={credentials:"same-origin"}){return pe(fetch(`${e}`,t)).pipe(fe(()=>R),x(r=>r.status!==200?Ot(()=>new Error(r.statusText)):H(r)))}function We(e,t){return pr(e,t).pipe(x(r=>r.json()),J(1))}function mo(e,t){let r=new DOMParser;return pr(e,t).pipe(x(n=>n.text()),l(n=>r.parseFromString(n,"text/xml")),J(1))}function lr(e){let t=M("script",{src:e});return I(()=>(document.head.appendChild(t),L(b(t,"load"),b(t,"error").pipe(x(()=>Ot(()=>new ReferenceError(`Invalid script: ${e}`))))).pipe(l(()=>{}),C(()=>document.head.removeChild(t)),Te(1))))}function ho(){return{x:Math.max(0,scrollX),y:Math.max(0,scrollY)}}function bo(){return L(b(window,"scroll",{passive:!0}),b(window,"resize",{passive:!0})).pipe(l(ho),q(ho()))}function vo(){return{width:innerWidth,height:innerHeight}}function go(){return b(window,"resize",{passive:!0}).pipe(l(vo),q(vo()))}function yo(){return Q([bo(),go()]).pipe(l(([e,t])=>({offset:e,size:t})),J(1))}function mr(e,{viewport$:t,header$:r}){let n=t.pipe(X("size")),o=Q([n,r]).pipe(l(()=>Je(e)));return Q([r,t,o]).pipe(l(([{height:i},{offset:s,size:a},{x:f,y:c}])=>({offset:{x:s.x-f,y:s.y-c+i},size:a})))}(()=>{function e(n,o){parent.postMessage(n,o||"*")}function t(...n){return n.reduce((o,i)=>o.then(()=>new Promise(s=>{let a=document.createElement("script");a.src=i,a.onload=s,document.body.appendChild(a)})),Promise.resolve())}var r=class extends EventTarget{constructor(n){super(),this.url=n,this.m=i=>{i.source===this.w&&(this.dispatchEvent(new MessageEvent("message",{data:i.data})),this.onmessage&&this.onmessage(i))},this.e=(i,s,a,f,c)=>{if(s===`${this.url}`){let u=new ErrorEvent("error",{message:i,filename:s,lineno:a,colno:f,error:c});this.dispatchEvent(u),this.onerror&&this.onerror(u)}};let o=document.createElement("iframe");o.hidden=!0,document.body.appendChild(this.iframe=o),this.w.document.open(),this.w.document.write(`

Automation actions

Actions are the end results of the automation described in your .cm file.

Legend

The icons indicate the availability status of each action.

  • Supported on GitHub
  • Supported on GitLab
  • Open beta - Feature is under development and currently available for all

Overview

send-http-request is executed immediately after the evaluation of the condition. For all other actions, gitStream executes the actions in the order they are listed per automation. If an action result fails, the following actions will not be executed.

Note

Multiple actions can be listed in a single automation. The actions are invoked one by one.

Dynamic actions arguments

Arguments values a dynamic value is supported using expressions based on Jinja2 syntax, and includes gitStream context variables, for example:

automations:
+  pr_complexity:
+    if:
+      - true
+    run:
+      - action: add-comment@v1
+        args:
+          comment: "Estimated {{ branch | estimatedReviewTime }} minutes to review"
+

Reference

add-comment

This action, once triggered, adds a comment to the PR.

This is a managed action, when a PR updates, the existing comments that were added by gitStream are re-evaluated and those that are not applicable are removed.

Args Usage Type Description
comment Required String Sets the comment, markdown is supported
example
automations:
+  senior_review:
+    if:
+      - {{ files | match(term='core/') | some }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: |
+            Core service update
+            (Updates API)
+

add-github-check

This action, once triggered, adds a completed check with the specified conclusion to the listed checks in the PR.

Args Usage Type Description
check_name Required String The check name to be added to the checks list on gitHub
conclusion Required String The conclusion of the check. The value is one of the following: action_required, cancelled, timed_out, failure, neutral, skipped, success
example
automations:
+  # Skip UI checks if the PR doesn't have a UI code changes
+  skip_ui_check:
+    if:
+      - {{ not has.fe_code_changes }}
+    run:
+      - action: add-github-check@v1
+        args:
+          check_name: FE-tests
+          conclusion: skipped
+has:
+    fe_code_changes: {{ files | match(regex=r/frontend\//) | some }}
+

add-label

This action, once triggered, adds a label to the PR.

This is a managed action, when a PR updates, the existing labels that were added by gitStream are re-evaluated and those that are not applicable are removed.

Args Usage Type Description
label Required String The label text any string can work
color Optional String The color in hex, for example: 'FEFEFE' (you can also add # prefix #FEFEFE)
example
automations:
+  senior_review:
+    if:
+      - {{ files | match(term='api/') | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: api-change
+

add-labels

This action, once triggered, adds a list of labels to the PR.

This is a managed action, when a PR updates existing labels that were added by gitStream are re-evaluated and those that are not applicable are removed.

Args Usage Type Description
labels Required [String] The list of text labels

add-reviewers

This action, once triggered, sets a specific reviewer.

Args Usage Type Description
reviewers Required [String] Sets required reviewers. Supports user names and teams. Teams notated by adding a prefix with the owner name e.g. owner/team
team_reviewers Optional [String] Sets required team reviewers without a prefix team
unless_reviewers_set Optional Bool When true, the reviewers are not added if the PR has already assigned reviewers. It is set to false by default
fail_on_error Optional Bool When true, trying to assign illegal reviewers shall fail the automation, when false these errors are silently ignored. It is set to true by default
wait_for_all_checks Optional Boolean By default false. When true, the action will add reviewers only if all checks (except gitStream) are completed with neutral, skipped, or success conclusion
example
automations:
+  senior_review:
+    if:
+      - {{ files | match(term='src/ui/') }}
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: [popeye, olive, acme/team-a]
+

Enable Team Write Access

If you want to assign teams as PR reviewers, you need to first make sure the team has write access to the repo in via your organization's settings. For more info, refer to the GitHub instructions for managing team review settings.

explain-code-experts

This action, shall add a comment with codeExperts suggestion. If the comment already exists, the comment shall be edited.

Args Usage Type Description
lt Optional Integer Filter the user list, keeping those below the specified threshold
gt Optional Integer Filter the user list, keeping those above the specified threshold
verbose Optional Bool When set to false then only shows the suggestion summary and skips the per file details (true by default)
example
automations:
+  code_experts:
+    if:
+      - true
+    run:
+      - action: explain-code-experts@v1
+        args:
+          gt: 10
+

approve

This action, once triggered, approves the PR for merge.

This is a managed action, when a PR updates existing approval by gitStream is re-evaluated and removed if no longer applicable.

example
automations:
+  small_change:
+    if:
+      - {{ source.diff.files | isFormattingChange }}
+    run:
+      - action: approve@v1
+

close

This action, once triggered, close the PR without merging.

example
automations:
+  close_ui_changes_by_non_ui:
+    if:
+      - {{ files | match(regex=r/src\/views/) | some }}
+      - {{ pr.author_teams | match(term='ui-team') | nope }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: |
+            Please contact a member of `ui-team` team if you need to make changes to files in `src/views`
+      - action: close@v1
+

merge

Once triggered, merge the PR if possible. It can be set to wait for all checks to pass or only required ones.

Args Usage Type Description
wait_for_all_checks Optional Boolean By default false, so only Required checks can block merge, when true the action will merge after all checks are completed with neutral, skipped, or success conclusion (except gitStream itself)
rebase_on_merge Optional Boolean By default false, when merging use rebase mode
squash_on_merge Optional Boolean By default false, when merging use squash mode
example
automations:
+  small_change:
+    if:
+      - {{ files | allDocs }}
+    run:
+      - action: merge@v1
+        args:
+          rebase_on_merge: true
+

request-changes

This action, once triggered, requests changes on the PR. As long as request change is set, gitStream will block the PR merge.

This is a managed action, when a PR updates an existing change request by gitStream is re-evaluated and removed if no longer applicable.

Args Usage Type Description
comment Required [String] The desired request changes comment
example
automations:
+  catch_deprecated:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/^[+].*oldFetch/) | some }}
+    run:
+      - action: request-changes@v1
+        args:
+          comment: |
+            You have used deprecated API `oldFetch`, use `newFetch` instead.
+

Attention

To allow this action to block merge, The following settings should be set:

Enable branch protection and set gitStream as a required check

Enable the "All threads must be resolved" Merge check

require-reviewers

This action, once triggered, requires a specific reviewer approval. The PR merge is blocked till approved by either of the listed users or teams.

Args Usage Type Description
reviewers Required [String] Sets required reviewers. Supports user names and teams. Teams notated by adding a prefix with the owner name e.g. owner/team. Merge is blocked till approved by either of the listed users
also_assign Optional Bool true by default, also assign the specified users as reviewers
example
automations:
+  senior_review:
+    if:
+      - {{ files | match(regex=r/src\/ui\//) | some }}
+    run:
+      - action: require-reviewers@v1
+        args:
+          reviewers: [popeye, olive, acme/team-a]
+

Attention

To allow this action to block merge, you should enable branch protection, and gitStream has to be set as required check in GitHub.

run-github-workflow

This action, once triggered, will start a workflow dispatch automation with the option to add a check to the list of checks in the PR

Args Usage Type Description
workflow Required String The ID or name of the workflow dispatch.
owner Optional String By default, the value of repo.owner context variable. The account owner of the repository. Case insensitive.
repo Optional String By default, the value of repo.name context variable. The name of the repository without the .git extension. Case insensitive.
ref Optional String By default, the value of branch.name context variable. The account owner of the repository. Case insensitive.
inputs Optional String By default, an empty list. Key-Value list with the arguments to provide to the workflow
check_name Optional String When added, after the workflow is complete, add the check name to the checks list on GitHub
stop_ongoing_workflow Optional Boolean By default, false. In case the workflow already runs on the branch, if true: cancel the ongoing workflow before running the newly dispatched workflow. If false: wait for the old workflow to finish before dispatching a new one
example
on:
+  - commit
+
+automations:
+  run_workflow_dispatch:
+    if:
+      - {{ has.fe_code_changes }}
+    run:
+      - action: run-github-workflow@v1
+        args:
+          owner: {{ repo.owner }}
+          repo: {{ repo.name}}
+          workflow: .github/workflows/frontend-manual.yml
+          ref: {{ branch.name }}
+          check_name: FE-tests
+has:
+    fe_code_changes: {{ files | match(regex=r/frontend\//) | some }}
+

Attention

  • This action will invoke the run of a workflow dispatch; thus, it might result in significant GitHub action minutes charge.
  • We encourage you to use this action with custom triggers

send-http-request

The action, once triggered, sends an HTTP request to the specified URL

Args Usage Type Description
url Required String The request URL
method Optional String By default GET, the request method
headers Optional [String] Empty by default ([]), Key-Value list of strings, which will be sent as the HTTP headers
user Optional String Empty by default, format: 'username:password'.
If used - adds a Basic-auth HTTP header, by setting the Authorization header. Using this arg will override any existing Authorization header that was set using headers
body Optional String Empty by default, the data to be sent as the request body. Only applicable for request methods PUT, POST, DELETE, and PATCH
timeout Optional String Empty by default (no timeout), the number of milliseconds before the request times out. When the time out is reached, the request will be aborted
example
automations:
+  send_webhook:
+    if:
+      - true
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "http://WEBHOOK_URL"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{"text": "Hello, world!"}'
+

send-slack-message

The action, once triggered, sends a webhook with a message content to a Slack app. To use this action, create a Slack app with Incoming Webhooks enabled. gitStream uses the webhook URL to send the message.

Args Usage Type Description
message Required String The message content
webhook_url Optional String The webhook URL. Use the env variable to pass secrets
example
automations:
+  send_slack:
+    if:
+      - true
+    run:
+      - action: send-slack-message@v1
+        args:
+          message: "Hello world :tada:."
+          webhook_url: "{{ slack_webhook }}"
+
+slack_webhook: {{ env.SLACK_WEBHOOK }}
+

set-required-approvals

This action, once triggered, blocks PR merge till the desired reviewers approved the PR. The actions fail the check to prevent the PR for merge.

Args Usage Type Description
approvals Required Integer Sets the number of required reviewer approvals for merge for that PR
example
automations:
+  double_review:
+    if:
+      - {{ files | match(regex=r/agent\//) | some }}
+    run:
+      - action: set-required-approvals@v1
+        args:
+          approvals: 2
+

Attention

To allow this action to block merge, you should enable branch protection, and gitStream has to be set as required check in GitHub.

update-description

This action, when triggered, updates the PR description with new content.

This is a managed action. When a PR updates, the existing comments that were added by gitStream are re-evaluated, and those that are not applicable are removed.

Args Usage Type Description
description Required String Sets the PR description
concat_mode Optional String replace by default, the mode to concatenate the new description with the existing one. Possible values: prepend, append, replace

For example, this automation updates the PR description with the ticket info if present in the PR title.

example
automations:
+  add_jira_to_desc:
+    if:
+      - {{ has.jira_ticket_in_title and (not has.jira_ticket_in_desc) }}
+    run:
+      - action: update-description@v1
+        args:
+          concat_mode: prepend
+          description: |
+            {{ jira_ticket_from_title }}
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }}
+
+jira_ticket_from_title: {{ pr.title | capture(regex=r/\b[A-Za-z]+-\d+\b/) }}
+

update-title

This action, when triggered, updates the PR title with new content.

This is a managed action. When a PR updates, the existing comments that were added by gitStream are re-evaluated, and those that are not applicable are removed.

Args Usage Type Description
title Required String Sets the PR title
concat_mode Optional String replace by default, the mode to concatenate the new description with the existing one. Possible values: prepend, append, replace

For example, this automation updates the PR title with the ticket info if present in the PR title.

example
automations:
+  add_jira_to_title:
+    if:
+      - {{ has.jira_ticket_in_desc and (not has.jira_ticket_in_title) }}
+    run:
+      - action: update-title@v1
+        args:
+          concat_mode: prepend
+          title: |
+            {{ jira_ticket_from_desc }} -
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }}
+
+jira_ticket_from_desc: {{ pr.description | capture(regex=r/\b[A-Za-z]+-\d+\b/) }}
+
\ No newline at end of file diff --git a/automations/additional-review-for-large-pr/Additional-review-for-large-PR.svg b/automations/additional-review-for-large-pr/Additional-review-for-large-PR.svg new file mode 100644 index 00000000..a6fe9be3 --- /dev/null +++ b/automations/additional-review-for-large-pr/Additional-review-for-large-PR.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/additional-review-for-large-pr/additional_review_for_large_pr.png b/automations/additional-review-for-large-pr/additional_review_for_large_pr.png new file mode 100644 index 00000000..d3dc53a4 Binary files /dev/null and b/automations/additional-review-for-large-pr/additional_review_for_large_pr.png differ diff --git a/automations/additional-review-for-large-pr/index.html b/automations/additional-review-for-large-pr/index.html new file mode 100644 index 00000000..2ce62f9e --- /dev/null +++ b/automations/additional-review-for-large-pr/index.html @@ -0,0 +1,20 @@ + Automation - Additional Review for Large PRs - gitStream Documentation

Additional Review for Large PRs

Require 2 reviewers for PRs that have more than 10 changed files in the src directory and the estimated time to review is 30 or more minutes.

Additional Review for Large PRs

Configuration Description

Conditions (all must be true):

  • There are 10 or more changed files
  • The estimated time to review is 30 minutes or more.
  • One or more of the changed files is inside the src directory.

Automation Actions:

  • Require a minumim of 2 reviews.
  • Post a comment that explains this is considered a large change that requires 2 reviews.

Additional Review for Large PRs

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  additional_review_for_large_pr:
+    if:
+      - {{ branch | estimatedReviewTime >= 30 }}
+      - {{ files | length >= 10 }}
+      - {{ files | match(regex=r/src\//) | some }}
+    run:
+      - action: set-required-approvals@v1
+        args:
+          approvals: 2
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR is a large change and requires 2 reviews.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/additional-review-for-large-pr/logo_additional_review_for_large_pr.png b/automations/additional-review-for-large-pr/logo_additional_review_for_large_pr.png new file mode 100644 index 00000000..fc91b8a7 Binary files /dev/null and b/automations/additional-review-for-large-pr/logo_additional_review_for_large_pr.png differ diff --git a/automations/approve-javascript-formatting-change/index.html b/automations/approve-javascript-formatting-change/index.html new file mode 100644 index 00000000..e4756cbc --- /dev/null +++ b/automations/approve-javascript-formatting-change/index.html @@ -0,0 +1,15 @@ + + + + + + Redirecting... + + + + + + +Redirecting... + + diff --git a/automations/approve-javascrpt-log-output/index.html b/automations/approve-javascrpt-log-output/index.html new file mode 100644 index 00000000..e3db89dd --- /dev/null +++ b/automations/approve-javascrpt-log-output/index.html @@ -0,0 +1,15 @@ + + + + + + Redirecting... + + + + + + +Redirecting... + + diff --git a/automations/approve-python-formatting-change/index.html b/automations/approve-python-formatting-change/index.html new file mode 100644 index 00000000..e8679658 --- /dev/null +++ b/automations/approve-python-formatting-change/index.html @@ -0,0 +1,15 @@ + + + + + + Redirecting... + + + + + + +Redirecting... + + diff --git a/automations/approve-python-log-output/index.html b/automations/approve-python-log-output/index.html new file mode 100644 index 00000000..140cfc58 --- /dev/null +++ b/automations/approve-python-log-output/index.html @@ -0,0 +1,15 @@ + + + + + + Redirecting... + + + + + + +Redirecting... + + diff --git a/automations/approve-safe-changes/Approve-safe-changes.svg b/automations/approve-safe-changes/Approve-safe-changes.svg new file mode 100644 index 00000000..43cf5533 --- /dev/null +++ b/automations/approve-safe-changes/Approve-safe-changes.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/approve-safe-changes/approve-safe-changes.png b/automations/approve-safe-changes/approve-safe-changes.png new file mode 100644 index 00000000..19d1055f Binary files /dev/null and b/automations/approve-safe-changes/approve-safe-changes.png differ diff --git a/automations/approve-safe-changes/index.html b/automations/approve-safe-changes/index.html new file mode 100644 index 00000000..c6f0456b --- /dev/null +++ b/automations/approve-safe-changes/index.html @@ -0,0 +1,31 @@ + Automation - Approve Safe Changes - gitStream Documentation

Approve Safe Changes

Automatically approve PRs that change docs, tests, and other safe assets.

Approve safe changes

Configuration Description

Conditions (all must be true):

  • The PR only contains documentation, tests, or formatting changes.

Automation Actions:

  • Add a safe-change label
  • Approve the PR
  • Post a comment that explains that this is a safe change

Approve Safe Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  safe_changes:
+    # Triggered for any changes that only affect formatting, documentation, tests, or images
+    if:
+      - {{ is.formatting or is.docs or is.tests or is.image }}
+    # Apply a safe change label, approve the PR and explain why in a comment.
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'safe-change'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR is considered a safe change and has been automatically approved.
+
+# These custom expressions are used in the safe_changes automation
+is:
+  formatting: {{ source.diff.files | isFormattingChange }}
+  docs: {{ files | allDocs }}
+  tests: {{ files | allTests }}
+  image: {{ files | allImages }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/approve-safe-changes/logo_approve_safe_changes.png b/automations/approve-safe-changes/logo_approve_safe_changes.png new file mode 100644 index 00000000..b3a8f3f8 Binary files /dev/null and b/automations/approve-safe-changes/logo_approve_safe_changes.png differ diff --git a/automations/approve-swimm/index.html b/automations/approve-swimm/index.html new file mode 100644 index 00000000..352e9c15 --- /dev/null +++ b/automations/approve-swimm/index.html @@ -0,0 +1,15 @@ + + + + + + Redirecting... + + + + + + +Redirecting... + + diff --git a/automations/approve-team-by-directory/approve_team_by_directory.png b/automations/approve-team-by-directory/approve_team_by_directory.png new file mode 100644 index 00000000..922135bb Binary files /dev/null and b/automations/approve-team-by-directory/approve_team_by_directory.png differ diff --git a/automations/approve-team-by-directory/index.html b/automations/approve-team-by-directory/index.html new file mode 100644 index 00000000..2aa29378 --- /dev/null +++ b/automations/approve-team-by-directory/index.html @@ -0,0 +1,19 @@ + Automation - Approve Trusted Team - gitStream Documentation

Approve Trusted Team

Automatically approve low-risk PRs from trusted teams.

Approve Expert Team

Configuration Description

Conditions (all must be true):

  • All changed files are inside the docs directory
  • The PR author is on the tech-writers team.

Automation Actions:

  • Approve the PR
  • Post a comment that explains the approval.

Approve Expert Team

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_team_by_directory:
+    # Triggered for PRs that only include changes to files inside the docs directory,
+    # and that are authored by someone on the tech-writers team.
+    if:
+      - {{ files | match(regex=r/docs\//) | every }}
+      - {{ pr.author_teams | match(term='tech-writers') }}
+    run: 
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Docs changes from the tech-writers team are automatically approved.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/approve-tests/approve_tests.png b/automations/approve-tests/approve_tests.png new file mode 100644 index 00000000..68f88001 Binary files /dev/null and b/automations/approve-tests/approve_tests.png differ diff --git a/automations/approve-tests/index.html b/automations/approve-tests/index.html new file mode 100644 index 00000000..9ea6620e --- /dev/null +++ b/automations/approve-tests/index.html @@ -0,0 +1,20 @@ + Automation - Approve test changes - gitStream Documentation

Approve test changes

Label and approve PRs that only include tests, and post an explanation comment.

Adding tests example

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to tests

Automation Actions:

  • Add a tests-only label
  • Approve the PR
  • Post a comment that explains why the PR was approved.

Approve Tests

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_tests:
+    if:
+      # Triggered for PRs that only include changes to tests
+      - {{ files | allTests }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'tests-only'
+      - action: add-comment@v1
+        args:
+          comment: |
+            This merge has been automatically approved because it only contains changes to tests.
+      - action: approve@v1
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/approve-tiny-changes/Approve-tiny-changes.svg b/automations/approve-tiny-changes/Approve-tiny-changes.svg new file mode 100644 index 00000000..cea2d570 --- /dev/null +++ b/automations/approve-tiny-changes/Approve-tiny-changes.svg @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/approve-tiny-changes/approve_tiny_change.png b/automations/approve-tiny-changes/approve_tiny_change.png new file mode 100644 index 00000000..1b05bae1 Binary files /dev/null and b/automations/approve-tiny-changes/approve_tiny_change.png differ diff --git a/automations/approve-tiny-changes/index.html b/automations/approve-tiny-changes/index.html new file mode 100644 index 00000000..23025279 --- /dev/null +++ b/automations/approve-tiny-changes/index.html @@ -0,0 +1,30 @@ + Automation - Approve Tiny Changes - gitStream Documentation

Approve Tiny Changes

Approve single-line changes to a single file.

Approve tiny change

Configuration Description

Conditions (all must be true):

  • If the PR contains a one-line change to a single file.

Automation Actions:

  • Apply a single-line label.
  • Approve the PR.
  • Post a comment explaining why the PR was approved.

name

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_tiny_change:
+    # Triggered for PRs that contain one file and one line.
+    if:
+      - {{ is.one_file and is.one_line }}
+    run:
+      - action: add-label@v1
+        args:
+          label: 'single-line'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it is only a single line
+
+changes:
+  # Sum all the lines added in the PR
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+  # Sum all the line removed in the PR
+  deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}
+
+is:
+  one_file: {{ files | length == 1 }}
+  one_line: {{ changes.additions - changes.deletions <= 1 }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/approve-tiny-changes/logo_approve_tiny_changes.png b/automations/approve-tiny-changes/logo_approve_tiny_changes.png new file mode 100644 index 00000000..2bdafc33 Binary files /dev/null and b/automations/approve-tiny-changes/logo_approve_tiny_changes.png differ diff --git a/automations/assign-reviewers-by-directory/assign_reviewers_by_directory.png b/automations/assign-reviewers-by-directory/assign_reviewers_by_directory.png new file mode 100644 index 00000000..8e045f80 Binary files /dev/null and b/automations/assign-reviewers-by-directory/assign_reviewers_by_directory.png differ diff --git a/automations/assign-reviewers-by-directory/index.html b/automations/assign-reviewers-by-directory/index.html new file mode 100644 index 00000000..f12d2dbb --- /dev/null +++ b/automations/assign-reviewers-by-directory/index.html @@ -0,0 +1,21 @@ + Automation - Assign Reviewers by Directory - gitStream Documentation

Assign Reviewers by Directory

Automatically assign code reviewers based on directory structure. Optionally, you can substitue require-reviewers for add-reviewers to make review from the specified teams and individuals mandatory.

Assign Reviewers by Directory

Configuration Description

Conditions (all must be true):

  • The PR contains changes to JavaScript files inside the src/ui directory.

Automation Actions:

  • Add a user named my-teamate and a team named my-organization/ui-team as reviewers. These should be customized to match your organization.
  • Post a comment explaining why these reviewers were assigned.

Assign Reviewers by Directory

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_ui:
+    # Triggered for PRs that contain any changes to JavaScript files inside the `src/ui` directory.
+    if:
+      - {{ files | match(regex=r/src\/ui\/.*/) | some}}
+    # Add a specified user and team as reviewers.
+    # Customize the reviewers to match your organization
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: [my-teamate, my-organization/security]
+      - action: add-comment@v1
+        args:
+          comment: |
+            The Security team has automatically been added for review because this PR contains changes to components inside `/src/ui`
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/assign-team-members-as-reviewers/index.html b/automations/assign-team-members-as-reviewers/index.html new file mode 100644 index 00000000..a961785c --- /dev/null +++ b/automations/assign-team-members-as-reviewers/index.html @@ -0,0 +1,14 @@ + Automation - Assign team members as reviewers - gitStream Documentation

Assign team members as reviewers

Assign PR reviewer based on the owner team membership.

You can also omit the | first filter to assign all teams the owner is member of.

name

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  add_first_team_reviewer:
+    if:
+      - true
+    run:
+      - action: add-reviewers@v1
+        args:
+          team_reviewers: {{ pr.author_teams | first }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/automation-library/index.html b/automations/automation-library/index.html new file mode 100644 index 00000000..af99b0f5 --- /dev/null +++ b/automations/automation-library/index.html @@ -0,0 +1 @@ + gitStream Automation Library - gitStream Documentation

gitStream Automation Library

This library of gitStream examples is meant to serve as a starting point for your automation. We encourage you to customize them for your project and organization.

How to use these examples.

These examples are all complete gitStream configuration files that you can download directly via the buttons below the examples and upload to the .cm directory of your repo. Alternatively, you can copy and paste the individual automations, but make sure you include all required declarations and any related custom expressions from the configurations to ensure they work properly.

Improve PR Efficiency

Auto-Approve Merges

Add PR Context With Labels and Comments

Improve PR Quality

Merge Routing

Quality Checks

Security and Policy Compliance

These examples help you follow your team's security best practices.

Third-party Integrations

GitHub / GitLab

Security & Compliance

Project Management

Chat & Communications

Feature Flags

Languages

Documentation

Other

Utilities

These examples provide useful components to use in other automations. These aren't intended to be used on their own; instead they act as a reference point for improving other automations.

  • Colors custom expression - A custom expression that implements all of GitHub's default label colors in a custom expression.
  • CM File Header - A header to copy/paste to the top of your CM files to help yourself, and others, understand the purpose of the file.

Contribute Your Idea

Have a great idea for an automation that should be included in this library?

Submit your configuration on GitHub. We'll recognize your contribution publicly (if you want) and might even send you some special swag for your contribution.

\ No newline at end of file diff --git a/automations/change-deprecated-components/change_deprecated_components.png b/automations/change-deprecated-components/change_deprecated_components.png new file mode 100644 index 00000000..bfc3dcfe Binary files /dev/null and b/automations/change-deprecated-components/change_deprecated_components.png differ diff --git a/automations/change-deprecated-components/index.html b/automations/change-deprecated-components/index.html new file mode 100644 index 00000000..32b433a6 --- /dev/null +++ b/automations/change-deprecated-components/index.html @@ -0,0 +1,34 @@ + Automation - Change Deprecated Components - gitStream Documentation

Change Deprecated Components

Request changes when a PR includes one or more deprecated components.

Change Deprecated Components

Configuration Description

Conditions (all must be true):

  • A PR contains one or more references to functions, methods, or classes that have been designated as deprecated.

Automation Actions:

  • Add a deprecated-component label to the PR
  • Request changes to the PR and post a comment that explains what deprecated component was included and what the alternative is.

Change Deprecated Components

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  # Request changes when a PR includes deprecated components.
+  # This requires the `item` custom expression found at the bottom of this file.
+  {% for item in deprecated %}
+  # Automation names must be unique, so this adds an iterator index to each instance
+  review_deprecated_component_{{ item.old }}:
+    # Triggered when any of the modified files use a deprecated component
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
+    # Apply a deprecated-component label, request changes, and post a comment with an explanation.
+    run:
+      - action: add-label@v1
+        args:
+          label: 'deprecated-component'
+          color: '#FF0000'
+      - action: request-changes@v1
+        args:
+          comment: |
+            `{{ item.old }}` component is deprecated, use `{{ item.new }}` instead
+  {% endfor %}
+
+# These are the deprecated files that are evaluated in catch_deprecated_components
+deprecated:
+  - regex: r/oldAPI/
+    old: oldAPI
+    new: newAPI
+  - regex: r/anotherOldAPI/
+    old: anotherOldAPI
+    new: anotherNewAPI
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/change-missing-lambda-field/change_missing_lambda_field.png b/automations/change-missing-lambda-field/change_missing_lambda_field.png new file mode 100644 index 00000000..88dc0e86 Binary files /dev/null and b/automations/change-missing-lambda-field/change_missing_lambda_field.png differ diff --git a/automations/change-missing-lambda-field/index.html b/automations/change-missing-lambda-field/index.html new file mode 100644 index 00000000..96fa61e7 --- /dev/null +++ b/automations/change-missing-lambda-field/index.html @@ -0,0 +1,22 @@ + Automation - Change Missing Lambda Field - gitStream Documentation

Change Missing Lambda Field

If a PR creates a new Lambda function, but lacks a description field, gitStream will request changes and post a comment that explains why.

Change Missing Lambda Info

Configuration Description

Conditions (all must be true):

  • The PR contains an update to a Lambda function.
  • The affected files are missing a description field.

Automation Actions:

  • Add a lambda-missing-field label to the PR.
  • Request changes and post a comment that explains why.

Change Missing Lambda Field

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  # Request changes when required Lambda information is missing from the PR.
+  catch_missing_lambda_info:
+    # Triggered for new Lambda functions that are missing a description field.
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/LambdaFunction/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=r/description:/) | nope }}
+    # Apply the lambda-missing-field label and request changes to the PR.
+    run:
+      - action: add-label@v1
+        args:
+          label: 'lambda-missing-field'
+          color: '#FF0000'
+      - action: request-changes@v1
+        args:
+          comment: |
+            New `LambdaFunction` must have `description:` field.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/close-wrong-team-by-directory/close_wrong_team_by_directory.png b/automations/close-wrong-team-by-directory/close_wrong_team_by_directory.png new file mode 100644 index 00000000..6e068ea0 Binary files /dev/null and b/automations/close-wrong-team-by-directory/close_wrong_team_by_directory.png differ diff --git a/automations/close-wrong-team-by-directory/index.html b/automations/close-wrong-team-by-directory/index.html new file mode 100644 index 00000000..ae05f220 --- /dev/null +++ b/automations/close-wrong-team-by-directory/index.html @@ -0,0 +1,18 @@ + Automation - Close Wrong Team by Directory - gitStream Documentation

Close Wrong Team by Directory

Close PRs to a specified directory if the PR author is not on an approved team.

Close Wrong Team by Directory

Configuration Description

Conditions (all must be true):

  • The PR changes one or more files inside /src/views. Customize this value for your project.
  • The PR author is not a member of the ui team. Customize this value for your organization.

Automation Actions:

  • Close the PR.
  • Post a comment that explains why the PR was closed.

Close Wrong Team by Directory

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  # Close PRs to restricted sections of the codebase if the PR author isn't on the correct team. 
+  close_wrong_team_by_directory:
+    # Triggered when someone who isn't on the `ui` team submits a PR to change files inside /src/views
+    if:
+      - {{ files | match(regex=r/src\/views/) | some }}
+      - {{ pr.author_teams | match(term='ui') | nope }}
+    # Close the PR and post a comment explaining the next step.
+    run:
+      - action: add-comment@v1
+        args: 
+          comment: Please contact a member of the `ui` team if you need to make changes to files in `src/views`
+      - action: close@v1
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/asana/label-missing-asana/index.html b/automations/integrations/asana/label-missing-asana/index.html new file mode 100644 index 00000000..6cea4947 --- /dev/null +++ b/automations/integrations/asana/label-missing-asana/index.html @@ -0,0 +1,26 @@ + Automation - Label Missing Asana - gitStream Documentation

Label Missing Asana

Automatically label PRs that are missing references to Asana resources.

Label Missing Asana

Configuration Description

Conditions (all must be true):

  • The PR is missing an Asana ticket reference in the PR title and a link to an Asana resource in the PR description.

Automation Actions:

  • Apply a red ⚠️ Missing Asana Link label
  • Post a comment that asks the author to add an Asana reference to the PR.

Label Missing Asana

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_missing_asana:
+    if:
+      - {{not (has.asana.ticket_in_title or has.asana.ticket_in_desc)}}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Asana Link"
+          color: {{ colors.red }}
+      - action: add-comment@v1
+        args:
+          comment: Please provide a link to the associated Asana resource.
+
+has:
+  asana:
+    ticket_in_title: {{ pr.title | includes(regex=r/asana-(\d+)/) }}
+    ticket_in_desc: {{ pr.description | includes(regex=r/app\.asana.\com\/(\d+)\/(\d+)\/(\d+)\/(\d+)\/(\d+)/) }}
+
+colors:
+  red: 'b60205'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/asana/label-missing-asana/label-missing-asana.svg b/automations/integrations/asana/label-missing-asana/label-missing-asana.svg new file mode 100644 index 00000000..fe978cfa --- /dev/null +++ b/automations/integrations/asana/label-missing-asana/label-missing-asana.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/automations/integrations/asana/label-missing-asana/logo_label_missing_asana.png b/automations/integrations/asana/label-missing-asana/logo_label_missing_asana.png new file mode 100644 index 00000000..fab7f334 Binary files /dev/null and b/automations/integrations/asana/label-missing-asana/logo_label_missing_asana.png differ diff --git a/automations/integrations/asana/link-asana/index.html b/automations/integrations/asana/link-asana/index.html new file mode 100644 index 00000000..1ffe4b05 --- /dev/null +++ b/automations/integrations/asana/link-asana/index.html @@ -0,0 +1,39 @@ + Automation - Automatically Link PRs to Related Asana Cards - gitStream Documentation

Automatically Link PRs to Related Asana Cards

Provide automatic links to Asana cards that are associated with PRs.

Automatically Link to the Related Asana Card

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Asana card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Asana Card.

Automatically Link to the Related Asana Card

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+provider: asana
+
+# Configure this to match your organization. It is used in tracker.asana.baseurl.
+asanaProject: 1234
+
+{% set ticketid = "" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  link_asana:
+    if:
+      - {{ has.ticket_in_title or has.ticket_in_branch }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})
+
+has:
+  ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}
+  ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}
+
+tracker:
+  asana:
+    baseurl: https://app.asana.com/0/[asanaProject]/0/
+    pattern: r/asana-(\d+)/
+
+tickets:
+  - {{branch.name | capture(regex=tracker[provider].pattern)}}
+  - {{pr.title | capture(regex=tracker[provider].pattern)}}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/asana/link-asana/link-asana.svg b/automations/integrations/asana/link-asana/link-asana.svg new file mode 100644 index 00000000..e555fef1 --- /dev/null +++ b/automations/integrations/asana/link-asana/link-asana.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/automations/integrations/asana/link-asana/logo_link_asana.png b/automations/integrations/asana/link-asana/logo_link_asana.png new file mode 100644 index 00000000..fab7f334 Binary files /dev/null and b/automations/integrations/asana/link-asana/logo_link_asana.png differ diff --git a/automations/integrations/azure-boards/label-missing-azure-boards/index.html b/automations/integrations/azure-boards/label-missing-azure-boards/index.html new file mode 100644 index 00000000..e49fdcaa --- /dev/null +++ b/automations/integrations/azure-boards/label-missing-azure-boards/index.html @@ -0,0 +1,26 @@ + Automation - Label Missing Azure Boards Info - gitStream Documentation

Label Missing Azure Boards Info

Automatically label PRs that are missing references to Azure Boards resources.

Label Missing Azure Boards

Configuration Description

Conditions (all must be true):

  • The PR is missing one of the following:
    • An Azure Boards ticket reference in the PR title.
    • A link to an Azure Boards resource in the PR description.

Automation Actions:

  • Apply a red ⚠️ Missing Azure Boards Link label
  • Post a comment that asks the author to add an Azure Boards reference to the PR.

Label Missing Azure Boards

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_missing_azure:
+    if:
+      - {{not (has.azure.ticket_in_title or has.azure.ticket_in_desc)}}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Azure Boards Link"
+          color: {{ colors.red }}
+      - action: add-comment@v1
+        args:
+          comment: Please provide a link to the associated resource in Azure Boards.
+
+has:
+  azure:
+    ticket_in_title: {{ pr.title | includes(regex=r/(\w+)-(\w+)-(\d+)/) }}
+    ticket_in_desc: {{ pr.description | includes(regex=r/(dev\.azure\.com|(\w+)\.visualstudio\.com)\/(\w+)\/(\w+)\/_workitems\/edit\/(\d+)/) }}
+
+colors:
+  red: 'b60205'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/azure-boards/label-missing-azure-boards/link-azure-boards.svg b/automations/integrations/azure-boards/label-missing-azure-boards/link-azure-boards.svg new file mode 100644 index 00000000..1b25affb --- /dev/null +++ b/automations/integrations/azure-boards/label-missing-azure-boards/link-azure-boards.svg @@ -0,0 +1,4 @@ + + + + diff --git a/automations/integrations/azure-boards/label-missing-azure-boards/logo_link_azure_boards.png b/automations/integrations/azure-boards/label-missing-azure-boards/logo_link_azure_boards.png new file mode 100644 index 00000000..cc6178dd Binary files /dev/null and b/automations/integrations/azure-boards/label-missing-azure-boards/logo_link_azure_boards.png differ diff --git a/automations/integrations/azure-boards/link-azure-boards/index.html b/automations/integrations/azure-boards/link-azure-boards/index.html new file mode 100644 index 00000000..33e9b690 --- /dev/null +++ b/automations/integrations/azure-boards/link-azure-boards/index.html @@ -0,0 +1,41 @@ + Automation - Automatically Link PRs to Related Azure Boards Resources - gitStream Documentation

Automatically Link PRs to Related Azure Boards Resources

Provide automatic links to Azure Boards resources that are associated with PRs.

Automatically Link to the Related Azure Boards Resource

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Azure Boards resource in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Azure Boards Resource.

Automatically Link to the Related Azure Boards Resource

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+# Configure these to match your organization.
+provider: azure
+# The name of your Azure organization
+orgName: org
+# The name of your Azure project
+azureProject: my_project
+
+{% set ticketid = "" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  link_azure_boards:
+    if:
+      - {{ has.ticket_in_title or has.ticket_in_branch }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})
+
+has:
+  ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}
+  ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}
+
+tracker:
+  azure:
+    baseurl: https://dev.azure.com/[orgName]/[azureProject]/_workitems/
+    pattern: r/(\w+)-(\w+)-(\d+)/
+
+tickets:
+  - {{branch.name | capture(regex=tracker[provider].pattern)}}
+  - {{pr.title | capture(regex=tracker[provider].pattern)}}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/azure-boards/link-azure-boards/link-azure-boards.svg b/automations/integrations/azure-boards/link-azure-boards/link-azure-boards.svg new file mode 100644 index 00000000..1b25affb --- /dev/null +++ b/automations/integrations/azure-boards/link-azure-boards/link-azure-boards.svg @@ -0,0 +1,4 @@ + + + + diff --git a/automations/integrations/azure-boards/link-azure-boards/logo_link_azure_boards.png b/automations/integrations/azure-boards/link-azure-boards/logo_link_azure_boards.png new file mode 100644 index 00000000..cc6178dd Binary files /dev/null and b/automations/integrations/azure-boards/link-azure-boards/logo_link_azure_boards.png differ diff --git a/automations/integrations/copilot/flag-copilot-pr/flag-copilot-pr.svg b/automations/integrations/copilot/flag-copilot-pr/flag-copilot-pr.svg new file mode 100644 index 00000000..89d3a05b --- /dev/null +++ b/automations/integrations/copilot/flag-copilot-pr/flag-copilot-pr.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/copilot/flag-copilot-pr/index.html b/automations/integrations/copilot/flag-copilot-pr/index.html new file mode 100644 index 00000000..5a170730 --- /dev/null +++ b/automations/integrations/copilot/flag-copilot-pr/index.html @@ -0,0 +1,84 @@ + Automation - Label GitHub Copilot PRs - gitStream Documentation

Automatically Label GitHub Copilot PRs

Automatically apply labels to PRs that are assisted by GitHub Copilot. You can apply labels based on a known list of Copilot users, PR tags, or by prompting the PR author to indicate if they used Copilot.

Prompt PR authors to indicate if they used Copilot for the PR and automatically label the PR if they did. This requires two separate automation files to handle posting the prompt and labeling accordingly.

Label Copilot by Prompt

Configuration Description

Conditions:

  • A PR is created

Automation Actions:

  • Post a comment prompting the author to indicate if Copilot assisted the author with writing the code in the PR.

Ask the PR author about Copilot usage.

-*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+
+automations:
+  comment_copilot_prompt:
+    # Post a comment for all PRs to prompt the PR author to indicate whether they used Copilot to assist coding in this PR
+    if:
+      - true
+    run:
+      - action: add-comment@v1
+        args:
+          comment: |
+            Please mark whether you used Copilot to assist coding in this PR
+
+            - [ ] Copilot Assisted
+            - [ ] Not Copilot Assisted
+

Configuration Description

Conditions:

  • A PR is updated or merged where the author indicates they used Copilot via a prompt.

Automation Actions:

  • Apply a 🤖 Copilot label to the PR

Label PRs where the user indicated Copilot usage

-*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  # You should use this automation in conjunction with comment_copilot_prompt.cm
+  label_copilot_pr:
+    # If the PR author has indicated that they used Copilot to assist coding in this PR, 
+    # apply a label indicating the PR was supported by Copilot
+    if:
+      - {{ pr.comments | filter(attr='commenter', term='gitstream-cm') | filter (attr='content', regex=r/\- \[x\] Copilot Assisted/) | some}}
+    run:
+      - action: add-label@v1
+        args:
+          label: '🤖 Copilot'
+

Automatically apply labels to PRs that are created by known users of generative AI coding tools.

Label by Contributors

Configuration Description

Conditions:

  • The PR author is one of a specified list of contributors

Automation Actions:

  • Apply a 🤖 Copilot label to the PR

Label by Contributors

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_genai:
+    # For all PRs authored by someone who is specified in the genai_contributors list
+    if:
+      - {{ pr.author | match(list=genai_contributors) | some  }}
+    # Apply a label indicating the user has adopted Copilot
+    run:
+      - action: add-label@v1
+        args:
+          label: '🤖 Copilot'
+
+genai_contributors:
+  - username1
+  - username2
+  - etc
+

Look for a specific tag in the PR title, description, comments or commit messages and if found add a label to the PR

Label Copilot by Tag

Configuration Description

Conditions:

  • The #copilot# tag is found in any of the PR title, description, comments or commit messages for commits in the PR

Automation Actions:

  • Apply a 🤖 Copilot label to the PR

Label Copilot by Tag

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - comment_added
+  - commit
+  - pr_created
+
+automations:
+  label_copilot:
+    # Detect PRs that contain the text '#copilot#' in the title, description, comments, or commit messages
+    if:
+      - {{ copilot_tag.pr_title or copilot_tag.pr_desc or copilot_tag.pr_comments or copilot_tag.commit_messages  }}
+    # Apply a label indicating the user has adopted Copilot
+    run:
+      - action: add-label@v1
+        args:
+          label: '🤖 Copilot'
+
+copilot_tag:
+  pr_title: {{ pr.title | includes(regex=r/#copilot#/) }}
+  pr_desc: {{pr.description | includes(regex=r/#copilot#/) }}
+  pr_comments: {{ pr.comments | map(attr='content') | match(regex=r/#copilot#/) | some }}
+  commit_messages: {{ branch.commits.messages | match(regex=r/#copilot#/) | some }}
+

\ No newline at end of file diff --git a/automations/integrations/copilot/flag-copilot-pr/label-copilot-by-contributors.png b/automations/integrations/copilot/flag-copilot-pr/label-copilot-by-contributors.png new file mode 100644 index 00000000..40dc341f Binary files /dev/null and b/automations/integrations/copilot/flag-copilot-pr/label-copilot-by-contributors.png differ diff --git a/automations/integrations/copilot/flag-copilot-pr/label-copilot-by-prompt.png b/automations/integrations/copilot/flag-copilot-pr/label-copilot-by-prompt.png new file mode 100644 index 00000000..2f2a951c Binary files /dev/null and b/automations/integrations/copilot/flag-copilot-pr/label-copilot-by-prompt.png differ diff --git a/automations/integrations/copilot/flag-copilot-pr/label-copilot-by-tag.png b/automations/integrations/copilot/flag-copilot-pr/label-copilot-by-tag.png new file mode 100644 index 00000000..e0e743f3 Binary files /dev/null and b/automations/integrations/copilot/flag-copilot-pr/label-copilot-by-tag.png differ diff --git a/automations/integrations/copilot/flag-copilot-pr/logo_flag_copilot_pr.png b/automations/integrations/copilot/flag-copilot-pr/logo_flag_copilot_pr.png new file mode 100644 index 00000000..117f155d Binary files /dev/null and b/automations/integrations/copilot/flag-copilot-pr/logo_flag_copilot_pr.png differ diff --git a/automations/integrations/dependabot/approve-dependabot/approve-dependabot.svg b/automations/integrations/dependabot/approve-dependabot/approve-dependabot.svg new file mode 100644 index 00000000..d8b1db8b --- /dev/null +++ b/automations/integrations/dependabot/approve-dependabot/approve-dependabot.svg @@ -0,0 +1,4 @@ + + + + diff --git a/automations/integrations/dependabot/approve-dependabot/index.html b/automations/integrations/dependabot/approve-dependabot/index.html new file mode 100644 index 00000000..847b028b --- /dev/null +++ b/automations/integrations/dependabot/approve-dependabot/index.html @@ -0,0 +1,49 @@ + Automation - Approve and Merge Dependabot Changes - gitStream Documentation

Approve and Merge Dependabot Changes

Auto-merge Dependabot PRs

Required gitStream Plugins

This example requires you to install the extractDependabotVersionBump and compareSemver plugins.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • The PR author is Dependabot.
  • The branch name includes 'dependabot'
  • The dependency change is a patch or minor update.

Automation Actions:

  • Approve the PR
  • Apply an approved-dependabot label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

manifest:
+  version: 1.0
+
+automations:
+  merge_dependabot_minor:
+    if:
+      - {{ bump == 'minor' }}
+      - {{ branch.name | includes(term="dependabot") }}
+      - {{ branch.author | includes(term="dependabot") }}
+    run:
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Dependabot `minor` version bumps are approved automatically.
+  merge_dependabot_minor_patch:
+    if:
+      - {{ bump == 'patch' }}
+      - {{ branch.name | includes(term="dependabot") }}
+      - {{ branch.author | includes(term="dependabot") }}
+    run:
+      - action: approve@v1
+      - action: merge@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Dependabot `patch` version bumps are approved and merged automatically.
+
+bump: {{ pr.description | extractDependabotVersionBump | compareSemver }}
+

Configuration Description

Conditions (all must be true):

  • The PR author is Dependabot.
  • The branch name includes 'dependabot'

Automation Actions:

  • Approve the PR
  • Apply an approved-dependabot label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_dependabot:
+    if:
+      - {{ branch.name | includes(term="dependabot") }}
+      - {{ branch.author | includes(term="dependabot") }}
+    run:
+      - action: approve@v1
+      - action: add-label@v1
+        args:
+          label: "approved-dependabot"
+      - action: merge@v1
+        args:
+          wait_for_all_checks: true
+          squash_on_merge: true
+

\ No newline at end of file diff --git a/automations/integrations/dependabot/approve-dependabot/logo_approve_dependabot.png b/automations/integrations/dependabot/approve-dependabot/logo_approve_dependabot.png new file mode 100644 index 00000000..c1a415a1 Binary files /dev/null and b/automations/integrations/dependabot/approve-dependabot/logo_approve_dependabot.png differ diff --git a/automations/integrations/devcycle/label-ff-devcycle/index.html b/automations/integrations/devcycle/label-ff-devcycle/index.html new file mode 100644 index 00000000..e3d0df42 --- /dev/null +++ b/automations/integrations/devcycle/label-ff-devcycle/index.html @@ -0,0 +1,29 @@ + Automation - Label PRs Based on Devcycle Feature Flags - gitStream Documentation

Label DevCycle Feature Flags

Automatically label code that contians specified feature flags.

Label PRs Based on Feature Flags

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+
+  {% for item in feature_flags %}
+  label_ff_devcycle_{{ item.name }}:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/key = '/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ item.name }}
+          color: {{ colors.yellow }}
+  {% endfor %}
+
+feature_flags:
+   - name: engineering_rollback_plan_activated 
+     regex: r/engineering_rollback_plan_activated/
+   - name: marketing_premium_plan_features_unlocked 
+     regex: r/marketing_premium_plan_features_unlocked/
+   - name: mobile_push_notifications_enabled
+     regex: r/mobile_push_notifications_enabled/
+
+colors:
+  yellow: 'ffb300'   
+
\ No newline at end of file diff --git a/automations/integrations/devcycle/label-ff-devcycle/label-ff-devcycle.png b/automations/integrations/devcycle/label-ff-devcycle/label-ff-devcycle.png new file mode 100644 index 00000000..183c673c Binary files /dev/null and b/automations/integrations/devcycle/label-ff-devcycle/label-ff-devcycle.png differ diff --git a/automations/integrations/flagr/label-ff-flagr/index.html b/automations/integrations/flagr/label-ff-flagr/index.html new file mode 100644 index 00000000..f45c15bb --- /dev/null +++ b/automations/integrations/flagr/label-ff-flagr/index.html @@ -0,0 +1,29 @@ + Automation - Label PRs Based on Flagr Feature Flags - gitStream Documentation

Label Flagr Feature Flags

Automatically label code that contians specified feature flags.

Label PRs Based on Feature Flags

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+
+  {% for item in feature_flags %}
+  label_ff_flagr_{{ item.name }}:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/evaluation_result.variant_id ==/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ item.name }}
+          color: {{ colors.yellow }}
+  {% endfor %}
+
+feature_flags:
+   - name: engineering_rollback_plan_activated 
+     regex: r/engineering_rollback_plan_activated/
+   - name: marketing_premium_plan_features_unlocked 
+     regex: r/marketing_premium_plan_features_unlocked/
+   - name: mobile_push_notifications_enabled
+     regex: r/mobile_push_notifications_enabled/
+
+colors:
+  yellow: 'ffb300'   
+
\ No newline at end of file diff --git a/automations/integrations/flagr/label-ff-flagr/label-ff-flagr.png b/automations/integrations/flagr/label-ff-flagr/label-ff-flagr.png new file mode 100644 index 00000000..183c673c Binary files /dev/null and b/automations/integrations/flagr/label-ff-flagr/label-ff-flagr.png differ diff --git a/automations/integrations/flagsmith/label-ff-flagsmith/index.html b/automations/integrations/flagsmith/label-ff-flagsmith/index.html new file mode 100644 index 00000000..cd304a68 --- /dev/null +++ b/automations/integrations/flagsmith/label-ff-flagsmith/index.html @@ -0,0 +1,29 @@ + Automation - Label PRs Based on Flagsmith Feature Flags - gitStream Documentation

Label Flagsmith Feature Flags

Automatically label code that contians specified feature flags.

Label PRs Based on Feature Flags

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+
+  {% for item in feature_flags %}
+  label_ff_flagsmith_{{ item.name }}:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/flagsmith.hasFeature\(/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ item.name }}
+          color: {{ colors.yellow }}
+  {% endfor %}
+
+feature_flags:
+   - name: engineering_rollback_plan_activated 
+     regex: r/engineering_rollback_plan_activated/
+   - name: marketing_premium_plan_features_unlocked 
+     regex: r/marketing_premium_plan_features_unlocked/
+   - name: mobile_push_notifications_enabled
+     regex: r/mobile_push_notifications_enabled/
+
+colors:
+  yellow: 'ffb300'   
+
\ No newline at end of file diff --git a/automations/integrations/flagsmith/label-ff-flagsmith/label-ff-flagsmith.png b/automations/integrations/flagsmith/label-ff-flagsmith/label-ff-flagsmith.png new file mode 100644 index 00000000..183c673c Binary files /dev/null and b/automations/integrations/flagsmith/label-ff-flagsmith/label-ff-flagsmith.png differ diff --git a/automations/integrations/github-actions/dispatch-github-action/dispatch-github-action.png b/automations/integrations/github-actions/dispatch-github-action/dispatch-github-action.png new file mode 100644 index 00000000..50901ea8 Binary files /dev/null and b/automations/integrations/github-actions/dispatch-github-action/dispatch-github-action.png differ diff --git a/automations/integrations/github-actions/dispatch-github-action/dispatch-github-action.svg b/automations/integrations/github-actions/dispatch-github-action/dispatch-github-action.svg new file mode 100644 index 00000000..14e13273 --- /dev/null +++ b/automations/integrations/github-actions/dispatch-github-action/dispatch-github-action.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/automations/integrations/github-actions/dispatch-github-action/index.html b/automations/integrations/github-actions/dispatch-github-action/index.html new file mode 100644 index 00000000..6276292b --- /dev/null +++ b/automations/integrations/github-actions/dispatch-github-action/index.html @@ -0,0 +1,107 @@ + Automation - Dispatch GitHub Actions - gitStream Documentation

Dispatch GitHub Actions

Automatically trigger GitHub Actions based on PR content like changed resources, source or target branch, slash commands, and more.

Automatically Dispatch GitHub Actions

Configuration Description

Conditions (all must be true):

  • The PR source or target branch matches a specified format.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions by Branch

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+  - commit
+
+automations:
+  {% for item in pipelines %}
+  # Change pr.target to branch.name if you want to trigger on the source branch rather then the target branch.
+  dispatch_github_action_{{ item.name }}:
+    if:
+      - {{ pr.target | includes(term=item.branch_prefix) }}
+    run:
+      - action: run-github-workflow@v1
+        args:
+          workflow: .github/workflows/{{ item.workflow }}
+          check_name: {{ item.name }}
+      - action: add-label@v1
+        args:
+          label: {{ item.label }}
+  {% endfor %}
+
+
+pipelines:
+  - name: mobile_ci
+    label: Mobile CI 
+    branch_prefix: 'mobile-'
+    workflow: mobile.yml
+  - name: backend_ci
+    label: Backend CI 
+    branch_prefix: 'backend-'
+    workflow: 'backend.yml'
+

Configuration Description

Conditions (all must be true):

  • The PR has one or more specified labels applied to it.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions Using Labels

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - label_added
+  - label_removed
+
+automations:
+  {% for item in pipelines %}
+  dispatch_github_action_{{ item.name }}:
+    if:
+      - {{ pr.labels | match(term=item.label) | some }}
+    run:
+      - action: run-github-workflow@v1
+        args:
+          workflow: .github/workflows/{{ item.workflow }}
+          check_name: {{ item.name }}
+  {% endfor %}
+
+pipelines:
+  - name: mobile-ci
+    label: Mobile CI 
+    workflow: mobile.yml
+  - name: backend-ci
+    label: Backend CI 
+    workflow: 'backend.yml'
+

Configuration Description

Conditions (all must be true):

  • The PR modifies one or more specified resources.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions Based on Modified Resources

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+  - commit
+
+automations:
+  {% for item in pipelines %}
+  dispatch_github_action_{{ item.name }}:
+    if:
+      - {{ files | match(list=item.resources) | some }}
+    run:
+      - action: run-github-workflow@v1
+        args:
+          workflow: .github/workflows/{{ item.workflow }}
+          check_name: {{ item.name }}
+      - action: add-label@v1
+        args:
+          label: {{ item.label }}
+  {% endfor %}
+
+
+pipelines:
+  - name: mobile-ci
+    label: Mobile CI 
+    resources:
+      - 'src/android/'
+      - 'src/ios/'
+    workflow: mobile.yml
+  - name: backend-ci
+    label: Backend CI 
+    resources:
+      - 'src/api/'
+      - 'src/services'
+    workflow: 'backend.yml'
+  - name: frontend-ci
+    label: Frontend CI
+    resources:
+      - 'src/app/'
+    workflow: 'frontend.yml'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/github-actions/dispatch-github-action/logo_dispatch_github_action.png b/automations/integrations/github-actions/dispatch-github-action/logo_dispatch_github_action.png new file mode 100644 index 00000000..bec1285f Binary files /dev/null and b/automations/integrations/github-actions/dispatch-github-action/logo_dispatch_github_action.png differ diff --git a/automations/integrations/github-actions/skip-github-action/dispatch-github-action.svg b/automations/integrations/github-actions/skip-github-action/dispatch-github-action.svg new file mode 100644 index 00000000..14e13273 --- /dev/null +++ b/automations/integrations/github-actions/skip-github-action/dispatch-github-action.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/automations/integrations/github-actions/skip-github-action/index.html b/automations/integrations/github-actions/skip-github-action/index.html new file mode 100644 index 00000000..283d22c6 --- /dev/null +++ b/automations/integrations/github-actions/skip-github-action/index.html @@ -0,0 +1,73 @@ + Automation - Skip Required GitHub Actions - gitStream Documentation

Skip Required GitHub Actions

Automatically skip GitHub Actions based on branch names, modified resource, slash commands, and more.

Automatically Skip GitHub Actions

Prerequisite Config for Required Statuses

If you want to skip a required status check, you will need to make sure that your branch protection is configured to allow gitStream to bypass status check requirements.

GitHub Branch Protection Config

Configuration Description

Conditions (all must be true):

  • The target branch name includes a specified keyword. Optionally, you can modify this to detect the source branch name.

Automation Actions:

  • Skip the specified CI pipelines.

Automatically Skip GitHub Actions by Branch

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+  - commit
+
+# Optionally, you can change pr.target to branch.name
+# if you want to trigger based on the source branch name rather then the target branch name.
+automations:
+  skip_github_action_branch:
+    if:
+      - {{ pr.target | includes(term='release') }}
+    run:
+      - action: add-github-check@v1
+        args:
+          check_name: staging-ci
+          conclusion: skipped
+      - action: add-comment@v1
+        args:
+          comment: |
+            [gitStream](https://docs.gitstream.cm) automatically skipped staging CI pipelines because this PR targets the release branch.
+

Configuration Description

Conditions (all must be true):

  • Someone applies one or more specified labels to a PR.

Automation Actions:

  • Skip the specified CI pipelines.

Use Labels to Automatically Skip GitHub Actions

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - label_added
+  - label_removed
+
+automations:
+  skip_github_action_label:
+    if:
+      - {{ pr.labels | match(term='experimental') | some }}
+    run:
+      - action: add-github-check@v1
+        args:
+          check_name: production-ci
+          conclusion: skipped
+      - action: add-comment@v1
+        args:
+          comment: |
+            [gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this is labeled for experimental release.
+

Configuration Description

Conditions (all must be true):

  • A PR modifies specific files or directories.

Automation Actions:

  • Skip a specified GitHub Action.

Automatically Skip GitHub Actions Based on Modified Resources

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+  - commit
+
+automations:
+  skip_github_action_resource:
+    if:
+      - {{ files | match(term='docs/') | every }}
+    run:
+      - action: add-github-check@v1
+        args:
+          check_name: release-ci
+          conclusion: skipped
+      - action: add-github-check@v1
+        args:
+          check_name: mobile-ci
+          conclusion: skipped
+      - action: add-comment@v1
+        args:
+          comment: |
+            [gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this PR only contains docs changes.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/github-actions/skip-github-action/logo_dispatch_github_action.png b/automations/integrations/github-actions/skip-github-action/logo_dispatch_github_action.png new file mode 100644 index 00000000..bec1285f Binary files /dev/null and b/automations/integrations/github-actions/skip-github-action/logo_dispatch_github_action.png differ diff --git a/automations/integrations/github-actions/skip-github-action/required-status-config.png b/automations/integrations/github-actions/skip-github-action/required-status-config.png new file mode 100644 index 00000000..2d70faf1 Binary files /dev/null and b/automations/integrations/github-actions/skip-github-action/required-status-config.png differ diff --git a/automations/integrations/github-actions/skip-github-action/skip-github-action.png b/automations/integrations/github-actions/skip-github-action/skip-github-action.png new file mode 100644 index 00000000..bd75a158 Binary files /dev/null and b/automations/integrations/github-actions/skip-github-action/skip-github-action.png differ diff --git a/automations/integrations/godoc/review-godoc-large/index.html b/automations/integrations/godoc/review-godoc-large/index.html new file mode 100644 index 00000000..5233c6b7 --- /dev/null +++ b/automations/integrations/godoc/review-godoc-large/index.html @@ -0,0 +1,31 @@ + Automation - Review Godoc for Large Changes - gitStream Documentation

Review Godoc for Large Changes

Require more extensive reviews for large Golang changes that lack Godoc updates.

Review Godoc for Large changes

Configuration Description

Conditions (all must be true):

  • The PR changes more than 100 lines of Golang code.

Automation Actions:

  • Post a comment asking the author to review all relevant Godoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow ⚠️ Missing Godoc Label

Review Godoc

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  #Require more extensive reviews for large Golang changes that lack Godoc updates.
+  review_godoc_large:
+    if:
+      - {{ changes.additions > 100}}
+      - {{ source.diff.files | matchDiffLines(regex=r/^\/\/.*/) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Godoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+              This PR makes major changes to Golang classes, but is missing updates to Godoc. Please double check for any necessary Godoc updates.
+      - action: add-reviewers@v1
+        args:
+          reviewers: [fourth-organization/tech-writers]
+
+changes:
+  # Sum all the lines added/edited in the PR
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/integrations/godoc/review-godoc-large/logo_review_godoc.png b/automations/integrations/godoc/review-godoc-large/logo_review_godoc.png new file mode 100644 index 00000000..49d5629d Binary files /dev/null and b/automations/integrations/godoc/review-godoc-large/logo_review_godoc.png differ diff --git a/automations/integrations/godoc/review-godoc-large/review-godoc-large.png b/automations/integrations/godoc/review-godoc-large/review-godoc-large.png new file mode 100644 index 00000000..3a16d5d0 Binary files /dev/null and b/automations/integrations/godoc/review-godoc-large/review-godoc-large.png differ diff --git a/automations/integrations/godoc/review-godoc-large/review-godoc.svg b/automations/integrations/godoc/review-godoc-large/review-godoc.svg new file mode 100644 index 00000000..a39e4729 --- /dev/null +++ b/automations/integrations/godoc/review-godoc-large/review-godoc.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/automations/integrations/godoc/review-godoc-new-class/index.html b/automations/integrations/godoc/review-godoc-new-class/index.html new file mode 100644 index 00000000..fc22e698 --- /dev/null +++ b/automations/integrations/godoc/review-godoc-new-class/index.html @@ -0,0 +1,25 @@ + Automation - Require Godoc for New Golang Classes - gitStream Documentation

Require Godoc for New Golang Classes

Require Godoc for all new Golang classes.

Enforce Godoc for New Golang Classes

Configuration Description

Conditions (all must be true):

  • The PR creates a new Golang class.
  • The PR lacks Godoc content.

Automation Actions:

  • Request changes and post a comment explaining that Godoc is required
  • Apply a yellow ⚠️ Missing Godoc label.

Enforce Godoc for New Golang Classes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_godoc_new_class: 
+    if:  
+      - {{ is.go and is.new }} 
+      - {{ source.diff.files | match(attr='diff', regex=r/\/*[\s\S]*?\//) | nope }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing godoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            godoc is required for all Golang classes. Please add godoc to all new classes in this PR.
+
+is:
+    go: {{ files | extensions | match(regex=r/go/) | every }}
+    new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/integrations/godoc/review-godoc-new-class/logo_review_godoc.png b/automations/integrations/godoc/review-godoc-new-class/logo_review_godoc.png new file mode 100644 index 00000000..49d5629d Binary files /dev/null and b/automations/integrations/godoc/review-godoc-new-class/logo_review_godoc.png differ diff --git a/automations/integrations/godoc/review-godoc-new-class/review-godoc-new-class.png b/automations/integrations/godoc/review-godoc-new-class/review-godoc-new-class.png new file mode 100644 index 00000000..207aabbf Binary files /dev/null and b/automations/integrations/godoc/review-godoc-new-class/review-godoc-new-class.png differ diff --git a/automations/integrations/godoc/review-godoc-new-class/review-godoc.svg b/automations/integrations/godoc/review-godoc-new-class/review-godoc.svg new file mode 100644 index 00000000..a39e4729 --- /dev/null +++ b/automations/integrations/godoc/review-godoc-new-class/review-godoc.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/automations/integrations/godoc/review-godoc/index.html b/automations/integrations/godoc/review-godoc/index.html new file mode 100644 index 00000000..06291683 --- /dev/null +++ b/automations/integrations/godoc/review-godoc/index.html @@ -0,0 +1,23 @@ + Automation - Review Godoc Changes - gitStream Documentation

Review Godoc Changes

Approve PRs that only contain changes to Godoc and assign optional reviewers.

Review Godoc

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to Godoc content.

Automation Actions:

  • Assign the org/tech-writers team for optional review.
  • Apply a green 📓 Godoc Only label
  • Approve the PR

Review Godoc

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  #Assign PRs that only affect godocs to the technical writing team and add docs label
+  review_godoc:
+    if:
+      - {{ source.diff.files | match(attr='diff', regex=r/^\/\/.*/) | every }}
+      - {{ files | extensions | match(regex=r/go/) | every }}
+
+    run:
+      - action: add-label@v1
+        args:
+            label: "📓godoc Only"
+            color: {{ colors.green }}
+      - action: add-reviewers@v1
+        args:
+          reviewers: [org/tech-writers]
+      - action: approve@v1
+
+colors:
+  green: '0e8a16'
+
\ No newline at end of file diff --git a/automations/integrations/godoc/review-godoc/logo_review_godoc.png b/automations/integrations/godoc/review-godoc/logo_review_godoc.png new file mode 100644 index 00000000..49d5629d Binary files /dev/null and b/automations/integrations/godoc/review-godoc/logo_review_godoc.png differ diff --git a/automations/integrations/godoc/review-godoc/review-godoc.png b/automations/integrations/godoc/review-godoc/review-godoc.png new file mode 100644 index 00000000..14adaa79 Binary files /dev/null and b/automations/integrations/godoc/review-godoc/review-godoc.png differ diff --git a/automations/integrations/godoc/review-godoc/review-godoc.svg b/automations/integrations/godoc/review-godoc/review-godoc.svg new file mode 100644 index 00000000..a39e4729 --- /dev/null +++ b/automations/integrations/godoc/review-godoc/review-godoc.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/automations/integrations/javadoc/review-javadoc-input-parameters/index.html b/automations/integrations/javadoc/review-javadoc-input-parameters/index.html new file mode 100644 index 00000000..5b482c3e --- /dev/null +++ b/automations/integrations/javadoc/review-javadoc-input-parameters/index.html @@ -0,0 +1,14 @@ + Automation - Review Java Input Parameters for Javadoc Changes - gitStream Documentation

Review Java Input Parameters for Javadoc Changes

If a PR modifies the input parameters for a Java method, but not the associated Javadocs, notify reviewers to check for Javadoc updates.

Review Javadoc Input Parameters

Configuration Description

Conditions (all must be true):

  • The PR changes one or more input parameters in Java methods.
    • Note: This may not trigger for methods with annotations, methods that throw exceptions, multi-line method definitions, and other non-standard use cases.
  • The PR lacks changes to ‘@param’ declarations.

Automation Actions:

  • Post a comment warning the user to review the method’s Javadoc to identify necessary updates.

Review Javadoc

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_javadoc_input_parameters: 
+    if:  
+        - {{ source.diff.files | matchDiffLines(regex=r/\*\s@param/) | nope }}
+        - {{ source.diff.files | matchDiffLines(regex=r/\b(public|protected|private|static|final|synchronized)?\s+\w+\s+\w+\s*\(([^)]*)\)\s*\{/) | some }}
+    run:
+      - action: add-comment@v1
+        args: 
+            comment: | 
+              This PR modifies method input parameters, but is missing Javadoc changes. Please check to ensure no Javadoc changes are necessary.
+
\ No newline at end of file diff --git a/automations/integrations/javadoc/review-javadoc-input-parameters/logo_review_javadoc.png b/automations/integrations/javadoc/review-javadoc-input-parameters/logo_review_javadoc.png new file mode 100644 index 00000000..4ba181f4 Binary files /dev/null and b/automations/integrations/javadoc/review-javadoc-input-parameters/logo_review_javadoc.png differ diff --git a/automations/integrations/javadoc/review-javadoc-input-parameters/review-javadoc-input-parameters.png b/automations/integrations/javadoc/review-javadoc-input-parameters/review-javadoc-input-parameters.png new file mode 100644 index 00000000..06de589f Binary files /dev/null and b/automations/integrations/javadoc/review-javadoc-input-parameters/review-javadoc-input-parameters.png differ diff --git a/automations/integrations/javadoc/review-javadoc-input-parameters/review-javadoc.svg b/automations/integrations/javadoc/review-javadoc-input-parameters/review-javadoc.svg new file mode 100644 index 00000000..f2c8632a --- /dev/null +++ b/automations/integrations/javadoc/review-javadoc-input-parameters/review-javadoc.svg @@ -0,0 +1,4 @@ + + + + diff --git a/automations/integrations/javadoc/review-javadoc-large-change/index.html b/automations/integrations/javadoc/review-javadoc-large-change/index.html new file mode 100644 index 00000000..7913e8ec --- /dev/null +++ b/automations/integrations/javadoc/review-javadoc-large-change/index.html @@ -0,0 +1,35 @@ + Automation - Review Javadoc for Large Changes - gitStream Documentation

Review Javadoc for Large Changes

Require more extensive reviews for large Java changes that lack Javadoc updates.

Review JavaDoc for Large Changes

Configuration Description

Conditions (all must be true):

  • The PR changes more than 25% of a Java class.
  • The PR lacks Javadoc changes.

Automation Actions:

  • Post a comment asking the author to review all relevant Javadoc to identify necessary updates.
  • Require a review from the my-organization/tech-writers team.
  • Apply a yellow ⚠️ Missing Javadoc Label

Review Javadoc for Large Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  #Require more extensive reviews for large Java changes that lack Javadoc updates.
+  review_javadoc_large:
+    if:
+      - {{ changes.ratio > 25}}
+      - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Javadoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+              This PR makes major changes to Java classes, but is missing updates to Javadoc. Please double check for any necessary Javadoc updates.
+      - action: add-reviewers@v1
+        args:
+          reviewers: [fourth-organization/tech-writers]
+
+changes:
+  # Sum all the lines added/edited in the PR
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+  # Sum all the line removed in the PR
+  deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}
+  # Calculate the ratio of new code
+  ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/integrations/javadoc/review-javadoc-large-change/logo_review_javadoc.png b/automations/integrations/javadoc/review-javadoc-large-change/logo_review_javadoc.png new file mode 100644 index 00000000..4ba181f4 Binary files /dev/null and b/automations/integrations/javadoc/review-javadoc-large-change/logo_review_javadoc.png differ diff --git a/automations/integrations/javadoc/review-javadoc-large-change/review-javadoc-large-change.png b/automations/integrations/javadoc/review-javadoc-large-change/review-javadoc-large-change.png new file mode 100644 index 00000000..121aed43 Binary files /dev/null and b/automations/integrations/javadoc/review-javadoc-large-change/review-javadoc-large-change.png differ diff --git a/automations/integrations/javadoc/review-javadoc-large-change/review-javadoc.svg b/automations/integrations/javadoc/review-javadoc-large-change/review-javadoc.svg new file mode 100644 index 00000000..f2c8632a --- /dev/null +++ b/automations/integrations/javadoc/review-javadoc-large-change/review-javadoc.svg @@ -0,0 +1,4 @@ + + + + diff --git a/automations/integrations/javadoc/review-javadoc/index.html b/automations/integrations/javadoc/review-javadoc/index.html new file mode 100644 index 00000000..086335d6 --- /dev/null +++ b/automations/integrations/javadoc/review-javadoc/index.html @@ -0,0 +1,22 @@ + Automation - Review Javadoc Changes - gitStream Documentation

Review Javadoc Changes

Unblock PRs that only change Javadoc content.

Review Javadoc Changes

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to Javadoc content.

Automation Actions:

  • Assign the org/tech-writersteam for optional review.
  • Apply a green 📓 Javadoc Only label
  • Approve the PR

Review Javadoc Changes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  # Assign PRs that only affect JavaDocs to the technical writing team and add docs label
+  review_javadoc:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/\b(public|protected|private|static|final|synchronized)?\s+\w+\s+\w+\s*\(([^)]*)\)\s*\{/) | nope }}
+    run:
+      - action: add-label@v1
+        args:
+            label: "📓 Javadoc Only"
+            color: {{ colors.green }}
+      - action: add-reviewers@v1
+        args:
+          reviewers: [org/tech-writers]
+      - action: approve@v1
+
+colors:
+  green: '0e8a16'
+
\ No newline at end of file diff --git a/automations/integrations/javadoc/review-javadoc/logo_review_javadoc.png b/automations/integrations/javadoc/review-javadoc/logo_review_javadoc.png new file mode 100644 index 00000000..4ba181f4 Binary files /dev/null and b/automations/integrations/javadoc/review-javadoc/logo_review_javadoc.png differ diff --git a/automations/integrations/javadoc/review-javadoc/review-javadoc.png b/automations/integrations/javadoc/review-javadoc/review-javadoc.png new file mode 100644 index 00000000..ef17b2ca Binary files /dev/null and b/automations/integrations/javadoc/review-javadoc/review-javadoc.png differ diff --git a/automations/integrations/javadoc/review-javadoc/review-javadoc.svg b/automations/integrations/javadoc/review-javadoc/review-javadoc.svg new file mode 100644 index 00000000..f2c8632a --- /dev/null +++ b/automations/integrations/javadoc/review-javadoc/review-javadoc.svg @@ -0,0 +1,4 @@ + + + + diff --git a/automations/integrations/javadoc/review-new-class-javadoc/index.html b/automations/integrations/javadoc/review-new-class-javadoc/index.html new file mode 100644 index 00000000..4b612cb3 --- /dev/null +++ b/automations/integrations/javadoc/review-new-class-javadoc/index.html @@ -0,0 +1,26 @@ + Automation - Enforce Javadoc Requirements for New Classes - gitStream Documentation

Enforce Javadoc Requirements for New Classes

Automatically request changes when someone creates a new Java class that lacks Javadoc content.

Enforce Javadoc Requirements for New Classes

Configuration Description

Conditions (all must be true):

  • The PR creates a new Java class.
  • The PR lacks Javadoc content.

Automation Actions:

  • Apply a ⚠️ Missing Javadoc label.
  • Request changes, and post a comment explaining that Javadoc is required

Review Javadoc Requirements for New Classes

manifest:
+  version: 1.0
+
+automations:
+  review_new_class_javadoc:
+    # Triggered for new Java files that lack Javadoc content.
+    if:
+      - {{ is.java and is.new }}
+      - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Javadoc"
+          color: {{ colors.yellow }}
+      - action: request-changes@v1
+        args:
+          comment: | 
+              This PR creates new Java classes, but is missing updates to Javadoc. Please double check for any necessary Javadoc updates.
+
+is:
+    java: {{ files | extensions | match(term='java') | every }}
+    new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/integrations/javadoc/review-new-class-javadoc/logo_review_javadoc.png b/automations/integrations/javadoc/review-new-class-javadoc/logo_review_javadoc.png new file mode 100644 index 00000000..4ba181f4 Binary files /dev/null and b/automations/integrations/javadoc/review-new-class-javadoc/logo_review_javadoc.png differ diff --git a/automations/integrations/javadoc/review-new-class-javadoc/review-javadoc.svg b/automations/integrations/javadoc/review-new-class-javadoc/review-javadoc.svg new file mode 100644 index 00000000..f2c8632a --- /dev/null +++ b/automations/integrations/javadoc/review-new-class-javadoc/review-javadoc.svg @@ -0,0 +1,4 @@ + + + + diff --git a/automations/integrations/javadoc/review-new-class-javadoc/review-new-class-javadoc.png b/automations/integrations/javadoc/review-new-class-javadoc/review-new-class-javadoc.png new file mode 100644 index 00000000..ab6ed0e5 Binary files /dev/null and b/automations/integrations/javadoc/review-new-class-javadoc/review-new-class-javadoc.png differ diff --git a/automations/integrations/jira/configure/index.html b/automations/integrations/jira/configure/index.html new file mode 100644 index 00000000..33561aac --- /dev/null +++ b/automations/integrations/jira/configure/index.html @@ -0,0 +1 @@ + Prerequisite configurations for Jira - gitStream Documentation

Configure Jira for gitStream Integrations

If you want to build gitStream automations to interact with the Jira API or Jira webhooks, you'll need to complete some setup in Jira, GitHub, and gitStream. This section outlines the setup process depending on the type of automation you want to build.

These guides are for sending HTTP requests to Jira

If the gitStream automations you want to use don't make any HTTP requests to a Jira API or webhook, you can ignore this section.

Use Webhooks to Trigger Jira Automations

Jira automations are the preferred method for gitStream to trigger actions within Jira, so you should use them whenever possible. If webhooks don't provide access to the data you need, or acheive the functionality you want, use the Jira API instead.

First, create a Jira automation that uses an incoming webhook as the trigger and add whatever automation components you want after this trigger. Save the webhook URL in a secure place, you'll need it later.

Here is an example of an automation that uses the webhookData property of the incoming data payload to create a new task. It expects the incoming data payload to contain title and pr_url fields to set the task summary and a pr_url custom field our demo environment already has configured.

Jira Automation Example - Create task from incoming webhook

Learn more about working with incoming webhooks in the Jira docs

Next, in GitHub, create an organization secret to store your Jira webhook URL and pass it to gitStream's env context variable by adding a line to .github/workflows/gitstream.yml inside your repo. Make sure to give this a unique name, such as JIRA_CREATE_ISSUE_WEBHOOK: ${{ secrets.JIRA_CREATE_ISSUE_WEBHOOK }}.

Once finished, you can use the env.JIRA_CREATE_ISSUE_WEBHOOK context variable inside CM files to send HTTP requests to Jira from your GitHub repo. For an example of how to do this, check out the create Jira issue automation.

Connect to the Jira API

The Jira API is useful in situations where you need to retreive data from Jira or need to access capabilities that aren't available via Jira Automations. The Jira API uses an account-based token system that follows a basic auth model; this means you'll need an individual account to connect to Jira's APIs and will pass the account email address and API token in the headers of your API requests.

Here's the process to grant gitStream access to the Jira API:

  1. Create an API token for your Jira account, and give it a unique name. Copy the API token, you'll need it in the next step.
  2. Create a GitHub organization secret to store the token and make the secret available to gitStream's env context variable.
  3. Add env.MY_API_TOKEN to any of your CM automations to access the API token and pass it to plugins and automation actions.

Check out the hasJiraIssue filter plugin for an example of how to use Jira API tokens.

\ No newline at end of file diff --git a/automations/integrations/jira/create-jira-issue/create-jira-issue-github.png b/automations/integrations/jira/create-jira-issue/create-jira-issue-github.png new file mode 100644 index 00000000..05c63ab0 Binary files /dev/null and b/automations/integrations/jira/create-jira-issue/create-jira-issue-github.png differ diff --git a/automations/integrations/jira/create-jira-issue/create-jira-issue-jira.png b/automations/integrations/jira/create-jira-issue/create-jira-issue-jira.png new file mode 100644 index 00000000..8a938224 Binary files /dev/null and b/automations/integrations/jira/create-jira-issue/create-jira-issue-jira.png differ diff --git a/automations/integrations/jira/create-jira-issue/index.html b/automations/integrations/jira/create-jira-issue/index.html new file mode 100644 index 00000000..45411444 --- /dev/null +++ b/automations/integrations/jira/create-jira-issue/index.html @@ -0,0 +1,56 @@ + Automation - Automatically Create Jira Issues - gitStream Documentation

Automatically Create Jira Issues from PRs

Automatically create Jira tickets for new pull/merge requests.

Jira API & Webhook Integration Required.

This automation requires you to connect to the Jira API and incoming webooks.

Required gitStream Plugins

This example requires you to install the hasJiraIssue plugin.

Learn more about gitStream plugins.

Create Jira Issue Create Jira Issue

Configuration Description

Conditions (all must be true):

  • The PR description contains the text - [x] Auto-create Jira Issue
  • No existing Jira issues reference the PRs URL.

Automation Actions:

  • Send an HTTP request to create a new Jira issue.

Automatically Create Jira Issues

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+
+###### ** Configure This Section ** ######
+
+# Configure this for your Jira instance and the email associated with your API key.
+# You can safely use these values because only your API key is sensitive. 
+jiraSpaceName: "my-company" # e.g. my-company.atlassian.net
+email: "my.email@example.com"
+# If you're concerned about exposing this information,
+# we recommend using environment variables for your production environment.
+
+# -----------
+
+# Pass the API token associated with the email above to gitStream via an environment variable.
+jiraAuth: {{ env.JIRA_API_TOKEN }}
+# Learn more about env: https://docs.gitstream.cm/context-variables/#env
+
+# -----------
+
+# Change this to the Jira field you want to match the input string against.
+jiraField: "myField"
+# If you want to search a custom field, you should provide the ID like so:
+# jiraField: "cf[XXXXX]"
+# Replace XXXXX with the ID of the custom field you want to search.
+# More information:
+# Using JQL to search the Jira API: https://support.atlassian.com/jira-service-management-cloud/docs/jql-fields/
+# How to find the ID of a custom field: https://confluence.atlassian.com/jirakb/how-to-find-any-custom-field-s-ids-744522503.html
+
+# -----------
+
+###### ** Automation ** ######
+# You may want to update the text in the comment gitStream posts;
+# otherwise, this section shouldn't need to be changed.
+prUrl: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+has_jira_issue: {{ prUrl  | hasJiraIssue(jiraAuth, jiraField, jiraSpaceName, email) }}
+
+automations:
+  automatic_jira_task: 
+    if:
+      - {{ not has_jira_issue }}
+      - {{ pr.description | includes(regex=r/\- \[x\] Auto-create Jira Task/)}}
+    run:
+      - action: send-http-request@v1
+        args:
+          url: {{ env.JIRA_WEBHOOK }}
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{"data":{"pr_url": "{{ prUrl }}","title":"{{ pr.title }}"}}'
+      - action: add-comment@v1
+        args:
+          comment: "gitStream automatically created a Jira task for this PR"
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/jira/create-jira-issue/jira_create.svg b/automations/integrations/jira/create-jira-issue/jira_create.svg new file mode 100644 index 00000000..a562b420 --- /dev/null +++ b/automations/integrations/jira/create-jira-issue/jira_create.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/integrations/jira/create-jira-ticket/create-jira-ticket.png b/automations/integrations/jira/create-jira-ticket/create-jira-ticket.png new file mode 100644 index 00000000..8bf98a58 Binary files /dev/null and b/automations/integrations/jira/create-jira-ticket/create-jira-ticket.png differ diff --git a/automations/integrations/jira/create-jira-ticket/index.html b/automations/integrations/jira/create-jira-ticket/index.html new file mode 100644 index 00000000..a2c07367 --- /dev/null +++ b/automations/integrations/jira/create-jira-ticket/index.html @@ -0,0 +1,19 @@ + Automation - Automatically Create Jira Tickets - gitStream Documentation

Automatically Create Jira Tickets

Automatically create Jira tickets for new PRs.

Required gitStream Plugins

This example requires you to install the hasJiraTicket plugin.

Learn more about gitStream plugins.

Create Jira Ticket

Configuration Description

Conditions (all must be true):

  • A Jira ticket does not yet exist with the same title as the PR.

Automation Actions:

  • Send an HTTP request to create a new Jira ticket.

Plugin:

  • hasJiraTicket

Create Jira Ticket

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+has_jira_ticket: {{ pr.title | hasJiraTicket(env.JIRA_API_TOKEN) }}
+
+automations:
+  add_jira: 
+    if:
+      - {{ not has_jira_ticket }}
+    run:
+      - action: send-http-request@v1
+        args:
+          url: env.JIRA_WEBHOOK_URL
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{"data":{"pr_url": "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}}'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/jira/jira-assign/index.html b/automations/integrations/jira/jira-assign/index.html new file mode 100644 index 00000000..8a7de65e --- /dev/null +++ b/automations/integrations/jira/jira-assign/index.html @@ -0,0 +1,34 @@ + Automation - Automatically Assign Jira Tickets - gitStream Documentation

Automatically Assign Jira Tickets

Automatically assign Jira tickets based on code review actions.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Automatically Assign Jira Tickets Automatically Assign Jira Tickets

Configuration Description

Conditions (all must be true):

  • The PR description contains the slash command: /gitstream assign-jira followed by a Jira username.

Automation Actions:

  • Trigger a Jira webhook to update the assignee field with the username provided in the slash command.

Automatically Assign Jira Tickets

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+assigneeRegex: r/(?<=\/gitstream assign-jira ).*(?=<br \/>)/
+
+{% set ticketid = "" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  jira_assign: 
+    if:
+      - {{ pr.description | includes(regex=assigneeRegex) }}
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ env.JIRA_WEBHOOK }}}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{"issues":["{{ticketid}}"],"data":{"assignee":"{{pr.description | capture(regex=assigneeRegex)}}"}}'
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_branch: {{ branch.name | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+
+tickets:
+  - {{branch.name | capture(regex=r/\b[A-Za-z]+-\d+\b/)}}
+  - {{pr.title | capture(regex=r/\b[A-Za-z]+-\d+\b/)}}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/jira/jira-assign/jira-assign-github.png b/automations/integrations/jira/jira-assign/jira-assign-github.png new file mode 100644 index 00000000..efd36fb9 Binary files /dev/null and b/automations/integrations/jira/jira-assign/jira-assign-github.png differ diff --git a/automations/integrations/jira/jira-assign/jira-assign-jira.png b/automations/integrations/jira/jira-assign/jira-assign-jira.png new file mode 100644 index 00000000..2ab047af Binary files /dev/null and b/automations/integrations/jira/jira-assign/jira-assign-jira.png differ diff --git a/automations/integrations/jira/jira-assign/jira_assign.svg b/automations/integrations/jira/jira-assign/jira_assign.svg new file mode 100644 index 00000000..a758e7df --- /dev/null +++ b/automations/integrations/jira/jira-assign/jira_assign.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/integrations/jira/jira-change-status/index.html b/automations/integrations/jira/jira-change-status/index.html new file mode 100644 index 00000000..812a77c9 --- /dev/null +++ b/automations/integrations/jira/jira-change-status/index.html @@ -0,0 +1,35 @@ + Automation - Automatic Jira Status Updates - gitStream Documentation

Automatic Jira Status Updates

Automatically update the status of Jira tickets when a PR is opened.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Automatic Jira Status Updates Automatic Jira Status Updates

Configuration Description

Conditions (all must be true):

  • A PR is created that references a Jira ticket in the title or description.

Automation Actions:

  • Make an HTTP request to a Jira webhook that is pre-configured to update the ticket status.

Automatic Jira Status Updates

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+
+{% set ticketid = "\b[A-Za-z]+-\d+\b" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  jira_change_status: 
+    if:
+      - {{ has.jira_ticket_in_title or has.jira_ticket_in_desc }}
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ env.JIRA_CHANGE_STATUS_WEBHOOK }}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{"issues":["{{ticketid}}"],"data":{"pr_url":"https://github.com/{{repo.owner}}/{{repo.name}}/pull/{{pr.number}}"}}'
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_branch: {{ branch.name | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+
+tickets:
+  - {{branch.name | capture(regex=r/\b[A-Za-z]+-\d+\b/)}}
+  - {{pr.title | capture(regex=r/\b[A-Za-z]+-\d+\b/)}}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/jira/jira-change-status/jira-change-status-github.png b/automations/integrations/jira/jira-change-status/jira-change-status-github.png new file mode 100644 index 00000000..e6a1096f Binary files /dev/null and b/automations/integrations/jira/jira-change-status/jira-change-status-github.png differ diff --git a/automations/integrations/jira/jira-change-status/jira-change-status-jira.png b/automations/integrations/jira/jira-change-status/jira-change-status-jira.png new file mode 100644 index 00000000..5d231f93 Binary files /dev/null and b/automations/integrations/jira/jira-change-status/jira-change-status-jira.png differ diff --git a/automations/integrations/jira/jira-change-status/jira_update.svg b/automations/integrations/jira/jira-change-status/jira_update.svg new file mode 100644 index 00000000..b1a19d57 --- /dev/null +++ b/automations/integrations/jira/jira-change-status/jira_update.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/integrations/jira/jira-update-field/index.html b/automations/integrations/jira/jira-update-field/index.html new file mode 100644 index 00000000..f15a6e0a --- /dev/null +++ b/automations/integrations/jira/jira-update-field/index.html @@ -0,0 +1,31 @@ + Automation - Automatic Jira Updates - gitStream Documentation

Automatic Jira Updates

Automatically update Jira tickets with pull request information. You can modify this to send any PR metadata to Jira.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Automatic Jira Updates Automatic Jira Updates

Configuration Description

Conditions (all must be true):

  • A PR is created that contains a Jira ticket reference in the title or branch name.

Automation Actions:

  • Send a webhook to Jira containing metadata to add to the Issue.

Automatic Jira Updates

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+
+{% set ticketid = "\b[A-Za-z]+-\d+\b" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  jira_update_field: 
+    if:
+      - {{ has.jira_ticket_in_title or has.jira_ticket_in_branch }}
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ env.JIRA_UPDATE_PR_FIELD_WEBHOOK }}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{"issues":["{{ticketid}}"],"data":{"pr_url":"https://github.com/{{repo.owner}}/{{repo.name}}/pull/{{pr.number}}"}}'
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_branch: {{ branch.name | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/jira/jira-update-field/jira-update-field-github.png b/automations/integrations/jira/jira-update-field/jira-update-field-github.png new file mode 100644 index 00000000..d2e9534d Binary files /dev/null and b/automations/integrations/jira/jira-update-field/jira-update-field-github.png differ diff --git a/automations/integrations/jira/jira-update-field/jira-update-field-jira.png b/automations/integrations/jira/jira-update-field/jira-update-field-jira.png new file mode 100644 index 00000000..d855bf1f Binary files /dev/null and b/automations/integrations/jira/jira-update-field/jira-update-field-jira.png differ diff --git a/automations/integrations/jira/jira-update-field/jira_update.svg b/automations/integrations/jira/jira-update-field/jira_update.svg new file mode 100644 index 00000000..b1a19d57 --- /dev/null +++ b/automations/integrations/jira/jira-update-field/jira_update.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/integrations/jira/label-missing-jira-info/index.html b/automations/integrations/jira/label-missing-jira-info/index.html new file mode 100644 index 00000000..5a705b54 --- /dev/null +++ b/automations/integrations/jira/label-missing-jira-info/index.html @@ -0,0 +1,21 @@ + Automation - Label Missing Jira Info - gitStream Documentation

Label Missing Jira Info

Label PRs that don't reference a Jira ticket in the title or description. This uses regex to detect Jira ticket formats in the title (e.g. ABC-1234), and URLs to Jira tickets in the description.

Label Missing Jira

Configuration Description

Conditions (all must be true):

  • The PR lacks a Jira ticket number in the title, or a link to a Jira ticket in the PR description.

Automation Actions:

  • Apply a missing-jira label.

Label Missing Jira Info

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_missing_jira_info:
+    # Triggered for PRs that don't have either a Jira ticket number in the title,
+    # or a link to a Jira ticket in the PR description.
+    if:
+      - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "missing-jira"
+          color: 'F6443B'
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }}
+
\ No newline at end of file diff --git a/automations/integrations/jira/label-missing-jira-info/label_missing_jira_info.png b/automations/integrations/jira/label-missing-jira-info/label_missing_jira_info.png new file mode 100644 index 00000000..008b0dcd Binary files /dev/null and b/automations/integrations/jira/label-missing-jira-info/label_missing_jira_info.png differ diff --git a/automations/integrations/jira/label-missing-jira-info/label_missing_jira_info.svg b/automations/integrations/jira/label-missing-jira-info/label_missing_jira_info.svg new file mode 100644 index 00000000..d26be068 --- /dev/null +++ b/automations/integrations/jira/label-missing-jira-info/label_missing_jira_info.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/integrations/jira/label-missing-jira-info/logo_label_missing_jira_info.png b/automations/integrations/jira/label-missing-jira-info/logo_label_missing_jira_info.png new file mode 100644 index 00000000..5bc90241 Binary files /dev/null and b/automations/integrations/jira/label-missing-jira-info/logo_label_missing_jira_info.png differ diff --git a/automations/integrations/jira/link-jira/index.html b/automations/integrations/jira/link-jira/index.html new file mode 100644 index 00000000..18488e9d --- /dev/null +++ b/automations/integrations/jira/link-jira/index.html @@ -0,0 +1,39 @@ + Automation - Automatically Link PRs to Related Jira Issues - gitStream Documentation

Automatically Link PRs to Related Jira Issues

Provide automatic links to Jira issues that are associated with PRs.

Automatically Link to the Related Jira Card

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Jira card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Jira Card.

Automatically Link to the Related Jira Card

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+provider: jira
+
+# Change this to the name of your Jira organization
+orgName: org
+
+{% set ticketid = "" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  link_jira:
+    if:
+      - {{ has.ticket_in_title or has.ticket_in_branch }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})
+
+has:
+  ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}
+  ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}
+
+tracker:
+  jira:
+    baseurl: https://[orgName].atlassian.net/browse/
+    pattern: r/\b[A-Za-z]+-\d+\b/
+
+tickets:
+  - {{branch.name | capture(regex=tracker[provider].pattern)}}
+  - {{pr.title | capture(regex=tracker[provider].pattern)}}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/jira/link-jira/link_jira.svg b/automations/integrations/jira/link-jira/link_jira.svg new file mode 100644 index 00000000..751ed246 --- /dev/null +++ b/automations/integrations/jira/link-jira/link_jira.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/integrations/jira/link-jira/logo_link_jira.png b/automations/integrations/jira/link-jira/logo_link_jira.png new file mode 100644 index 00000000..212f3ccf Binary files /dev/null and b/automations/integrations/jira/link-jira/logo_link_jira.png differ diff --git a/automations/integrations/jit/label-jit-alerts/index.html b/automations/integrations/jit/label-jit-alerts/index.html new file mode 100644 index 00000000..d4683fff --- /dev/null +++ b/automations/integrations/jit/label-jit-alerts/index.html @@ -0,0 +1,32 @@ + Automation - Label Jit Alerts - gitStream Documentation

Label Jit Alerts

Label the number of high, medium, and low risk vulnerabilities Jit reports for PRs.

Label Jit Alerts

Configuration Description

Conditions (all must be true):

  • Jit reports one or more high, medium, or low risk security vulnerabilities for the PR.

Automation Actions:

  • Apply labels to indicate the number of each type of vulnerability

Label Jit Alerts

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in reports %}
+  label_jit_{{ item.name }}:
+    if:
+      - {{ item.count > 0}}
+    run:
+      - action: add-label@v1
+        args:
+          label: 'Jit: {{ item.count }} {{ item.name }} vulnerabilities'
+          color: {{ colors.red if (item.name == 'high') else (colors.orange if (item.name == 'medium' ) else colors.yellow) }}
+  {% endfor %}
+
+jit: {{ pr | extractJitFindings }}
+
+reports:
+  - name: high
+    count: {{ jit.metrics.HIGH }}
+  - name: medium
+    count: {{ jit.metrics.MEDIUM }}
+  - name: low
+    count: {{ jit.metrics.LOW }}
+
+colors:
+  red: 'b60205'
+  orange: 'd93f0b'
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/integrations/jit/label-jit-alerts/label-jit-alerts.png b/automations/integrations/jit/label-jit-alerts/label-jit-alerts.png new file mode 100644 index 00000000..e85a7612 Binary files /dev/null and b/automations/integrations/jit/label-jit-alerts/label-jit-alerts.png differ diff --git a/automations/integrations/jit/label-jit-alerts/logo_review_jit_alerts.png b/automations/integrations/jit/label-jit-alerts/logo_review_jit_alerts.png new file mode 100644 index 00000000..973cd051 Binary files /dev/null and b/automations/integrations/jit/label-jit-alerts/logo_review_jit_alerts.png differ diff --git a/automations/integrations/jit/label-jit-alerts/review-jit-alerts.svg b/automations/integrations/jit/label-jit-alerts/review-jit-alerts.svg new file mode 100644 index 00000000..0b531498 --- /dev/null +++ b/automations/integrations/jit/label-jit-alerts/review-jit-alerts.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/jit/review-jit-alerts/index.html b/automations/integrations/jit/review-jit-alerts/index.html new file mode 100644 index 00000000..2543fccd --- /dev/null +++ b/automations/integrations/jit/review-jit-alerts/index.html @@ -0,0 +1,51 @@ + Automation - Review Jit Security Alerts - gitStream Documentation

Review Jit Security Alerts

Manage review assignment for high and medium risk Jit security alerts.

Label Jit Alerts

Configuration Description

**Review Jit High Alerts**
+
+* Conditions (all must be true):
+    * Jit reports one or more high vulnerabilities for the PR
+* Automation Actions:
+    * Require a review from the organization’s security team.
+    * Require 2 reviewers.
+    * Post a comment explaining why this action was taken.
+
+**Review Jit Medium Alerts**
+
+* Conditions (all must be true):
+    * Jit reports one or more medium vulnerabilities for the PR
+* Automation Actions:
+    * Require 2 reviewers
+    * Post a comment explaining why this action was taken.
+

Review Jit Security Alerts

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_jit_high_alerts:
+    if:
+      - {{ jit.metrics.HIGH > 0 }}
+    run:
+      - action: require-reviewers@v1
+        args:
+          reviewers: [my-organization/security-team]
+      - action: set-required-approvals@v1
+        args:
+          approvals: 2
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR requires additional review because Jit reported one or more high risk vulnerabilities.
+  review_jit_medium_alerts:
+    if:
+      - {{ jit.metrics.MEDIUM > 0 }}
+    run:
+      - action: set-required-approvals@v1
+        args:
+          approvals: 2
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR requires additional reviewers because Jit reported one or more medium risk vulnerabilities.
+
+
+jit: {{ pr | extractJitFindings }}
+
\ No newline at end of file diff --git a/automations/integrations/jit/review-jit-alerts/logo_review_jit_alerts.png b/automations/integrations/jit/review-jit-alerts/logo_review_jit_alerts.png new file mode 100644 index 00000000..973cd051 Binary files /dev/null and b/automations/integrations/jit/review-jit-alerts/logo_review_jit_alerts.png differ diff --git a/automations/integrations/jit/review-jit-alerts/review-jit-alerts.png b/automations/integrations/jit/review-jit-alerts/review-jit-alerts.png new file mode 100644 index 00000000..64033da7 Binary files /dev/null and b/automations/integrations/jit/review-jit-alerts/review-jit-alerts.png differ diff --git a/automations/integrations/jit/review-jit-alerts/review-jit-alerts.svg b/automations/integrations/jit/review-jit-alerts/review-jit-alerts.svg new file mode 100644 index 00000000..0b531498 --- /dev/null +++ b/automations/integrations/jit/review-jit-alerts/review-jit-alerts.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/jit/review-jit-ignore-accept/index.html b/automations/integrations/jit/review-jit-ignore-accept/index.html new file mode 100644 index 00000000..aa42dab6 --- /dev/null +++ b/automations/integrations/jit/review-jit-ignore-accept/index.html @@ -0,0 +1,24 @@ + Automation - Review Jit Ignore and Accept - gitStream Documentation

Review Jit Ignore and Accept

Notify your Security team when someone ignores a Jit vulnerability report and accepts the risk.

Label Jit Alerts

Configuration Description

Conditions (all must be true):

Automation Actions:

  • Request review from the organization’s security team.
  • Label the PR to indicate someone accepted the risk of a Jit security alert.
  • Post a comment explaining why this action was taken.

Review Jit Ignore and Accept

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_jit_ignore_accept:
+    if:
+      - {{ pr.conversations | reject(attr='commenter', term='jit-ci') | filter(attr='content', term='#jit_ignore_accept') | some }}
+    run:
+
+      - action: add-reviewers@v1
+        args:
+          reviewers: [my-organziation/security]
+      - action: add-label@v1
+        args:
+          label: '❕ Jit: Ignore - Accept Risk'
+      - action: add-comment@v1
+        args:
+          comment: |
+            The security team has been assigned for optional review because this PR ignores a Jit alert and accepts the associated risks.
+
+jit: {{ pr | extractJitFindings }}
+
\ No newline at end of file diff --git a/automations/integrations/jit/review-jit-ignore-accept/logo_review_jit_alerts.png b/automations/integrations/jit/review-jit-ignore-accept/logo_review_jit_alerts.png new file mode 100644 index 00000000..973cd051 Binary files /dev/null and b/automations/integrations/jit/review-jit-ignore-accept/logo_review_jit_alerts.png differ diff --git a/automations/integrations/jit/review-jit-ignore-accept/review-jit-alerts.svg b/automations/integrations/jit/review-jit-ignore-accept/review-jit-alerts.svg new file mode 100644 index 00000000..0b531498 --- /dev/null +++ b/automations/integrations/jit/review-jit-ignore-accept/review-jit-alerts.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/jit/review-jit-ignore-accept/review-jit-ignore-accept.png b/automations/integrations/jit/review-jit-ignore-accept/review-jit-ignore-accept.png new file mode 100644 index 00000000..f8c8ab5a Binary files /dev/null and b/automations/integrations/jit/review-jit-ignore-accept/review-jit-ignore-accept.png differ diff --git a/automations/integrations/jit/review-jit-secret/index.html b/automations/integrations/jit/review-jit-secret/index.html new file mode 100644 index 00000000..16fb7fcd --- /dev/null +++ b/automations/integrations/jit/review-jit-secret/index.html @@ -0,0 +1,23 @@ + Automation - Review Jit Secret Detection - gitStream Documentation

Review Jit Secret Detection

Close PRs where Jit detects a secret and post a comment explaining steps to remedy the situation.

Label Jit Alerts

Configuration Description

Conditions (all must be true):

  • Jit detects a secret in the PR.

Automation Actions:

  • Close the PR
  • Post a comment explaining why this action was taken and to outline the necessary steps to remedy the situation.

Review Jit Security Control

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_jit_secret:
+    if:
+      - true
+      - {{ jit.vulnerabilities | match(attr='security_control', term='Secret Detection') | some }}
+    run:
+      - action: add-comment@v1
+        args: 
+          comment: |
+            Jit detects secrets in this PR. Please complete the following steps:
+            1. Undo the commit with git reset and remove all secrets from the files you modified.
+            2. Deactivate the secret in any locations its used and replace it with a new key
+            3. Commit your changes and resubmit your PR.
+      - action: close@v1
+
+
+jit: {{ pr | extractJitFindings }}
+
\ No newline at end of file diff --git a/automations/integrations/jit/review-jit-secret/logo_review_jit_alerts.png b/automations/integrations/jit/review-jit-secret/logo_review_jit_alerts.png new file mode 100644 index 00000000..973cd051 Binary files /dev/null and b/automations/integrations/jit/review-jit-secret/logo_review_jit_alerts.png differ diff --git a/automations/integrations/jit/review-jit-secret/review-jit-alerts.svg b/automations/integrations/jit/review-jit-secret/review-jit-alerts.svg new file mode 100644 index 00000000..0b531498 --- /dev/null +++ b/automations/integrations/jit/review-jit-secret/review-jit-alerts.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/jit/review-jit-secret/review-jit-secret.png b/automations/integrations/jit/review-jit-secret/review-jit-secret.png new file mode 100644 index 00000000..ef8fcbba Binary files /dev/null and b/automations/integrations/jit/review-jit-secret/review-jit-secret.png differ diff --git a/automations/integrations/jsdoc/review-jsdoc-input/index.html b/automations/integrations/jsdoc/review-jsdoc-input/index.html new file mode 100644 index 00000000..45d68b67 --- /dev/null +++ b/automations/integrations/jsdoc/review-jsdoc-input/index.html @@ -0,0 +1,15 @@ + Automation - Review JSDoc Input Parameters - gitStream Documentation

Review JSDoc Input Parameters

Warn PR authors when they change JavaScript function or constructor input parameters without updating JSDoc content.

Review JSDoc Input Parameters

Configuration Description

Conditions (all must be true):

  • The PR changes an input parameter in one or more JavaScript methods.
  • The PR lacks changes to ‘@param’ declarations.

Automation Actions:

  • Post a comment warning the user to review the method’s JSDoc to identify necessary updates.

Review JSDoc Input Parameters

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_jsdoc_input: 
+    if:  
+      - {{ source.diff.files | matchDiffLines(regex=r/.*\s@param/) | nope }}
+      - {{ source.diff.files | matchDiffLines(regex=r/\((?:.*\:.*\))/) | some }}
+
+    run:
+      - action: add-comment@v1
+        args: 
+          comment: | 
+              This PR appears to modify method input parameters, but is missing JSDoc changes. Please check to ensure no JSDoc changes are necessary.
+
\ No newline at end of file diff --git a/automations/integrations/jsdoc/review-jsdoc-input/logo_review_jsdoc_input.png b/automations/integrations/jsdoc/review-jsdoc-input/logo_review_jsdoc_input.png new file mode 100644 index 00000000..558dd531 Binary files /dev/null and b/automations/integrations/jsdoc/review-jsdoc-input/logo_review_jsdoc_input.png differ diff --git a/automations/integrations/jsdoc/review-jsdoc-input/review-jsdoc-input.png b/automations/integrations/jsdoc/review-jsdoc-input/review-jsdoc-input.png new file mode 100644 index 00000000..02792e19 Binary files /dev/null and b/automations/integrations/jsdoc/review-jsdoc-input/review-jsdoc-input.png differ diff --git a/automations/integrations/jsdoc/review-jsdoc-input/review-jsdoc-input.svg b/automations/integrations/jsdoc/review-jsdoc-input/review-jsdoc-input.svg new file mode 100644 index 00000000..0021575a --- /dev/null +++ b/automations/integrations/jsdoc/review-jsdoc-input/review-jsdoc-input.svg @@ -0,0 +1,4 @@ + + + + diff --git a/automations/integrations/jsdoc/review-jsdoc-large/index.html b/automations/integrations/jsdoc/review-jsdoc-large/index.html new file mode 100644 index 00000000..98b3680b --- /dev/null +++ b/automations/integrations/jsdoc/review-jsdoc-large/index.html @@ -0,0 +1,34 @@ + Automation - Review JSDoc for Large Changes - gitStream Documentation

Review JSDoc for Large Changes

Require more extensive reviews for large JavaScript changes that lack JSDoc updates.

Review JSDoc for Large changes

Configuration Description

Conditions (all must be true):

  • The PR changes more than 25% of a JavaScript class.

Automation Actions:

  • Post a comment asking the author to review all relevant JSDoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow ⚠️ Missing JSDoc Label

Review JSDoc

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  #Require more extensive reviews for large Javascript changes that lack JSDoc updates.
+  review_jsdoc_large:
+    if:
+      - {{ changes.ratio > 25}}
+      - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ No JSDoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            This PR makes major changes to JavaScript classes, but is missing updates to JSDoc. Please double check for any necessary JSDoc updates.
+
+      - action: add-reviewers@v1
+        args:
+          reviewers: [fourth-organization/tech-writers]
+
+changes:
+  # Sum all the lines added/edited in the PR
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+  # Sum all the line removed in the PR
+  deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}
+  # Calculate the ratio of new code
+  ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/integrations/jsdoc/review-jsdoc-large/logo_review_jsdoc_input.png b/automations/integrations/jsdoc/review-jsdoc-large/logo_review_jsdoc_input.png new file mode 100644 index 00000000..558dd531 Binary files /dev/null and b/automations/integrations/jsdoc/review-jsdoc-large/logo_review_jsdoc_input.png differ diff --git a/automations/integrations/jsdoc/review-jsdoc-large/review-jsdoc-input.svg b/automations/integrations/jsdoc/review-jsdoc-large/review-jsdoc-input.svg new file mode 100644 index 00000000..0021575a --- /dev/null +++ b/automations/integrations/jsdoc/review-jsdoc-large/review-jsdoc-input.svg @@ -0,0 +1,4 @@ + + + + diff --git a/automations/integrations/jsdoc/review-jsdoc-large/review-jsdoc-large.png b/automations/integrations/jsdoc/review-jsdoc-large/review-jsdoc-large.png new file mode 100644 index 00000000..062ba51f Binary files /dev/null and b/automations/integrations/jsdoc/review-jsdoc-large/review-jsdoc-large.png differ diff --git a/automations/integrations/jsdoc/review-jsdoc-new-class/index.html b/automations/integrations/jsdoc/review-jsdoc-new-class/index.html new file mode 100644 index 00000000..18ee8199 --- /dev/null +++ b/automations/integrations/jsdoc/review-jsdoc-new-class/index.html @@ -0,0 +1,25 @@ + Automation - Enforce JSDoc for New JavaScript Classes - gitStream Documentation

Enforce JSDoc for New JavaScript Classes

Require JSDoc for all new JavaScript classes.

Enforce JSDoc for New JavaScript Classes

Configuration Description

Conditions (all must be true):

  • The PR creates a new JavaScript class.
  • The PR lacks JSDoc content.

Automation Actions:

  • Request changes and post a comment explaining that JSDoc is required
  • Apply a yellow ⚠️ Missing JSDoc label.

Enforce JSDoc for New JavaScript Classes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_jsdoc_new_class: 
+    if:  
+        - {{ is.javascript and is.new }} 
+        - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing JSDoc"
+          color: {{ colors.yellow }}
+      - action: request-changes@v1
+        args: 
+          comment: | 
+            JSDoc is required for all JavaScript classes. Please add JSDoc to all new classes in this PR.
+
+is:
+    javascript: {{ files | extensions | match(list=['js', 'ts']) | every }}
+    new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/integrations/jsdoc/review-jsdoc-new-class/logo_review_jsdoc_input.png b/automations/integrations/jsdoc/review-jsdoc-new-class/logo_review_jsdoc_input.png new file mode 100644 index 00000000..558dd531 Binary files /dev/null and b/automations/integrations/jsdoc/review-jsdoc-new-class/logo_review_jsdoc_input.png differ diff --git a/automations/integrations/jsdoc/review-jsdoc-new-class/review-jsdoc-input.svg b/automations/integrations/jsdoc/review-jsdoc-new-class/review-jsdoc-input.svg new file mode 100644 index 00000000..0021575a --- /dev/null +++ b/automations/integrations/jsdoc/review-jsdoc-new-class/review-jsdoc-input.svg @@ -0,0 +1,4 @@ + + + + diff --git a/automations/integrations/jsdoc/review-jsdoc-new-class/review-jsdoc-new-class.png b/automations/integrations/jsdoc/review-jsdoc-new-class/review-jsdoc-new-class.png new file mode 100644 index 00000000..9fb67916 Binary files /dev/null and b/automations/integrations/jsdoc/review-jsdoc-new-class/review-jsdoc-new-class.png differ diff --git a/automations/integrations/jsdoc/review-jsdoc/index.html b/automations/integrations/jsdoc/review-jsdoc/index.html new file mode 100644 index 00000000..695c4e95 --- /dev/null +++ b/automations/integrations/jsdoc/review-jsdoc/index.html @@ -0,0 +1,21 @@ + Automation - Review JSDoc Changes - gitStream Documentation

Review JSDoc Changes

Approve PRs that only contain changes to JSDoc and assign optional reviewers.

Review JSDoc

Configuration Description

Conditions (all must be true):

  • The PR only affects JavaScript and TypeScript files
  • The PR only contains changes to JSDoc content.

Automation Actions:

  • Assign the ORG/tech-writers team.
  • Apply a green 📓 JSDoc Only label
  • Approve the PR

Review JSDoc

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  #Assign PRs that only affect JSDocs to the technical writing team and add docs label
+  review_jsdoc:
+    if:
+      - {{ source.diff.files | match(attr='diff', regex=r/\/*\*[\s\S]*?\//) | every }}
+    run:
+      - action: add-label@v1
+        args:
+            label: "📓JSDoc Only"
+            color: {{ colors.green }}
+      - action: add-reviewers@v1
+        args:
+          reviewers: [fourth-organization/tech-writers]
+      - action: approve@v1
+
+colors:
+  green: '0e8a16'
+
\ No newline at end of file diff --git a/automations/integrations/jsdoc/review-jsdoc/logo_review_jsdoc_input.png b/automations/integrations/jsdoc/review-jsdoc/logo_review_jsdoc_input.png new file mode 100644 index 00000000..558dd531 Binary files /dev/null and b/automations/integrations/jsdoc/review-jsdoc/logo_review_jsdoc_input.png differ diff --git a/automations/integrations/jsdoc/review-jsdoc/review-jsdoc-input.svg b/automations/integrations/jsdoc/review-jsdoc/review-jsdoc-input.svg new file mode 100644 index 00000000..0021575a --- /dev/null +++ b/automations/integrations/jsdoc/review-jsdoc/review-jsdoc-input.svg @@ -0,0 +1,4 @@ + + + + diff --git a/automations/integrations/jsdoc/review-jsdoc/review-jsdoc.png b/automations/integrations/jsdoc/review-jsdoc/review-jsdoc.png new file mode 100644 index 00000000..3a96404c Binary files /dev/null and b/automations/integrations/jsdoc/review-jsdoc/review-jsdoc.png differ diff --git a/automations/integrations/launch-darkly/label-ff-launch-darkly/index.html b/automations/integrations/launch-darkly/label-ff-launch-darkly/index.html new file mode 100644 index 00000000..93e365f7 --- /dev/null +++ b/automations/integrations/launch-darkly/label-ff-launch-darkly/index.html @@ -0,0 +1,29 @@ + Automation - Label PRs Based on LaunchDarkly Feature Flags - gitStream Documentation

Label LaunchDarkly Feature Flags

Automatically label code that contians specified feature flags.

Label PRs Based on Feature Flags

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+
+  {% for item in feature_flags %}
+  label_ff_launchdarkly_{{ item.name }}:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/var flagValue = ldclient/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ item.name }}
+          color: {{ colors.yellow }}
+  {% endfor %}
+
+feature_flags:
+   - name: engineering_rollback_plan_activated 
+     regex: r/engineering_rollback_plan_activated/
+   - name: marketing_premium_plan_features_unlocked 
+     regex: r/marketing_premium_plan_features_unlocked/
+   - name: mobile_push_notifications_enabled
+     regex: r/mobile_push_notifications_enabled/
+
+colors:
+  yellow: 'ffb300'   
+
\ No newline at end of file diff --git a/automations/integrations/launch-darkly/label-ff-launch-darkly/label-ff-launch-darkly.png b/automations/integrations/launch-darkly/label-ff-launch-darkly/label-ff-launch-darkly.png new file mode 100644 index 00000000..183c673c Binary files /dev/null and b/automations/integrations/launch-darkly/label-ff-launch-darkly/label-ff-launch-darkly.png differ diff --git a/automations/integrations/launch-darkly/label-ff-launch-darkly/label-ff-launch-darkly.svg b/automations/integrations/launch-darkly/label-ff-launch-darkly/label-ff-launch-darkly.svg new file mode 100644 index 00000000..a9e3c0f5 --- /dev/null +++ b/automations/integrations/launch-darkly/label-ff-launch-darkly/label-ff-launch-darkly.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/launch-darkly/label-ff-launch-darkly/logo_label_ff_launch_darkly.png b/automations/integrations/launch-darkly/label-ff-launch-darkly/logo_label_ff_launch_darkly.png new file mode 100644 index 00000000..ca436a37 Binary files /dev/null and b/automations/integrations/launch-darkly/label-ff-launch-darkly/logo_label_ff_launch_darkly.png differ diff --git a/automations/integrations/linearb/copilot-label-metrics.png b/automations/integrations/linearb/copilot-label-metrics.png new file mode 100644 index 00000000..c1db5004 Binary files /dev/null and b/automations/integrations/linearb/copilot-label-metrics.png differ diff --git a/automations/integrations/linearb/resource-label-metrics.png b/automations/integrations/linearb/resource-label-metrics.png new file mode 100644 index 00000000..3e54bd7f Binary files /dev/null and b/automations/integrations/linearb/resource-label-metrics.png differ diff --git a/automations/integrations/orca/label-orca-scan-results/index.html b/automations/integrations/orca/label-orca-scan-results/index.html new file mode 100644 index 00000000..cf5f39a2 --- /dev/null +++ b/automations/integrations/orca/label-orca-scan-results/index.html @@ -0,0 +1,29 @@ + Automation - Auto-Label Orca Scan Results - gitStream Documentation

Auto-Label Orca Scan Results

Automatically apply labels to PRs that indicate the result of Orca Security scans.

Required gitStream Plugin

This example requires you to install the extractOrcaFindings plugin.

Learn more about gitStream plugins.

Auto-Label Orca Scan ResultsAuto-Label Orca Scan Results

Configuration Description

Conditions (all must be true):

  • Orca Security detects one or more issues with the code in the PR.

Automation Actions:

  • Apply a label that indicates which issue was identified.

Auto-Label Orca Scan Results

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in reports %}
+  label_orca_{{ item.name }}:
+    if:
+      - {{ item.count > 0 }}
+    run:
+      - action: add-label@v1
+        args:
+          label: 'orca:{{ item.name }}'
+  {% endfor %}
+
+orca: {{ pr | extractOrcaFindings }}
+
+reports:
+  - name: introduced-cves
+    count: {{ orca.vulnerabilities.count }}
+  - name: iac-misconfigurations
+    count: {{ orca.infrastructure_as_code.count }}
+  - name: exposed-secrets 
+    count: {{ orca.secrets.count }}
+
+colors:
+  red: 'b60205'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/orca/label-orca-scan-results/label-orca-scan-results-dark.png b/automations/integrations/orca/label-orca-scan-results/label-orca-scan-results-dark.png new file mode 100644 index 00000000..53fb2db4 Binary files /dev/null and b/automations/integrations/orca/label-orca-scan-results/label-orca-scan-results-dark.png differ diff --git a/automations/integrations/orca/label-orca-scan-results/label-orca-scan-results.png b/automations/integrations/orca/label-orca-scan-results/label-orca-scan-results.png new file mode 100644 index 00000000..4b7204f3 Binary files /dev/null and b/automations/integrations/orca/label-orca-scan-results/label-orca-scan-results.png differ diff --git a/automations/integrations/orca/label-orca-scan-results/logo_review_orca_alerts.png b/automations/integrations/orca/label-orca-scan-results/logo_review_orca_alerts.png new file mode 100644 index 00000000..30f08096 Binary files /dev/null and b/automations/integrations/orca/label-orca-scan-results/logo_review_orca_alerts.png differ diff --git a/automations/integrations/orca/label-orca-scan-results/review-orca-alerts.svg b/automations/integrations/orca/label-orca-scan-results/review-orca-alerts.svg new file mode 100644 index 00000000..a9fc0169 --- /dev/null +++ b/automations/integrations/orca/label-orca-scan-results/review-orca-alerts.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/automations/integrations/orca/review-orca-alerts/index.html b/automations/integrations/orca/review-orca-alerts/index.html new file mode 100644 index 00000000..6fced93b --- /dev/null +++ b/automations/integrations/orca/review-orca-alerts/index.html @@ -0,0 +1,24 @@ + Automation - Review Orca Security Alerts - gitStream Documentation

Require Security Review for Orca Alerts

Automatically require review from your SecOps team for Orca Security violations in pull requests.

Review Orca Security Alerts Review Orca Security Alerts Review Orca Security Alerts Review Orca Security Alerts

Configuration Description

Conditions (all must be true):

  • The PR contains a vulnerability, IAC problem, or secret that is flagged as High or Medium.

Automation Actions:

  • Require review from your organization's security team.
  • Post a comment explaining the requirement.

Review Orca Security Alerts

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+automations:
+  review_orca_alerts:
+    if:
+      - {{ has.vulnerability or has.iac_violation or has.secret }}
+    run:
+      - action: require-reviewers@v1
+        args:
+          reviewers: [my-organization/security-team]
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR requires additional review because it fails to meet Orca Security safe code standards.
+
+orca: {{ pr | extractOrcaFindings }}
+
+has:
+  vulnerability: {{ orca.vulnerabilities.priority == 'High' or orca.vulnerabilities.priority == 'Medium' }}
+  iac_violation: {{ orca.infrastructure_as_code.priority == 'High' or orca.infrastructure_as_code.priority == 'Medium' }}
+  secret: {{ orca.secrets.priority == 'High' or orca.secrets.priority == 'Medium' }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/orca/review-orca-alerts/logo_review_orca_alerts.png b/automations/integrations/orca/review-orca-alerts/logo_review_orca_alerts.png new file mode 100644 index 00000000..30f08096 Binary files /dev/null and b/automations/integrations/orca/review-orca-alerts/logo_review_orca_alerts.png differ diff --git a/automations/integrations/orca/review-orca-alerts/review-orca-alerts-1-dark.png b/automations/integrations/orca/review-orca-alerts/review-orca-alerts-1-dark.png new file mode 100644 index 00000000..dfb9da31 Binary files /dev/null and b/automations/integrations/orca/review-orca-alerts/review-orca-alerts-1-dark.png differ diff --git a/automations/integrations/orca/review-orca-alerts/review-orca-alerts-1-light.png b/automations/integrations/orca/review-orca-alerts/review-orca-alerts-1-light.png new file mode 100644 index 00000000..c82e3d76 Binary files /dev/null and b/automations/integrations/orca/review-orca-alerts/review-orca-alerts-1-light.png differ diff --git a/automations/integrations/orca/review-orca-alerts/review-orca-alerts-2-dark.png b/automations/integrations/orca/review-orca-alerts/review-orca-alerts-2-dark.png new file mode 100644 index 00000000..f4efe5f9 Binary files /dev/null and b/automations/integrations/orca/review-orca-alerts/review-orca-alerts-2-dark.png differ diff --git a/automations/integrations/orca/review-orca-alerts/review-orca-alerts-2-light.png b/automations/integrations/orca/review-orca-alerts/review-orca-alerts-2-light.png new file mode 100644 index 00000000..e6b68262 Binary files /dev/null and b/automations/integrations/orca/review-orca-alerts/review-orca-alerts-2-light.png differ diff --git a/automations/integrations/orca/review-orca-alerts/review-orca-alerts.svg b/automations/integrations/orca/review-orca-alerts/review-orca-alerts.svg new file mode 100644 index 00000000..a9fc0169 --- /dev/null +++ b/automations/integrations/orca/review-orca-alerts/review-orca-alerts.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/automations/integrations/rdoc/review-rdoc-input/index.html b/automations/integrations/rdoc/review-rdoc-input/index.html new file mode 100644 index 00000000..2a03e9e4 --- /dev/null +++ b/automations/integrations/rdoc/review-rdoc-input/index.html @@ -0,0 +1,14 @@ + Automation - Review RDoc Input Parameters - gitStream Documentation

Review RDoc Input Parameters

Warn PR authors when they change Ruby function or constructor input parameters without updating RDoc content.

Review RDoc Input Parameters

Configuration Description

Conditions (all must be true):

  • The PR changes one or more input parameters in Ruby methods.
  • The PR lacks RDoc updates.

Automation Actions:

  • Post a comment warning the user to review the method’s RDoc to identify necessary updates.

Review RDoc Input Parameters

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_rdoc_input: 
+    if:  
+      - {{ source.diff.files | match(attr='diff', regex=r/(\#.*\n.*)*def/) | nope }}
+      - {{ source.diff.files | match(attr='diff', regex=r/def.*\(.*\)/ | some }}
+    run:
+    - action: add-comment@v1
+      args: 
+        comment: | 
+            This PR modifies method input parameters, but is missing RDoc changes. Please check to ensure no RDoc changes are necessary.
+
\ No newline at end of file diff --git a/automations/integrations/rdoc/review-rdoc-input/review-rdoc-input.png b/automations/integrations/rdoc/review-rdoc-input/review-rdoc-input.png new file mode 100644 index 00000000..5693e39c Binary files /dev/null and b/automations/integrations/rdoc/review-rdoc-input/review-rdoc-input.png differ diff --git a/automations/integrations/rdoc/review-rdoc-large/index.html b/automations/integrations/rdoc/review-rdoc-large/index.html new file mode 100644 index 00000000..7822cc30 --- /dev/null +++ b/automations/integrations/rdoc/review-rdoc-large/index.html @@ -0,0 +1,32 @@ + Automation - Review RDoc for Large Changes - gitStream Documentation

Review RDoc for Large Changes

Require more extensive reviews for large Ruby changes that lack RDoc updates.

Review RDoc for Large changes

Configuration Description

Conditions (all must be true):

  • The PR changes more than 150 lines of Ruby code.

Automation Actions:

  • Post a comment asking the author to review all relevant RDoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow ⚠️ Missing RDoc Label

Review RDoc

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  #Require more extensive reviews for large Ruby changes that lack RDoc updates.
+  review_rdoc_large:
+    if:
+      - {{ changes.additions > 150}}
+      - {{ source.diff.files | matchDiffLines(regex=r/(\#.*\n.*)*def/) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing RDoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+              This PR makes major changes to Ruby methods, but is missing updates to RDoc. Please double check for any necessary RDoc updates.
+      - action: add-reviewers@v1
+        args:
+          reviewers: [fourth-organization/tech-writers]
+
+changes:
+  # Sum all the lines added/edited in the PR
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/integrations/rdoc/review-rdoc-large/review-rdoc-large.png b/automations/integrations/rdoc/review-rdoc-large/review-rdoc-large.png new file mode 100644 index 00000000..035ea5ba Binary files /dev/null and b/automations/integrations/rdoc/review-rdoc-large/review-rdoc-large.png differ diff --git a/automations/integrations/rdoc/review-rdoc-new-class/index.html b/automations/integrations/rdoc/review-rdoc-new-class/index.html new file mode 100644 index 00000000..1089c906 --- /dev/null +++ b/automations/integrations/rdoc/review-rdoc-new-class/index.html @@ -0,0 +1,25 @@ + Automation - Enforce RDoc for New Ruby Classes - gitStream Documentation

Enforce RDoc for New Ruby Classes

Require RDoc for all new Ruby classes.

Enforce RDoc for New Ruby Classes

Configuration Description

Conditions (all must be true):

  • The PR creates a new Ruby class.
  • The PR lacks RDoc content.

Automation Actions:

  • Request changes and post a comment explaining that RDoc is required
  • Apply a yellow ⚠️ Missing RDoc label.

Enforce RDoc for New Ruby Classes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_rdoc_new_class: 
+    if:  
+      - {{ is.rb and is.new }} 
+      - {{ source.diff.files | match(attr='diff', regex=r/(\#.*\n.*)*def/) | nope }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing RDoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            RDoc is required for all Ruby classes. Please add documentation for this PR.
+
+is:
+    rb: {{ files | extensions | match(regex=r/rb/) | every }}
+    new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/integrations/rdoc/review-rdoc-new-class/review-rdoc-new-class.png b/automations/integrations/rdoc/review-rdoc-new-class/review-rdoc-new-class.png new file mode 100644 index 00000000..778b1d97 Binary files /dev/null and b/automations/integrations/rdoc/review-rdoc-new-class/review-rdoc-new-class.png differ diff --git a/automations/integrations/rdoc/review-rdoc/index.html b/automations/integrations/rdoc/review-rdoc/index.html new file mode 100644 index 00000000..424c2433 --- /dev/null +++ b/automations/integrations/rdoc/review-rdoc/index.html @@ -0,0 +1,20 @@ + Automation - Approve RDoc Changes - gitStream Documentation

Automatically Approve RDoc Changes

Approve PRs that only contain changes to RDoc and assign optional reviewers.

Review RDoc

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to RDoc content.

Automation Actions:

  • Assign the org/tech-writers team for optional review.
  • Apply a green 📓 RDoc Only label
  • Approve the PR

Review RDoc

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_rdoc:
+    if:
+      - {{ source.diff.files | match(attr='diff', regex=r/^[\s\t]*#.*/) | every }}
+    run:
+      - action: add-label@v1
+        args:
+            label: "📓RDoc Only"
+            color: {{ colors.green }}
+      - action: add-reviewers@v1
+        args:
+          reviewers: [org/tech-writers]
+      - action: approve@v1
+
+colors:
+  green: '0e8a16'
+
\ No newline at end of file diff --git a/automations/integrations/rdoc/review-rdoc/review-rdoc.png b/automations/integrations/rdoc/review-rdoc/review-rdoc.png new file mode 100644 index 00000000..6e4defe8 Binary files /dev/null and b/automations/integrations/rdoc/review-rdoc/review-rdoc.png differ diff --git a/automations/integrations/renovate/approve-renovate/approve-renovate.png b/automations/integrations/renovate/approve-renovate/approve-renovate.png new file mode 100644 index 00000000..0b7b8dfe Binary files /dev/null and b/automations/integrations/renovate/approve-renovate/approve-renovate.png differ diff --git a/automations/integrations/renovate/approve-renovate/approve-renovate.svg b/automations/integrations/renovate/approve-renovate/approve-renovate.svg new file mode 100644 index 00000000..48fd11bf --- /dev/null +++ b/automations/integrations/renovate/approve-renovate/approve-renovate.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/automations/integrations/renovate/approve-renovate/index.html b/automations/integrations/renovate/approve-renovate/index.html new file mode 100644 index 00000000..2771af1c --- /dev/null +++ b/automations/integrations/renovate/approve-renovate/index.html @@ -0,0 +1,49 @@ + Automation - Approve and Merge Renovate Changes - gitStream Documentation

Approve and Merge Renovate Changes

Auto-merge Renovate PRs

Required gitStream Plugins

This example requires you to install the extractRenovateVersionBump, compareMultiSemver and compareSemver plugins.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • The PR author is Renovate.
  • The branch name includes 'renovate'
  • The dependency change is a patch or minor update.

Automation Actions:

  • Approve the PR
  • Apply an approved-renovate label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

manifest:
+  version: 1.0
+
+automations:
+  merge_renovate_minor:
+    if:
+      - {{ bump == 'minor' }}
+      - {{ branch.name | includes(term="renovate") }}
+      - {{ branch.author | includes(term="renovate") }}
+    run:
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Renovate `minor` version bumps are approved automatically.
+
+  merge_renovate_minor_patch:
+    if:
+      - {{ bump == 'patch' }}
+      - {{ branch.name | includes(term="renovate") }}
+      - {{ branch.author | includes(term="renovate") }}
+    run:
+      - action: approve@v1
+      - action: merge@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Renovate `patch` version bumps are approved and merged automatically.
+
+bump: {{ pr.description | extractRenovateVersionBump | compareMultiSemver }}
+

Configuration Description

Conditions (all must be true):

  • The PR author is Renovate.
  • The branch name includes 'renovate'

Automation Actions:

  • Approve the PR
  • Apply an approved-renovate label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_renovate:
+    if:
+      - {{ branch.author | includes(term="renovate") }}
+    run:
+      - action: approve@v1
+      - action: add-label@v1
+        args:
+          label: "approved-renovate"
+      - action: merge@v1
+        args:
+          wait_for_all_checks: true
+          squash_on_merge: true
+

\ No newline at end of file diff --git a/automations/integrations/renovate/approve-renovate/logo_approve_renovate.png b/automations/integrations/renovate/approve-renovate/logo_approve_renovate.png new file mode 100644 index 00000000..ab3d2d57 Binary files /dev/null and b/automations/integrations/renovate/approve-renovate/logo_approve_renovate.png differ diff --git a/automations/integrations/shortcut/label-missing-shortcut/index.html b/automations/integrations/shortcut/label-missing-shortcut/index.html new file mode 100644 index 00000000..67cbdddf --- /dev/null +++ b/automations/integrations/shortcut/label-missing-shortcut/index.html @@ -0,0 +1,26 @@ + Automation - Label Missing Shortcut - gitStream Documentation

Label Missing Shortcut

Automatically label PRs that are missing references to Shortcut resources.

Label Missing Shortcut

Configuration Description

Conditions (all must be true):

  • The PR is missing one of the following:
    • An Shortcut ticket reference in the PR title.
    • A link to an Shortcut resource in the PR description.

Automation Actions:

  • Apply a red ⚠️ Missing Shortcut Link label
  • Post a comment that asks the author to add an Shortcut reference to the PR.

Label Missing Shortcut

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_missing_shortcut:
+    if:
+      - {{not (has.shortcut.ticket_in_title or has.shortcut.ticket_in_desc)}}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Shortcut Link"
+          color: {{ colors.red }}
+      - action: add-comment@v1
+        args:
+          comment: Please provide a link to the associated Shortcut resource.
+
+has:
+  shortcut:
+    ticket_in_title: {{ pr.title | includes(regex=r/(\w+)\/sc-(\d+)/) }}
+    ticket_in_desc: {{ pr.description | includes(regex=r/(app\.shortcut\.com)\/(\w+)\/story\/(\d+)\/(\w+)/) }}
+
+colors:
+  red: 'b60205'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/shortcut/label-missing-shortcut/link-shortcut.svg b/automations/integrations/shortcut/label-missing-shortcut/link-shortcut.svg new file mode 100644 index 00000000..37ed1604 --- /dev/null +++ b/automations/integrations/shortcut/label-missing-shortcut/link-shortcut.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/shortcut/label-missing-shortcut/logo_link_shortcut.png b/automations/integrations/shortcut/label-missing-shortcut/logo_link_shortcut.png new file mode 100644 index 00000000..0fa58f8e Binary files /dev/null and b/automations/integrations/shortcut/label-missing-shortcut/logo_link_shortcut.png differ diff --git a/automations/integrations/shortcut/link-shortcut/index.html b/automations/integrations/shortcut/link-shortcut/index.html new file mode 100644 index 00000000..7a91c69e --- /dev/null +++ b/automations/integrations/shortcut/link-shortcut/index.html @@ -0,0 +1,40 @@ + Automation - Automatically Link PRs to Related Shortcut Tasks - gitStream Documentation

Automatically Link PRs to Related Shortcut Tasks

Provide automatic links to Shortcut tasks that are associated with PRs.

Automatically Link to the Related Shortcut Task

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Shortcut card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Shortcut Task.

Automatically Link to the Related Shortcut Task

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+# Configure these to match your organization.
+provider: jira
+
+# Change this to match the name of your Shortcut organization. This is used in tracker.shortcut.baseurl
+orgName: org
+
+{% set ticketid = "" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  link_shortcut:
+    if:
+      - {{ has.ticket_in_title or has.ticket_in_branch }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})
+
+has:
+  ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}
+  ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}
+
+tracker:
+  shortcut:
+    baseurl: https://app.shortcut.com/[orgName]/story/
+    pattern: r/(\w+)\/sc-(\d+)/
+
+tickets:
+  - {{branch.name | capture(regex=tracker[provider].pattern)}}
+  - {{pr.title | capture(regex=tracker[provider].pattern)}}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/shortcut/link-shortcut/link-shortcut.svg b/automations/integrations/shortcut/link-shortcut/link-shortcut.svg new file mode 100644 index 00000000..37ed1604 --- /dev/null +++ b/automations/integrations/shortcut/link-shortcut/link-shortcut.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/shortcut/link-shortcut/logo_link_shortcut.png b/automations/integrations/shortcut/link-shortcut/logo_link_shortcut.png new file mode 100644 index 00000000..0fa58f8e Binary files /dev/null and b/automations/integrations/shortcut/link-shortcut/logo_link_shortcut.png differ diff --git a/automations/integrations/slack/slack-auto-recognition/index.html b/automations/integrations/slack/slack-auto-recognition/index.html new file mode 100644 index 00000000..2cc1b2ce --- /dev/null +++ b/automations/integrations/slack/slack-auto-recognition/index.html @@ -0,0 +1,18 @@ + Automation - Automatic Slack Messages - gitStream Documentation

Automatic Slack Messages

Automatically post positive recognition messages in Slack for well-structured PRs.

Automatic Slack Messages

Configuration Description

Conditions (all must be true):

  • The PR contains updates to tests.
  • The PR has fewer than 5 modified files.
  • The PR branch references a Jira ticket.
  • The PR has fewer than 150 lines of code changed.

Automation Actions:

  • Post a Slack message that automatically recognizes the PR author and provides a link to the PR.

Automatic Slack Messages

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  slack_auto_recognition:
+    if:
+        - {{ files | match(regex=r/(test|spec)/) | some }} # this pr has at least 1 test
+        - {{ files | length <= 5 }} # this pr has 5 or less files
+        - {{ branch.name | includes(regex=r/[A-Z]{2,}-\d+.*/) }} # this branch has the Jira ticket prefix
+        - {{ branch.diff.size <= 150 }} # this branch has 150 lines of code or less changed
+    run:
+        - action: send-slack-message@v1
+          args:
+            webhook_url: "{{ env.SLACK_WEBHOOK }}"
+            message: ":tada: Congrats to {{ pr.author }} for the amazing new PR, '{{ pr.title }}'! Check it out at https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/slack/slack-auto-recognition/logo_slack_auto_recognition.png b/automations/integrations/slack/slack-auto-recognition/logo_slack_auto_recognition.png new file mode 100644 index 00000000..425e5f3c Binary files /dev/null and b/automations/integrations/slack/slack-auto-recognition/logo_slack_auto_recognition.png differ diff --git a/automations/integrations/slack/slack-auto-recognition/slack-auto-recognition.png b/automations/integrations/slack/slack-auto-recognition/slack-auto-recognition.png new file mode 100644 index 00000000..5bc8ad60 Binary files /dev/null and b/automations/integrations/slack/slack-auto-recognition/slack-auto-recognition.png differ diff --git a/automations/integrations/slack/slack-auto-recognition/slack-auto-recognition.svg b/automations/integrations/slack/slack-auto-recognition/slack-auto-recognition.svg new file mode 100644 index 00000000..0577cd2f --- /dev/null +++ b/automations/integrations/slack/slack-auto-recognition/slack-auto-recognition.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/automations/integrations/slack/slack-send-notification/index.html b/automations/integrations/slack/slack-send-notification/index.html new file mode 100644 index 00000000..14ac8c1b --- /dev/null +++ b/automations/integrations/slack/slack-send-notification/index.html @@ -0,0 +1,34 @@ + Automation - Send Slack Notifications - gitStream Documentation

Send Slack Notifications

Automatically send Slack notifications to specific channels based on the contents of a pull request.

Send Slack Notifications

Configuration Description

Conditions (all must be true):

  • The PR meets one or more of the specified trigger criteria for Slack notifications.

Automation Actions:

  • Post a Slack message based on the contents of the PR.

Send Slack Notifications

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  send_slack_security:
+    # use your custom logic here to determine whether this needs a security review
+    if:
+      - true
+    run:
+      - action: send-slack-message@v1
+        args:
+          webhook_url: "{{ env.SLACK_WEBHOOK_SECURITY }}"
+          message: "A PR requires a security review. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+  send_slack_qa:
+    # use your custom logic here to determine whether this needs a qa review
+    if:
+      - {{ not (files | match(regex=r/(test|spec)/) | some) }}
+    run:
+      - action: send-slack-message@v1
+        args:
+          webhook_url: "{{ env.SLACK_WEBHOOK_QA }}"
+          message: "A PR was submitted without tests. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+  send_slack_docs:
+    # use your custom logic here to determine whether this needs a docs review
+    if:
+      - {{ files | match(regex=r/(docs)/) | some }}
+    run:
+      - action: send-slack-message@v1
+        args:
+          webhook_url: "{{ env.SLACK_WEBHOOK_DOCS }}"
+          message: "A PR has modified the docs. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/slack/slack-send-notification/logo_slack_auto_recognition.png b/automations/integrations/slack/slack-send-notification/logo_slack_auto_recognition.png new file mode 100644 index 00000000..425e5f3c Binary files /dev/null and b/automations/integrations/slack/slack-send-notification/logo_slack_auto_recognition.png differ diff --git a/automations/integrations/slack/slack-send-notification/slack-auto-recognition.svg b/automations/integrations/slack/slack-send-notification/slack-auto-recognition.svg new file mode 100644 index 00000000..0577cd2f --- /dev/null +++ b/automations/integrations/slack/slack-send-notification/slack-auto-recognition.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/automations/integrations/slack/slack-send-notification/slack-send-notification.png b/automations/integrations/slack/slack-send-notification/slack-send-notification.png new file mode 100644 index 00000000..c6457e1c Binary files /dev/null and b/automations/integrations/slack/slack-send-notification/slack-send-notification.png differ diff --git a/automations/integrations/snyk/approve-snyk/approve-snyk.png b/automations/integrations/snyk/approve-snyk/approve-snyk.png new file mode 100644 index 00000000..c68b1f7b Binary files /dev/null and b/automations/integrations/snyk/approve-snyk/approve-snyk.png differ diff --git a/automations/integrations/snyk/approve-snyk/approve-snyk.svg b/automations/integrations/snyk/approve-snyk/approve-snyk.svg new file mode 100644 index 00000000..e9e81850 --- /dev/null +++ b/automations/integrations/snyk/approve-snyk/approve-snyk.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/integrations/snyk/approve-snyk/index.html b/automations/integrations/snyk/approve-snyk/index.html new file mode 100644 index 00000000..70dbf16f --- /dev/null +++ b/automations/integrations/snyk/approve-snyk/index.html @@ -0,0 +1,19 @@ + Automation - Approve and Merge Snyk Changes - gitStream Documentation

Approve and Merge Snyk Changes

Approve PRs from Snyk

Approve and Merge Snyk Changes

Configuration Description

Conditions (all must be true):

  • The PR author is Snyk.

Automation Actions:

  • Approve the PR
  • Apply an approved-snyk label to the PR
  • Merge the PR if all status checks pass.

Approve Snyk

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_snyk:
+    if:
+      - {{ branch.author | includes(term="snyk") }}
+    run:
+      - action: approve@v1
+      - action: add-label@v1
+        args:
+          label: "approved-snyk"
+      - action: merge@v1
+        args:
+          wait_for_all_checks: true
+          squash_on_merge: true
+
\ No newline at end of file diff --git a/automations/integrations/snyk/approve-snyk/logo_approve_snyk.png b/automations/integrations/snyk/approve-snyk/logo_approve_snyk.png new file mode 100644 index 00000000..f61a7c7a Binary files /dev/null and b/automations/integrations/snyk/approve-snyk/logo_approve_snyk.png differ diff --git a/automations/integrations/sonar/approve-sonar-clean-code/approve-sonar-clean-code.png b/automations/integrations/sonar/approve-sonar-clean-code/approve-sonar-clean-code.png new file mode 100644 index 00000000..049be25c Binary files /dev/null and b/automations/integrations/sonar/approve-sonar-clean-code/approve-sonar-clean-code.png differ diff --git a/automations/integrations/sonar/approve-sonar-clean-code/index.html b/automations/integrations/sonar/approve-sonar-clean-code/index.html new file mode 100644 index 00000000..55eb75e2 --- /dev/null +++ b/automations/integrations/sonar/approve-sonar-clean-code/index.html @@ -0,0 +1,28 @@ + Automation - Approve SonarCloud Clean Code - gitStream Documentation

Approve Sonar Clean Code

Approve PRs that pass SonarCloud's quality gate.

Aprove Sonar Clean Code

Configuration Description

Conditions (all must be true):

  • SonarCloud reports an 'A' rating for vulnerabilities, bugs, security hotspots, and code smells.
  • There is no duplicated code.

Automation Actions:

  • Apply a Sonar: Clean Code label to the PR.
  • Approve the PR.
  • Post a comment that explains why the PR was approved.

Aprove Sonar Clean Code

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+automations:
+  approve_sonar_clean_code:
+    if:
+      - {{ sonar.bugs.rating == 'A' }}
+      - {{ sonar.code_smells.rating == 'A' }}
+      - {{ sonar.vulnerabilities.rating == 'A' }}
+      - {{ sonar.security_hotspots.rating == 'A' }}
+      - {{ sonar.duplications == null or sonar.duplications == 0 }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: '✅ Sonar: Clean Code'
+          color: {{ colors.green }}
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR passes the SonarCloud quality gate check and as been automatically approved.
+
+sonar: {{ pr | extractSonarFindings }}
+
+colors:
+  green: '0e8a16'
+
\ No newline at end of file diff --git a/automations/integrations/sonar/approve-sonar-clean-code/logo_review_sonar_alerts.png b/automations/integrations/sonar/approve-sonar-clean-code/logo_review_sonar_alerts.png new file mode 100644 index 00000000..aa5f290e Binary files /dev/null and b/automations/integrations/sonar/approve-sonar-clean-code/logo_review_sonar_alerts.png differ diff --git a/automations/integrations/sonar/approve-sonar-clean-code/review-sonar-alerts.svg b/automations/integrations/sonar/approve-sonar-clean-code/review-sonar-alerts.svg new file mode 100644 index 00000000..59ef16e0 --- /dev/null +++ b/automations/integrations/sonar/approve-sonar-clean-code/review-sonar-alerts.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/sonar/label-sonar/index.html b/automations/integrations/sonar/label-sonar/index.html new file mode 100644 index 00000000..7527bfca --- /dev/null +++ b/automations/integrations/sonar/label-sonar/index.html @@ -0,0 +1,42 @@ + Automation - Label SonarCloud Quality Reports - gitStream Documentation

Label SonarCloud Quality Reports

Label the number of bugs, vulnerabilities, security hotspots, and code smells reported by SonarCloud.

Label SonarCloud Quality Reports

Configuration Description

Conditions (all must be true):

  • There is at least one vulnerability, code smell, security hotspot, or bug reported by SonarCloud. Uses the extractSonarFindings filter function

Automation Actions:

  • Apply color-coded labels to indicate the number of vulnerabilities, code smells, security hotspots, and bugs.

Label SonarCloud Quality Reports

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in reports %}
+  label_sonar_{{ item.name }}:
+    if:
+      - {{ item.count > 0}}
+    run:
+      - action: add-label@v1
+        args:
+          label: '{{ item.icon }} sonar:{{ item.name }}-{{ item.rating }}'
+          color: {{ colors.red if (item.rating == 'E' or item.rating == 'D') else (colors.orange if (item.rating == 'C' ) else colors.yellow) }}
+  {% endfor %}
+
+sonar: {{ pr | extractSonarFindings }}
+
+reports:
+  - name: vulnerabilities
+    count: {{ sonar.vulnerabilities.count }}
+    icon: 🔓
+    rating: {{ sonar.vulnerabilities.rating }}
+  - name: code smells
+    count: {{ sonar.code_smells.count }}
+    icon: ☣️
+    rating: {{ sonar.code_smells.rating }}
+  - name: security hotspots
+    count: {{ sonar.security_hotspots.count }}
+    icon: 🛡️
+    rating: {{ sonar.security_hotspots.rating }}
+  - name: bugs
+    count: {{ sonar.bugs.count }}
+    icon: 🪲
+    rating: {{ sonar.bugs.rating }}
+
+colors:
+  red: 'b60205'
+  orange: 'd93f0b'
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/integrations/sonar/label-sonar/label-sonar.png b/automations/integrations/sonar/label-sonar/label-sonar.png new file mode 100644 index 00000000..9aa99aa1 Binary files /dev/null and b/automations/integrations/sonar/label-sonar/label-sonar.png differ diff --git a/automations/integrations/sonar/label-sonar/logo_review_sonar_alerts.png b/automations/integrations/sonar/label-sonar/logo_review_sonar_alerts.png new file mode 100644 index 00000000..aa5f290e Binary files /dev/null and b/automations/integrations/sonar/label-sonar/logo_review_sonar_alerts.png differ diff --git a/automations/integrations/sonar/label-sonar/review-sonar-alerts.svg b/automations/integrations/sonar/label-sonar/review-sonar-alerts.svg new file mode 100644 index 00000000..59ef16e0 --- /dev/null +++ b/automations/integrations/sonar/label-sonar/review-sonar-alerts.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/sonar/review-sonar-alerts/index.html b/automations/integrations/sonar/review-sonar-alerts/index.html new file mode 100644 index 00000000..b38deb25 --- /dev/null +++ b/automations/integrations/sonar/review-sonar-alerts/index.html @@ -0,0 +1,19 @@ + Automation - Review SonarCloud Security Alerts - gitStream Documentation

Review Sonar Security Alerts

Require additional reviews for Sonar security alerts. gitStream will remove this requirement if the alerts are resolved.

Review Sonar Security Alerts

Configuration Description

Conditions (all must be true):

  • The SonarCloud quality gate check fails to pass for code smells, vulnerabilities, or security hotspots.

Automation Actions:

  • Require a review from the my-organization/security-team team. Customize this to match your organization.
  • Post a comment explaining why this PR requires additional review.

Review Sonar Alerts

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+automations:
+  review_sonar_alerts:
+      if:
+        - {{ sonar.code_smells.rating != 'A' or sonar.vulnerabilities.rating != 'A' or sonar.security_hotspots.rating != 'A'}}
+      run:
+        - action: require-reviewers@v1
+          args:
+            reviewers: [my-organization/security-team]
+        - action: add-comment@v1
+          args:
+            comment: |
+              This PR requires additional review because it fails to meet SonarCloud clean code standards.
+
+sonar: {{ pr | extractSonarFindings }}
+
\ No newline at end of file diff --git a/automations/integrations/sonar/review-sonar-alerts/logo_review_sonar_alerts.png b/automations/integrations/sonar/review-sonar-alerts/logo_review_sonar_alerts.png new file mode 100644 index 00000000..aa5f290e Binary files /dev/null and b/automations/integrations/sonar/review-sonar-alerts/logo_review_sonar_alerts.png differ diff --git a/automations/integrations/sonar/review-sonar-alerts/review-sonar-alerts.png b/automations/integrations/sonar/review-sonar-alerts/review-sonar-alerts.png new file mode 100644 index 00000000..0a00a2b5 Binary files /dev/null and b/automations/integrations/sonar/review-sonar-alerts/review-sonar-alerts.png differ diff --git a/automations/integrations/sonar/review-sonar-alerts/review-sonar-alerts.svg b/automations/integrations/sonar/review-sonar-alerts/review-sonar-alerts.svg new file mode 100644 index 00000000..59ef16e0 --- /dev/null +++ b/automations/integrations/sonar/review-sonar-alerts/review-sonar-alerts.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/sonar/review-sonar-duplications/index.html b/automations/integrations/sonar/review-sonar-duplications/index.html new file mode 100644 index 00000000..c61b2472 --- /dev/null +++ b/automations/integrations/sonar/review-sonar-duplications/index.html @@ -0,0 +1,23 @@ + Automation - Review SonarCloud Duplications - gitStream Documentation

Review Sonar Duplications

Request changes when Sonar reports an excessive level of duplicated code.

Review Sonar Duplications

Configuration Description

Conditions (all must be true):

  • The PR contains more than 3% duplicated code.

Automation Actions:

  • Apply a label that indicates how much duplicated code Sonar detected.
  • Request changes and post a comment explaining why.

Review Sonar Duplications

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+automations:
+  review_sonar_duplications:
+    if:
+      - {{ sonar.duplications > 3 }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'Sonar: {{ sonar.duplications}}% duplication'
+          color: {{ colors.yellow }}
+      - action: request-changes@v1
+        args:
+          comment: |
+            Sonar reports an excessive level of code duplication. Please consider refactoring your PR to reduce duplications.
+
+sonar: {{ pr | extractSonarFindings }}
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/integrations/sonar/review-sonar-duplications/logo_review_sonar_alerts.png b/automations/integrations/sonar/review-sonar-duplications/logo_review_sonar_alerts.png new file mode 100644 index 00000000..aa5f290e Binary files /dev/null and b/automations/integrations/sonar/review-sonar-duplications/logo_review_sonar_alerts.png differ diff --git a/automations/integrations/sonar/review-sonar-duplications/review-sonar-alerts.svg b/automations/integrations/sonar/review-sonar-duplications/review-sonar-alerts.svg new file mode 100644 index 00000000..59ef16e0 --- /dev/null +++ b/automations/integrations/sonar/review-sonar-duplications/review-sonar-alerts.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/sonar/review-sonar-duplications/review-sonar-duplications.png b/automations/integrations/sonar/review-sonar-duplications/review-sonar-duplications.png new file mode 100644 index 00000000..4642be72 Binary files /dev/null and b/automations/integrations/sonar/review-sonar-duplications/review-sonar-duplications.png differ diff --git a/automations/integrations/swimm/approve-swimm/approve-swimm.png b/automations/integrations/swimm/approve-swimm/approve-swimm.png new file mode 100644 index 00000000..d4a1968d Binary files /dev/null and b/automations/integrations/swimm/approve-swimm/approve-swimm.png differ diff --git a/automations/integrations/swimm/approve-swimm/approve-swimm.svg b/automations/integrations/swimm/approve-swimm/approve-swimm.svg new file mode 100644 index 00000000..a6f58a9f --- /dev/null +++ b/automations/integrations/swimm/approve-swimm/approve-swimm.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/swimm/approve-swimm/index.html b/automations/integrations/swimm/approve-swimm/index.html new file mode 100644 index 00000000..fd501e88 --- /dev/null +++ b/automations/integrations/swimm/approve-swimm/index.html @@ -0,0 +1,22 @@ + Automation - Approve Swimm Changes - gitStream Documentation

Approve Swimm Changes

Approve changes that only affect Swimm documentation.

Approve Swimm Changes

Configuration Description

Conditions (all must be true):

  • The PR only affects files that end in a .swm extension.

Automation Actions:

  • Add a swimm-docs-only label
  • Approve the PR
  • Post a comment that explains that this is a Swimm docs change only.

Approve Swimm Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_swimm_changes:
+    # Triggered for any changes to Swimm documentation
+    if:
+      - {{ branch.diff.files_metadata | match(attr='file', regex=r/\.swm\//) | every }}
+    # Apply a swimm-docs-only label, approve the PR and explain why in a comment.
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'swimm-docs-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR is considered a safe change as it only affects Swimm Docs. 
+            It has been automatically approved.
+

Special thanks to Omerr for providing this example.

\ No newline at end of file diff --git a/automations/integrations/swimm/approve-swimm/logo_approve_swimm.png b/automations/integrations/swimm/approve-swimm/logo_approve_swimm.png new file mode 100644 index 00000000..f18d5d95 Binary files /dev/null and b/automations/integrations/swimm/approve-swimm/logo_approve_swimm.png differ diff --git a/automations/integrations/teams/teams-auto-recognition/index.html b/automations/integrations/teams/teams-auto-recognition/index.html new file mode 100644 index 00000000..b850d88c --- /dev/null +++ b/automations/integrations/teams/teams-auto-recognition/index.html @@ -0,0 +1,20 @@ + Automation - Automatic MS Teams Notifications - gitStream Documentation

Automatic MS Teams Notifications

Automatically post positive recognition messages in MS Teams for well-structured PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains updates to tests.
  • The PR has fewer than 5 modified files.
  • The PR branch references a Jira ticket.
  • The PR has fewer than 150 lines of code changed.

Automation Actions:

  • Post an MS Teams message that automatically recognizes the PR author and provides a link to the PR.

Automatic MS Teams Notifications

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  teams_auto_recognition:
+    if:
+      - {{ files | match(regex=r/(test|spec)/) | some }} # this pr has at least 1 test
+      - {{ files | length <= 5 }} # this pr has 5 or less files
+      - {{ branch.name | includes(regex=r/[A-Z]{2,}-\d+.*/) }} # this branch has the Jira ticket prefix
+      - {{ branch.diff.size <= 150 }} # this branch has 150 lines of code or less changed
+    run:
+      - action: send-http-request@v1
+        args:
+          method: "POST"
+          headers: '{"Content-type": "application/json"}'
+          url: "{{ env.MS_TEAMS_WEBHOOK }}"
+          body: '{"text": "Congrats to {{ pr.author }} for the amazing new PR, {{ pr.title }}! Check it out at https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/teams/teams-auto-recognition/logo_teams_auto_recognition.png b/automations/integrations/teams/teams-auto-recognition/logo_teams_auto_recognition.png new file mode 100644 index 00000000..ab1815bc Binary files /dev/null and b/automations/integrations/teams/teams-auto-recognition/logo_teams_auto_recognition.png differ diff --git a/automations/integrations/teams/teams-auto-recognition/teams-auto-recognition.svg b/automations/integrations/teams/teams-auto-recognition/teams-auto-recognition.svg new file mode 100644 index 00000000..b6a0f6fb --- /dev/null +++ b/automations/integrations/teams/teams-auto-recognition/teams-auto-recognition.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/automations/integrations/teams/teams-send-notification/index.html b/automations/integrations/teams/teams-send-notification/index.html new file mode 100644 index 00000000..3ba10dff --- /dev/null +++ b/automations/integrations/teams/teams-send-notification/index.html @@ -0,0 +1,40 @@ + Automation - Automatically Notify MS Teams Channels - gitStream Documentation

Automatically Notify MS Teams Channels

Automatically send Slack notifications to specific channels based on the contents of a pull request.

Configuration Description

Conditions (all must be true):

  • The PR meets one or more of the specified trigger criteria for MS Teams notifications.

Automation Actions:

  • Post an MS Teams message based on the contents of the PR.

Automatically Notify MS Teams Channels

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  send_teams_security:
+    if:
+      # use your custom logic here to determine whether this needs a security review
+      - true
+    run:
+      - action: send-http-request@v1
+        args:
+          method: "POST"
+          headers: '{"Content-type": "application/json"}'
+          url: "{{ env.MS_TEAMS_WEBHOOK_SECURITY }}"
+          body: '{"text": "A PR requires a security review. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}'
+  send_teams_qa:
+    if:
+      # use your custom logic here to determine whether this needs a qa review
+      - {{ not (files | match(regex=r/(test|spec)/) | some) }}
+    run:
+      - action: send-http-request@v1
+        args:
+          method: "POST"
+          headers: '{"Content-type": "application/json"}'
+          url: "{{ env.MS_TEAMS_WEBHOOK_QA }}"
+          body: '{"text": "A PR was submitted without tests. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}'
+  send_teams_docs:
+    if:
+      # use your custom logic here to determine whether this needs a docs review
+      - {{ files | match(regex=r/(docs)/) | some }}
+    run:
+      - action: send-http-request@v1
+        args:
+          method: "POST"
+          headers: '{"Content-type": "application/json"}'
+          url: "{{ env.MS_TEAMS_WEBHOOK_DOCS }}"
+          body: '{"text": "A PR has modified the docs. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/teams/teams-send-notification/logo_teams_send_notification.png b/automations/integrations/teams/teams-send-notification/logo_teams_send_notification.png new file mode 100644 index 00000000..ab1815bc Binary files /dev/null and b/automations/integrations/teams/teams-send-notification/logo_teams_send_notification.png differ diff --git a/automations/integrations/teams/teams-send-notification/teams-send-notification.svg b/automations/integrations/teams/teams-send-notification/teams-send-notification.svg new file mode 100644 index 00000000..b6a0f6fb --- /dev/null +++ b/automations/integrations/teams/teams-send-notification/teams-send-notification.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/automations/integrations/terraform/review-new-module/index.html b/automations/integrations/terraform/review-new-module/index.html new file mode 100644 index 00000000..6eb6ddd0 --- /dev/null +++ b/automations/integrations/terraform/review-new-module/index.html @@ -0,0 +1,45 @@ + Automation - Review Terraform Module Directory - gitStream Documentation

Review New Terraform Modules

Request changes if a PR that creates a new Terraform module which do not conform to the required directory structure.

Review New Module

Configuration Description

Conditions (all must be true):

  • The PR creates a new Terraform module
    • A new sub-directory is created inside the /modules directory.
  • The PR lacks one or more required components from the list in the terraform custom expression.

Automation Actions:

  • Request changes and post a comment explaining the missing parts of the module.
  • Apply Label : ⚠️ Missing Terraform Components

Review New Module

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+{% set misslist = [] %}
+{% for pattern in terraform %}
+{% if (newfilesinpr | match(term=pattern) | nope) %}
+{% set misslist = misslist + [pattern+' '] %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  review_new_terraform_module:
+    if: 
+      - {{misslist | match(regex=r/.*/) | some}}
+      - {{is.mainfile and is.mainfilenotinroot }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: |
+            New terraform modules must contain all required components before merging. Please update your PR with the required components and gitStream will automatically remove this comment once completed.
+
+            Here are the required components, {{misslist}} should be customized appropriately:
+            my_module/
+            ├── main.tf
+            ├── outputs.tf
+            ├── providers.tf
+      - action: add-label@v1
+        args:
+          label: '⚠️ Missing Terraform Components'
+          color: '#FFA500'
+
+resources:
+  module_directory: 'modules'
+terraform:
+  - main.tf
+  - outputs.tf
+  - providers.tf
+is:
+  mainfile: {{newfilesinpr | match(term = "main.tf") | some}}
+  mainfilenotinroot: {{source.diff.files | map(attr='original_file') | match(term = "main.tf") | nope }}
+newfilesinpr:
+  {{ branch.diff.files_metadata | map(attr='new_file')}}
+
\ No newline at end of file diff --git a/automations/integrations/terraform/review-new-module/logo_review_terraform.png b/automations/integrations/terraform/review-new-module/logo_review_terraform.png new file mode 100644 index 00000000..245aad96 Binary files /dev/null and b/automations/integrations/terraform/review-new-module/logo_review_terraform.png differ diff --git a/automations/integrations/terraform/review-new-module/review-new-module.png b/automations/integrations/terraform/review-new-module/review-new-module.png new file mode 100644 index 00000000..0448159c Binary files /dev/null and b/automations/integrations/terraform/review-new-module/review-new-module.png differ diff --git a/automations/integrations/terraform/review-new-module/review-terraform.svg b/automations/integrations/terraform/review-new-module/review-terraform.svg new file mode 100644 index 00000000..134b2f39 --- /dev/null +++ b/automations/integrations/terraform/review-new-module/review-terraform.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/terraform/review-terraform-module-name/index.html b/automations/integrations/terraform/review-terraform-module-name/index.html new file mode 100644 index 00000000..33f60004 --- /dev/null +++ b/automations/integrations/terraform/review-terraform-module-name/index.html @@ -0,0 +1,43 @@ + Automation - Review Terraform Module Name - gitStream Documentation

Review Terraform Module Name

Request changes if a PR creates a new Terraform module that is missing a required prefix or keyword in the name.

Review Terraform Source Version

Configuration Description

Conditions (all must be true):

  • The PR creates a new Terraform module.
  • The module name lacks a required name prefix, or one or more keywords.

Automation Actions:

  • Request review changes on the PR with a comment explaining the structure of module name.

Review Terraform Module Name

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+# Prefix Check Logic
+{% set prefixcheck = [] %}
+{% for pattern in terraform.prefixes %}
+{% if(newfilesinpr | match(term=module_location + pattern) | some) %}
+{% set prefixcheck = prefixcheck + [true]%}
+{% else %}
+{% set prefixcheck = prefixcheck + [false]  %}
+{% endif %}
+{% endfor %}
+
+automations:
+  review_new_terraform_module:
+    if: 
+      - {{is.mainfile and is.mainfilenotinroot}}
+      - {{module_name_checks.prefix or module_name_checks.keyword}}
+    run:
+      - action: request-changes@v1
+        args:
+          comment: |
+            Terraform module names must contain a required prefix and keyword:
+            * Prefixes: {{ terraform.prefixes }}
+            * Keywords: {{ terraform.keywords }}
+
+module_name_checks:
+  prefix: {{prefixcheck | match(term='true') | nope}}
+  keyword: {{newfilesinpr | match(list=terraform.keywords) | nope}}
+
+module_location: infrastructure/modules/
+terraform:
+  prefixes: ['aws', 'gcp', 'azure']
+  keywords: ['db', 'networking', 'security']
+
+is:
+  mainfile: {{newfilesinpr | match(term = "main.tf") | some}}
+  mainfilenotinroot: {{source.diff.files | map(attr='original_file') | match(term = "main.tf") | nope }}
+newfilesinpr:
+  {{ branch.diff.files_metadata | map(attr='new_file')}}
+
\ No newline at end of file diff --git a/automations/integrations/terraform/review-terraform-module-name/logo_review_terraform.png b/automations/integrations/terraform/review-terraform-module-name/logo_review_terraform.png new file mode 100644 index 00000000..245aad96 Binary files /dev/null and b/automations/integrations/terraform/review-terraform-module-name/logo_review_terraform.png differ diff --git a/automations/integrations/terraform/review-terraform-module-name/review-terraform-module-name.png b/automations/integrations/terraform/review-terraform-module-name/review-terraform-module-name.png new file mode 100644 index 00000000..e839e3a3 Binary files /dev/null and b/automations/integrations/terraform/review-terraform-module-name/review-terraform-module-name.png differ diff --git a/automations/integrations/terraform/review-terraform-module-name/review-terraform.svg b/automations/integrations/terraform/review-terraform-module-name/review-terraform.svg new file mode 100644 index 00000000..134b2f39 --- /dev/null +++ b/automations/integrations/terraform/review-terraform-module-name/review-terraform.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/terraform/review-terraform-source-version/index.html b/automations/integrations/terraform/review-terraform-source-version/index.html new file mode 100644 index 00000000..f0375941 --- /dev/null +++ b/automations/integrations/terraform/review-terraform-source-version/index.html @@ -0,0 +1,23 @@ + Automation - Review Terraform Module Imports - gitStream Documentation

Review Terraform Source Version

Ensure that all Terraform modules imported via a source URL specify a version.

Review Terraform Source Version

Configuration Description

Conditions (all must be true):

  • The PR contains a Terraform source declaration via URL that lacks a version reference.
  • The source is not included in a whitelist custom expression that defines one or more whitelisted source locations.

Automation Actions:

  • Request review changes on the PR with a comment explaining version number requirement.

Review Terraform Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_terraform_source_version:
+    # Check if New Content contains a source URL, the URL is not part of allow list and lacks version reference
+    if: 
+      - {{ source.diff.files | match(attr='new_content', regex=r/source.*?=.*\".*(http|https).*\"/) | some }}
+      - {{ source.diff.files | match(attr='new_content', list=allowlist) | nope }}
+      - {{ source.diff.files | match(attr='new_content', regex=r/source.*?=.*\?ref=v.*/) | nope }}
+    run:
+      - action: request-changes@v1
+        args:
+          comment: |
+            You must reference a specific version when accessing Terraform module sources via URL, e.g. `?ref=v1.0.0`. Please update your Terraform files to follow this practice.
+
+allowlist:
+  - 'https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git'
+  - 'https://github.com/terraform-aws-modules/terraform-aws-vpc.git'
+  - 'https://github.com/terraform-aws-modules/terraform-aws-eks.git'
+
\ No newline at end of file diff --git a/automations/integrations/terraform/review-terraform-source-version/logo_review_terraform.png b/automations/integrations/terraform/review-terraform-source-version/logo_review_terraform.png new file mode 100644 index 00000000..245aad96 Binary files /dev/null and b/automations/integrations/terraform/review-terraform-source-version/logo_review_terraform.png differ diff --git a/automations/integrations/terraform/review-terraform-source-version/review-terraform-source-version.png b/automations/integrations/terraform/review-terraform-source-version/review-terraform-source-version.png new file mode 100644 index 00000000..6f4e308b Binary files /dev/null and b/automations/integrations/terraform/review-terraform-source-version/review-terraform-source-version.png differ diff --git a/automations/integrations/terraform/review-terraform-source-version/review-terraform.svg b/automations/integrations/terraform/review-terraform-source-version/review-terraform.svg new file mode 100644 index 00000000..134b2f39 --- /dev/null +++ b/automations/integrations/terraform/review-terraform-source-version/review-terraform.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/terraform/review-terraform/index.html b/automations/integrations/terraform/review-terraform/index.html new file mode 100644 index 00000000..ab00a097 --- /dev/null +++ b/automations/integrations/terraform/review-terraform/index.html @@ -0,0 +1,20 @@ + Automation - Automatically assign infrastructure team for Terraform changes - gitStream Documentation

Require Reviewers for Terraform changes

Automatically assign org/infrastructure team for reviewing changes when PR contains Terraform file changes.

Review Terraform Changes

Configuration Description

Conditions (all must be true):

  • The PR contains changes to one or more Terraform configuration files.

Automation Actions:

  • Require a review from the org/infrastructure team.

Review Terraform Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_terraform:
+    # Triggered for any changes to Terraform files
+    if:
+      - {{ files | match(regex=r/.*\.tf.*/) | some }}
+    # Assign infrastructure team as reviewer for change in Terraform files
+    run:
+      - action: require-reviewers@v1
+        args:
+          reviewers: [org/infrastructure]
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR affects Terraform configurations and requires a review from the Infra team.
+
\ No newline at end of file diff --git a/automations/integrations/terraform/review-terraform/logo_review_terraform.png b/automations/integrations/terraform/review-terraform/logo_review_terraform.png new file mode 100644 index 00000000..245aad96 Binary files /dev/null and b/automations/integrations/terraform/review-terraform/logo_review_terraform.png differ diff --git a/automations/integrations/terraform/review-terraform/review-terraform.png b/automations/integrations/terraform/review-terraform/review-terraform.png new file mode 100644 index 00000000..13e1fbce Binary files /dev/null and b/automations/integrations/terraform/review-terraform/review-terraform.png differ diff --git a/automations/integrations/terraform/review-terraform/review-terraform.svg b/automations/integrations/terraform/review-terraform/review-terraform.svg new file mode 100644 index 00000000..134b2f39 --- /dev/null +++ b/automations/integrations/terraform/review-terraform/review-terraform.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/unleash/label-ff-unleash/index.html b/automations/integrations/unleash/label-ff-unleash/index.html new file mode 100644 index 00000000..abd0354b --- /dev/null +++ b/automations/integrations/unleash/label-ff-unleash/index.html @@ -0,0 +1,29 @@ + Automation - Label PRs Based on Unleash Feature Flags - gitStream Documentation

Label Unleash Feature Flags

Automatically label code that contians specified feature flags.

Label PRs Based on Feature Flags

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+
+  {% for item in feature_flags %}
+  label_ff_unleash_{{ item.name }}:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/const notificationBadgeEnabled = useFlag/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ item.name }}
+          color: {{ colors.yellow }}
+  {% endfor %}
+
+feature_flags:
+   - name: engineering_rollback_plan_activated 
+     regex: r/engineering_rollback_plan_activated/
+   - name: marketing_premium_plan_features_unlocked 
+     regex: r/marketing_premium_plan_features_unlocked/
+   - name: mobile_push_notifications_enabled
+     regex: r/mobile_push_notifications_enabled/
+
+colors:
+  yellow: 'ffb300'   
+
\ No newline at end of file diff --git a/automations/integrations/unleash/label-ff-unleash/label-ff-unleash.png b/automations/integrations/unleash/label-ff-unleash/label-ff-unleash.png new file mode 100644 index 00000000..183c673c Binary files /dev/null and b/automations/integrations/unleash/label-ff-unleash/label-ff-unleash.png differ diff --git a/automations/integrations/zapier/zapier-export-pr-description-title-url/index.html b/automations/integrations/zapier/zapier-export-pr-description-title-url/index.html new file mode 100644 index 00000000..1bf9ca84 --- /dev/null +++ b/automations/integrations/zapier/zapier-export-pr-description-title-url/index.html @@ -0,0 +1,22 @@ + Automation - Create Project Management Tasks Via Zapier - gitStream Documentation

Create Project Management Tasks Via Zapier

Export new PR titles, description, and URL to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends a webhook to Zapier that contains the PR title, description, and URL.

Create Project Management Tasks Via Zapier

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+pr_url: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+
+on:
+    - pr_created
+
+automations:
+  zapier_export_pr_description_title_url:
+    if:
+      - true
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ ZAPIER_WEBHOOK }}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{ "pr_description":"{{ pr.description }}", "pr_title":"{{ pr.title }}", "pr_url":"{{ pr_url }}" }'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/zapier/zapier-export-pr-description-title-url/logo_zapier_export_pr_number.png b/automations/integrations/zapier/zapier-export-pr-description-title-url/logo_zapier_export_pr_number.png new file mode 100644 index 00000000..ccca4107 Binary files /dev/null and b/automations/integrations/zapier/zapier-export-pr-description-title-url/logo_zapier_export_pr_number.png differ diff --git a/automations/integrations/zapier/zapier-export-pr-description-title-url/zapier-export-pr-number.svg b/automations/integrations/zapier/zapier-export-pr-description-title-url/zapier-export-pr-number.svg new file mode 100644 index 00000000..421a004f --- /dev/null +++ b/automations/integrations/zapier/zapier-export-pr-description-title-url/zapier-export-pr-number.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/zapier/zapier-export-pr-number-title-url/index.html b/automations/integrations/zapier/zapier-export-pr-number-title-url/index.html new file mode 100644 index 00000000..6c5f88fe --- /dev/null +++ b/automations/integrations/zapier/zapier-export-pr-number-title-url/index.html @@ -0,0 +1,22 @@ + Automation - Export PR Number, Title, and URL to Zapier - gitStream Documentation

Export PR Number, Title, and URL to Zapier

Export new PR titles, numbers, and URLs to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends the PR number, title, and URL to Zapier via webhook.

Export PR Number, Title, and URL to Zapier

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+  pr_url: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+
+on:
+    - pr_created
+
+automations:
+  zapier_export_pr_number_title_url:
+    if:
+      - true
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ ZAPIER_WEBHOOK }}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{ "pr_number":"{{ pr.number }}", "pr_title":"{{ pr.title }}", "pr_url":"{{ pr_url }}" }'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/zapier/zapier-export-pr-number-title-url/logo_zapier_export_pr_number.png b/automations/integrations/zapier/zapier-export-pr-number-title-url/logo_zapier_export_pr_number.png new file mode 100644 index 00000000..ccca4107 Binary files /dev/null and b/automations/integrations/zapier/zapier-export-pr-number-title-url/logo_zapier_export_pr_number.png differ diff --git a/automations/integrations/zapier/zapier-export-pr-number-title-url/zapier-export-pr-number.svg b/automations/integrations/zapier/zapier-export-pr-number-title-url/zapier-export-pr-number.svg new file mode 100644 index 00000000..421a004f --- /dev/null +++ b/automations/integrations/zapier/zapier-export-pr-number-title-url/zapier-export-pr-number.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/zapier/zapier-export-pr-number/index.html b/automations/integrations/zapier/zapier-export-pr-number/index.html new file mode 100644 index 00000000..756bd95a --- /dev/null +++ b/automations/integrations/zapier/zapier-export-pr-number/index.html @@ -0,0 +1,17 @@ + Automation - Export PR Data to Zapier - gitStream Documentation

Export PR Data to Zapier

This is an example of how to send data from gitStream to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends a webhook to Zapier that contains the PR number

Export PR Number to Zapier

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  zapier_export_pr_number:
+    if:
+      - true
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ ZAPIER_WEBHOOK }}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{ "pr_number":"{{ pr.number }}" }'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/zapier/zapier-export-pr-number/logo_zapier_export_pr_number.png b/automations/integrations/zapier/zapier-export-pr-number/logo_zapier_export_pr_number.png new file mode 100644 index 00000000..ccca4107 Binary files /dev/null and b/automations/integrations/zapier/zapier-export-pr-number/logo_zapier_export_pr_number.png differ diff --git a/automations/integrations/zapier/zapier-export-pr-number/zapier-export-pr-number.svg b/automations/integrations/zapier/zapier-export-pr-number/zapier-export-pr-number.svg new file mode 100644 index 00000000..421a004f --- /dev/null +++ b/automations/integrations/zapier/zapier-export-pr-number/zapier-export-pr-number.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/integrations/zapier/zapier-export-pr-reviewers/index.html b/automations/integrations/zapier/zapier-export-pr-reviewers/index.html new file mode 100644 index 00000000..cb2ad7c5 --- /dev/null +++ b/automations/integrations/zapier/zapier-export-pr-reviewers/index.html @@ -0,0 +1,19 @@ + Automation - Auto-Schedule Sync Meetings via Zapier - gitStream Documentation

Auto-Schedule Sync Meetings via Zapier

Automatically update Zapier with a list of PR reviewers.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • gitStream sends the list of reviewers to Zapier via webooks.

Auto-Schedule Sync Meetings via Zapier

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+pr_url: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+
+automations:
+  zapier_export_pr_reviewers:
+    if:
+      - true
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ env.ZAPIER_WEBHOOK }}"
+          method: "POST"
+          headers: '{"Content-type": "application/json"}'
+          body: '{ "reviewers": "{{ pr.reviewers }}" }'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/integrations/zapier/zapier-export-pr-reviewers/logo_zapier_export_pr_number.png b/automations/integrations/zapier/zapier-export-pr-reviewers/logo_zapier_export_pr_number.png new file mode 100644 index 00000000..ccca4107 Binary files /dev/null and b/automations/integrations/zapier/zapier-export-pr-reviewers/logo_zapier_export_pr_number.png differ diff --git a/automations/integrations/zapier/zapier-export-pr-reviewers/zapier-export-pr-number.svg b/automations/integrations/zapier/zapier-export-pr-reviewers/zapier-export-pr-number.svg new file mode 100644 index 00000000..421a004f --- /dev/null +++ b/automations/integrations/zapier/zapier-export-pr-reviewers/zapier-export-pr-number.svg @@ -0,0 +1,3 @@ + + + diff --git a/automations/label-deleted-files/Label-deleted-file.svg b/automations/label-deleted-files/Label-deleted-file.svg new file mode 100644 index 00000000..e641082c --- /dev/null +++ b/automations/label-deleted-files/Label-deleted-file.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/label-deleted-files/index.html b/automations/label-deleted-files/index.html new file mode 100644 index 00000000..bc1e5d7f --- /dev/null +++ b/automations/label-deleted-files/index.html @@ -0,0 +1,20 @@ + Automation - Label Deleted Files - gitStream Documentation

Label Deleted Files

Label PRs that delete files.

Label Deleted Files

Configuration Description

Conditions (all must be true):

  • The PR deletes one or more files.

Automation Actions:

  • Apply a deleted-files label to the PR.

Label Deleted Files

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  # Apply a label that indicates when a PR deletes files
+  # This uses the `has` custom expression found at the bottom of this file
+  label_deleted_files:
+    if:
+      - {{ has.deleted_files }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'deleted-files'
+          color: '#DF9C04'
+
+# This is used in the `label_deleted_files` automation
+has:
+  deleted_files: {{ source.diff.files | map(attr='new_file') | match(term='/dev/null') | some }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/label-deleted-files/label_deleted_files.png b/automations/label-deleted-files/label_deleted_files.png new file mode 100644 index 00000000..5f072269 Binary files /dev/null and b/automations/label-deleted-files/label_deleted_files.png differ diff --git a/automations/label-deleted-files/logo_label_deleted_file.png b/automations/label-deleted-files/logo_label_deleted_file.png new file mode 100644 index 00000000..f5790ae1 Binary files /dev/null and b/automations/label-deleted-files/logo_label_deleted_file.png differ diff --git a/automations/label-missing-jira-info/index.html b/automations/label-missing-jira-info/index.html new file mode 100644 index 00000000..35fd96c5 --- /dev/null +++ b/automations/label-missing-jira-info/index.html @@ -0,0 +1,15 @@ + + + + + + Redirecting... + + + + + + +Redirecting... + + diff --git a/automations/label-missing-project-tracker/Flag-missing-project-tracking-info.svg b/automations/label-missing-project-tracker/Flag-missing-project-tracking-info.svg new file mode 100644 index 00000000..cc2594a5 --- /dev/null +++ b/automations/label-missing-project-tracker/Flag-missing-project-tracking-info.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/label-missing-project-tracker/index.html b/automations/label-missing-project-tracker/index.html new file mode 100644 index 00000000..e1801c6c --- /dev/null +++ b/automations/label-missing-project-tracker/index.html @@ -0,0 +1,34 @@ + Automation - Flag Missing Project Tracking Info - gitStream Documentation

Flag Missing Project Tracking Info

Label PRs that lack a reference to a project tracker issue (Jira, Azure Boards, Shortcut and Asana) in the PR title or description.

Label Missing Project Tracker

Configuration Description

Conditions (all must be true):

  • The PR lacks a project tracker ticket number in the title, or a link to a project tracker resource in the PR description.

Automation Actions:

  • Apply Label : ⚠️ Missing Project Tracker
  • Post a comment asking the author to reference the associated project tracker resource.

Label Missing Project Tracker

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_missing_project_tracker:
+    if:
+      - {{not (has[provider].ticket_in_title or has[provider].ticket_in_desc)}}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Project Tracker"
+          color: 'F6443B'
+      - action: add-comment@v1
+        args:
+          comment: Please provide a link to the associated resource in your team's project tracker.
+
+has:
+  jira:
+    ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+    ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }}
+  asana:
+    ticket_in_title: {{ pr.title | includes(regex=r/asana-(\d+)/) }}
+    ticket_in_desc: {{ pr.description | includes(regex=r/app\.asana.\com\/(\d+)\/(\d+)\/(\d+)\/(\d+)\/(\d+)/) }}
+  azure:
+    ticket_in_title: {{ pr.title | includes(regex=r/(\w+)-(\w+)-(\d+)/) }}
+    ticket_in_desc: {{ pr.description | includes(regex=r/(dev\.azure\.com|(\w+)\.visualstudio\.com)\/(\w+)\/(\w+)\/_workitems\/edit\/(\d+)/) }}
+  shortcut:
+    ticket_in_title: {{ pr.title | includes(regex=r/(\w+)\/sc-(\d+)/) }}
+    ticket_in_desc: {{ pr.description | includes(regex=r/(app\.shortcut\.com)\/(\w+)\/story\/(\d+)\/(\w+)/) }}
+
+provider: jira
+
\ No newline at end of file diff --git a/automations/label-missing-project-tracker/label-missing-project-tracker.png b/automations/label-missing-project-tracker/label-missing-project-tracker.png new file mode 100644 index 00000000..6c35093e Binary files /dev/null and b/automations/label-missing-project-tracker/label-missing-project-tracker.png differ diff --git a/automations/label-missing-project-tracker/logo_flag_missing_project_tracking_info.png b/automations/label-missing-project-tracker/logo_flag_missing_project_tracking_info.png new file mode 100644 index 00000000..bdd7f0a3 Binary files /dev/null and b/automations/label-missing-project-tracker/logo_flag_missing_project_tracking_info.png differ diff --git a/automations/label-prs-without-tests/index.html b/automations/label-prs-without-tests/index.html new file mode 100644 index 00000000..969bdbe9 --- /dev/null +++ b/automations/label-prs-without-tests/index.html @@ -0,0 +1,15 @@ + Automation - Label PRs Without Tests - gitStream Documentation

Label PRs Without Tests

Apply a missing-tests label to any PRs that don't update tests. gitStream will remove this label if the contributor adds a test change to the PR.

Automation Name

Configuration Description

Conditions (all must be true):

  • The PR has no changes to a test.

Automation Actions:

  • Apply a missing-tests label.

Label PRs Without Tests

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_prs_without_tests:
+    if:
+      - {{ files | match(regex=r/[^a-zA-Z0-9](spec|test|tests)[^a-zA-Z0-9]/) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'missing-tests'
+          color: '#E94637'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/label-prs-without-tests/label-prs-without-tests.svg b/automations/label-prs-without-tests/label-prs-without-tests.svg new file mode 100644 index 00000000..67096a8c --- /dev/null +++ b/automations/label-prs-without-tests/label-prs-without-tests.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/label-prs-without-tests/label_prs_without_tests.png b/automations/label-prs-without-tests/label_prs_without_tests.png new file mode 100644 index 00000000..8305ab13 Binary files /dev/null and b/automations/label-prs-without-tests/label_prs_without_tests.png differ diff --git a/automations/label-prs-without-tests/logo_label_prs_without_tests.png b/automations/label-prs-without-tests/logo_label_prs_without_tests.png new file mode 100644 index 00000000..1481c9c5 Binary files /dev/null and b/automations/label-prs-without-tests/logo_label_prs_without_tests.png differ diff --git a/automations/languages/approve-log-output.png b/automations/languages/approve-log-output.png new file mode 100644 index 00000000..a9ab223a Binary files /dev/null and b/automations/languages/approve-log-output.png differ diff --git a/automations/languages/css/review-css-important/index.html b/automations/languages/css/review-css-important/index.html new file mode 100644 index 00000000..4bcf3251 --- /dev/null +++ b/automations/languages/css/review-css-important/index.html @@ -0,0 +1,15 @@ + + + + + + Redirecting... + + + + + + +Redirecting... + + diff --git a/automations/languages/golang/approve-golang-log-output/approve-formatting-changes-go.svg b/automations/languages/golang/approve-golang-log-output/approve-formatting-changes-go.svg new file mode 100644 index 00000000..e8e9dafe --- /dev/null +++ b/automations/languages/golang/approve-golang-log-output/approve-formatting-changes-go.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/golang/approve-golang-log-output/index.html b/automations/languages/golang/approve-golang-log-output/index.html new file mode 100644 index 00000000..549afb56 --- /dev/null +++ b/automations/languages/golang/approve-golang-log-output/index.html @@ -0,0 +1,21 @@ + Automation - Approve Golang Log Output Changes - gitStream Documentation

Approve Golang Log Output Changes

Approve changes to Golang files that only affect lines of code that invoke the logger object.

approve Golang log output

Configuration Description

Conditions (all must be true):

  • All files end in .go
  • The changes only affect lines of code that invoke the log object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Golang Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_golang_log_output:
+    # Triggered for Golang changes that only affect the console.log() method
+    if: 
+      - {{ files | extensions | match(term='go') | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^.*log\.Println/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+
\ No newline at end of file diff --git a/automations/languages/golang/approve-golang-log-output/logo_approve_formatting_changes_go.png b/automations/languages/golang/approve-golang-log-output/logo_approve_formatting_changes_go.png new file mode 100644 index 00000000..42913471 Binary files /dev/null and b/automations/languages/golang/approve-golang-log-output/logo_approve_formatting_changes_go.png differ diff --git a/automations/languages/golang/index.html b/automations/languages/golang/index.html new file mode 100644 index 00000000..8d8687ba --- /dev/null +++ b/automations/languages/golang/index.html @@ -0,0 +1,52 @@ + Automation - Integrate gitStream with Golang - gitStream Documentation

Automation - Integrate gitStream with Golang

Approve Golang Log Output Changes

Approve changes to Golang files that only affect lines of code that invoke the logger object.

approve Golang log output

Configuration Description

Conditions (all must be true):

  • All files end in .go
  • The changes only affect lines of code that invoke the log object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Golang Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_golang_log_output:
+    # Triggered for Golang changes that only affect the console.log() method
+    if: 
+      - {{ files | extensions | match(term='go') | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^.*log\.Println/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+

Review Missing Golang Tests

Automatically request changes for Golang PRs that are missing tests.

Review Missing Golang Tests

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Golang files
  • The PR lacks new test files that match the name of the Golang files

Automation Actions:

  • The PR lacks new test files that match the name of the Golang files
  • Apply a red missing-tests label

Review Missing Golang Tests

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^(pkg|internal)\/(?!.*\_test\.go$).*\.go$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/.*\_test\.go$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+
+newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^(pkg|internal)\/(?!.*\_test\.go$).*\.go$/) | filter(attr='original_file', regex=r/^$/) | length }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/.*\_test\.go$/) | filter(attr='original_file', regex=r/^$/) | length }}
+
+automations:
+  review_missing_golang_tests:
+    if:
+      - {{ newFilesCount != newTestsCount }}
+    run: 
+      - action: add-label@v1
+        args:
+            label: "⚠️ Missing Tests"
+            color: {{ colors.orange }}    
+      - action: request-changes@v1
+        args:
+          comment: |
+            Some of your new Golang files are missing corresponding tests. Please ensure that all new files have a corresponding test file.
+
+            **New Files**: {{ newFilesCount }}
+            {{ newFiles }}
+
+            **New Tests**: {{ newTestsCount }}
+            {{ newTests }}
+colors:
+  orange: 'd93f0b'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

\ No newline at end of file diff --git a/automations/languages/golang/review-missing-golang-tests/approve-formatting-changes-go.svg b/automations/languages/golang/review-missing-golang-tests/approve-formatting-changes-go.svg new file mode 100644 index 00000000..e8e9dafe --- /dev/null +++ b/automations/languages/golang/review-missing-golang-tests/approve-formatting-changes-go.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/golang/review-missing-golang-tests/index.html b/automations/languages/golang/review-missing-golang-tests/index.html new file mode 100644 index 00000000..37d012c7 --- /dev/null +++ b/automations/languages/golang/review-missing-golang-tests/index.html @@ -0,0 +1,32 @@ + Automation - Review Missing Golang Tests - gitStream Documentation

Review Missing Golang Tests

Automatically request changes for Golang PRs that are missing tests.

Review Missing Golang Tests

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Golang files
  • The PR lacks new test files that match the name of the Golang files

Automation Actions:

  • The PR lacks new test files that match the name of the Golang files
  • Apply a red missing-tests label

Review Missing Golang Tests

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^(pkg|internal)\/(?!.*\_test\.go$).*\.go$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/.*\_test\.go$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+
+newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^(pkg|internal)\/(?!.*\_test\.go$).*\.go$/) | filter(attr='original_file', regex=r/^$/) | length }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/.*\_test\.go$/) | filter(attr='original_file', regex=r/^$/) | length }}
+
+automations:
+  review_missing_golang_tests:
+    if:
+      - {{ newFilesCount != newTestsCount }}
+    run: 
+      - action: add-label@v1
+        args:
+            label: "⚠️ Missing Tests"
+            color: {{ colors.orange }}    
+      - action: request-changes@v1
+        args:
+          comment: |
+            Some of your new Golang files are missing corresponding tests. Please ensure that all new files have a corresponding test file.
+
+            **New Files**: {{ newFilesCount }}
+            {{ newFiles }}
+
+            **New Tests**: {{ newTestsCount }}
+            {{ newTests }}
+colors:
+  orange: 'd93f0b'
+
\ No newline at end of file diff --git a/automations/languages/golang/review-missing-golang-tests/logo_approve_formatting_changes_go.png b/automations/languages/golang/review-missing-golang-tests/logo_approve_formatting_changes_go.png new file mode 100644 index 00000000..42913471 Binary files /dev/null and b/automations/languages/golang/review-missing-golang-tests/logo_approve_formatting_changes_go.png differ diff --git a/automations/languages/golang/review-missing-golang-tests/review-missing-golang-tests.png b/automations/languages/golang/review-missing-golang-tests/review-missing-golang-tests.png new file mode 100644 index 00000000..8248cd46 Binary files /dev/null and b/automations/languages/golang/review-missing-golang-tests/review-missing-golang-tests.png differ diff --git a/automations/languages/html/enforce-html-title-length/approve-formatting-changes-HTML.svg b/automations/languages/html/enforce-html-title-length/approve-formatting-changes-HTML.svg new file mode 100644 index 00000000..b591a8d9 --- /dev/null +++ b/automations/languages/html/enforce-html-title-length/approve-formatting-changes-HTML.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/html/enforce-html-title-length/enforce-html-title-length.png b/automations/languages/html/enforce-html-title-length/enforce-html-title-length.png new file mode 100644 index 00000000..71ed9f4b Binary files /dev/null and b/automations/languages/html/enforce-html-title-length/enforce-html-title-length.png differ diff --git a/automations/languages/html/enforce-html-title-length/index.html b/automations/languages/html/enforce-html-title-length/index.html new file mode 100644 index 00000000..8e119cdd --- /dev/null +++ b/automations/languages/html/enforce-html-title-length/index.html @@ -0,0 +1,14 @@ + Automation - Enforce HTML Title Length Requirements - gitStream Documentation

Enforce HTML Title Length Requirements

Automatically request changes for <title> tags that don't comply with best practices.

Enforce HTML Title Length Requirements

Configuration Description

Conditions (all must be true):

  • The PR adds a <title> tag that is less than 30 or greater than 90 characters.

Automation Actions:

  • Request changes and post a comment asking the author to modify the title.

Enforce HTML Title Length Requirements

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  enforce_html_title_length:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/(<title>([\w\W]{1,29})<\/title>)|(<title>([\w\W]{61,})<\/title>)/) | some }}
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: | 
+              Please ensure that all HTML titles are between 30 and 60 characters.
+
\ No newline at end of file diff --git a/automations/languages/html/enforce-html-title-length/logo_approve_formatting_changes_html.png b/automations/languages/html/enforce-html-title-length/logo_approve_formatting_changes_html.png new file mode 100644 index 00000000..f5eb4e2d Binary files /dev/null and b/automations/languages/html/enforce-html-title-length/logo_approve_formatting_changes_html.png differ diff --git a/automations/languages/html/enforce-image-alt/approve-formatting-changes-HTML.svg b/automations/languages/html/enforce-image-alt/approve-formatting-changes-HTML.svg new file mode 100644 index 00000000..b591a8d9 --- /dev/null +++ b/automations/languages/html/enforce-image-alt/approve-formatting-changes-HTML.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/html/enforce-image-alt/enforce-image-alt.png b/automations/languages/html/enforce-image-alt/enforce-image-alt.png new file mode 100644 index 00000000..47b6b6d4 Binary files /dev/null and b/automations/languages/html/enforce-image-alt/enforce-image-alt.png differ diff --git a/automations/languages/html/enforce-image-alt/index.html b/automations/languages/html/enforce-image-alt/index.html new file mode 100644 index 00000000..fc790e54 --- /dev/null +++ b/automations/languages/html/enforce-image-alt/index.html @@ -0,0 +1,23 @@ + Automation - Enforce Image Alt Attributes - gitStream Documentation

Enforce Image Alt Attributes

Automatically request changes for PRs HTML files that are missing image alt attributes.

Enforce Image Alt Attributes

Configuration Description

Conditions (all must be true):

  • The PR adds an image tag to an HTML file.
  • The PR is missing alt attributes for one or more images.

Automation Actions:

  • Add a ⚠️ Missing alt label label
  • Request changes and post a comment asking the author to add alt attributes to images.

Enforce Image Alt Attributes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  enforce_image_alt:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/<img src/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=r/<img src.*alt=/) | nope}}
+
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing alt label"
+          color: {{ colors.yellow }}
+      - action: request-changes@v1
+        args:
+          comment: | 
+                 Please ensure that all images in HTML files have an alt attribute. For example: <img alt="Alt Message">
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/languages/html/enforce-image-alt/logo_approve_formatting_changes_html.png b/automations/languages/html/enforce-image-alt/logo_approve_formatting_changes_html.png new file mode 100644 index 00000000..f5eb4e2d Binary files /dev/null and b/automations/languages/html/enforce-image-alt/logo_approve_formatting_changes_html.png differ diff --git a/automations/languages/html/flag-duplicate-h1/approve-formatting-changes-HTML.svg b/automations/languages/html/flag-duplicate-h1/approve-formatting-changes-HTML.svg new file mode 100644 index 00000000..b591a8d9 --- /dev/null +++ b/automations/languages/html/flag-duplicate-h1/approve-formatting-changes-HTML.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/html/flag-duplicate-h1/flag-duplicate-h1.png b/automations/languages/html/flag-duplicate-h1/flag-duplicate-h1.png new file mode 100644 index 00000000..0c6dd92b Binary files /dev/null and b/automations/languages/html/flag-duplicate-h1/flag-duplicate-h1.png differ diff --git a/automations/languages/html/flag-duplicate-h1/index.html b/automations/languages/html/flag-duplicate-h1/index.html new file mode 100644 index 00000000..f9bafb1c --- /dev/null +++ b/automations/languages/html/flag-duplicate-h1/index.html @@ -0,0 +1,16 @@ + Automation - Flag Duplicate H1 - gitStream Documentation

Flag Duplicate H1

Automatically request changes when PRs contain HTML files that have more than one H1 heading.

Flag Duplicate H1

Configuration Description

Conditions (all must be true):

  • The PR contains more than one H1 heading in an HTML file.

Automation Actions:

  • Post a comment requesting the author to reduce H1 headings to one per file.

Flag Duplicate H1

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  flag_duplicate_h1:
+    if:
+      - {{ duplicateH1 > 0 }}
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: | 
+              This PR contains HTML files with multiple H1 tags. Please ensure that each HTML file has only one H1 tag.
+
+duplicateH1: {{ source.diff.files | filter(attr='new_content', regex=r/<h1>(.|\n)*<h1>/) | length }}
+
\ No newline at end of file diff --git a/automations/languages/html/flag-duplicate-h1/logo_approve_formatting_changes_html.png b/automations/languages/html/flag-duplicate-h1/logo_approve_formatting_changes_html.png new file mode 100644 index 00000000..f5eb4e2d Binary files /dev/null and b/automations/languages/html/flag-duplicate-h1/logo_approve_formatting_changes_html.png differ diff --git a/automations/languages/html/flag-missing-html-tags/approve-formatting-changes-HTML.svg b/automations/languages/html/flag-missing-html-tags/approve-formatting-changes-HTML.svg new file mode 100644 index 00000000..b591a8d9 --- /dev/null +++ b/automations/languages/html/flag-missing-html-tags/approve-formatting-changes-HTML.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/html/flag-missing-html-tags/flag-missing-html-tags.png b/automations/languages/html/flag-missing-html-tags/flag-missing-html-tags.png new file mode 100644 index 00000000..edf55485 Binary files /dev/null and b/automations/languages/html/flag-missing-html-tags/flag-missing-html-tags.png differ diff --git a/automations/languages/html/flag-missing-html-tags/index.html b/automations/languages/html/flag-missing-html-tags/index.html new file mode 100644 index 00000000..6891ae4f --- /dev/null +++ b/automations/languages/html/flag-missing-html-tags/index.html @@ -0,0 +1,27 @@ + Automation - Flag Missing HTML Tags - gitStream Documentation

Flag Missing HTML Tags

Request changes for HTML files that lack the canonical and robots tag.

Flag Missing HTML Tags

Configuration Description

Conditions (all must be true):

  • The PR contains only new HTML files
  • One or more files are missing a canonical tag
  • One or more files are missing a robots meta tag

Automation Actions:

  • Apply a ⚠️ Missing Required Tag label.
  • Post a comment asking the user to add required tags.

Flag Missing HTML Tags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  flag_missing_html_tags:
+    if:
+      - {{ is.html and is.new }}
+      - {{ source.diff.files | matchDiffLines(regex=r/rel="canonical"/) | nope }}
+      - {{ source.diff.files | matchDiffLines(regex=r/meta name="robots"/) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Required Tag"
+          color: {{ colors.yellow }}
+      - action: request-changes@v1
+        args:
+          comment: | 
+              Please ensure new HTML files contain canonical and robots meta tags.
+
+is:
+    html: {{ files | extensions | match(term='html') | every }}
+    new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/languages/html/flag-missing-html-tags/logo_approve_formatting_changes_html.png b/automations/languages/html/flag-missing-html-tags/logo_approve_formatting_changes_html.png new file mode 100644 index 00000000..f5eb4e2d Binary files /dev/null and b/automations/languages/html/flag-missing-html-tags/logo_approve_formatting_changes_html.png differ diff --git a/automations/languages/html/index.html b/automations/languages/html/index.html new file mode 100644 index 00000000..c92dfd85 --- /dev/null +++ b/automations/languages/html/index.html @@ -0,0 +1,100 @@ + Automation - Integrate gitStream with HTML and CSS - gitStream Documentation

Automation - Integrate gitStream with HTML and CSS

Request Changes for CSS Important Tags

Flag the use of !important in CSS files and automatically request changes.

Review Important Tags in CSS Files

Configuration Description

Conditions (all must be true):

  • The PR contains changes to CSS files.
  • The changes include !important

Automation Actions:

  • Apply an orange label that says ⚠️ Includes !important tag
  • Request changes an post a comment asking the PR author to remove the important tage.

Review Important Tags in CSS Files

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_css_important:
+    if:
+      - {{ files | extensions | match(term='css') | some }}
+      - {{ source.diff.files | matchDiffLines(regex=r/!important/) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: '⚠️ Includes !important tag'
+          color: '{{ colors.orange }}'
+      - action: request-changes@v1
+        args:
+          comment: |
+            Please remove the `!important` tag from your CSS.
+
+
+colors:
+  orange: 'd93f0b'
+

Flag Missing HTML Tags

Request changes for HTML files that lack the canonical and robots tag.

Flag Missing HTML Tags

Configuration Description

Conditions (all must be true):

  • The PR contains only new HTML files
  • One or more files are missing a canonical tag
  • One or more files are missing a robots meta tag

Automation Actions:

  • Apply a ⚠️ Missing Required Tag label.
  • Post a comment asking the user to add required tags.

Flag Missing HTML Tags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  flag_missing_html_tags:
+    if:
+      - {{ is.html and is.new }}
+      - {{ source.diff.files | matchDiffLines(regex=r/rel="canonical"/) | nope }}
+      - {{ source.diff.files | matchDiffLines(regex=r/meta name="robots"/) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Required Tag"
+          color: {{ colors.yellow }}
+      - action: request-changes@v1
+        args:
+          comment: | 
+              Please ensure new HTML files contain canonical and robots meta tags.
+
+is:
+    html: {{ files | extensions | match(term='html') | every }}
+    new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}
+
+colors:
+  yellow: 'fbca04'
+

Flag Duplicate H1

Automatically request changes when PRs contain HTML files that have more than one H1 heading.

Flag Duplicate H1

Configuration Description

Conditions (all must be true):

  • The PR contains more than one H1 heading in an HTML file.

Automation Actions:

  • Post a comment requesting the author to reduce H1 headings to one per file.

Flag Duplicate H1

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  flag_duplicate_h1:
+    if:
+      - {{ duplicateH1 > 0 }}
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: | 
+              This PR contains HTML files with multiple H1 tags. Please ensure that each HTML file has only one H1 tag.
+
+duplicateH1: {{ source.diff.files | filter(attr='new_content', regex=r/<h1>(.|\n)*<h1>/) | length }}
+

Enforce HTML Title Length Requirements

Automatically request changes for <title> tags that don't comply with best practices.

Enforce HTML Title Length Requirements

Configuration Description

Conditions (all must be true):

  • The PR adds a <title> tag that is less than 30 or greater than 90 characters.

Automation Actions:

  • Request changes and post a comment asking the author to modify the title.

Enforce HTML Title Length Requirements

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  enforce_html_title_length:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/(<title>([\w\W]{1,29})<\/title>)|(<title>([\w\W]{61,})<\/title>)/) | some }}
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: | 
+              Please ensure that all HTML titles are between 30 and 60 characters.
+

Enforce Image Alt Attributes

Automatically request changes for PRs HTML files that are missing image alt attributes.

Enforce Image Alt Attributes

Configuration Description

Conditions (all must be true):

  • The PR adds an image tag to an HTML file.
  • The PR is missing alt attributes for one or more images.

Automation Actions:

  • Add a ⚠️ Missing alt label label
  • Request changes and post a comment asking the author to add alt attributes to images.

Enforce Image Alt Attributes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  enforce_image_alt:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/<img src/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=r/<img src.*alt=/) | nope}}
+
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing alt label"
+          color: {{ colors.yellow }}
+      - action: request-changes@v1
+        args:
+          comment: | 
+                 Please ensure that all images in HTML files have an alt attribute. For example: <img alt="Alt Message">
+
+colors:
+  yellow: 'fbca04'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

\ No newline at end of file diff --git a/automations/languages/html/review-css-important/approve-formatting-changes-HTML.svg b/automations/languages/html/review-css-important/approve-formatting-changes-HTML.svg new file mode 100644 index 00000000..b591a8d9 --- /dev/null +++ b/automations/languages/html/review-css-important/approve-formatting-changes-HTML.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/html/review-css-important/index.html b/automations/languages/html/review-css-important/index.html new file mode 100644 index 00000000..8cc72776 --- /dev/null +++ b/automations/languages/html/review-css-important/index.html @@ -0,0 +1,24 @@ + Automation - Flag CSS Important Tags - gitStream Documentation

Review Important Tags in CSS Files

Flag the use of !important in CSS files and automatically request changes.

Review Important Tags in CSS Files

Configuration Description

Conditions (all must be true):

  • The PR contains changes to CSS files.
  • The changes include !important

Automation Actions:

  • Apply an orange label that says ⚠️ Includes !important tag
  • Request changes an post a comment asking the PR author to remove the important tage.

Review Important Tags in CSS Files

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_css_important:
+    if:
+      - {{ files | extensions | match(term='css') | some }}
+      - {{ source.diff.files | matchDiffLines(regex=r/!important/) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: '⚠️ Includes !important tag'
+          color: '{{ colors.orange }}'
+      - action: request-changes@v1
+        args:
+          comment: |
+            Please remove the `!important` tag from your CSS.
+
+
+colors:
+  orange: 'd93f0b'
+
\ No newline at end of file diff --git a/automations/languages/html/review-css-important/logo_approve_formatting_changes_html.png b/automations/languages/html/review-css-important/logo_approve_formatting_changes_html.png new file mode 100644 index 00000000..f5eb4e2d Binary files /dev/null and b/automations/languages/html/review-css-important/logo_approve_formatting_changes_html.png differ diff --git a/automations/languages/html/review-css-important/review-css-important.png b/automations/languages/html/review-css-important/review-css-important.png new file mode 100644 index 00000000..91c39dc1 Binary files /dev/null and b/automations/languages/html/review-css-important/review-css-important.png differ diff --git a/automations/languages/java/approve-java-log-output/approve-formatting-changes-JAV.svg b/automations/languages/java/approve-java-log-output/approve-formatting-changes-JAV.svg new file mode 100644 index 00000000..51539e1e --- /dev/null +++ b/automations/languages/java/approve-java-log-output/approve-formatting-changes-JAV.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/java/approve-java-log-output/index.html b/automations/languages/java/approve-java-log-output/index.html new file mode 100644 index 00000000..8ff10847 --- /dev/null +++ b/automations/languages/java/approve-java-log-output/index.html @@ -0,0 +1,21 @@ + Automation - Approve Java Log Output Changes - gitStream Documentation

Approve Java Log Output Changes

Approve changes to Java files that only affect lines of code that invoke the logger object.

approve Java log output

Configuration Description

Conditions (all must be true):

  • All files end in .java
  • The changes only affect lines of code that invoke logger object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Java Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_java_log_output:
+    # Triggered for Java changes that only affect the logger method
+    if: 
+      - {{ files | extensions | match(term='java') | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^.*logger\.(trace|fatal|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+
\ No newline at end of file diff --git a/automations/languages/java/approve-java-log-output/logo_approve_formatting_changes_jav.png b/automations/languages/java/approve-java-log-output/logo_approve_formatting_changes_jav.png new file mode 100644 index 00000000..c462d2d1 Binary files /dev/null and b/automations/languages/java/approve-java-log-output/logo_approve_formatting_changes_jav.png differ diff --git a/automations/languages/java/index.html b/automations/languages/java/index.html new file mode 100644 index 00000000..390e21ae --- /dev/null +++ b/automations/languages/java/index.html @@ -0,0 +1,69 @@ + Automation - Integrate gitStream with Java - gitStream Documentation

Automation - Integrate gitStream with Java

Approve Java Log Output Changes

Approve changes to Java files that only affect lines of code that invoke the logger object.

approve Java log output

Configuration Description

Conditions (all must be true):

  • All files end in .java
  • The changes only affect lines of code that invoke logger object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Java Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_java_log_output:
+    # Triggered for Java changes that only affect the logger method
+    if: 
+      - {{ files | extensions | match(term='java') | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^.*logger\.(trace|fatal|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+

Review Missing Java Tests

Automatically request changes for Java PRs that lack test files.

Review Missing Java Tests

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Java files
  • The PR lacks new test files that match the name of the Java files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Java Tests

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*Test\.java$).*\.java$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*Test\.java$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+
+newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*Test\.java$).*\.java$/) | filter(attr='original_file', regex=r/^$/) | length }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*Test\.java$/) | filter(attr='original_file', regex=r/^$/) | length }}
+
+automations:
+  review_missing_java_tests:
+    if:
+      - {{ newFilesCount != newTestsCount }}
+    run: 
+      - action: add-label@v1
+        args:
+            label: "⚠️ Missing Tests"
+            color: {{ colors.orange }}    
+      - action: request-changes@v1
+        args:
+          comment: |
+            Some of your new Java files are missing corresponding tests. Please ensure that all new files have a corresponding test file.
+
+            **New Files**: {{ newFilesCount }}
+            {{ newFiles }}
+
+            **New Tests**: {{ newTestsCount }}
+            {{ newTests }}
+colors:
+  orange: 'd93f0b'
+

Review Java Test Names

Automatically request changes for Java test files that fail to match the required naming convention.

Review Java Test Name

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Java test files
  • The Java test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Java test name requirements.

Review Java Test Name

# -*- mode: yaml -*-
+manifest:
+  version: 1.0  
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/test\/) }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/test\/) | length }}
+
+automations:
+  review_java_test_name:
+    if:
+       - {{ newTestsCount > 0}}     
+       - {{ source.diff.files | filter(attr='new_file', regex=r/^src\/test\/) | match(attr='new_file', regex=r/Test.java$/) | nope }}
+
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: |
+              The test file name does not follow the Java test name conventions. A test file name needs to have the word Test at the end of class name. For example, if you are testing a class called Data then the test file name has to be DataTest.java.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

\ No newline at end of file diff --git a/automations/languages/java/review-java-test-name/approve-formatting-changes-JAV.svg b/automations/languages/java/review-java-test-name/approve-formatting-changes-JAV.svg new file mode 100644 index 00000000..51539e1e --- /dev/null +++ b/automations/languages/java/review-java-test-name/approve-formatting-changes-JAV.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/java/review-java-test-name/index.html b/automations/languages/java/review-java-test-name/index.html new file mode 100644 index 00000000..7614132c --- /dev/null +++ b/automations/languages/java/review-java-test-name/index.html @@ -0,0 +1,18 @@ + Automation - Review Java Test Name - gitStream Documentation

Review Java Test Name

Automatically request changes for Java test files that fail to match the required naming convention.

Review Java Test Name

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Java test files
  • The Java test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Java test name requirements.

Review Java Test Name

# -*- mode: yaml -*-
+manifest:
+  version: 1.0  
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/test\/) }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/test\/) | length }}
+
+automations:
+  review_java_test_name:
+    if:
+       - {{ newTestsCount > 0}}     
+       - {{ source.diff.files | filter(attr='new_file', regex=r/^src\/test\/) | match(attr='new_file', regex=r/Test.java$/) | nope }}
+
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: |
+              The test file name does not follow the Java test name conventions. A test file name needs to have the word Test at the end of class name. For example, if you are testing a class called Data then the test file name has to be DataTest.java.
+
\ No newline at end of file diff --git a/automations/languages/java/review-java-test-name/logo_approve_formatting_changes_jav.png b/automations/languages/java/review-java-test-name/logo_approve_formatting_changes_jav.png new file mode 100644 index 00000000..c462d2d1 Binary files /dev/null and b/automations/languages/java/review-java-test-name/logo_approve_formatting_changes_jav.png differ diff --git a/automations/languages/java/review-java-test-name/review-java-test-name.png b/automations/languages/java/review-java-test-name/review-java-test-name.png new file mode 100644 index 00000000..14f4e306 Binary files /dev/null and b/automations/languages/java/review-java-test-name/review-java-test-name.png differ diff --git a/automations/languages/java/review-missing-java-tests/approve-formatting-changes-JAV.svg b/automations/languages/java/review-missing-java-tests/approve-formatting-changes-JAV.svg new file mode 100644 index 00000000..51539e1e --- /dev/null +++ b/automations/languages/java/review-missing-java-tests/approve-formatting-changes-JAV.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/java/review-missing-java-tests/index.html b/automations/languages/java/review-missing-java-tests/index.html new file mode 100644 index 00000000..ec4f6a5a --- /dev/null +++ b/automations/languages/java/review-missing-java-tests/index.html @@ -0,0 +1,32 @@ + Automation - Review Missing Java Tests - gitStream Documentation

Review Missing Java Tests

Automatically request changes for Java PRs that lack test files.

Review Missing Java Tests

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Java files
  • The PR lacks new test files that match the name of the Java files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Java Tests

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*Test\.java$).*\.java$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*Test\.java$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+
+newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*Test\.java$).*\.java$/) | filter(attr='original_file', regex=r/^$/) | length }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*Test\.java$/) | filter(attr='original_file', regex=r/^$/) | length }}
+
+automations:
+  review_missing_java_tests:
+    if:
+      - {{ newFilesCount != newTestsCount }}
+    run: 
+      - action: add-label@v1
+        args:
+            label: "⚠️ Missing Tests"
+            color: {{ colors.orange }}    
+      - action: request-changes@v1
+        args:
+          comment: |
+            Some of your new Java files are missing corresponding tests. Please ensure that all new files have a corresponding test file.
+
+            **New Files**: {{ newFilesCount }}
+            {{ newFiles }}
+
+            **New Tests**: {{ newTestsCount }}
+            {{ newTests }}
+colors:
+  orange: 'd93f0b'
+
\ No newline at end of file diff --git a/automations/languages/java/review-missing-java-tests/logo_approve_formatting_changes_jav.png b/automations/languages/java/review-missing-java-tests/logo_approve_formatting_changes_jav.png new file mode 100644 index 00000000..c462d2d1 Binary files /dev/null and b/automations/languages/java/review-missing-java-tests/logo_approve_formatting_changes_jav.png differ diff --git a/automations/languages/java/review-missing-java-tests/review-missing-java-tests.png b/automations/languages/java/review-missing-java-tests/review-missing-java-tests.png new file mode 100644 index 00000000..4d06219a Binary files /dev/null and b/automations/languages/java/review-missing-java-tests/review-missing-java-tests.png differ diff --git a/automations/languages/javascript/approve-javascript-formatting-change/approve-formatting-changes-JS.svg b/automations/languages/javascript/approve-javascript-formatting-change/approve-formatting-changes-JS.svg new file mode 100644 index 00000000..f06f8282 --- /dev/null +++ b/automations/languages/javascript/approve-javascript-formatting-change/approve-formatting-changes-JS.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/javascript/approve-javascript-formatting-change/approve-javascript-formatting-change.png b/automations/languages/javascript/approve-javascript-formatting-change/approve-javascript-formatting-change.png new file mode 100644 index 00000000..367247dc Binary files /dev/null and b/automations/languages/javascript/approve-javascript-formatting-change/approve-javascript-formatting-change.png differ diff --git a/automations/languages/javascript/approve-javascript-formatting-change/index.html b/automations/languages/javascript/approve-javascript-formatting-change/index.html new file mode 100644 index 00000000..6ba531a0 --- /dev/null +++ b/automations/languages/javascript/approve-javascript-formatting-change/index.html @@ -0,0 +1,20 @@ + Automation - Approve JavaScript Formatting Changes - gitStream Documentation

Approve JavaScript Formatting Changes

Approve PRs that only contain formatting changes to JavaScript or TypeScript files.

Approve JavaScript formatting changes

Configuration Description

Conditions (all must be true):

  • All of the files end in .js or .ts
  • All changes are non-functional

Automation Actions:

  • Approve the PR
  • Apply a code-formatting label.
  • Post a comment that explains the automation.

Approve JavaScript Formatting Change

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_javascript_formatting:
+    if:
+      - {{ files | extensions | match(list=['js', 'ts']) | every }}
+      - {{ source.diff.files | isFormattingChange }}
+    run:
+      - action: approve@v1
+      - action: add-label@v1
+        args:
+          label: code-formatting
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR only contains formatting changes and has been approved.
+

\ No newline at end of file diff --git a/automations/languages/javascript/approve-javascript-formatting-change/logo_approve_formatting_changes_js.png b/automations/languages/javascript/approve-javascript-formatting-change/logo_approve_formatting_changes_js.png new file mode 100644 index 00000000..aff107ce Binary files /dev/null and b/automations/languages/javascript/approve-javascript-formatting-change/logo_approve_formatting_changes_js.png differ diff --git a/automations/languages/javascript/approve-javascript-log-output/approve-formatting-changes-JS.svg b/automations/languages/javascript/approve-javascript-log-output/approve-formatting-changes-JS.svg new file mode 100644 index 00000000..f06f8282 --- /dev/null +++ b/automations/languages/javascript/approve-javascript-log-output/approve-formatting-changes-JS.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/javascript/approve-javascript-log-output/index.html b/automations/languages/javascript/approve-javascript-log-output/index.html new file mode 100644 index 00000000..4d459f46 --- /dev/null +++ b/automations/languages/javascript/approve-javascript-log-output/index.html @@ -0,0 +1,21 @@ + Automation - Approve JavaScript Log Output Changes - gitStream Documentation

Approve JavaScript Log Output Changes

Approve changes to JavaScript files that only affect lines of code that invoke the console.log() method.

approve JavaScript log output

Configuration Description

Conditions (all must be true):

  • All files must end in .js or .ts
  • The changes only affect lines of code that invoke console.log()

Automation Actions:

  • Applies a log-output-only label
  • Approves the PR
  • Posts a comment explaining that the change only affects logging output.

Approve JavaScript Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_javascript_log_output:
+    # Triggered for JavaScript changes that only affect the console.log() method
+    if: 
+      - {{ files | match(regex=r/\.js$|\.ts$/) | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^[+-].*console\.log/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+

\ No newline at end of file diff --git a/automations/languages/javascript/approve-javascript-log-output/logo_approve_formatting_changes_js.png b/automations/languages/javascript/approve-javascript-log-output/logo_approve_formatting_changes_js.png new file mode 100644 index 00000000..aff107ce Binary files /dev/null and b/automations/languages/javascript/approve-javascript-log-output/logo_approve_formatting_changes_js.png differ diff --git a/automations/languages/javascript/index.html b/automations/languages/javascript/index.html new file mode 100644 index 00000000..839dfa66 --- /dev/null +++ b/automations/languages/javascript/index.html @@ -0,0 +1,89 @@ + Automation - Integrate gitStream with JavaScript - gitStream Documentation

Automation - Integrate gitStream with JavaScript

Auto-Approve JavaScript Log Output Changes

Approve changes to JavaScript files that only affect lines of code that invoke the console.log() method.

approve JavaScript log output

Configuration Description

Conditions (all must be true):

  • All files must end in .js or .ts
  • The changes only affect lines of code that invoke console.log()

Automation Actions:

  • Applies a log-output-only label
  • Approves the PR
  • Posts a comment explaining that the change only affects logging output.

Approve JavaScript Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_javascript_log_output:
+    # Triggered for JavaScript changes that only affect the console.log() method
+    if: 
+      - {{ files | match(regex=r/\.js$|\.ts$/) | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^[+-].*console\.log/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+

Auto-Approve JavaScript Formatting Change

Approve PRs that only contain formatting changes to JavaScript or TypeScript files.

Approve JavaScript formatting changes

Configuration Description

Conditions (all must be true):

  • All of the files end in .js or .ts
  • All changes are non-functional

Automation Actions:

  • Approve the PR
  • Apply a code-formatting label.
  • Post a comment that explains the automation.

Approve JavaScript Formatting Change

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_javascript_formatting:
+    if:
+      - {{ files | extensions | match(list=['js', 'ts']) | every }}
+      - {{ source.diff.files | isFormattingChange }}
+    run:
+      - action: approve@v1
+      - action: add-label@v1
+        args:
+          label: code-formatting
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR only contains formatting changes and has been approved.
+

Review Missing JavaScript Tests

Request changes for JavaScript PRs that lack test files.

Review Missing JavaScript Tests

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new JavaScript files
  • The PR lacks new test files that match the name of the JavaScript files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing JavaScript Tests

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*\.test\.js$).*\.js$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*\.test\.js$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+
+newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*\.test\.js$).*\.js$/) | filter(attr='original_file', regex=r/^$/) | length }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*\.test\.js$/) | filter(attr='original_file', regex=r/^$/) | length }}
+
+automations:
+  review_missing_javascript_tests:
+    if:
+      - {{ newFilesCount != newTestsCount }}
+    run: 
+      - action: add-label@v1
+        args:
+            label: "⚠️ Missing Tests"
+            color: {{ colors.orange }}    
+      - action: request-changes@v1
+        args:
+          comment: |
+            Some of your new JavaScript files are missing corresponding tests. Please ensure that all new files have a corresponding test file.
+
+            **New Files**: {{ newFilesCount }}
+            {{ newFiles }}
+
+            **New Tests**: {{ newTestsCount }}
+            {{ newTests }}
+colors:
+  orange: 'd93f0b'
+

Review JavaScript Test Name

Automatically request changes for JavaScript test files that fail to match the required naming convention.

Review JavaScript Test Name

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new JavaScript test files
  • The JavaScript test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the JavaScript test name requirements.

Review JavaScript Test Name

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^test/) }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^test/) | length }}
+
+automations:
+  review_javascript_test_name:
+    if:
+
+      - {{ newTestsCount > 0}}     
+      - {{ source.diff.files | filter(attr='new_file', regex=r/^test/) | match(attr='new_file', regex=r/.test.js$/) | nope }}
+
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: |
+              The test file name does not follow the JavaScript test name conventions. A test file name needs to have the suffix .test after class name. For example, if you are testing a class file called Data.js then the test file name has to be data.test.js.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/languages/javascript/review-javascript-test-name/approve-formatting-changes-JS.svg b/automations/languages/javascript/review-javascript-test-name/approve-formatting-changes-JS.svg new file mode 100644 index 00000000..f06f8282 --- /dev/null +++ b/automations/languages/javascript/review-javascript-test-name/approve-formatting-changes-JS.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/javascript/review-javascript-test-name/index.html b/automations/languages/javascript/review-javascript-test-name/index.html new file mode 100644 index 00000000..461b065f --- /dev/null +++ b/automations/languages/javascript/review-javascript-test-name/index.html @@ -0,0 +1,19 @@ + Automation - Review JavaScript Test Name - gitStream Documentation

Review JavaScript Test Name

Automatically request changes for JavaScript test files that fail to match the required naming convention.

Review JavaScript Test Name

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new JavaScript test files
  • The JavaScript test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the JavaScript test name requirements.

Review JavaScript Test Name

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^test/) }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^test/) | length }}
+
+automations:
+  review_javascript_test_name:
+    if:
+
+      - {{ newTestsCount > 0}}     
+      - {{ source.diff.files | filter(attr='new_file', regex=r/^test/) | match(attr='new_file', regex=r/.test.js$/) | nope }}
+
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: |
+              The test file name does not follow the JavaScript test name conventions. A test file name needs to have the suffix .test after class name. For example, if you are testing a class file called Data.js then the test file name has to be data.test.js.
+
\ No newline at end of file diff --git a/automations/languages/javascript/review-javascript-test-name/logo_approve_formatting_changes_js.png b/automations/languages/javascript/review-javascript-test-name/logo_approve_formatting_changes_js.png new file mode 100644 index 00000000..aff107ce Binary files /dev/null and b/automations/languages/javascript/review-javascript-test-name/logo_approve_formatting_changes_js.png differ diff --git a/automations/languages/javascript/review-javascript-test-name/review-javascript-test-name.png b/automations/languages/javascript/review-javascript-test-name/review-javascript-test-name.png new file mode 100644 index 00000000..c4c4d2c3 Binary files /dev/null and b/automations/languages/javascript/review-javascript-test-name/review-javascript-test-name.png differ diff --git a/automations/languages/javascript/review-missing-javascript-tests/approve-formatting-changes-JS.svg b/automations/languages/javascript/review-missing-javascript-tests/approve-formatting-changes-JS.svg new file mode 100644 index 00000000..f06f8282 --- /dev/null +++ b/automations/languages/javascript/review-missing-javascript-tests/approve-formatting-changes-JS.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/javascript/review-missing-javascript-tests/index.html b/automations/languages/javascript/review-missing-javascript-tests/index.html new file mode 100644 index 00000000..44eff775 --- /dev/null +++ b/automations/languages/javascript/review-missing-javascript-tests/index.html @@ -0,0 +1,32 @@ + Automation - Review Missing JavaScript Tests - gitStream Documentation

Review Missing JavaScript Tests

Request changes for JavaScript PRs that lack test files.

Review Missing JavaScript Tests

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new JavaScript files
  • The PR lacks new test files that match the name of the JavaScript files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing JavaScript Tests

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*\.test\.js$).*\.js$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*\.test\.js$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+
+newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*\.test\.js$).*\.js$/) | filter(attr='original_file', regex=r/^$/) | length }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*\.test\.js$/) | filter(attr='original_file', regex=r/^$/) | length }}
+
+automations:
+  review_missing_javascript_tests:
+    if:
+      - {{ newFilesCount != newTestsCount }}
+    run: 
+      - action: add-label@v1
+        args:
+            label: "⚠️ Missing Tests"
+            color: {{ colors.orange }}    
+      - action: request-changes@v1
+        args:
+          comment: |
+            Some of your new JavaScript files are missing corresponding tests. Please ensure that all new files have a corresponding test file.
+
+            **New Files**: {{ newFilesCount }}
+            {{ newFiles }}
+
+            **New Tests**: {{ newTestsCount }}
+            {{ newTests }}
+colors:
+  orange: 'd93f0b'
+
\ No newline at end of file diff --git a/automations/languages/javascript/review-missing-javascript-tests/logo_approve_formatting_changes_js.png b/automations/languages/javascript/review-missing-javascript-tests/logo_approve_formatting_changes_js.png new file mode 100644 index 00000000..aff107ce Binary files /dev/null and b/automations/languages/javascript/review-missing-javascript-tests/logo_approve_formatting_changes_js.png differ diff --git a/automations/languages/javascript/review-missing-javascript-tests/review-missing-javascript-tests.png b/automations/languages/javascript/review-missing-javascript-tests/review-missing-javascript-tests.png new file mode 100644 index 00000000..6d15a5b2 Binary files /dev/null and b/automations/languages/javascript/review-missing-javascript-tests/review-missing-javascript-tests.png differ diff --git a/automations/languages/python/approve-python-formatting-change/approve-formatting-changes-PY.svg b/automations/languages/python/approve-python-formatting-change/approve-formatting-changes-PY.svg new file mode 100644 index 00000000..91c13fba --- /dev/null +++ b/automations/languages/python/approve-python-formatting-change/approve-formatting-changes-PY.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/python/approve-python-formatting-change/approve_python_formatting_change.png b/automations/languages/python/approve-python-formatting-change/approve_python_formatting_change.png new file mode 100644 index 00000000..367247dc Binary files /dev/null and b/automations/languages/python/approve-python-formatting-change/approve_python_formatting_change.png differ diff --git a/automations/languages/python/approve-python-formatting-change/index.html b/automations/languages/python/approve-python-formatting-change/index.html new file mode 100644 index 00000000..1eeda083 --- /dev/null +++ b/automations/languages/python/approve-python-formatting-change/index.html @@ -0,0 +1,20 @@ + Automation - Approve Python Formatting Changes - gitStream Documentation

Approve Python Formatting Changes

Approve PRs that only contain formatting changes to Python files.

Approve Python Formatting Changes

Configuration Description

Conditions (all must be true):

  • All of the files end in .py.
  • All changes are non-functional

Automation Actions:

  • Approve the PR
  • Apply a code-formatting label.
  • Post a comment that explains the automation.

Approve Python Formatting Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_python_formatting:
+    if:
+      - {{ files | extensions | match(list=['py']) | every }}
+      - {{ source.diff.files | isFormattingChange }}
+    run:
+      - action: approve@v1
+      - action: add-label@v1
+        args:
+          label: code-formatting
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR only contains formatting changes and has been approved.
+

\ No newline at end of file diff --git a/automations/languages/python/approve-python-formatting-change/logo_approve_formatting_changes_py.png b/automations/languages/python/approve-python-formatting-change/logo_approve_formatting_changes_py.png new file mode 100644 index 00000000..74cfa040 Binary files /dev/null and b/automations/languages/python/approve-python-formatting-change/logo_approve_formatting_changes_py.png differ diff --git a/automations/languages/python/approve-python-log-output/approve-formatting-changes-PY.svg b/automations/languages/python/approve-python-log-output/approve-formatting-changes-PY.svg new file mode 100644 index 00000000..91c13fba --- /dev/null +++ b/automations/languages/python/approve-python-log-output/approve-formatting-changes-PY.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/python/approve-python-log-output/index.html b/automations/languages/python/approve-python-log-output/index.html new file mode 100644 index 00000000..9fc5ad05 --- /dev/null +++ b/automations/languages/python/approve-python-log-output/index.html @@ -0,0 +1,22 @@ + Automation - Approve Python Log Output Changes - gitStream Documentation

Approve Python Log Output Changes

Approve changes to Python files that only affect lines of code that invoke a specified logging object.

approve Python log output

Configuration Description

Conditions (all must be true):

  • All files must end in .py
  • The changes only affect lines of code that invoke a logger object. This should be customized to your environment.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Python Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_python_log_output:
+    # Triggered for python changes that only affect lines of code that invoke a logger object. 
+    # Modify 'logger' to match your dev environment.
+    if: 
+      - {{ files | match(regex=r/\.py$/) | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^[+-].*logger\.(trace|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+

\ No newline at end of file diff --git a/automations/languages/python/approve-python-log-output/logo_approve_formatting_changes_py.png b/automations/languages/python/approve-python-log-output/logo_approve_formatting_changes_py.png new file mode 100644 index 00000000..74cfa040 Binary files /dev/null and b/automations/languages/python/approve-python-log-output/logo_approve_formatting_changes_py.png differ diff --git a/automations/languages/python/index.html b/automations/languages/python/index.html new file mode 100644 index 00000000..54e5b8a2 --- /dev/null +++ b/automations/languages/python/index.html @@ -0,0 +1,89 @@ + Automation - Integrate gitStream with Python - gitStream Documentation

Automation - Integrate gitStream with Python

Auto-Approve Python Log Output Changes

Approve changes to Python files that only affect lines of code that invoke a specified logging object.

approve Python log output

Configuration Description

Conditions (all must be true):

  • All files must end in .py
  • The changes only affect lines of code that invoke a logger object. This should be customized to your environment.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Python Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_python_log_output:
+    # Triggered for python changes that only affect lines of code that invoke a logger object. 
+    # Modify 'logger' to match your dev environment.
+    if: 
+      - {{ files | match(regex=r/\.py$/) | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^[+-].*logger\.(trace|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+

Auto-Approve Python Formatting Changes

Approve PRs that only contain formatting changes to Python files.

Approve Python Formatting Changes

Configuration Description

Conditions (all must be true):

  • All of the files end in .py.
  • All changes are non-functional

Automation Actions:

  • Approve the PR
  • Apply a code-formatting label.
  • Post a comment that explains the automation.

Approve Python Formatting Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_python_formatting:
+    if:
+      - {{ files | extensions | match(list=['py']) | every }}
+      - {{ source.diff.files | isFormattingChange }}
+    run:
+      - action: approve@v1
+      - action: add-label@v1
+        args:
+          label: code-formatting
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR only contains formatting changes and has been approved.
+

Review Missing Python Tests

Automatically request changes for Python PRs that lack test files.

Review Missing Python Tests

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Python files
  • The PR lacks new test files that match the name of the Python files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Python Tests

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!test_.*\.py$).*\.py$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^tests\/test_.*\.py$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+
+newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!test_.*\.py$).*\.py$/) | filter(attr='original_file', regex=r/^$/) | length }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^tests\/test_.*\.py$/) | filter(attr='original_file', regex=r/^$/) | length }}
+
+automations:
+  review_missing_python_tests:
+    if:
+      - {{ newFilesCount != newTestsCount }}
+    run: 
+      - action: add-label@v1
+        args:
+            label: "⚠️ Missing Tests"
+            color: {{ colors.orange }}    
+      - action: request-changes@v1
+        args:
+          comment: |
+            Some of your new Python files are missing corresponding tests. Please ensure that all new files have a corresponding test file.
+
+            **New Files**: {{ newFilesCount }}
+            {{ newFiles }}
+
+            **New Tests**: {{ newTestsCount }}
+            {{ newTests }}
+colors:
+  orange: 'd93f0b'
+

Review Python Test Name

Automatically request changes for Python test files that fail to match the required naming convention.

Review Python Test Name

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Python test files
  • The Python test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Python test name requirements.

Review Python Test Name

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) | length }}
+
+automations:
+  review_python_test_name:
+    if:
+      - {{ newTestsCount > 0}}     
+      - {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) | match(attr='new_file', regex=r/test_.*\.py$/) | nope }}   
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: |
+              The test file name does not follow the Python test name conventions. A test file name needs to have the prefix test_ before class name. For example, if you are testing a class file called Data.py then the test file name has to be test_data.py.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/languages/python/review-missing-python-tests/approve-formatting-changes-PY.svg b/automations/languages/python/review-missing-python-tests/approve-formatting-changes-PY.svg new file mode 100644 index 00000000..91c13fba --- /dev/null +++ b/automations/languages/python/review-missing-python-tests/approve-formatting-changes-PY.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/python/review-missing-python-tests/index.html b/automations/languages/python/review-missing-python-tests/index.html new file mode 100644 index 00000000..440aaa05 --- /dev/null +++ b/automations/languages/python/review-missing-python-tests/index.html @@ -0,0 +1,32 @@ + Automation - Review Missing Python Tests - gitStream Documentation

Review Missing Python Tests

Automatically request changes for Python PRs that lack test files.

Review Missing Python Tests

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Python files
  • The PR lacks new test files that match the name of the Python files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Python Tests

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!test_.*\.py$).*\.py$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^tests\/test_.*\.py$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+
+newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!test_.*\.py$).*\.py$/) | filter(attr='original_file', regex=r/^$/) | length }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^tests\/test_.*\.py$/) | filter(attr='original_file', regex=r/^$/) | length }}
+
+automations:
+  review_missing_python_tests:
+    if:
+      - {{ newFilesCount != newTestsCount }}
+    run: 
+      - action: add-label@v1
+        args:
+            label: "⚠️ Missing Tests"
+            color: {{ colors.orange }}    
+      - action: request-changes@v1
+        args:
+          comment: |
+            Some of your new Python files are missing corresponding tests. Please ensure that all new files have a corresponding test file.
+
+            **New Files**: {{ newFilesCount }}
+            {{ newFiles }}
+
+            **New Tests**: {{ newTestsCount }}
+            {{ newTests }}
+colors:
+  orange: 'd93f0b'
+
\ No newline at end of file diff --git a/automations/languages/python/review-missing-python-tests/logo_approve_formatting_changes_py.png b/automations/languages/python/review-missing-python-tests/logo_approve_formatting_changes_py.png new file mode 100644 index 00000000..74cfa040 Binary files /dev/null and b/automations/languages/python/review-missing-python-tests/logo_approve_formatting_changes_py.png differ diff --git a/automations/languages/python/review-missing-python-tests/review-missing-python-tests.png b/automations/languages/python/review-missing-python-tests/review-missing-python-tests.png new file mode 100644 index 00000000..b20db9d9 Binary files /dev/null and b/automations/languages/python/review-missing-python-tests/review-missing-python-tests.png differ diff --git a/automations/languages/python/review-python-test-name/approve-formatting-changes-PY.svg b/automations/languages/python/review-python-test-name/approve-formatting-changes-PY.svg new file mode 100644 index 00000000..91c13fba --- /dev/null +++ b/automations/languages/python/review-python-test-name/approve-formatting-changes-PY.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/python/review-python-test-name/index.html b/automations/languages/python/review-python-test-name/index.html new file mode 100644 index 00000000..33a90026 --- /dev/null +++ b/automations/languages/python/review-python-test-name/index.html @@ -0,0 +1,18 @@ + Automation - Review Python Test Name - gitStream Documentation

Review Python Test Name

Automatically request changes for Python test files that fail to match the required naming convention.

Review Python Test Name

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Python test files
  • The Python test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Python test name requirements.

Review Python Test Name

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) | length }}
+
+automations:
+  review_python_test_name:
+    if:
+      - {{ newTestsCount > 0}}     
+      - {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) | match(attr='new_file', regex=r/test_.*\.py$/) | nope }}   
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: |
+              The test file name does not follow the Python test name conventions. A test file name needs to have the prefix test_ before class name. For example, if you are testing a class file called Data.py then the test file name has to be test_data.py.
+
\ No newline at end of file diff --git a/automations/languages/python/review-python-test-name/logo_approve_formatting_changes_py.png b/automations/languages/python/review-python-test-name/logo_approve_formatting_changes_py.png new file mode 100644 index 00000000..74cfa040 Binary files /dev/null and b/automations/languages/python/review-python-test-name/logo_approve_formatting_changes_py.png differ diff --git a/automations/languages/python/review-python-test-name/review-python-test-name.png b/automations/languages/python/review-python-test-name/review-python-test-name.png new file mode 100644 index 00000000..ecbce075 Binary files /dev/null and b/automations/languages/python/review-python-test-name/review-python-test-name.png differ diff --git a/automations/languages/ruby/approve-ruby-log-output/approve-formatting-changes-RB.svg b/automations/languages/ruby/approve-ruby-log-output/approve-formatting-changes-RB.svg new file mode 100644 index 00000000..0427425e --- /dev/null +++ b/automations/languages/ruby/approve-ruby-log-output/approve-formatting-changes-RB.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/ruby/approve-ruby-log-output/index.html b/automations/languages/ruby/approve-ruby-log-output/index.html new file mode 100644 index 00000000..0b93f506 --- /dev/null +++ b/automations/languages/ruby/approve-ruby-log-output/index.html @@ -0,0 +1,21 @@ + Automation - Approve Ruby Log Output Changes - gitStream Documentation

Approve Ruby Log Output Changes

Approve changes to Ruby files that only affect lines of code that invoke the logger object.

approve Ruby log output

Configuration Description

Conditions (all must be true):

  • All files end in .rb
  • The changes only affect lines of code that invoke logger object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Ruby Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_ruby_log_output:
+    # Triggered for Ruby changes that only affect the logger method
+    if: 
+      - {{ files | extensions | match(term='rb') | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^.*logger\.(fatal|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+
\ No newline at end of file diff --git a/automations/languages/ruby/approve-ruby-log-output/logo_approve_formatting_changes_rb.png b/automations/languages/ruby/approve-ruby-log-output/logo_approve_formatting_changes_rb.png new file mode 100644 index 00000000..ed275170 Binary files /dev/null and b/automations/languages/ruby/approve-ruby-log-output/logo_approve_formatting_changes_rb.png differ diff --git a/automations/languages/ruby/index.html b/automations/languages/ruby/index.html new file mode 100644 index 00000000..df6cc962 --- /dev/null +++ b/automations/languages/ruby/index.html @@ -0,0 +1,68 @@ + Automation - Integrate gitStream with Ruby - gitStream Documentation

Automation - Integrate gitStream with Ruby

Approve Ruby Log Output Changes

Approve changes to Ruby files that only affect lines of code that invoke the logger object.

approve Ruby log output

Configuration Description

Conditions (all must be true):

  • All files end in .rb
  • The changes only affect lines of code that invoke logger object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Ruby Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_ruby_log_output:
+    # Triggered for Ruby changes that only affect the logger method
+    if: 
+      - {{ files | extensions | match(term='rb') | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^.*logger\.(fatal|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+

Review Missing Ruby Tests

Automatically request changes for Ruby PRs that lack test files.

Review Missing Ruby Tests

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Ruby files
  • The PR lacks new test files that match the name of the Ruby files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Ruby Tests

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^app\/(?!.*\_spec\.rb$).*\.rb$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/spec\/.*\_spec\.rb$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+
+newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^app\/(?!.*\_spec\.rb$).*\.rb$/) | filter(attr='original_file', regex=r/^$/) | length }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/spec\/.*\_spec\.rb$/) | filter(attr='original_file', regex=r/^$/) | length }}
+
+automations:
+  review_missing_ruby_tests:
+    if:
+      - {{ newFilesCount != newTestsCount }}
+    run: 
+      - action: add-label@v1
+        args:
+            label: "⚠️ Missing Tests"
+            color: {{ colors.orange }}    
+      - action: request-changes@v1
+        args:
+          comment: |
+            Some of your new Ruby files are missing corresponding tests. Please ensure that all new files have a corresponding test file.
+
+            **New Files**: {{ newFilesCount }}
+            {{ newFiles }}
+
+            **New Tests**: {{ newTestsCount }}
+            {{ newTests }}
+colors:
+  orange: 'd93f0b'
+

Review Ruby Test Name

Automatically request changes for Ruby test files that fail to match the required naming convention.

Review Ruby Test Name

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Ruby test files
  • The Ruby test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Ruby test name requirements.

Review Ruby Test Name

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) | length }}
+
+automations:
+  review_ruby_test_name:
+    if:
+      - {{ newTestsCount > 0}}     
+      - {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) | match(attr='new_file', regex=r/_spec.rb$/) | nope }}
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: |
+              The test file name does not follow the Ruby test name conventions. A test file name needs to have the suffix _spec after class name. For example, if you are testing a class file called data.rb then the test file name has to be data_spec.rb.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

\ No newline at end of file diff --git a/automations/languages/ruby/review-missing-ruby-tests/approve-formatting-changes-RB.svg b/automations/languages/ruby/review-missing-ruby-tests/approve-formatting-changes-RB.svg new file mode 100644 index 00000000..0427425e --- /dev/null +++ b/automations/languages/ruby/review-missing-ruby-tests/approve-formatting-changes-RB.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/ruby/review-missing-ruby-tests/index.html b/automations/languages/ruby/review-missing-ruby-tests/index.html new file mode 100644 index 00000000..326082e3 --- /dev/null +++ b/automations/languages/ruby/review-missing-ruby-tests/index.html @@ -0,0 +1,32 @@ + Automation - Review Missing Ruby Tests - gitStream Documentation

Review Missing Ruby Tests

Automatically request changes for Ruby PRs that lack test files.

Review Missing Ruby Tests

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Ruby files
  • The PR lacks new test files that match the name of the Ruby files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Ruby Tests

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^app\/(?!.*\_spec\.rb$).*\.rb$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/spec\/.*\_spec\.rb$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}
+
+newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^app\/(?!.*\_spec\.rb$).*\.rb$/) | filter(attr='original_file', regex=r/^$/) | length }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/spec\/.*\_spec\.rb$/) | filter(attr='original_file', regex=r/^$/) | length }}
+
+automations:
+  review_missing_ruby_tests:
+    if:
+      - {{ newFilesCount != newTestsCount }}
+    run: 
+      - action: add-label@v1
+        args:
+            label: "⚠️ Missing Tests"
+            color: {{ colors.orange }}    
+      - action: request-changes@v1
+        args:
+          comment: |
+            Some of your new Ruby files are missing corresponding tests. Please ensure that all new files have a corresponding test file.
+
+            **New Files**: {{ newFilesCount }}
+            {{ newFiles }}
+
+            **New Tests**: {{ newTestsCount }}
+            {{ newTests }}
+colors:
+  orange: 'd93f0b'
+
\ No newline at end of file diff --git a/automations/languages/ruby/review-missing-ruby-tests/logo_approve_formatting_changes_rb.png b/automations/languages/ruby/review-missing-ruby-tests/logo_approve_formatting_changes_rb.png new file mode 100644 index 00000000..ed275170 Binary files /dev/null and b/automations/languages/ruby/review-missing-ruby-tests/logo_approve_formatting_changes_rb.png differ diff --git a/automations/languages/ruby/review-missing-ruby-tests/review-missing-ruby-tests.png b/automations/languages/ruby/review-missing-ruby-tests/review-missing-ruby-tests.png new file mode 100644 index 00000000..07167563 Binary files /dev/null and b/automations/languages/ruby/review-missing-ruby-tests/review-missing-ruby-tests.png differ diff --git a/automations/languages/ruby/review-ruby-test-name/approve-formatting-changes-RB.svg b/automations/languages/ruby/review-ruby-test-name/approve-formatting-changes-RB.svg new file mode 100644 index 00000000..0427425e --- /dev/null +++ b/automations/languages/ruby/review-ruby-test-name/approve-formatting-changes-RB.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/ruby/review-ruby-test-name/index.html b/automations/languages/ruby/review-ruby-test-name/index.html new file mode 100644 index 00000000..05d83084 --- /dev/null +++ b/automations/languages/ruby/review-ruby-test-name/index.html @@ -0,0 +1,17 @@ + Automation - Review Ruby Test Name - gitStream Documentation

Review Ruby Test Name

Automatically request changes for Ruby test files that fail to match the required naming convention.

Review Ruby Test Name

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Ruby test files
  • The Ruby test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Ruby test name requirements.

Review Ruby Test Name

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) }}
+newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) | length }}
+
+automations:
+  review_ruby_test_name:
+    if:
+      - {{ newTestsCount > 0}}     
+      - {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) | match(attr='new_file', regex=r/_spec.rb$/) | nope }}
+    run: 
+      - action: request-changes@v1
+        args:
+          comment: |
+              The test file name does not follow the Ruby test name conventions. A test file name needs to have the suffix _spec after class name. For example, if you are testing a class file called data.rb then the test file name has to be data_spec.rb.
+
\ No newline at end of file diff --git a/automations/languages/ruby/review-ruby-test-name/logo_approve_formatting_changes_rb.png b/automations/languages/ruby/review-ruby-test-name/logo_approve_formatting_changes_rb.png new file mode 100644 index 00000000..ed275170 Binary files /dev/null and b/automations/languages/ruby/review-ruby-test-name/logo_approve_formatting_changes_rb.png differ diff --git a/automations/languages/ruby/review-ruby-test-name/review-ruby-test-name.png b/automations/languages/ruby/review-ruby-test-name/review-ruby-test-name.png new file mode 100644 index 00000000..c2a7985e Binary files /dev/null and b/automations/languages/ruby/review-ruby-test-name/review-ruby-test-name.png differ diff --git a/automations/languages/rust/approve-rust-log-output/approve-formatting-changes-rs.svg b/automations/languages/rust/approve-rust-log-output/approve-formatting-changes-rs.svg new file mode 100644 index 00000000..08c45159 --- /dev/null +++ b/automations/languages/rust/approve-rust-log-output/approve-formatting-changes-rs.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/automations/languages/rust/approve-rust-log-output/index.html b/automations/languages/rust/approve-rust-log-output/index.html new file mode 100644 index 00000000..bc18b4e5 --- /dev/null +++ b/automations/languages/rust/approve-rust-log-output/index.html @@ -0,0 +1,21 @@ + Automation - Approve Rust Log Output Changes - gitStream Documentation

Approve Rust Log Output Changes

Approve changes to Rust files that only affect lines of code that invoke the logging marcos.

approve Rust log output

Configuration Description

Conditions (all must be true):

  • All files end in .rs
  • The changes only affect lines of code that invoke print, println or dbg macros or use the log crate macros.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Rust Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_rust_log_output:
+    # Triggered for Rust changes that only affect the logging macros
+    if: 
+      - {{ files | extensions | match(term='rs') | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^.*\b(println|print|dbg|error|warn|info|debug|trace)\b!/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+
\ No newline at end of file diff --git a/automations/languages/rust/approve-rust-log-output/logo_approve_formatting_changes_rs.png b/automations/languages/rust/approve-rust-log-output/logo_approve_formatting_changes_rs.png new file mode 100644 index 00000000..e5d13b54 Binary files /dev/null and b/automations/languages/rust/approve-rust-log-output/logo_approve_formatting_changes_rs.png differ diff --git a/automations/languages/rust/index.html b/automations/languages/rust/index.html new file mode 100644 index 00000000..8d40513d --- /dev/null +++ b/automations/languages/rust/index.html @@ -0,0 +1,21 @@ + Automation - Integrate gitStream with Rust - gitStream Documentation

Automation - Integrate gitStream with Rust

Approve Rust Log Output Changes

Approve changes to Rust files that only affect lines of code that invoke the logging marcos.

approve Rust log output

Configuration Description

Conditions (all must be true):

  • All files end in .rs
  • The changes only affect lines of code that invoke print, println or dbg macros or use the log crate macros.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Rust Log Output Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_rust_log_output:
+    # Triggered for Rust changes that only affect the logging macros
+    if: 
+      - {{ files | extensions | match(term='rs') | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/^.*\b(println|print|dbg|error|warn|info|debug|trace)\b!/, ignoreWhiteSpaces=true) | every }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'log-output-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR has been approved because it only contains changes to log output
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/percent-new-code/Calculate-percentage-of-new-code.svg b/automations/percent-new-code/Calculate-percentage-of-new-code.svg new file mode 100644 index 00000000..09e961bd --- /dev/null +++ b/automations/percent-new-code/Calculate-percentage-of-new-code.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/percent-new-code/index.html b/automations/percent-new-code/index.html new file mode 100644 index 00000000..1caf8983 --- /dev/null +++ b/automations/percent-new-code/index.html @@ -0,0 +1,23 @@ + Automation - Calculate the Percentage of New Code - gitStream Documentation

Calculate the Percentage of New Code

Post a comment that indicates what percentage of the PR contains new code.

Percent new code

Configuration Description

Conditions (all must be true):

  • Any PR

Automation Actions:

  • Use the changes custom expression to post a comment that indicates what percentage of the PR is new code.

Calculate the Percentage of New Code

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  percent_new_code:
+    if:
+      - true
+    run: 
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR is {{ changes.ratio }}% new code.
+
+changes:
+  # Sum all the lines added/edited in the PR
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+  # Sum all the line removed in the PR
+  deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}
+  # Calculate the ratio of new code
+  ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/percent-new-code/logo_calculate_percentage_of_new_code.png b/automations/percent-new-code/logo_calculate_percentage_of_new_code.png new file mode 100644 index 00000000..5fd77766 Binary files /dev/null and b/automations/percent-new-code/logo_calculate_percentage_of_new_code.png differ diff --git a/automations/percent-new-code/percent_new_code.png b/automations/percent-new-code/percent_new_code.png new file mode 100644 index 00000000..b7016a10 Binary files /dev/null and b/automations/percent-new-code/percent_new_code.png differ diff --git a/automations/provide-estimated-time-to-review/estimated_time_to_review.svg b/automations/provide-estimated-time-to-review/estimated_time_to_review.svg new file mode 100644 index 00000000..83127ad8 --- /dev/null +++ b/automations/provide-estimated-time-to-review/estimated_time_to_review.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/automations/provide-estimated-time-to-review/index.html b/automations/provide-estimated-time-to-review/index.html new file mode 100644 index 00000000..497b5c79 --- /dev/null +++ b/automations/provide-estimated-time-to-review/index.html @@ -0,0 +1,24 @@ + Automation - Provide Estimated Time to Review - gitStream Documentation

Provide Estimated Time to Review

Label all PRs with an estimated number of minutes it would take someone to review. gitStream will automatically update this label whenever a PR changes.

Estimated time to review

Configuration Description

Conditions (all must be true):

  • Any new PR or change to an existing PR.

Automation Actions:

  • Apply a color coded label that provides an estimated number of minutes someone will need to review the PR.

Provide Estimated Time to Review

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  estimated_time_to_review:
+    if:
+      - true
+    run:
+      - action: add-label@v1
+        args:
+          label: "{{ calc.etr }} min review"
+          color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}
+
+calc:
+  etr: {{ branch | estimatedReviewTime }}
+
+
+colors:
+  red: 'b60205'
+  yellow: 'fbca04'
+  green: '0e8a16'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/provide-estimated-time-to-review/logo_estimated_time_to_review.png b/automations/provide-estimated-time-to-review/logo_estimated_time_to_review.png new file mode 100644 index 00000000..73fec47a Binary files /dev/null and b/automations/provide-estimated-time-to-review/logo_estimated_time_to_review.png differ diff --git a/automations/provide-estimated-time-to-review/provide_estimated_time_to_review.png b/automations/provide-estimated-time-to-review/provide_estimated_time_to_review.png new file mode 100644 index 00000000..7b60ba4a Binary files /dev/null and b/automations/provide-estimated-time-to-review/provide_estimated_time_to_review.png differ diff --git a/automations/request-screenshot/Request-screenshot.svg b/automations/request-screenshot/Request-screenshot.svg new file mode 100644 index 00000000..3c57c3d1 --- /dev/null +++ b/automations/request-screenshot/Request-screenshot.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/request-screenshot/index.html b/automations/request-screenshot/index.html new file mode 100644 index 00000000..6f05a2dc --- /dev/null +++ b/automations/request-screenshot/index.html @@ -0,0 +1,24 @@ + Automation - Request Screenshot - gitStream Documentation

Request Screenshot

If the PR lacks an image file, or link to an image in the description, apply a no-screenshot label and post a comment to request a screenshot. If the PR author updates the description, gitStream will remove the label.

Request Screenshot

Configuration Description

Conditions (all must be true):

  • The PR description lacks an image or link to an image.

Automation Actions:

  • Apply a no-screenshot label.
  • Post a comment that requests a screenshot. Update this action to provide specific context for your project.

Request Screenshot

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations: 
+  request_screenshot:
+    # Triggered for PRs that lack an image file or link to an image in the PR description
+    if:
+      - {{ not (has.screenshot_link or has.image_uploaded) }}
+    run:
+      - action: add-label@v1
+        args:
+          label: 'no-screenshot'
+          color: '#FF000A'
+      - action: add-comment@v1
+        args:
+          comment: |
+            Be a life saver 🛟 by adding a screenshot of the changes you made.
+
+has:
+  screenshot_link: {{ pr.description | includes(regex=r/!\[.*\]\(.*(jpg|svg|png|gif|psd).*\)/) }}
+  image_uploaded: {{ pr.description | includes(regex=r/<img.*src.*(jpg|svg|png|gif|psd).*>/) }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/request-screenshot/logo_request_screenshot.png b/automations/request-screenshot/logo_request_screenshot.png new file mode 100644 index 00000000..6d3af6c5 Binary files /dev/null and b/automations/request-screenshot/logo_request_screenshot.png differ diff --git a/automations/request-screenshot/request-screenshot.png b/automations/request-screenshot/request-screenshot.png new file mode 100644 index 00000000..04dddf40 Binary files /dev/null and b/automations/request-screenshot/request-screenshot.png differ diff --git a/automations/standard/branch-management/enforce-branch-name/enforce-branch-name.png b/automations/standard/branch-management/enforce-branch-name/enforce-branch-name.png new file mode 100644 index 00000000..100141a9 Binary files /dev/null and b/automations/standard/branch-management/enforce-branch-name/enforce-branch-name.png differ diff --git a/automations/standard/branch-management/enforce-branch-name/index.html b/automations/standard/branch-management/enforce-branch-name/index.html new file mode 100644 index 00000000..a5ccb071 --- /dev/null +++ b/automations/standard/branch-management/enforce-branch-name/index.html @@ -0,0 +1,27 @@ + Automation - Enforce Branch Naming Conventions - gitStream Documentation

Enforce Branch Naming Conventions

Automatically enforce prefixes or keywords in PR branch names.

Enforce Branch Naming Conventions

Configuration Description

Conditions (all must be true):

  • The incoming branch name is missing a required prefix feature fix or stable
  • The invoming branch name fails to match a specified regex pattern. In this case abc- followed by a number.
  • The incoming branch name is not listed in an ignoreList custom expression.

Automation Actions:

  • Post a comment explaining the branch name requirements.
  • Apply a red label: ❗ Incorrect Branch Name
  • Close the PR.

Enforce Branch Naming Conventions

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  enforce_branch_name: 
+    if:  
+      - {{ not has.requiredBranchPrefix }}
+      - {{ not has.requiredBranchKeyword }}
+      - {{ not ignoreList }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "❗ Incorrect Branch Name"
+          color: {{ colors.red }}
+      - action: add-comment@v1
+        args:
+          comment: |
+            All PR branch names must be prefixed by feature, stable, or fix, and must contain a reference to a Jira ticket. E.g. 'feature-abc-1234'
+            Please move your changes to a new branch that meets these requirements and open a new PR.
+      - action: close@v1
+
+has:
+  requiredBranchPrefix: {{ branch.name | includes(regex=r/^(feature|stable|fix)/) }}
+  requiredBranchKeyword: {{ branch.name | includes(regex=r/abc+-\d+/) }}
+
+ignoreList: {{ branch.name | match(regex=r/^(development|staging)/) }}
+

\ No newline at end of file diff --git a/automations/standard/branch-management/index.html b/automations/standard/branch-management/index.html new file mode 100644 index 00000000..d0cb4b1f --- /dev/null +++ b/automations/standard/branch-management/index.html @@ -0,0 +1,27 @@ + Automation - Manage git Branches With gitStream - gitStream Documentation

Manage git Branches With gitStream

Use gitStream to enforce branch naming conventions, review assignment, and other branch managment workflows.

Enforce Branch Naming Conventions - Automatically enforce prefixes or keywords in PR branch names.

Assign Reviewers Based on Target Branch - Automatically assign PR reviewers for target branches that include a specified keyword.

Enforce Branch Naming Conventions

Enforce Branch Naming Conventions

Automatically enforce prefixes or keywords in PR branch names.

Enforce Branch Naming Conventions

Configuration Description

Conditions (all must be true):

  • The incoming branch name is missing a required prefix feature fix or stable
  • The invoming branch name fails to match a specified regex pattern. In this case abc- followed by a number.
  • The incoming branch name is not listed in an ignoreList custom expression.

Automation Actions:

  • Post a comment explaining the branch name requirements.
  • Apply a red label: ❗ Incorrect Branch Name
  • Close the PR.

Enforce Branch Naming Conventions

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  enforce_branch_name: 
+    if:  
+      - {{ not has.requiredBranchPrefix }}
+      - {{ not has.requiredBranchKeyword }}
+      - {{ not ignoreList }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "❗ Incorrect Branch Name"
+          color: {{ colors.red }}
+      - action: add-comment@v1
+        args:
+          comment: |
+            All PR branch names must be prefixed by feature, stable, or fix, and must contain a reference to a Jira ticket. E.g. 'feature-abc-1234'
+            Please move your changes to a new branch that meets these requirements and open a new PR.
+      - action: close@v1
+
+has:
+  requiredBranchPrefix: {{ branch.name | includes(regex=r/^(feature|stable|fix)/) }}
+  requiredBranchKeyword: {{ branch.name | includes(regex=r/abc+-\d+/) }}
+
+ignoreList: {{ branch.name | match(regex=r/^(development|staging)/) }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/enforce-copyright-header/enforce-copyright-header.png b/automations/standard/enforce-copyright-header/enforce-copyright-header.png new file mode 100644 index 00000000..ba501259 Binary files /dev/null and b/automations/standard/enforce-copyright-header/enforce-copyright-header.png differ diff --git a/automations/standard/enforce-copyright-header/index.html b/automations/standard/enforce-copyright-header/index.html new file mode 100644 index 00000000..6c6c0e9d --- /dev/null +++ b/automations/standard/enforce-copyright-header/index.html @@ -0,0 +1,20 @@ + Automation - Enforce Copyright Headers - gitStream Documentation

Enforce Copyright Headers

Automatically require copyright headers for all new source code files.

Enforce Copyright Headers

Configuration Description

Conditions (all must be true):

  • The PR creates a new file inside the /src directory that lacks a specified copyright header at the top of the file.

Automation Actions:

  • Request changes and post a comment that explains the copyright header requirement.

Enforce Copyright Headers

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  enforce_copyright_header: 
+    if:   
+      - {{ source.diff.files | filter(attr='new_file', regex=r/src\//) | map(attr='original_file') | match(regex=r/^$/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=licence.licenceRegex) | nope }}
+
+    run:
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            All new files in the '/src' directory must include the required copyright header at the top of the file. For example:
+              // Copyright (c) ORG  and contributors. All rights reserved.
+             // Licensed under the MIT license. See LICENSE file in the project root for details.
+
+licence:
+  licenceRegex: r/(Copyright \(c\) )|(Licensed under the MIT license)/
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/enforce-pr-title/enforce-pr-title.png b/automations/standard/enforce-pr-title/enforce-pr-title.png new file mode 100644 index 00000000..69724e7b Binary files /dev/null and b/automations/standard/enforce-pr-title/enforce-pr-title.png differ diff --git a/automations/standard/enforce-pr-title/index.html b/automations/standard/enforce-pr-title/index.html new file mode 100644 index 00000000..74576d01 --- /dev/null +++ b/automations/standard/enforce-pr-title/index.html @@ -0,0 +1,31 @@ + Automation - Enforce PR Semantic Titles - gitStream Documentation

Enforce PR Semantic Title Names

Automatically enforce PR naming conventions; this example expects the format: <type>(<scope>): <short summary>

Enforce PR Semantic Title Names

Configuration Description

Conditions (all must be true):

  • The PR fails to follow a predefined semantic release format:

Automation Actions:

  • Request changes and post a comment explaining why.

Enforce PR Semantic Title Names

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  enforce_pr_title: 
+    if:       
+      - {{ pr.title | match(regex=titlePolicy.titleRegex) | nope }}
+    run:
+      - action: request-changes@v1
+        args: 
+          comment: | 
+            All PRs must be titled according to our semantic naming policy: `<type>(<scope>): <short summary>`
+
+            Type must be one of the following:
+
+             * build
+             * ci 
+             * docs
+             * feature
+             * fix
+
+            Scope must be one of the following:
+
+             * common
+             * core
+             * elements
+             * forms
+             * http 
+titlePolicy:
+    titleRegex: r/\b(build|ci|docs|feature|fix)\b\s*\((common|core|elements|forms|http)\):\s*\w+.*/
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/explain-code-experts/explain-code-experts.png b/automations/standard/explain-code-experts/explain-code-experts.png new file mode 100644 index 00000000..00eca829 Binary files /dev/null and b/automations/standard/explain-code-experts/explain-code-experts.png differ diff --git a/automations/standard/explain-code-experts/explain-code-experts.svg b/automations/standard/explain-code-experts/explain-code-experts.svg new file mode 100644 index 00000000..515968ac --- /dev/null +++ b/automations/standard/explain-code-experts/explain-code-experts.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/standard/explain-code-experts/index.html b/automations/standard/explain-code-experts/index.html new file mode 100644 index 00000000..a031bfd8 --- /dev/null +++ b/automations/standard/explain-code-experts/index.html @@ -0,0 +1,14 @@ + Automation - Explain Code Experts - gitStream Documentation

Explain Code Experts

Post a comment that uses git blame and history to list the most relevant experts for all PRs. The comment will automatically update as additional commits are added to the PR.

Explain Code Experts

Configuration Description

Conditions (all must be true):

  • A PR is created or modified.

Automation Actions:

  • Post a comment that identifies the people with the highest level of code expetise.

Explain Code Experts

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  explain_code_experts:
+    if:
+      - {{ pr.labels | match(term='suggest-reviewer') | some }}
+    run:
+      - action: explain-code-experts@v1 
+        args:
+          gt: 10 
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/explain-code-experts/logo_explain_code_experts.png b/automations/standard/explain-code-experts/logo_explain_code_experts.png new file mode 100644 index 00000000..6f5b6c03 Binary files /dev/null and b/automations/standard/explain-code-experts/logo_explain_code_experts.png differ diff --git a/automations/standard/flag-merged-no-review/flag-merged-no-review.png b/automations/standard/flag-merged-no-review/flag-merged-no-review.png new file mode 100644 index 00000000..32fa18ec Binary files /dev/null and b/automations/standard/flag-merged-no-review/flag-merged-no-review.png differ diff --git a/automations/standard/flag-merged-no-review/index.html b/automations/standard/flag-merged-no-review/index.html new file mode 100644 index 00000000..2c413797 --- /dev/null +++ b/automations/standard/flag-merged-no-review/index.html @@ -0,0 +1,40 @@ + Automation - Flag Code That's Merged Without Review - gitStream Documentation

Flag Code That's Merged Without Review

Automatically send notifications to your team when code is merged without review.

Flag Code That's Merged Without Review

Slack Message

Configuration Description

Conditions (all must be true):

  • A PR is merged without at least one review.

Automation Actions:

  • Send a Slack notification to alert your team.
  • Apply a red DCF5-merged-without-review label.
  • Post a comment explaining SOC II requirements.

Flag Code That's Merged Without Review

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+on:
+  - merge
+
+# https://docs.gitstream.cm/automation-actions/#send-slack-message
+slack_webhook: {{ env.SLACK_WEBHOOK }}
+
+# Update security_team to match your organization
+security_team: 'my-org/app-sec'
+
+automations:
+  flag_merged_no_review:
+    if:
+      - {{ pr.approvals | length == 0 }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "DCF5-merged-without-review"
+          color: {{ colors.red }}
+
+      - action: send-slack-message@v1
+        args:
+          message: "PR #{{ pr.number }} - {{ pr.title }} - was merged without peer reviews. SOC2 requires code reviews for every code change. _SOC2 ref: CC8.1_"
+          webhook_url: "{{ slack_webhook }}"
+
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR was merged without peer reviews. SOC2 requires code reviews for every code change.
+            _SOC2 ref: CC8.1_
+
+            @{{ security_team }}
+
+
+colors:
+  red: 'F6443B'
+
\ No newline at end of file diff --git a/automations/standard/flag-merged-no-review/slack-message.png b/automations/standard/flag-merged-no-review/slack-message.png new file mode 100644 index 00000000..8c14b56e Binary files /dev/null and b/automations/standard/flag-merged-no-review/slack-message.png differ diff --git a/automations/standard/label-management/enforce-labels/enforce-labels.png b/automations/standard/label-management/enforce-labels/enforce-labels.png new file mode 100644 index 00000000..4f18a5eb Binary files /dev/null and b/automations/standard/label-management/enforce-labels/enforce-labels.png differ diff --git a/automations/standard/label-management/enforce-labels/index.html b/automations/standard/label-management/enforce-labels/index.html new file mode 100644 index 00000000..7b55fe58 --- /dev/null +++ b/automations/standard/label-management/enforce-labels/index.html @@ -0,0 +1,12 @@ + Automation - Enforce Required Labels - gitStream Documentation

Enforce Required Labels

Automatically enforce the use of required PR labels.

Enforce Required Labels

Configuration Description

Conditions (all must be true):

  • The PR lacks one or more labels from a list of required labels.

Automation Actions:

  • Apply a Missing Required Labels label.
  • Post a comment explaining why the label was applied and which labels are required.

Enforce Required Labels

manifest:
+  version: 1.0
+
+automations:
+  enforce_required_labels:
+    if:
+      - {{ pr.labels | match(list=['Core', 'Mobile', 'UI']) | nope }}
+    run:
+      - action: request-changes@v1
+        args:
+          comment: Please ensure that your PR is labeled with either 'Core', 'Mobile', or 'UI'. These labels help us to better track and manage your contribution. Thank you.
+
\ No newline at end of file diff --git a/automations/standard/label-management/index.html b/automations/standard/label-management/index.html new file mode 100644 index 00000000..fa36da91 --- /dev/null +++ b/automations/standard/label-management/index.html @@ -0,0 +1,124 @@ + Automation - Automate PR Labels With gitStream - gitStream Documentation

PR Label Management with gitStream

Use YAML to automate label management on your git repo with gitStream.

Enforce Required Labels

Enforce Required Labels

Automatically enforce the use of required PR labels.

Enforce Required Labels

Configuration Description

Conditions (all must be true):

  • The PR lacks one or more labels from a list of required labels.

Automation Actions:

  • Apply a Missing Required Labels label.
  • Post a comment explaining why the label was applied and which labels are required.

Enforce Required Labels

manifest:
+  version: 1.0
+
+automations:
+  enforce_required_labels:
+    if:
+      - {{ pr.labels | match(list=['Core', 'Mobile', 'UI']) | nope }}
+    run:
+      - action: request-changes@v1
+        args:
+          comment: Please ensure that your PR is labeled with either 'Core', 'Mobile', or 'UI'. These labels help us to better track and manage your contribution. Thank you.
+

Label Modified Resources

Label Changed Resources By Percent

Apply a label to all PRs that indicates what percentage of new lines of code modify one or more specified resources.

Label Changed Resources By Percent

Configuration Description

Conditions (all must be true):

  • A PR modifies resources listed in one or more specified locations.

Automation Actions:

  • Apply labels that indicate what percentage of new code lines modify the specified resources.

Label Changed Resources By Percent

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in labels %}
+  label_resource_percent_{{ item.name }}:
+      if:
+        - {{ files | match(list=item.resources) | some }}
+      run:
+        - action: add-label@v1
+          args:
+            label: '{{ item.additions | round }}% {{ item.name }}'
+  {% endfor %}
+
+resources:
+  core:
+    - src/app
+    - src/core
+  mobile: 
+    - src/android
+    - src/ios
+  docs:
+    - docs/
+
+labels:
+  - name: Core
+    resources: {{ resources.core }}
+    additions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.core ) | map(attr='additions') | sum / total.additions * 100 }}
+  - name: Mobile
+    resources: {{ resources.mobile }}
+    additions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.mobile ) | map(attr='additions') | sum / total.additions * 100 }}
+  - name: Docs
+    resources: {{ resources.docs }}
+    additions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.docs ) | map(attr='additions') | sum / total.additions * 100 }}
+
+total:
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+

Label PRs by Language

Automatically detect which programming languages are contained in PRs and automatically label the PRs appropriately.

Label PRs by Language

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Label the PR for each programming language that is included.

Label PRs by Language

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in labels %}
+  label_{{ item.name }}_pr:
+      if:
+        - {{ files | match(regex=item.resources) | some }}
+      run:
+        - action: add-label@v1
+          args:
+            label: '{{ item.name }}'
+  {% endfor %}
+
+labels:
+  - name: Java
+    resources: r/.java$/
+  - name: Rust
+    resources: r/.rs$/
+  - name: HTML
+    resources: r/.html$/
+  - name: JavaScript
+    resources: r/.js$/
+  - name: Python
+    resources: r/.py$/
+  - name: Golang
+    resources: r/.go$/
+  - name: Ruby
+    resources: r/.rb$/
+  - name: CSS
+    resources: r/.css/
+

Label the Number of Unresolved Code Review Threads


Label Unresolved Review Threads

Automatically label PRs when there are unresolved code review comments.

Label Unresolved Review Threads

Configuration Description

Conditions (all must be true):

  • The PR has one or more unresolved code review comments.

Automation Actions:

  • Apply a label that indicates how many unresolved comments the PR has.

Label Unresolved Review Threads

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  label_unresolved_threads:  
+    if:  
+      - {{ pr.unresolved_threads }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ pr.unresolved_threads }} Unresolved Thread(s)
+          color: {{ colors.yellow }}
+
+colors:
+  yellow: 'fbca04'
+

Automatically Recommend Labels for New PRs

Suggest Labels

Automatically suggest labels to apply to new PRs.

Suggest Labels

Configuration Description

Conditions (all must be true):

  • A PR is created or updated that has no labels.

Automation Actions:

  • Post a comment that suggest labels the author can apply to the PR.

Suggest Labels

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  suggest_labels:  
+    if:  
+      - {{ pr.labels | length == 0}}
+    run:
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            All PRs must contain labels that indicate which CI/CD systems must be run. PLease update your PR to include one of the following labels: `Build: Mobile`, `Build: UI`, `Build: All`, `Build: None`
+
+            Additionally, Here are some labels you can apply to this PR that may be helpful:
+               * Suggest Reviewer - Use this if you aren't sure who to assign as the reviewer.
+               * WIP - Indicate this is a work in progress that shouldn't be merged.
+

Label PRs with the Number of Approvals

Label the Number of Approvals

Automatically label PRs with the number of completed reviews that approve the PR.

Label the Number of Approvals

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Apply or update a label that indicates how many merge approvals have been granted.

Label the Number of Approvals

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  label_approvals: 
+    if:  
+      - {{ pr.approvals | length > 0 }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ pr.approvals | length }} Approved Review(s)
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for help with these examples.

\ No newline at end of file diff --git a/automations/standard/label-management/label-approvals/index.html b/automations/standard/label-management/label-approvals/index.html new file mode 100644 index 00000000..30158c0d --- /dev/null +++ b/automations/standard/label-management/label-approvals/index.html @@ -0,0 +1,12 @@ + Automation - Label the Number of Approvals - gitStream Documentation

Label the Number of Approvals

Automatically label PRs with the number of completed reviews that approve the PR.

Label the Number of Approvals

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Apply or update a label that indicates how many merge approvals have been granted.

Label the Number of Approvals

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  label_approvals: 
+    if:  
+      - {{ pr.approvals | length > 0 }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ pr.approvals | length }} Approved Review(s)
+
\ No newline at end of file diff --git a/automations/standard/label-management/label-approvals/label-approvals.png b/automations/standard/label-management/label-approvals/label-approvals.png new file mode 100644 index 00000000..3e249411 Binary files /dev/null and b/automations/standard/label-management/label-approvals/label-approvals.png differ diff --git a/automations/standard/label-management/label-modified-resources/index.html b/automations/standard/label-management/label-modified-resources/index.html new file mode 100644 index 00000000..84846cb6 --- /dev/null +++ b/automations/standard/label-management/label-modified-resources/index.html @@ -0,0 +1,26 @@ + Automation - Label Modified Resources - gitStream Documentation

Label Based on Modified Resources

Automatically label PRs to indicate what resources are being changed.

Label Modified Resources

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Apply labels based on the branch name or modified resources.

Label Modified Resources

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in labels %}
+  label_resource_{{ item.name }}:
+      if:
+        -{{ branch.name | includes(regex=item.branch) or files | match(list=item.resources) }}
+      run:
+        - action: add-label@v1
+          args:
+            label: {{ item.name }}
+  {% endfor %}
+
+labels:
+  - name: Core
+    resources:
+    - src/app
+    branch: r/^core-/
+  - name: mobile
+    resources:
+    - src/android
+    - src/ios
+    branch: r/^mobile-/
+

\ No newline at end of file diff --git a/automations/standard/label-management/label-modified-resources/label-modified-resources.png b/automations/standard/label-management/label-modified-resources/label-modified-resources.png new file mode 100644 index 00000000..26f9d03a Binary files /dev/null and b/automations/standard/label-management/label-modified-resources/label-modified-resources.png differ diff --git a/automations/standard/label-management/label-prs-by-language/index.html b/automations/standard/label-management/label-prs-by-language/index.html new file mode 100644 index 00000000..b2e03ca3 --- /dev/null +++ b/automations/standard/label-management/label-prs-by-language/index.html @@ -0,0 +1,33 @@ + Automation - Label PRs by Language - gitStream Documentation

Label PRs by Language

Automatically detect which programming languages are contained in PRs and automatically label the PRs appropriately.

Label PRs by Language

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Label the PR for each programming language that is included.

Label PRs by Language

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in labels %}
+  label_{{ item.name }}_pr:
+      if:
+        - {{ files | match(regex=item.resources) | some }}
+      run:
+        - action: add-label@v1
+          args:
+            label: '{{ item.name }}'
+  {% endfor %}
+
+labels:
+  - name: Java
+    resources: r/.java$/
+  - name: Rust
+    resources: r/.rs$/
+  - name: HTML
+    resources: r/.html$/
+  - name: JavaScript
+    resources: r/.js$/
+  - name: Python
+    resources: r/.py$/
+  - name: Golang
+    resources: r/.go$/
+  - name: Ruby
+    resources: r/.rb$/
+  - name: CSS
+    resources: r/.css/
+

\ No newline at end of file diff --git a/automations/standard/label-management/label-prs-by-language/label-prs-by-language.png b/automations/standard/label-management/label-prs-by-language/label-prs-by-language.png new file mode 100644 index 00000000..71b72020 Binary files /dev/null and b/automations/standard/label-management/label-prs-by-language/label-prs-by-language.png differ diff --git a/automations/standard/label-management/label-resources-percent/index.html b/automations/standard/label-management/label-resources-percent/index.html new file mode 100644 index 00000000..218257cb --- /dev/null +++ b/automations/standard/label-management/label-resources-percent/index.html @@ -0,0 +1,39 @@ + Automation - Label Changed Resources By Percent - gitStream Documentation

Label Changed Resources By Percent

Apply a label to all PRs that indicates what percentage of new lines of code modify one or more specified resources.

Label Changed Resources By Percent

Configuration Description

Conditions (all must be true):

  • A PR modifies resources listed in one or more specified locations.

Automation Actions:

  • Apply labels that indicate what percentage of new code lines modify the specified resources.

Label Changed Resources By Percent

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in labels %}
+  label_resource_percent_{{ item.name }}:
+      if:
+        - {{ files | match(list=item.resources) | some }}
+      run:
+        - action: add-label@v1
+          args:
+            label: '{{ item.additions | round }}% {{ item.name }}'
+  {% endfor %}
+
+resources:
+  core:
+    - src/app
+    - src/core
+  mobile: 
+    - src/android
+    - src/ios
+  docs:
+    - docs/
+
+labels:
+  - name: Core
+    resources: {{ resources.core }}
+    additions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.core ) | map(attr='additions') | sum / total.additions * 100 }}
+  - name: Mobile
+    resources: {{ resources.mobile }}
+    additions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.mobile ) | map(attr='additions') | sum / total.additions * 100 }}
+  - name: Docs
+    resources: {{ resources.docs }}
+    additions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.docs ) | map(attr='additions') | sum / total.additions * 100 }}
+
+total:
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+
\ No newline at end of file diff --git a/automations/standard/label-management/label-resources-percent/label-resources-percent.png b/automations/standard/label-management/label-resources-percent/label-resources-percent.png new file mode 100644 index 00000000..2088bdc3 Binary files /dev/null and b/automations/standard/label-management/label-resources-percent/label-resources-percent.png differ diff --git a/automations/standard/label-management/label-unresolved-threads/Label-unresolved-thread.svg b/automations/standard/label-management/label-unresolved-threads/Label-unresolved-thread.svg new file mode 100644 index 00000000..f27f4983 --- /dev/null +++ b/automations/standard/label-management/label-unresolved-threads/Label-unresolved-thread.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/standard/label-management/label-unresolved-threads/index.html b/automations/standard/label-management/label-unresolved-threads/index.html new file mode 100644 index 00000000..bdaa3ce1 --- /dev/null +++ b/automations/standard/label-management/label-unresolved-threads/index.html @@ -0,0 +1,16 @@ + Automation - Label Unresolved Review Threads - gitStream Documentation

Label Unresolved Review Threads

Automatically label PRs when there are unresolved code review comments.

Label Unresolved Review Threads

Configuration Description

Conditions (all must be true):

  • The PR has one or more unresolved code review comments.

Automation Actions:

  • Apply a label that indicates how many unresolved comments the PR has.

Label Unresolved Review Threads

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  label_unresolved_threads:  
+    if:  
+      - {{ pr.unresolved_threads }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ pr.unresolved_threads }} Unresolved Thread(s)
+          color: {{ colors.yellow }}
+
+colors:
+  yellow: 'fbca04'
+
\ No newline at end of file diff --git a/automations/standard/label-management/label-unresolved-threads/label-unresolved-threads.png b/automations/standard/label-management/label-unresolved-threads/label-unresolved-threads.png new file mode 100644 index 00000000..90eddb72 Binary files /dev/null and b/automations/standard/label-management/label-unresolved-threads/label-unresolved-threads.png differ diff --git a/automations/standard/label-management/suggest-labels/index.html b/automations/standard/label-management/suggest-labels/index.html new file mode 100644 index 00000000..d1dd1796 --- /dev/null +++ b/automations/standard/label-management/suggest-labels/index.html @@ -0,0 +1,17 @@ + Automation - PR Label Guidance - gitStream Documentation

Suggest Labels

Automatically suggest labels to apply to new PRs.

Suggest Labels

Configuration Description

Conditions (all must be true):

  • A PR is created or updated that has no labels.

Automation Actions:

  • Post a comment that suggest labels the author can apply to the PR.

Suggest Labels

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  suggest_labels:  
+    if:  
+      - {{ pr.labels | length == 0}}
+    run:
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            All PRs must contain labels that indicate which CI/CD systems must be run. PLease update your PR to include one of the following labels: `Build: Mobile`, `Build: UI`, `Build: All`, `Build: None`
+
+            Additionally, Here are some labels you can apply to this PR that may be helpful:
+               * Suggest Reviewer - Use this if you aren't sure who to assign as the reviewer.
+               * WIP - Indicate this is a work in progress that shouldn't be merged.
+
\ No newline at end of file diff --git a/automations/standard/label-management/suggest-labels/suggest-labels.png b/automations/standard/label-management/suggest-labels/suggest-labels.png new file mode 100644 index 00000000..df63b910 Binary files /dev/null and b/automations/standard/label-management/suggest-labels/suggest-labels.png differ diff --git a/automations/standard/link-issue-tracker/index.html b/automations/standard/link-issue-tracker/index.html new file mode 100644 index 00000000..2628e8c1 --- /dev/null +++ b/automations/standard/link-issue-tracker/index.html @@ -0,0 +1,49 @@ + Automation - Automatic Project Tracker Links - gitStream Documentation

Automatic Project Tracker Links

Post a PR comment that links the associated resource in your issue tracker, such as Jira, Azure Boards, Shortcut, Asana, and more.

Link Issue Tracker

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to project tracking tickets in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated project tracking resource.

Link Issue Tracker

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+# Configure these to match your organization.
+provider: jira
+orgName: org
+asanaProject: 1234
+azureProject: my_project
+
+{% set ticketid = "" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  comment_issue_tracker:
+    if:
+      - {{ has.ticket_in_title or has.ticket_in_branch }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})
+
+has:
+  ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}
+  ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}
+
+tracker:
+  jira:
+    baseurl: https://[orgName].atlassian.net/browse/
+    pattern: r/\b[A-Za-z]+-\d+\b/
+  asana:
+    baseurl: https://app.asana.com/0/[asanaProject]/0/
+    pattern: r/asana-(\d+)/
+  azure:
+    baseurl: https://dev.azure.com/[orgName]/[azureProject]/_workitems/
+    pattern: r/(\w+)-(\w+)-(\d+)/
+  shortcut:
+    baseurl: https://app.shortcut.com/[orgName]/story/
+    pattern: r/(\w+)\/sc-(\d+)/
+
+tickets:
+  - {{branch.name | capture(regex=tracker[provider].pattern)}}
+  - {{pr.title | capture(regex=tracker[provider].pattern)}}
+
\ No newline at end of file diff --git a/automations/standard/link-issue-tracker/link-issue-tracker.png b/automations/standard/link-issue-tracker/link-issue-tracker.png new file mode 100644 index 00000000..c88dc99a Binary files /dev/null and b/automations/standard/link-issue-tracker/link-issue-tracker.png differ diff --git a/automations/standard/review-assignment/assign-code-experts/assign-code-experts.svg b/automations/standard/review-assignment/assign-code-experts/assign-code-experts.svg new file mode 100644 index 00000000..e8ef07e7 --- /dev/null +++ b/automations/standard/review-assignment/assign-code-experts/assign-code-experts.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automations/standard/review-assignment/assign-code-experts/assign_code_experts.png b/automations/standard/review-assignment/assign-code-experts/assign_code_experts.png new file mode 100644 index 00000000..ac7118df Binary files /dev/null and b/automations/standard/review-assignment/assign-code-experts/assign_code_experts.png differ diff --git a/automations/standard/review-assignment/assign-code-experts/index.html b/automations/standard/review-assignment/assign-code-experts/index.html new file mode 100644 index 00000000..654b0ca1 --- /dev/null +++ b/automations/standard/review-assignment/assign-code-experts/index.html @@ -0,0 +1,20 @@ + Automation - Assign Code Experts - gitStream Documentation

Assign Code Experts

When someone applies a suggest-reviewers label to a PR, use codeExperts to assign recommended reviewers and post a comment with the explainCodeExperts automation action.

Assign Code Experts

Configuration Description

Conditions (all must be true):

  • The PR has a suggest-reviewers label attached to it.

Automation Actions:

  • Use codeExperts to assign recommended reviewers.
  • Use explainCodeExperts to post a comment that lists the top code experts for the PR.

Assign Code Experts

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  assign_code_experts:
+    # Triggered when someone applies a suggest-reviewer label to a PR.
+    if: 
+      - {{ pr.labels | match(term='suggest-reviewer') | some }}
+    # More info about code experts
+    # https://docs.gitstream.cm/filter-functions/#codeexperts
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: {{ repo | codeExperts(gt=10) }}
+      - action: explain-code-experts@v1 
+        args:
+          gt: 10 
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/review-assignment/assign-code-experts/logo_assign_code_experts.png b/automations/standard/review-assignment/assign-code-experts/logo_assign_code_experts.png new file mode 100644 index 00000000..75443237 Binary files /dev/null and b/automations/standard/review-assignment/assign-code-experts/logo_assign_code_experts.png differ diff --git a/automations/standard/review-assignment/index.html b/automations/standard/review-assignment/index.html new file mode 100644 index 00000000..359def7f --- /dev/null +++ b/automations/standard/review-assignment/index.html @@ -0,0 +1,203 @@ + Automation - Code Review Assignment with gitStream - gitStream Documentation

Use gitStream for Automatic Code Review Assignment

Automatically assign code reviews based on changed resources, code expertise, branch, and more.

Assign Code Experts

When someone applies a suggest-reviewers label to a PR, use codeExperts to assign recommended reviewers and post a comment with the explainCodeExperts automation action.

Assign Code Experts

Configuration Description

Conditions (all must be true):

  • The PR has a suggest-reviewers label attached to it.

Automation Actions:

  • Use codeExperts to assign recommended reviewers.
  • Use explainCodeExperts to post a comment that lists the top code experts for the PR.

Assign Code Experts

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  assign_code_experts:
+    # Triggered when someone applies a suggest-reviewer label to a PR.
+    if: 
+      - {{ pr.labels | match(term='suggest-reviewer') | some }}
+    # More info about code experts
+    # https://docs.gitstream.cm/filter-functions/#codeexperts
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: {{ repo | codeExperts(gt=10) }}
+      - action: explain-code-experts@v1 
+        args:
+          gt: 10 
+

Branch-Based Review Policies

Automatically route and manage PRs based on the target or destination branch.

Branch-Based Review Policies

Configuration Description

Conditions (all must be true):

  • The target or source branch name contains a specified prefix.

Automation Actions:

  • Implement custom review policies for the branch.

Review Target Branch

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  {% for item in branches %}
+  review_target_branch_{{ item.name }}: 
+    if:       
+    - {{ pr.target| match(regex=item.prefix) }}
+    run:
+      - action: set-required-approvals@v1
+        args:
+          approvals: {{ item.reviews }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            PRs to the {{ item.name }} branch require {{ item.reviews }} review(s).
+      - action: add-reviewers@v1
+        args:
+          reviewers: [{{ item.reviewers }}]
+  {% endfor %}
+
+branches:
+    - prefix: r/^release/ 
+      reviews: 4
+      name: Release
+    - prefix: r/^experimental-/ 
+      reviews: 1
+      name: Experimental
+

Review Source Branch

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  {% for item in branches %}
+  review_source_branch{{ item.name }}: 
+    if:       
+    - {{ branch.name | match(regex=item.prefix) }}
+    run:
+      - action: set-required-approvals@v1
+        args:
+          approvals: {{ item.reviews }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            Reviewers from the {{ item.name }} team have automatically been assigned to this PR.
+      - action: add-reviewers@v1
+        args:
+          reviewers: [{{ item.reviewers }}]
+  {% endfor %}
+
+branches:
+    - prefix: r/^ABC/ 
+      reviewers: org/a-team
+      name: ABC
+    - prefix: r/^XYZ-/ 
+      reviewers: org/x-team
+      name: XYZ
+

Review Sensitive Files

Compare the changed files to a pre-defined list of files and directories in. If any files match, require a review from the team my-organization/security.

Review Sensitive Files

Configuration Description

Conditions (all must be true):

  • Any files match the files or directories listed in the sensitive_files custom expression. Customize this list for your project.

Automation Actions:

  • Assign my-organization/security to review the PR. Customize this value to match your organization.
  • Require 2 approvals.
  • Post a comment that explains the automation.

Review Sensitive Files

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  # Assign special teams to review sensitive files. 
+  # This requires the `sensitive` custom expression found at the bottom of this file.
+  review_sensitive_files:
+    # For all files listed in the sensitive custom expression.
+    if:
+      - {{ files | match(list=sensitive_files) | some }}
+    run:
+      # Add reviewers from the dev-leads team, and require two approvals
+      # Modify `my-organization/security` to match your organization.
+      - action: add-reviewers@v1
+        args:
+          reviewers: [my-organization/security]
+      - action: set-required-approvals@v1
+        args:
+          approvals: 2
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR affects one or more sensitive files and requires review from the security team.
+
+# The `sensitive_file_review` automation requires this custom expression.
+# Modify this list to suit your security needs.
+sensitive_files:
+  - src/app/auth/
+  - src/app/routing/
+  - src/app/resources/
+

Custom Team Review Policies

Automatically assign the PR author's team to review PRs.

Assign the Author's Team for Review

Configuration Description

Conditions (all must be true):

  • The PR author is a member of one of the teams specified in the teams custom expression.

Automation Actions:

  • Assign that team to review the PR.

Assign the Author's Team for Review

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in teams %}
+  review_team_{{ item.name }}: 
+    if:  
+      - {{ pr.author_teams | match(regex=item.regex) }}
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: [{{ item.team }}] 
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            This {{ item.name }} team has been automatically assigned to review this PR.
+  {% endfor %}
+
+teams:
+  - regex: r/ui-team/
+    name: UI Team
+    team: org/ui-team
+  - regex: r/mobile-team/
+    name: Mobile
+    team: org/mobile-team
+

Distribute Code Reviews to Share Knowledge

Require the reviewer as a previous contributor with code expertise between set thresholds when PR contains Share Knowledge label.

Knowledge Share

Configuration Description

Conditions (all must be true):

  • A Share Knowledge label has been applied to the PR

Automation Actions:

  • Choose a previous contributor between specified expertise thresholds and assign them as a reviewer.
  • Post a comment explaining why this action was taken.

Knowledge Share

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  share_knowledge:
+    if:
+      - {{ pr.labels | match(term='Share Knowledge') | some }}
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: {{ repo | codeExperts(gt=30, lt=60) | random }}
+      - action: add-comment@v1
+        args:
+          comment: |
+            gitStream has assigned a reviewer to increase knowledge sharing on this PR.
+

Notify Watcher

Automatically notify code reviewers based on a resource watchlist.

Notify Watchlist

Configuration Description

Conditions (all must be true):

  • The PR modifies any files listed under the watchers custom expression.

Automation Actions:

  • Post a comment that notifies the responsible team or individual of the changes.

Notify Watcher

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+## change orgName to match your git organization name.
+orgName: company
+
+automations:
+    {% for item in watchers %}
+    notify_watcher_{{ item.owner if item.owner else item.team }}:
+        if:
+        - {{ (files | match(list=item.files) | some) or (source.diff.files | match(attr="diff", list=item.diffs) | some) }}
+        run:
+        - action: add-comment@v1
+          args:
+            comment: |
+                @{{ item.owner if item.owner else (["{{ orgName }}/", item.team] | join) }} - this PR has changes you're watching
+
+                {% if files | match(list=item.files) | some -%}
+                files:
+                {%- for file in files | filter(list=item.files) %}
+                - {{ file }}
+                {%- endfor -%}
+                {%- endif %}
+
+                {% if source.diff.files | match(attr="diff", list=item.diffs) | some -%}
+                diffs:
+                {%- for diff in item.diffs -%}
+                {%- if source.diff.files | match(attr="diff", list=diff) | some %}
+                - {{ diff }}
+                {%- for file in source.diff.files | filter(attr="diff", list=diff) | map(attr="new_file") %}
+                - {{ file }}
+                {%- endfor -%}
+                {%- endif -%}
+                {%- endfor -%}
+                {%- endif %}
+        - action: add-reviewers@v1
+          args:
+            reviewers: {{ item.owner }}
+            team_reviewers: {{ item.team }}
+  {% endfor %}
+
+
+
+watchers:
+  - owner: juliaspencer
+    files:
+      - src/auth
+  - team: release
+    files:
+      - package.json
+      - yarn.lock
+
\ No newline at end of file diff --git a/automations/standard/review-assignment/notify-watcher/index.html b/automations/standard/review-assignment/notify-watcher/index.html new file mode 100644 index 00000000..5a92d1f4 --- /dev/null +++ b/automations/standard/review-assignment/notify-watcher/index.html @@ -0,0 +1,54 @@ + Automation - Notify Watchlist - gitStream Documentation

Notify Watchlist

Automatically notify code reviewers based on a resource watchlist.

Notify Watchlist

Configuration Description

Conditions (all must be true):

  • The PR modifies any files listed under the watchers custom expression.

Automation Actions:

  • Post a comment that notifies the responsible team or individual of the changes.

Notify Watcher

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+## change orgName to match your git organization name.
+orgName: company
+
+automations:
+    {% for item in watchers %}
+    notify_watcher_{{ item.owner if item.owner else item.team }}:
+        if:
+        - {{ (files | match(list=item.files) | some) or (source.diff.files | match(attr="diff", list=item.diffs) | some) }}
+        run:
+        - action: add-comment@v1
+          args:
+            comment: |
+                @{{ item.owner if item.owner else (["{{ orgName }}/", item.team] | join) }} - this PR has changes you're watching
+
+                {% if files | match(list=item.files) | some -%}
+                files:
+                {%- for file in files | filter(list=item.files) %}
+                - {{ file }}
+                {%- endfor -%}
+                {%- endif %}
+
+                {% if source.diff.files | match(attr="diff", list=item.diffs) | some -%}
+                diffs:
+                {%- for diff in item.diffs -%}
+                {%- if source.diff.files | match(attr="diff", list=diff) | some %}
+                - {{ diff }}
+                {%- for file in source.diff.files | filter(attr="diff", list=diff) | map(attr="new_file") %}
+                - {{ file }}
+                {%- endfor -%}
+                {%- endif -%}
+                {%- endfor -%}
+                {%- endif %}
+        - action: add-reviewers@v1
+          args:
+            reviewers: {{ item.owner }}
+            team_reviewers: {{ item.team }}
+  {% endfor %}
+
+
+
+watchers:
+  - owner: juliaspencer
+    files:
+      - src/auth
+  - team: release
+    files:
+      - package.json
+      - yarn.lock
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/review-assignment/notify-watcher/notify-watcher.png b/automations/standard/review-assignment/notify-watcher/notify-watcher.png new file mode 100644 index 00000000..b285c9c0 Binary files /dev/null and b/automations/standard/review-assignment/notify-watcher/notify-watcher.png differ diff --git a/automations/standard/review-assignment/review-branch/index.html b/automations/standard/review-assignment/review-branch/index.html new file mode 100644 index 00000000..f0f6af6e --- /dev/null +++ b/automations/standard/review-assignment/review-branch/index.html @@ -0,0 +1,57 @@ + Automation - Branch-Based Review Policies - gitStream Documentation

Branch-Based Review Policies

Automatically route and manage PRs based on the target or destination branch.

Branch-Based Review Policies

Configuration Description

Conditions (all must be true):

  • The target or source branch name contains a specified prefix.

Automation Actions:

  • Implement custom review policies for the branch.

Review Target Branch

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  {% for item in branches %}
+  review_target_branch_{{ item.name }}: 
+    if:       
+    - {{ pr.target| match(regex=item.prefix) }}
+    run:
+      - action: set-required-approvals@v1
+        args:
+          approvals: {{ item.reviews }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            PRs to the {{ item.name }} branch require {{ item.reviews }} review(s).
+      - action: add-reviewers@v1
+        args:
+          reviewers: [{{ item.reviewers }}]
+  {% endfor %}
+
+branches:
+    - prefix: r/^release/ 
+      reviews: 4
+      name: Release
+    - prefix: r/^experimental-/ 
+      reviews: 1
+      name: Experimental
+

Review Source Branch

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  {% for item in branches %}
+  review_source_branch{{ item.name }}: 
+    if:       
+    - {{ branch.name | match(regex=item.prefix) }}
+    run:
+      - action: set-required-approvals@v1
+        args:
+          approvals: {{ item.reviews }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            Reviewers from the {{ item.name }} team have automatically been assigned to this PR.
+      - action: add-reviewers@v1
+        args:
+          reviewers: [{{ item.reviewers }}]
+  {% endfor %}
+
+branches:
+    - prefix: r/^ABC/ 
+      reviewers: org/a-team
+      name: ABC
+    - prefix: r/^XYZ-/ 
+      reviewers: org/x-team
+      name: XYZ
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/review-assignment/review-branch/review-branch.png b/automations/standard/review-assignment/review-branch/review-branch.png new file mode 100644 index 00000000..86f4d53d Binary files /dev/null and b/automations/standard/review-assignment/review-branch/review-branch.png differ diff --git a/automations/standard/review-assignment/review-sensitive-files/index.html b/automations/standard/review-assignment/review-sensitive-files/index.html new file mode 100644 index 00000000..47461633 --- /dev/null +++ b/automations/standard/review-assignment/review-sensitive-files/index.html @@ -0,0 +1,32 @@ + Automation - Review Sensitive Files - gitStream Documentation

Review Sensitive Files

Compare the changed files to a pre-defined list of files and directories in. If any files match, require a review from the team my-organization/security.

Review Sensitive Files

Configuration Description

Conditions (all must be true):

  • Any files match the files or directories listed in the sensitive_files custom expression. Customize this list for your project.

Automation Actions:

  • Assign my-organization/security to review the PR. Customize this value to match your organization.
  • Require 2 approvals.
  • Post a comment that explains the automation.

Review Sensitive Files

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  # Assign special teams to review sensitive files. 
+  # This requires the `sensitive` custom expression found at the bottom of this file.
+  review_sensitive_files:
+    # For all files listed in the sensitive custom expression.
+    if:
+      - {{ files | match(list=sensitive_files) | some }}
+    run:
+      # Add reviewers from the dev-leads team, and require two approvals
+      # Modify `my-organization/security` to match your organization.
+      - action: add-reviewers@v1
+        args:
+          reviewers: [my-organization/security]
+      - action: set-required-approvals@v1
+        args:
+          approvals: 2
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR affects one or more sensitive files and requires review from the security team.
+
+# The `sensitive_file_review` automation requires this custom expression.
+# Modify this list to suit your security needs.
+sensitive_files:
+  - src/app/auth/
+  - src/app/routing/
+  - src/app/resources/
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/review-assignment/review-sensitive-files/review_sensitive_files.png b/automations/standard/review-assignment/review-sensitive-files/review_sensitive_files.png new file mode 100644 index 00000000..a1cc93c3 Binary files /dev/null and b/automations/standard/review-assignment/review-sensitive-files/review_sensitive_files.png differ diff --git a/automations/standard/review-assignment/review-team/index.html b/automations/standard/review-assignment/review-team/index.html new file mode 100644 index 00000000..ee84962f --- /dev/null +++ b/automations/standard/review-assignment/review-team/index.html @@ -0,0 +1,27 @@ + Automation - Automatic Team Review Assignment - gitStream Documentation

Assign the Author's Team for Review

Automatically assign the PR author's team to review PRs.

Assign the Author's Team for Review

Configuration Description

Conditions (all must be true):

  • The PR author is a member of one of the teams specified in the teams custom expression.

Automation Actions:

  • Assign that team to review the PR.

Assign the Author's Team for Review

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in teams %}
+  review_team_{{ item.name }}: 
+    if:  
+      - {{ pr.author_teams | match(regex=item.regex) }}
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: [{{ item.team }}] 
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            This {{ item.name }} team has been automatically assigned to review this PR.
+  {% endfor %}
+
+teams:
+  - regex: r/ui-team/
+    name: UI Team
+    team: org/ui-team
+  - regex: r/mobile-team/
+    name: Mobile
+    team: org/mobile-team
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/review-assignment/review-team/review-team.png b/automations/standard/review-assignment/review-team/review-team.png new file mode 100644 index 00000000..b466654d Binary files /dev/null and b/automations/standard/review-assignment/review-team/review-team.png differ diff --git a/automations/standard/review-assignment/share-knowledge/index.html b/automations/standard/review-assignment/share-knowledge/index.html new file mode 100644 index 00000000..b8dfc834 --- /dev/null +++ b/automations/standard/review-assignment/share-knowledge/index.html @@ -0,0 +1,18 @@ + Automation - Knowledge Share - gitStream Documentation

Knowledge Share

Require the reviewer as a previous contributor with code expertise between set thresholds when PR contains Share Knowledge label.

Knowledge Share

Configuration Description

Conditions (all must be true):

  • A Share Knowledge label has been applied to the PR

Automation Actions:

  • Choose a previous contributor between specified expertise thresholds and assign them as a reviewer.
  • Post a comment explaining why this action was taken.

Knowledge Share

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  share_knowledge:
+    if:
+      - {{ pr.labels | match(term='Share Knowledge') | some }}
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: {{ repo | codeExperts(gt=30, lt=60) | random }}
+      - action: add-comment@v1
+        args:
+          comment: |
+            gitStream has assigned a reviewer to increase knowledge sharing on this PR.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/review-assignment/share-knowledge/share-knowledge.png b/automations/standard/review-assignment/share-knowledge/share-knowledge.png new file mode 100644 index 00000000..ec8a2872 Binary files /dev/null and b/automations/standard/review-assignment/share-knowledge/share-knowledge.png differ diff --git a/automations/standard/review-changelog/index.html b/automations/standard/review-changelog/index.html new file mode 100644 index 00000000..6ad1c18b --- /dev/null +++ b/automations/standard/review-changelog/index.html @@ -0,0 +1,22 @@ + Automation - Enforce Changelog Updates - gitStream Documentation

Enforce Changelog Updates

Request changes if a PR that meets specified criteria lacks an update to the project's changelog.

Review Changelog

Configuration Description

Conditions (All must be true):

  • The branch name contains the phrase feature
  • The PR lacks changes to the docs/changelog.md file

Automation Actions:

  • Apply a yellow label that says ⚠️ Missing Changelog
  • Request changes and post a comment explaining why.

Review Changelog

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  # Request changes for new features that lack changelog updates.
+  review_changelog: 
+    if: 
+      - {{ branch.name | includes(term="feature") }}
+      - {{ files | match(regex=r/^docs\/changelog\.md$/) | nope }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Changelog"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            All new features require an update to the changelog. Please modify your PR to include any relevant changelog updates.
+
+colors:
+  yellow: 'fbca04'
+

Special thanks to Boemo W Mmopelwa for providing this example.

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/review-changelog/review-changelog.png b/automations/standard/review-changelog/review-changelog.png new file mode 100644 index 00000000..f6c9aa74 Binary files /dev/null and b/automations/standard/review-changelog/review-changelog.png differ diff --git a/automations/standard/review-todo-comments/index.html b/automations/standard/review-todo-comments/index.html new file mode 100644 index 00000000..f4811b02 --- /dev/null +++ b/automations/standard/review-todo-comments/index.html @@ -0,0 +1,13 @@ + Automation - Review TODO Comments - gitStream Documentation

Review TODO Comments

Request changes for a PR that contains a TODO statement.

Review TODO Comments

Configuration Description

Conditions (all must be true):

  • The PR contains a TODO statement

Automation Actions:

  • Request changes and post a comment explaining why.

Review TODO Comments

manifest:
+  version: 1.0
+
+automations:
+  review_todo_comments:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/^[+].*(TODO|todo)/) | some }}
+    run:
+      - action: request-changes@v1
+        args:
+          comment: |
+            This PR contains a TODO statement. Please check to see if they should be removed.
+
\ No newline at end of file diff --git a/automations/standard/review-todo-comments/review-todo-comments.png b/automations/standard/review-todo-comments/review-todo-comments.png new file mode 100644 index 00000000..cd16f5da Binary files /dev/null and b/automations/standard/review-todo-comments/review-todo-comments.png differ diff --git a/automations/standard/summarize-language-changes/index.html b/automations/standard/summarize-language-changes/index.html new file mode 100644 index 00000000..181fd5d5 --- /dev/null +++ b/automations/standard/summarize-language-changes/index.html @@ -0,0 +1,63 @@ + Automation - Summarize Language Changes - gitStream Documentation

Summarize Language Changes

Post a comment that summarizes which programming languages are contained in PRs.

Summarize Language Changes

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • Post a comment containing a table that shows the percent of total changes for each programming language present in the PR.

Summarize Language Changes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+on: 
+  - pr_created
+
+automations:
+  summarize_language_changes:
+    if:
+      - true
+    run:
+    - action: add-comment@v1
+      args:
+        comment:  
+          <h3>Summary of Changes by Language</h3>
+              <table>
+              <tr>
+              <td>Language</td>
+              <td>Language Change Percentage</td>
+              </tr>
+              <tr>
+              <td>Java</td>
+              <td>{{ total.java | round }}%</td>
+              </tr>
+                <tr>
+              <td>JavaScript</td>
+              <td>{{ total.javascript | round }}%</td>
+              </tr>
+            <td>Rust</td>
+              <td>{{ total.rust | round }}%</td>
+              </tr>
+                <tr>
+              <td>Ruby</td>
+              <td>{{ total.ruby  | round }}%</td>
+              </tr>
+                <td>HTML</td>
+              <td>{{ total.html  | round }}%</td>
+              </tr>
+            <td>CSS</td>
+              <td>{{ total.css  | round }}%</td>
+              </tr>
+                <tr>
+              <td>Golang</td>
+              <td>{{ total.golang  | round }}%</td>
+              </tr>
+                <tr>
+              <td>Python</td>
+              <td>{{ total.python  | round }}%</td>
+              </tr>
+              </table>
+
+total:
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+  java: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.java$/ ) | map(attr='additions') | sum / total.additions * 100 }}
+  javascript: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.js$/ ) | map(attr='additions') | sum / total.additions * 100 }}
+  rust: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.rs$/ ) | map(attr='additions') | sum / total.additions * 100 }}
+  ruby: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.rb$/ ) | map(attr='additions') | sum / total.additions * 100 }}
+  html: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.html$/ ) | map(attr='additions') | sum / total.additions * 100 }}
+  css: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.css$/ ) | map(attr='additions') | sum / total.additions * 100 }}
+  golang: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.go$/ ) | map(attr='additions') | sum / total.additions * 100 }}
+  python: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.py$/ ) | map(attr='additions') | sum / total.additions * 100 }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/standard/summarize-language-changes/summarize-language-changes.png b/automations/standard/summarize-language-changes/summarize-language-changes.png new file mode 100644 index 00000000..6f312646 Binary files /dev/null and b/automations/standard/summarize-language-changes/summarize-language-changes.png differ diff --git a/automations/utilities/cm-header/index.html b/automations/utilities/cm-header/index.html new file mode 100644 index 00000000..9714dbb3 --- /dev/null +++ b/automations/utilities/cm-header/index.html @@ -0,0 +1,20 @@ + Automation - CM File Header - gitStream Documentation

CM File Header

This header is useful to add to the top of any configuration files you create for your organization. This will help others who want to make improvements to your configurations in the future.

CM File Header

# -*- mode: yaml -*-
+
+# +----------------------------------------------------------------------------+
+# | WARNING: This file controls repo automations, use caution when modifying   |
+# +----------------------------------------------------------------------------+
+# | This file contains one or more /:\ gitStream automations:                  |
+# | https:// docs.gitstream.cm                                                 |
+# |                                                                            |
+# | gitStream uses YAML syntax with nunjucks templating via Jinja 2.           |
+# |                                                                            |
+# | Automations follow an "if this, then that" execution format.               |
+# | More info here: https://docs.gitstream.cm/how-it-works/                    |
+# |                                                                            |
+# +----------------------------------------------------------------------------+
+
+# /:\ gitStream Reference Docs: 
+#    Context Variables: https://docs.gitstream.cm/context-variables/
+#    Filter Functions: https://docs.gitstream.cm/filter-functions/
+#    Automation Actions: https://docs.gitstream.cm/automation-actions/
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/utilities/colors-custom-expression/index.html b/automations/utilities/colors-custom-expression/index.html new file mode 100644 index 00000000..faf4195b --- /dev/null +++ b/automations/utilities/colors-custom-expression/index.html @@ -0,0 +1,36 @@ + Automation - Colors Custom Expression - gitStream Documentation

Colors Custom Expression

This automation demonstrates all of GitHub's default label colors, implemented as a colors custom expression. This is meant to help improve other automations rather than being used on its own.

Colors Custom Expression

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+# This automation demonstrates all of GitHub's default label colors.
+# This is meant to be used as a reference, not as an automation in your repo.
+automations:
+  label_colors:
+    if:
+      - true
+    run:
+      - action: add-label@v1
+        args:
+          label: "Test Label"
+          color: {{ colors.green }}
+
+# These are all of the colors in GitHub's default label color palette.
+colors:
+  red: 'b60205'
+  orange: 'd93f0b'
+  yellow: 'fbca04'
+  green: '0e8a16'
+  teal: '006b75'
+  blue: '1d76db'
+  dark-blue: '0052cc'
+  purple: '5319e7'
+  light-red: 'e99695'
+  light-orange: 'f9d0c4'
+  light-yellow: 'fef2c0'
+  light-green: 'c2e0c6'
+  light-teal: 'bfdadc'
+  light-blue: 'c5def5'
+  light-dark-blue: 'bfd4f2'
+  light-purple: 'd4c5f9'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/welcome-newcomer/index.html b/automations/welcome-newcomer/index.html new file mode 100644 index 00000000..2eb1d955 --- /dev/null +++ b/automations/welcome-newcomer/index.html @@ -0,0 +1,28 @@ + Automation - Welcome Newcomer - gitStream Documentation

Welcome Newcomer

Post a welcome message when someone makes their first PR to a repo, and provide context to help them know what's next.

Welcome Newcomer

Configuration Description

Conditions (all must be true):

  • The PR author made their first contribution to the repo during the current day.

Automation Actions:

  • Add the my-organization/mentors team to review the PR. Customize this to match your organization.
  • Apply a new-contributor label to the PR.
  • Post a comment explaining the next steps. Customize this to match your project.

Welcome Newcomer

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  # Help newcomers find mentors to guide them.
+  welcome_newcomer:
+    # If the PR author made their first contirbution on the current day
+    if:
+      - {{ repo.author_age < 1 and repo.age > 0 }}
+    # 1. Add reviewers from the team `my_organization/mentors`. Replace this string to match your organization
+    # 2. Apply a new-contributor label.
+    # 3 Post a comment that explains the next steps.
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: [my_organization/mentors]
+      - action: add-label@v1
+        args:
+          label: 'new-contributor'
+          color: '#FBBD10'
+      - action : add-comment@v1
+        args:
+          comment: |
+            Hello {{ pr.author }} 👋 Thanks for making your first PR, and welcome to our project!
+            Our mentor team has automatically been assigned to review this PR and guide you through the process.
+            Please reach out to that team if you have questions about the next steps.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/automations/welcome-newcomer/logo_welcome_newcomer.png b/automations/welcome-newcomer/logo_welcome_newcomer.png new file mode 100644 index 00000000..79b00ee8 Binary files /dev/null and b/automations/welcome-newcomer/logo_welcome_newcomer.png differ diff --git a/automations/welcome-newcomer/welcome_newcomer.png b/automations/welcome-newcomer/welcome_newcomer.png new file mode 100644 index 00000000..8a8431c0 Binary files /dev/null and b/automations/welcome-newcomer/welcome_newcomer.png differ diff --git a/automations/welcome-newcomer/welcome_newcomer.svg b/automations/welcome-newcomer/welcome_newcomer.svg new file mode 100644 index 00000000..3be8c60c --- /dev/null +++ b/automations/welcome-newcomer/welcome_newcomer.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/changelog/index.html b/changelog/index.html new file mode 100644 index 00000000..c5b997c1 --- /dev/null +++ b/changelog/index.html @@ -0,0 +1 @@ + /:\ gitStream Changelog - gitStream Documentation

/:\ gitStream Changelog

All notable changes to this project will be documented in this file.

2024.5.06

  • Simplified GitLab workflow file: Using the image directly instead of docker Dind

2024.5.06

  • Reorganized trigger configuration: Moved the top-level on keyword under a new triggers keyword to consolidate all trigger settings.
  • Enhanced repository and branch triggering:
    • Moved config.include_repository and config.ignore_repository to triggers.include.repository and triggers.exclude.repository, aligning repository-specific triggers with the new consolidated trigger configuration.
    • Introduced triggers.include.branch and triggers.exclude.branch to specify branch-specific conditions for triggering automations.

2024.4.16

  • Added a cache option for the docker image

2024.3.28

  • Supporting regular expressions in ~~config.ignore_repositories~~ triggers.include.repository and triggers.exclude.repository

2024.3.14

  • Added the following explicit triggers:
    • pr_ready_for_review
    • pr_closed
    • pr_reopened

2024.3.7

  • Triggering on comment edits
  • Added support for request-changes action in GitLab

2023.11.22

  • gitStream Playground official release
\ No newline at end of file diff --git a/cm-file/index.html b/cm-file/index.html new file mode 100644 index 00000000..029ea9a2 --- /dev/null +++ b/cm-file/index.html @@ -0,0 +1,73 @@ + gitStream Configuration Overview - gitStream Documentation

gitStream Configuration Overview

Continuous Merge automation files have a .cm extension. In a repository, gitStream loads and parse the .cm directory, which can have multiple automation files, each of which is evaluated independently.

You can edit the .cm files and add your own checks and rules. Check out the Automation examples.

Automation rules

There are two types of automation rules: repository level rules and organization level rules.

Repository level rules are set by creating a special .cm directory in the repository root. Automation rules are specified in files in this directory, which can have any name but must end with .cm.

Organization level rules are defined by creating a special repository named cm in the organization or group. In this repository, you can add CM automation files, which will apply to all the repositories that gitStream app is connected.

When organization level rules are defines, repository level automation shall take precedence and override organization automation when having the same identifier.

An automation identifier is a composition of the CM file name and the automation name. For example when safe_changes is defined in gitstream.cm then the automation identifier shall be gitstream/safe_changes

Tip

You can select (include or exclude) certain repositories per automation file using the triggers.include.repository and triggers.exclude.repository

Repository automation rules

Repository automation rules are set by creating a special .cm directory in your repository root. Automation rules are specified in files in this directory, these files can have any name but must end with .cm. By default, you start with a single automation file .cm/gitstream.cm.

Every file is parsed independently, and the parsing results are combined and executed.

Specifically:

  1. Automation rules are allowed to have same name in different .cm files
  2. The config section is defined per .cm file (except config.admin)
  3. Any accessory expression defined in each file scope, therefore cannot be reused in another file (but it can be duplicated)

When configured correctly, your repository directory structure should look like that (for GitHub):

Repsository automation rules
.
+├─ .cm/
+│  └─ *.cm
+├─ .github/
+│  └─ workflows/
+│     └─ gitstream.yml
+

Note

The .cm/gitstream.cm is special, as it allows repository-level configuration such as config.admin.

Organization automation rules

Organization automation rules are defined by creating a special repository cm in your organization or group. In this repository, you can add CM automation files, which will apply to all the repositories that gitStream app is connected.

When configured correctly, the cm repository directory structure should look like that (for GitHub):

Repsository automation rules
.
+├─ *.cm
+├─ .github/
+│  └─ workflows/
+│     └─ gitstream.yml
+

For each PR the following automation rules are applied:

  1. Repository level rules
  2. Organization-level rules, unless with the same identifier as a repository-level automation

When organization level rules are defined, then the CI/CD will be executed on the cm repository on behalf of the PR repository.

Setting up Global Automation rules

By utilizing the following techniques, you can effectively combine and manage global and repository rules to customize the behavior of your automations to fit the specific requirements of your repositories:

  1. Global rules are defined in the configuration management cm repository and are applied to all repositories that are connected to gitStream.
  2. To exclude or run only on specific repositories from a global rule, you can use triggers.include.repository and triggers.exclude.repository in the cm file and add a list of the unwanted or wanted repositories respectfully.
  3. To override a global rule for specific automation in a repository, you can duplicate the rule (both the file and automation name) and place it in the desired repository. The locally defined rule will then take precedence over the global rule for that specific repository.

The .cm automation file

Schema

The following sections are used in .cm file to describe the desired automations:

manifest

The first section in a gitstream.cm file is the manifest.

manifest:
+  version: 1.0
+

The only field required is version.

Key Required Type Description
manifest Y Map The manifest section root
manifest.version Y String Specify the .cm spec version: 0.1, 1.0

The manifest version field is used to parse the .cm file, in the future if breaking changes are introduced to the parser then older automation will be still supported.

config

The config section in the .cm file is optional and specifies settings that affect gitStream's operation within a given context.

Key Type Default Scope Description
config Map - per .cm file Root configuration section, applies to the automations defined in the current file.
config.admin.users [String] [] gitstream.cm List of admin users, identified by Git provider usernames.
config.ignore_files [String] [] per .cm file Files to exclude from consideration.
config.user_mapping [String: String] [] per .cm file Map Git user details to provider account names.
config.admin.users

When specified in gitstream.cm the config.admin.users allows adding admin rights, when a PR changes the *.cm files only, if the user is listed in config.admin.users the PR will be then approved by gitStream. For example, setting popeye as admin:

example
config:
+  admin:
+    users: ['popeye']
+

This configuration is valid only when used in .cm/gitstream.cm, when defined in other .cm files this configuration is ignored.

When you add a user to config.admin.users in your organization's cm repository, they are granted administrative privileges to CM changes across every repository in the organization. gitStream evaluates CM rules in the individual repository and your organization's cm repository to determine admin users.

config.ignore_files

The config.ignore_files supports glob pattern matching that contains a list of files to ignore.

Common usage, since some files such as lock files are intentionally not a required part of a review, they would not want to them to be counted in the estimated review time. In such cases, you can add config.ignore_files to the relevant CM file, for example:

example
config:
+  ignore_files:
+    - 'yarn.lock'
+    - 'package-lock.json'
+    - 'openapi.json'
+    - 'ui/src/**/*Model.d.ts'
+
config.user_mapping

Accepts list of key value strings.

For example, when using rankByGitBlame or explainRankByGitBlame Git users are mapped to their matching Git provider accounts based on the Git details. The automatic mapping can sometimes result with the wrong account or fail to find a proper mapping, in these cases you can configure the config.user_mapping. This allows you to map confusing Git user into their specific accounts and dump some irrelevant accounts:

example
config:
+  user_mapping:
+    - 'Popeye Man <popeye@invalid.com>': 'popeye-the-salyor-man' # (1)
+    - 'Popeye Man <popeye2@invalid.com>': 'popeye-the-salyor-man' # (2)
+    - 'olive <olive@invalid.com>': null # (3)
+
  1. Map Git user signature to the correct Git provider user name (e.g. GitHub)
  2. Map Git user signature to the correct Git provider user name (e.g. GitHub)
  3. Mapping to null removes this Git user from the suggested results

When using rankByGitBlame to assign reviewers automatically with add-reviewers@v1 then mapping users to null is a way to prevent the automatic mapping in certain cases, like in your example contributors that are not longer part of the team.

On the other hand, when using explainRankByGitBlame with add-comment@v1 it still shows these users details in the PR comment suggestion as this info might be valuable by itself.

- action: add-reviewers@v1
+  args: # (1)
+    reviewers: {{ repo | rankByGitBlame(gt=25) }}
+
+- action: add-comment@v1
+  args: # (2)
+    comment: |
+      {{ repo | explainRankByGitBlame(gt=25) }}
+
  1. rankByGitBlame will drop null users
  2. explainRankByGitBlame will NOT drop null users

triggers

The triggers is section specifies when automations are executed, supporting include and exclude lists for branch and repository patterns at the file level. The on keyword can also be used within individual automations to define specific events that trigger those automations.

triggers:
+  on:
+    - pr_created
+    - commit
+  exclude:
+    branch:
+      - hotfix
+

Read more here: triggers.

automations

The automations section defines the automations and their conditions.

automations:
+  mark_small_pr:
+    if:
+      - {{ checks.size.is.xsmall }}
+    run:
+      - action: add-label@v1
+        args:
+          label: xsmall
+

Each automation includes its name, and few fields: if and run.

Key Required Type Description
automations Y Map The automations section root
automations.NAME Y Map User defined name of the automation, can be any string
automations.NAME.if Y Map List of conditions with AND relationship
automations.NAME.run Y Map Actions to run if all conditions are met, invoked one by one

The if field includes the list of conditions. The conditions are checked when a pull request is opened or changed, if all the conditions pass, the automation is executed.

The run field includes the automation to execute. It includes the following fields:

Key Required Type Description
action Y String The action pointer
engine N String The action engine, default is gitstream
args N List The action inputs list

For gitstream engine, the action is specified by: name@version

gitStream supported actions, see actions.

Reusing checks

You can define an accessory section, e.g. checks, that defines common conditions, and reuse.

size:
+  is:
+    small: {{ branch.diff.size < 20 }}
+    medium: {{ branch.diff.size >= 20 and branch.diff.size < 100 }}
+    large: {{ branch.diff.size >= 100 }}
+
+automations:
+  approve_small:
+    if:
+      - {{ size.is.small }}
+    run:
+      - action: approve@v1
+  mark_small_medium:
+    if:
+      # Check that the PR is either small or medium size
+      - {{ size.is.small or size.is.medium }}
+      # AND its less than 5 minutes review (estimated)
+      - {{ branch | estimatedReviewTime <= 5 }}
+    run:
+      - action: add-label@v1
+        args:
+          label: 'good-size'
+
\ No newline at end of file diff --git a/cm-syntax/index.html b/cm-syntax/index.html new file mode 100644 index 00000000..3747fa2f --- /dev/null +++ b/cm-syntax/index.html @@ -0,0 +1,15 @@ + + + + + + Redirecting... + + + + + + +Redirecting... + + diff --git a/context-variables/index.html b/context-variables/index.html new file mode 100644 index 00000000..9c723db9 --- /dev/null +++ b/context-variables/index.html @@ -0,0 +1,200 @@ + gitStream Reference - Context Variables - gitStream Documentation

Context variables

Context variable are the inputs for the automation conditions or checks.

Legend

The icons indicate the availability status of each action.

  • Supported on GitHub
  • Supported on GitLab
  • Under development and not available yet.
  • Open beta - Under development and currently available for all

Overview

Context

gitStream includes a collection of variables called contexts.

Structures

The following structures are used in the context objects:

Example of a context object

Partial example of a context object for a PR that changed few lines in a README.md file:

{
+  "branch": {
+    "name": "new-feature-branch",
+    "base": "main",
+    "diff": {
+      "size": 50,
+      "files_metadata": [
+        {
+          "original_file": "README.md",
+          "new_file": "README.md",
+          "deletions": 0,
+          "additions": 2
+        }
+      ]
+    },
+    "num_of_commits": 1
+  },
+  "source": {
+    "diff": {
+      "files": [
+        {
+          "original_file": "README.md",
+          "new_file": "README.md",
+          "diff": "@@ -10,3 +10,5 @@ This project \n+\n+## Intro",
+          "original_content": "This project \n",
+          "new_content": "This project \n\n## Intro"
+        }
+      ]
+    }
+  },
+  "repo": {
+    "contributors": {
+      "popeye": "46",
+      "olive": "6"
+    },
+    "owner": "acme"
+  },
+  "files": [
+    "README.md"
+  ]
+}
+

Reference

branch

The branch context contains info regarding the branch changes compared to the base branch.

Note

compared to the source context does not include actual source code.

Values Type Description
branch Map Includes the info related to the current branch
branch.author String The branch author (the user that did first commit in the branch). The formatted like author in git-log, e.g. Popeye <popeye@acme.com>
branch.author_name String The branch author name
branch.author_email String The branch author email
branch.base String The main branch, main
branch.commits.messages [String] A list with all the commit messages in this branch
branch.diff.size Integer The sum of line changed: additions, edits and deletions
branch.diff.files_metadata FileMetadata List of changed files including their relative path
branch.name String The current branch, feature-123-branch
branch.num_of_commits Integer The number of commits in the branch

The branch context doesn't include any source code, but only related metadata.

Example for using branch.name and branch.author to automatically approve and merge version bumps.

automations:
+  dependabot:
+    if:
+      - {{ branch.name | includes(term="dependabot") }}
+      - {{ branch.author | includes(term="dependabot") }}
+    run:
+      - action: approve@v1
+      - action: add-label@v1
+        args:
+          label: "approved-dependabot"
+      - action: merge@v1
+        args:
+          wait_for_all_checks: true
+          squash_on_merge: true
+

Tip

The files context doesn't include deleted file, to identify both modified and deleted files use the branch.diff.files_metadata, for example:

{{ branch.diff.files_metadata | match(attr='file', regex=r/\.md$/) | every }}
+

env

The env context allows the user to pass data from the repo that is unavailable in the other context variables. Thus, the structure of the variable is not fixed and depends on user configuration.

To configure the env variable, add the env field to gitstream's workflow job configurations on .github/workflows/gitstream.yml. For more information, visit GitHub's guide for Using secrets in GitHub Actions

examle: add secrets to the env variable
...
+jobs:
+  gitStream:
+    timeout-minutes: 5
+    runs-on: ubuntu-latest
+    name: gitStream workflow automation
+    env:
+      SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
+...
+

To use the context variable, access to the env variable's fields as configured in gitstream.yml

example: use slack webhook secret
automations:
+  send_slack:
+    if:
+      - true
+    run:
+      - action: send-slack-message@v1
+        args:
+          message: "Hello world :tada:."
+          webhook_url: "{{ slack_webhook }}"
+
+slack_webhook: {{ env.SLACK_WEBHOOK }}
+

files

The files context includes the list of changed files in the branch compared to the main branch.

Values Type Description
files [String] List of all changed files with their full path

For example, a typical files context can look like this:

[
+  "README.md",
+  "package.json",
+  "src/app.js",
+  "src/index.js",
+  "docs/examples.md"
+]
+

Example for checking if certain changes are made:

automations:
+  ui_review:
+    if:
+      - {{ files | match(list=ui_templates_files) | some }}
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: [GitHubUser1, GitHubUser2]
+
+ui_templates_files:
+  - resources/app/ui_template.yml
+  - resources/app/role_template.yml
+  - resources/app/account_template.yml
+

pr

The pr context includes metadata related to the pull request.

Values Type Description
pr Map Includes the info related to the PR
pr.approvals [String] A list of the of reviewers that approved the PR
pr.author String The PR author name
pr.author_teams String The teams which the PR author is member of
pr.author_is_org_member Bool true if the PR author is a member of the organization where gitStream is installed
pr.checks [Check] List of checks, names and status
pr.comments [Comment] List of PR comments objects
pr.conflicted_files_count Integer The number files in the PR with conflicts
pr.conversations [Conversation] List of PR conversation objects, usually when reviewer have comments about the source code
pr.created_at String The date and time the PR was created
pr.draft Bool true when the PR is marked as Draft/WIP
pr.description String The PR description text
pr.labels [String] The labels that are attached to the PR
pr.number Integer The PR or MR Id number
pr.provider String The Git cloud provider name, e.g. GitHub, GitLab etc.
pr.reviewers [String] The list of reviewers set for this PR
pr.source String The branch from which the PR originates
pr.status String The PR status: open, closed and merged
pr.target String The branch the PR is intended merged into
pr.title String The PR title
pr.requested_changes [String] List of users that requested changes
pr.reviews [Review] List of PR reviews, relevant in GitHub
pr.unresolved_threads Integer The number of open review comments in the PR
pr.updated_at String The date and time the PR was last updated

Example for checking the PR title includes a Jira ticket:

automations:
+  check_jira_ticket:
+    if:
+      - {{ not has.jira_ticket }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "missing-ticket"
+          color: 'F6443B'
+
+has:
+  jira_ticket: {{ pr.title | includes(regex=r/^\[?\w{3,4}-\d{1,6}\]?(\s|-|_).{20,}$/) }}
+

repo

The repo context includes metadata related to the repo.

Values Type Description
repo Map Includes the info related to the current repo
repo.age Integer Number of days since first commit (of any user)
repo.author_age Integer number of days since first commit to this repo
repo.blame GitBlame The percentage each user's lines in a file, the list includes all changed files in the branch. The list is sorted by the ratio field
repo.contributors Contributor List of contributors in the repo
repo.git_activity GitActivity Per file and user, the number of lines changed every week for the last 52 weeks
repo.name String Repository name
repo.owner String Repository owner account name
repo.visibility String The visibility of the source branch repo. Value is one of: private, internal, or public

source

The source context includes a list of FileDiff objects that can be used to get insights based on code changes. The changes compared to the latest main branch.

Values Type Description
source.diff.files FileDiff List of changed files with their code changes

The source context include all code changes, it is not safe to share it with unknown services.

Check structure

{
+  "name": String, # The check name
+  "status": String, # The check status: `queued`, `in_progress`, `completed`
+  "conclusion": String, # The check conclusion: `action_required`, `cancelled`, `failure` `neutral`, `success`, `skipped`, `stale`, `timed_out`
+}
+

Comment structure

{
+  "commenter": String, # The user that add the comment
+  "content": String, # The comment body
+  "created_at": String, # The time on which the comment was created
+  "updated_at": String, # The time on which the comment was last updated
+}
+

Conversation structure

{
+  "commenter": String, # The user that add the comment
+  "content": String, # The comment body
+  "created_at": String, # The time on which the comment was created
+  "updated_at": String, # The time on which the comment was updated
+  "start_line": Integer, # The first line marked for this comment
+  "end_line": Integer, # The last line marked for this comment
+  "is_resolved": Boolean # `true` when marked as resolved
+}
+

Contributor structure

The repo.contributors mapping includes a list of Contributor, where the user name is used as dynamic key:

{
+  USER_NAME: Integer # Number of commits
+}
+

FileDiff structure

The source.diff.files mapping includes a list of FileDiff:

{
+  "diff": String, #  The content in diff format `+` for additions, `-` for deletions
+  "new_content": String, # The new content in this branch
+  "new_file": String, # The name of the file after the changes, including its path
+  "original_content": String, #  The content as is in the `main` branch
+  "original_file": String, #  The name of the file before the changes, including its path
+}
+

FileMetadata structure

The branch.diff.files_metadata mapping includes a list of FileMetadata:

{
+  "additions": Integer, # The number of lines edited or added to the file
+  "deletions": Integer, # The number of lines removed from the file
+  "file": String, # The name of the file before the changes, including its path
+}
+

For example, sum additions in javascript code files:

{{ branch.diff.files_metadata | filter(attr='new_file', regex=r/\.js$|\.ts$/) | map(attr='additions') | sum }}
+

GitActivity structure

This structure include per changed file, for every user, the number of lines changed every week for the last 52 weeks.

{
+  FILE_NAME: # The file name and path
+  {
+    # The git user identifier (String)
+    GIT_USER: {
+      "week_INDEX": Integer # Number of lines changed that week
+      # ... for the last 52 weeks
+    }
+  }
+}
+

For example:

{
+  "src/utils/service.js": {
+    "popeye <popeye@acme.com>": {
+      "week_1": 20,
+      "week_2": 15,
+      "week_10": 250
+    },
+    "olive <olive@acme.com>": {
+      "week_1": 3,
+      "week_3": 50,
+      "week_52": 250
+    }
+  },
+  "README.md": {
+    "popeye <popeye@acme.com>": {
+      "week_2": 15,
+      "week_3": 10
+    }
+  }
+}
+

GitBlame structure

For each file, a list of user's blame ratio.

{
+  FILE_NAME: # The file name and path
+  {
+    # The git user identifier (String)
+    GIT_USER: Integer, # Precentage 0-100, ratio of user's lines / total lines in file
+  }
+}
+

For example:

{
+  "src/utils/service.js": {
+    "popeye <popeye@acme.com>": 78,
+    "olive <olive@acme.com>": 22,
+  },
+  "README.md": {
+    "popeye <popeye@acme.com>": 13,
+    "olive <olive@acme.com>": 22,
+    "brutus <brutus@acme.com>": 65,
+  }
+}
+

Review structure

{
+  "commenter": String, # The user that add the comment
+  "content": String, # The comment body
+  "created_at": String, # The time on which the comment was created
+  "state": String, # Either `approved`, `changes_requested`, `commented`, `pending`, `submitted`
+  "conversations": [Conversation], # Conversations that are relvant to this Review feedback
+}
+
\ No newline at end of file diff --git a/custom-github-app/index.html b/custom-github-app/index.html new file mode 100644 index 00000000..156bfc4c --- /dev/null +++ b/custom-github-app/index.html @@ -0,0 +1 @@ + How to Set Up Custom GitHub App and Connect to gitStream Services - gitStream Documentation

Note

This guide is for installations on self-hosted GitHub Server. If you are using the gitStream cloud service, please refer to this guide.

Custom GitHub App for Self-Hosted GitHub Server

A GitHub application serves as the link between gitStream and GitHub. It facilitates user authentication via OAuth2 and allows users to select repositories accessible by gitStream.

Prerequisites

GitHub Server v3.10 or higher

In this section, we'll guide you through creating a GitHub app for your self-hosted gitStream installation. By the end, you should have noted down the following values:

  • App ID
  • Private Key

Note

Throughout this document, when we refer to a GitHub account, it refers to your own GitHub Server installation.

1. Connect GitHub Server to LinearB

First login, or create a free account on the LinearB app.

In LinearB, go to Settings -> Git -> click the Connect gitStream button next to your GitHub Server integration. You’ll need to use the Webhook URL and Webhook secret later when setting up the GitHub App.

LinearB setup

Keep this window open and complete the next steps in GitHub. Once you have the App ID and Private Key (.pem file), you can complete the connection in LinearB.

2. Create a New GitHub App

Any GitHub account can own the app, but we recommend creating it under the organization account of the team who will maintain the gitStream installation.

  • Log in to GitHub and go to your organization account page (e.g., https://github.com/<organization account name>)
  • Click on Settings -> Developer Settings -> GitHub Apps -> New GitHub App as shown below
  • Or go directly to https://github.com/organizations/<organization account name>/settings/apps/new

GitHub App Creation

3. Set Up URLs and General Information

Fill in the app information as shown in the screenshot below. For URLs, replace gitstream.<your-domain>.com with the actual endpoint at which you'll be hosting the gitStream application.

Warning

  1. Do not forget trailing slashes for the URLs
  2. Do not forget to disable the "Expire user authorization tokens" checkbox
  3. The GitHub App name must contain gitstream in lower case

Tip

Use the following texts:

  1. GitHub App name: gitstream app
  2. Homepage URL: https://gitstream.cm

GitHub App Setup - Register

Tip

Use the following texts:

  1. Webhook URL from LinearB setup page
  2. Webhook secret from LinearB setup page

GitHub App Setup - Post Installation

4. Set Up Permissions

We need the following permissions to enable all gitStream functionality:

  • Write access to dedicated gitStream app files: Used to set up the gitStream workflow files
  • Write access to code: To allow gitStream to approve PRs once all conditions are met
  • Read access to administration, issues, and metadata: To get user team membership and branch protection settings
  • Read and write access to actions, checks, pull requests, and workflows: Trigger workflows, create and update pull requests and their checks, and modify workflow files
  • User email: Used to identify users |

You need to enable these under the permissions section as shown below:

Permissions Setup 1

Tip

Add the following Path (content paths to single files the app can access):

  1. .cm/gitstream.cm
  2. github/workflows/gitstream.yml

Permissions Setup 2 Permissions Setup 3 Permissions Setup 4

5. Webhook Events and Scope

  • Subscribe to events so gitStream is notified when a PR is created, changed, or commented on, etc

Permissions Setup 5 Permissions Setup 6

Tip

"Where can this GitHub App be installed?" choose "Any account" so other orgs in your company can use gitStream as well. For on-prem installations that work with github.com, only repositories under your company's org account can be accessed via gitStream.

Permissions Setup 7

6. Generate a Private Key

Once the app is created, scroll down and click Generate private key. This will create and download a .pem file for you.

Tip

Please keep this file safe, we'll need to put it back in LinearB setup.

Private Key

Download the logo file and upload the logo to your app.

8. Get App Configuration

On your newly created app page, you can find the App ID.

Tip

Please keep the App ID, we'll need to put it back in LinearB setup.

App Config Details

9. Finish Setup in LinearB

To complete the integration, fill in the App ID and Private Key in the LinearB setup screen.

Tip

Use the App ID, and Private key (.pem file) to complete the LinearB setup.

LinearB setup

10. Connect GitHub App to Your Repositories

Go to your organization settings in GitHub and in Third-party Access choose the GitHub Apps. You may need to choose the account to install the gitStream app on. Choose your org you used to create the GitHub app in the previous sections.

GitHub app setup

Choose the repositories you want to connect.

Tip

It's recommended to select All repositories, as it covers also future repositories.

Repository access

11. Finish Setting Up gitStream

Follow the instructions to configure your repository using the GitHub Instructions

\ No newline at end of file diff --git a/downloads/approvals.cm b/downloads/approvals.cm new file mode 100644 index 00000000..fe0b620f --- /dev/null +++ b/downloads/approvals.cm @@ -0,0 +1,114 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Automatically approve documentation improvements from the `tech-writers` team. + docs_approval: + if: + - {{ files | allDocs }} + - {{ pr.author_teams | match(term='tech-writers') }} + run: + - action: add-label@v1 + args: + label: 'safe-change' + - action: approve@v1 + + + tests_approval: + # Triggered for tests that are more than 80% new additions. + # Uses the `changes` custom expression at the bottom of this file. + if: + - {{ files | allTests }} + - {{ changes.ratio > 0.8 }} + # Post a comment + run: + - action: add-comment@v1 + args: + comment: | + PR added tests (ratio: {{ changes.ratio }}) + - action: approve@v1 + + + # Close PRs to restricted sections of the codebase. + close_ui_changes_by_non_ui: + # Triggered when someone who isn't on the `ui` team submits a PR to change files inside /src/views + if: + - {{ files | match(regex=r/src\/views/) | some }} + - {{ pr.author_teams | match(term='ui') | nope }} + # Close the PR and post a comment explaining the next step. + run: + - action: add-comment@v1 + args: + comment: Please contact a member of the `ui` team if you need to make changes to files in `src/views` + - action: close@v1 + + # Approve small changes automatically. + # This requires the `is` custom expression found at the bottom of this file. + approve_tiny_fix: + # Triggered for PRS that are only one change in a single file. + if: + - {{ is.one_file and is.one_line }} + # Apply the tiny-fix label and approve the PR. + run: + - action: add-label@v1 + args: + label: 'tiny-fix' + - action: approve@v1 + + # Request changes when required information is missing from the PR. + catch_missing_lambda_info: + # Triggered for new Lambda functions that are missing a description field. + if: + - {{ source.diff.files | matchDiffLines(regex=r/LambdaFunction/) | some }} + - {{ source.diff.files | matchDiffLines(regex=r/description:/) | nope }} + # Apply the lambda-missing-field label and request changes to the PR. + run: + - action: add-label@v1 + args: + label: 'lambda-missing-field' + color: '#FF0000' + - action: request-changes@v1 + args: + comment: | + New `LambdaFunction` must have `description:` field. + + # Request changes when a PR includes deprecated components. + # This requires the `item` custom expression found at the bottom of this file. + {% for item in deprecated %} + # Automation names must be unique, so this adds an iterator index to each instance + catch_deprecated_components_{{ loop.index }}: + # Triggered when any of the modified files use a deprecated component + if: + - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }} + # Apply a deprecated-component label, request changes, and post a comment with an explanation. + run: + - action: add-label@v1 + args: + label: 'deprecated-component' + color: '#FF0000' + - action: request-changes@v1 + args: + comment: | + `{{ item.old }}` component is deprecated, use `{{ item.new }}` instead + {% endfor %} + +# These calculations are used in the `tests_approval` automation +changes: + additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }} + deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }} + ratio: {{ changes.additions / (changes.additions + changes.deletions) }} + +# This custom expression is used in the `approve_tiny_fix` automation +is: + one_file: {{ files | length == 1 }} + one_line: {{ branch.diff.size <= 2 }} + +# These are the deprecated files that are evaluated in catch_deprecated_components +deprecated: + - regex: r/oldAPI/ + old: oldAPI + new: newAPI + - regex: r/anotherOldAPI/ + old: anotherOldAPI + new: anotherNewAPI diff --git a/downloads/approve-additions-to-tests.cm b/downloads/approve-additions-to-tests.cm new file mode 100644 index 00000000..e2503a51 --- /dev/null +++ b/downloads/approve-additions-to-tests.cm @@ -0,0 +1,32 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + tests_safe_changes: + if: + # Given the PR files changes, check that only tests were changed. The allTests filter checks for + # the substring `test` or `spec` in the file path or file name. + - {{ files | allTests }} + # Checking `changes.ratio` which is calculated below + - {{ changes.ratio > 0.8 }} + run: + - action: add-label@v1 + args: + label: 'tests-changes' + - action: add-comment@v1 + args: + comment: | + PR added tests (ratio: {{ changes.ratio }}) + # - action: approve@v1 + +# You can add more sections to the .cm file to place more logic, and use it in your automations +# The following logic `ratio` result is used in the automation above by checking `changes.ratio` +changes: + # Sum all the line added/edited in the PR + additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }} + # Sum all the line removed in the PR + deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }} + # Calculate the ratio to check if it is about new code + ratio: {{ changes.additions / (changes.additions + changes.deletions) }} \ No newline at end of file diff --git a/downloads/approve-changes-to-prints.cm b/downloads/approve-changes-to-prints.cm new file mode 100644 index 00000000..1c5f92fd --- /dev/null +++ b/downloads/approve-changes-to-prints.cm @@ -0,0 +1,29 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + # for JavaScript + prints_changes_in_js: + if: + - {{ files | match(regex=r/\.js$|\.ts$/) | every }} + - {{ files | length == 1 }} + - {{ source.diff.files | matchDiffLines(regex=r/^[+-].*console\.log/, ignoreWhiteSpaces=true) | every }} + run: + - action: add-label@v1 + args: + label: 'prints-changes' + - action: approve@v1 + + # for Python + prints_changes_in_py: + if: + - {{ files | match(regex=r/\.py$/) | every }} + - {{ files | length == 1 }} + - {{ source.diff.files | matchDiffLines(regex=r/^[+-].*logger\.(trace|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }} + run: + - action: add-label@v1 + args: + label: 'prints-changes' + - action: approve@v1 \ No newline at end of file diff --git a/downloads/assign-mentors-to-new-contributors.cm b/downloads/assign-mentors-to-new-contributors.cm new file mode 100644 index 00000000..529f72b6 --- /dev/null +++ b/downloads/assign-mentors-to-new-contributors.cm @@ -0,0 +1,21 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + junior: + if: + - {{ repo.author_age < 21 and (repo.age - repo.author_age) >= 21 }} + run: + - action: add-label@v1 + args: + label: 'first-weeks' + color: '#FBBD10' + - action : add-comment@v1 + args: + comment: | + During your first 21 days, your team lead will be assigned to review your PRs. + - action: add-reviewers@v1 + args: + reviewers: [popeye] \ No newline at end of file diff --git a/downloads/assign-reviewers-by-type-of-change.cm b/downloads/assign-reviewers-by-type-of-change.cm new file mode 100644 index 00000000..acd9e0db --- /dev/null +++ b/downloads/assign-reviewers-by-type-of-change.cm @@ -0,0 +1,13 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + review_ui: + if: + - {{ files | match(regex=r/src\/ui\/.*\.js$/) | some}} + run: + - action: add-reviewers@v1 + args: + reviewers: [popeye, olive] \ No newline at end of file diff --git a/downloads/assign-team-to-prs-by-their-member.cm b/downloads/assign-team-to-prs-by-their-member.cm new file mode 100644 index 00000000..7397fab9 --- /dev/null +++ b/downloads/assign-team-to-prs-by-their-member.cm @@ -0,0 +1,13 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + add_first_team_reviewer: + if: + - true + run: + - action: add-reviewers@v1 + args: + team_reviewers: {{ pr.author_teams | first }} \ No newline at end of file diff --git a/downloads/assign-the-relevant-reviewers-to-prs.cm b/downloads/assign-the-relevant-reviewers-to-prs.cm new file mode 100644 index 00000000..161d644c --- /dev/null +++ b/downloads/assign-the-relevant-reviewers-to-prs.cm @@ -0,0 +1,17 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + the_right_reviewer: + if: + - true + run: + - action: add-comment@v1 + args: + comment: | + {{ repo | explainRankByGitBlame(gt=25) }} + - action: add-reviewers@v1 + args: + reviewers: {{ repo | rankByGitBlame(gt=25) | random }} \ No newline at end of file diff --git a/downloads/assigning-non-contributors-to-prs.cm b/downloads/assigning-non-contributors-to-prs.cm new file mode 100644 index 00000000..379c483d --- /dev/null +++ b/downloads/assigning-non-contributors-to-prs.cm @@ -0,0 +1,13 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + share_knowledge: + if: + - true + run: + - action: add-reviewers@v1 + args: + reviewers: {{ repo | rankByGitBlame(lt=50) | random }} \ No newline at end of file diff --git a/downloads/automation-library/additional_review_for_large_pr.cm b/downloads/automation-library/additional_review_for_large_pr.cm new file mode 100644 index 00000000..3f9618fe --- /dev/null +++ b/downloads/automation-library/additional_review_for_large_pr.cm @@ -0,0 +1,19 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + additional_review_for_large_pr: + if: + - {{ branch | estimatedReviewTime >= 30 }} + - {{ files | length >= 10 }} + - {{ files | match(regex=r/src\//) | some }} + run: + - action: set-required-approvals@v1 + args: + approvals: 2 + - action: add-comment@v1 + args: + comment: | + This PR is a large change and requires 2 reviews. diff --git a/downloads/automation-library/approve-safe-changes.cm b/downloads/automation-library/approve-safe-changes.cm new file mode 100644 index 00000000..afdbbc7f --- /dev/null +++ b/downloads/automation-library/approve-safe-changes.cm @@ -0,0 +1,27 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + safe_changes: + # Triggered for any changes that only affect formatting, documentation, tests, or images + if: + - {{ is.formatting or is.docs or is.tests or is.image }} + # Apply a safe change label, approve the PR and explain why in a comment. + run: + - action: add-label@v1 + args: + label: 'safe-change' + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + This PR is considered a safe change and has been automatically approved. + +# These custom expressions are used in the safe_changes automation +is: + formatting: {{ source.diff.files | isFormattingChange }} + docs: {{ files | allDocs }} + tests: {{ files | allTests }} + image: {{ files | allImages }} diff --git a/downloads/automation-library/approve_javascript_formatting_change.cm b/downloads/automation-library/approve_javascript_formatting_change.cm new file mode 100644 index 00000000..5ac7b024 --- /dev/null +++ b/downloads/automation-library/approve_javascript_formatting_change.cm @@ -0,0 +1,19 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_javascript_formatting: + if: + - {{ files | extensions | match(list=['js', 'ts']) | every }} + - {{ source.diff.files | isFormattingChange }} + run: + - action: approve@v1 + - action: add-label@v1 + args: + label: code-formatting + - action: add-comment@v1 + args: + comment: | + This PR only contains formatting changes and has been approved. \ No newline at end of file diff --git a/downloads/automation-library/approve_javascript_log_output.cm b/downloads/automation-library/approve_javascript_log_output.cm new file mode 100644 index 00000000..ef087829 --- /dev/null +++ b/downloads/automation-library/approve_javascript_log_output.cm @@ -0,0 +1,20 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_javascript_log_output: + # Triggered for JavaScript changes that only affect the console.log() method + if: + - {{ files | match(regex=r/\.js$|\.ts$/) | every }} + - {{ source.diff.files | matchDiffLines(regex=r/^[+-].*console\.log/, ignoreWhiteSpaces=true) | every }} + run: + - action: add-label@v1 + args: + label: 'log-output-only' + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + This PR has been approved because it only contains changes to log output \ No newline at end of file diff --git a/downloads/automation-library/approve_python_formatting_change.cm b/downloads/automation-library/approve_python_formatting_change.cm new file mode 100644 index 00000000..8599e67d --- /dev/null +++ b/downloads/automation-library/approve_python_formatting_change.cm @@ -0,0 +1,19 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_python_formatting: + if: + - {{ files | extensions | match(list=['py']) | every }} + - {{ source.diff.files | isFormattingChange }} + run: + - action: approve@v1 + - action: add-label@v1 + args: + label: code-formatting + - action: add-comment@v1 + args: + comment: | + This PR only contains formatting changes and has been approved. \ No newline at end of file diff --git a/downloads/automation-library/approve_python_log_output.cm b/downloads/automation-library/approve_python_log_output.cm new file mode 100644 index 00000000..9be0d6d4 --- /dev/null +++ b/downloads/automation-library/approve_python_log_output.cm @@ -0,0 +1,21 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_python_log_output: + # Triggered for python changes that only affect lines of code that invoke a logger object. + # Modify 'logger' to match your dev environment. + if: + - {{ files | match(regex=r/\.py$/) | every }} + - {{ source.diff.files | matchDiffLines(regex=r/^[+-].*logger\.(trace|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }} + run: + - action: add-label@v1 + args: + label: 'log-output-only' + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + This PR has been approved because it only contains changes to log output \ No newline at end of file diff --git a/downloads/automation-library/approve_team_by_directory.cm b/downloads/automation-library/approve_team_by_directory.cm new file mode 100644 index 00000000..ec8c3e59 --- /dev/null +++ b/downloads/automation-library/approve_team_by_directory.cm @@ -0,0 +1,18 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_team_by_directory: + # Triggered for PRs that only include changes to files inside the docs directory, + # and that are authored by someone on the tech-writers team. + if: + - {{ files | match(regex=r/docs\//) | every }} + - {{ pr.author_teams | match(term='tech-writers') }} + run: + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + Docs changes from the tech-writers team are automatically approved. \ No newline at end of file diff --git a/downloads/automation-library/approve_tests.cm b/downloads/automation-library/approve_tests.cm new file mode 100644 index 00000000..d8748a45 --- /dev/null +++ b/downloads/automation-library/approve_tests.cm @@ -0,0 +1,20 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_tests: + if: + # Triggered for PRs that only include changes to tests + - {{ files | allTests }} + run: + - action: add-label@v1 + args: + label: 'tests-only' + - action: add-comment@v1 + args: + comment: | + This merge has been automatically approved because it only contains changes to tests. + - action: approve@v1 + diff --git a/downloads/automation-library/approve_tiny_changes.cm b/downloads/automation-library/approve_tiny_changes.cm new file mode 100644 index 00000000..b7eeb4a9 --- /dev/null +++ b/downloads/automation-library/approve_tiny_changes.cm @@ -0,0 +1,29 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_tiny_change: + # Triggered for PRs that contain one file and one line. + if: + - {{ is.one_file and is.one_line }} + run: + - action: add-label@v1 + args: + label: 'single-line' + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + This PR has been approved because it is only a single line + +changes: + # Sum all the lines added in the PR + additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }} + # Sum all the line removed in the PR + deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }} + +is: + one_file: {{ files | length == 1 }} + one_line: {{ changes.additions - changes.deletions <= 1 }} \ No newline at end of file diff --git a/downloads/automation-library/assign-team-to-prs-by-their-member.cm b/downloads/automation-library/assign-team-to-prs-by-their-member.cm new file mode 100644 index 00000000..7397fab9 --- /dev/null +++ b/downloads/automation-library/assign-team-to-prs-by-their-member.cm @@ -0,0 +1,13 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + add_first_team_reviewer: + if: + - true + run: + - action: add-reviewers@v1 + args: + team_reviewers: {{ pr.author_teams | first }} \ No newline at end of file diff --git a/downloads/automation-library/assign_reviewers_by_directory.cm b/downloads/automation-library/assign_reviewers_by_directory.cm new file mode 100644 index 00000000..f6ee4d18 --- /dev/null +++ b/downloads/automation-library/assign_reviewers_by_directory.cm @@ -0,0 +1,20 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + review_ui: + # Triggered for PRs that contain any changes to JavaScript files inside the `src/ui` directory. + if: + - {{ files | match(regex=r/src\/ui\/.*/) | some}} + # Add a specified user and team as reviewers. + # Customize the reviewers to match your organization + run: + - action: add-reviewers@v1 + args: + reviewers: [my-teamate, my-organization/security] + - action: add-comment@v1 + args: + comment: | + The Security team has automatically been added for review because this PR contains changes to components inside `/src/ui` diff --git a/downloads/automation-library/change_deprecated_components.cm b/downloads/automation-library/change_deprecated_components.cm new file mode 100644 index 00000000..83b903d6 --- /dev/null +++ b/downloads/automation-library/change_deprecated_components.cm @@ -0,0 +1,33 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Request changes when a PR includes deprecated components. + # This requires the `item` custom expression found at the bottom of this file. + {% for item in deprecated %} + # Automation names must be unique, so this adds an iterator index to each instance + review_deprecated_component_{{ item.old }}: + # Triggered when any of the modified files use a deprecated component + if: + - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }} + # Apply a deprecated-component label, request changes, and post a comment with an explanation. + run: + - action: add-label@v1 + args: + label: 'deprecated-component' + color: '#FF0000' + - action: request-changes@v1 + args: + comment: | + `{{ item.old }}` component is deprecated, use `{{ item.new }}` instead + {% endfor %} + +# These are the deprecated files that are evaluated in catch_deprecated_components +deprecated: + - regex: r/oldAPI/ + old: oldAPI + new: newAPI + - regex: r/anotherOldAPI/ + old: anotherOldAPI + new: anotherNewAPI diff --git a/downloads/automation-library/change_missing_lambda_field.cm b/downloads/automation-library/change_missing_lambda_field.cm new file mode 100644 index 00000000..35e2fe79 --- /dev/null +++ b/downloads/automation-library/change_missing_lambda_field.cm @@ -0,0 +1,21 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Request changes when required Lambda information is missing from the PR. + catch_missing_lambda_info: + # Triggered for new Lambda functions that are missing a description field. + if: + - {{ source.diff.files | matchDiffLines(regex=r/LambdaFunction/) | some }} + - {{ source.diff.files | matchDiffLines(regex=r/description:/) | nope }} + # Apply the lambda-missing-field label and request changes to the PR. + run: + - action: add-label@v1 + args: + label: 'lambda-missing-field' + color: '#FF0000' + - action: request-changes@v1 + args: + comment: | + New `LambdaFunction` must have `description:` field. \ No newline at end of file diff --git a/downloads/automation-library/close_wrong_team_by_directory.cm b/downloads/automation-library/close_wrong_team_by_directory.cm new file mode 100644 index 00000000..c616e0b9 --- /dev/null +++ b/downloads/automation-library/close_wrong_team_by_directory.cm @@ -0,0 +1,17 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Close PRs to restricted sections of the codebase if the PR author isn't on the correct team. + close_wrong_team_by_directory: + # Triggered when someone who isn't on the `ui` team submits a PR to change files inside /src/views + if: + - {{ files | match(regex=r/src\/views/) | some }} + - {{ pr.author_teams | match(term='ui') | nope }} + # Close the PR and post a comment explaining the next step. + run: + - action: add-comment@v1 + args: + comment: Please contact a member of the `ui` team if you need to make changes to files in `src/views` + - action: close@v1 \ No newline at end of file diff --git a/downloads/automation-library/create_jira_ticket.cm b/downloads/automation-library/create_jira_ticket.cm new file mode 100644 index 00000000..2b16b686 --- /dev/null +++ b/downloads/automation-library/create_jira_ticket.cm @@ -0,0 +1,18 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +has_jira_ticket: {{ pr.title | hasJiraTicket(env.JIRA_API_TOKEN) }} + +automations: + add_jira: + if: + - {{ not has_jira_ticket }} + run: + - action: send-http-request@v1 + args: + url: env.JIRA_WEBHOOK_URL + method: POST + headers: '{"Content-type": "application/json"}' + body: '{"data":{"pr_url": "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}}' diff --git a/downloads/automation-library/integrations/asana/label_missing_asana.cm b/downloads/automation-library/integrations/asana/label_missing_asana.cm new file mode 100644 index 00000000..a9a0ec25 --- /dev/null +++ b/downloads/automation-library/integrations/asana/label_missing_asana.cm @@ -0,0 +1,25 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + label_missing_asana: + if: + - {{not (has.asana.ticket_in_title or has.asana.ticket_in_desc)}} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Asana Link" + color: {{ colors.red }} + - action: add-comment@v1 + args: + comment: Please provide a link to the associated Asana resource. + +has: + asana: + ticket_in_title: {{ pr.title | includes(regex=r/asana-(\d+)/) }} + ticket_in_desc: {{ pr.description | includes(regex=r/app\.asana.\com\/(\d+)\/(\d+)\/(\d+)\/(\d+)\/(\d+)/) }} + +colors: + red: 'b60205' \ No newline at end of file diff --git a/downloads/automation-library/integrations/asana/link_asana.cm b/downloads/automation-library/integrations/asana/link_asana.cm new file mode 100644 index 00000000..0f5fd37f --- /dev/null +++ b/downloads/automation-library/integrations/asana/link_asana.cm @@ -0,0 +1,38 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +provider: asana + +# Configure this to match your organization. It is used in tracker.asana.baseurl. +asanaProject: 1234 + +{% set ticketid = "" %} +{% for ticket in tickets %} +{% if (ticket | includes(regex=r/.+/)) %} +{% set ticketid = ticket %} +{% endif %} +{% endfor %} + +automations: + link_asana: + if: + - {{ has.ticket_in_title or has.ticket_in_branch }} + run: + - action: add-comment@v1 + args: + comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}}) + +has: + ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }} + ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }} + +tracker: + asana: + baseurl: https://app.asana.com/0/[asanaProject]/0/ + pattern: r/asana-(\d+)/ + +tickets: + - {{branch.name | capture(regex=tracker[provider].pattern)}} + - {{pr.title | capture(regex=tracker[provider].pattern)}} diff --git a/downloads/automation-library/integrations/azure-boards/label_missing_azure_boards.cm b/downloads/automation-library/integrations/azure-boards/label_missing_azure_boards.cm new file mode 100644 index 00000000..a84f69d4 --- /dev/null +++ b/downloads/automation-library/integrations/azure-boards/label_missing_azure_boards.cm @@ -0,0 +1,25 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + label_missing_azure: + if: + - {{not (has.azure.ticket_in_title or has.azure.ticket_in_desc)}} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Azure Boards Link" + color: {{ colors.red }} + - action: add-comment@v1 + args: + comment: Please provide a link to the associated resource in Azure Boards. + +has: + azure: + ticket_in_title: {{ pr.title | includes(regex=r/(\w+)-(\w+)-(\d+)/) }} + ticket_in_desc: {{ pr.description | includes(regex=r/(dev\.azure\.com|(\w+)\.visualstudio\.com)\/(\w+)\/(\w+)\/_workitems\/edit\/(\d+)/) }} + +colors: + red: 'b60205' \ No newline at end of file diff --git a/downloads/automation-library/integrations/azure-boards/link_azure_boards.cm b/downloads/automation-library/integrations/azure-boards/link_azure_boards.cm new file mode 100644 index 00000000..35a950b7 --- /dev/null +++ b/downloads/automation-library/integrations/azure-boards/link_azure_boards.cm @@ -0,0 +1,40 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +# Configure these to match your organization. +provider: azure +# The name of your Azure organization +orgName: org +# The name of your Azure project +azureProject: my_project + +{% set ticketid = "" %} +{% for ticket in tickets %} +{% if (ticket | includes(regex=r/.+/)) %} +{% set ticketid = ticket %} +{% endif %} +{% endfor %} + +automations: + link_azure_boards: + if: + - {{ has.ticket_in_title or has.ticket_in_branch }} + run: + - action: add-comment@v1 + args: + comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}}) + +has: + ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }} + ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }} + +tracker: + azure: + baseurl: https://dev.azure.com/[orgName]/[azureProject]/_workitems/ + pattern: r/(\w+)-(\w+)-(\d+)/ + +tickets: + - {{branch.name | capture(regex=tracker[provider].pattern)}} + - {{pr.title | capture(regex=tracker[provider].pattern)}} diff --git a/downloads/automation-library/integrations/copilot/comment_copilot_prompt.cm b/downloads/automation-library/integrations/copilot/comment_copilot_prompt.cm new file mode 100644 index 00000000..0ea82cae --- /dev/null +++ b/downloads/automation-library/integrations/copilot/comment_copilot_prompt.cm @@ -0,0 +1,21 @@ +-*- mode: yaml -*- + +manifest: + version: 1.0 + +on: + - pr_created + +automations: + comment_copilot_prompt: + # Post a comment for all PRs to prompt the PR author to indicate whether they used Copilot to assist coding in this PR + if: + - true + run: + - action: add-comment@v1 + args: + comment: | + Please mark whether you used Copilot to assist coding in this PR + + - [ ] Copilot Assisted + - [ ] Not Copilot Assisted diff --git a/downloads/automation-library/integrations/copilot/label_copilot_by_contributors.cm b/downloads/automation-library/integrations/copilot/label_copilot_by_contributors.cm new file mode 100644 index 00000000..4bf4f3fc --- /dev/null +++ b/downloads/automation-library/integrations/copilot/label_copilot_by_contributors.cm @@ -0,0 +1,20 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + label_genai: + # For all PRs authored by someone who is specified in the genai_contributors list + if: + - {{ pr.author | match(list=genai_contributors) | some }} + # Apply a label indicating the user has adopted Copilot + run: + - action: add-label@v1 + args: + label: '🤖 Copilot' + +genai_contributors: + - username1 + - username2 + - etc diff --git a/downloads/automation-library/integrations/copilot/label_copilot_by_prompt.cm b/downloads/automation-library/integrations/copilot/label_copilot_by_prompt.cm new file mode 100644 index 00000000..3dce4b1a --- /dev/null +++ b/downloads/automation-library/integrations/copilot/label_copilot_by_prompt.cm @@ -0,0 +1,16 @@ +-*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + # You should use this automation in conjunction with comment_copilot_prompt.cm + label_copilot_pr: + # If the PR author has indicated that they used Copilot to assist coding in this PR, + # apply a label indicating the PR was supported by Copilot + if: + - {{ pr.comments | filter(attr='commenter', term='gitstream-cm') | filter (attr='content', regex=r/\- \[x\] Copilot Assisted/) | some}} + run: + - action: add-label@v1 + args: + label: '🤖 Copilot' \ No newline at end of file diff --git a/downloads/automation-library/integrations/copilot/label_copilot_by_tag.cm b/downloads/automation-library/integrations/copilot/label_copilot_by_tag.cm new file mode 100644 index 00000000..a3acc7bd --- /dev/null +++ b/downloads/automation-library/integrations/copilot/label_copilot_by_tag.cm @@ -0,0 +1,26 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +on: + - comment_added + - commit + - pr_created + +automations: + label_copilot: + # Detect PRs that contain the text '#copilot#' in the title, description, comments, or commit messages + if: + - {{ copilot_tag.pr_title or copilot_tag.pr_desc or copilot_tag.pr_comments or copilot_tag.commit_messages }} + # Apply a label indicating the user has adopted Copilot + run: + - action: add-label@v1 + args: + label: '🤖 Copilot' + +copilot_tag: + pr_title: {{ pr.title | includes(regex=r/#copilot#/) }} + pr_desc: {{pr.description | includes(regex=r/#copilot#/) }} + pr_comments: {{ pr.comments | map(attr='content') | match(regex=r/#copilot#/) | some }} + commit_messages: {{ branch.commits.messages | match(regex=r/#copilot#/) | some }} diff --git a/downloads/automation-library/integrations/dependabot/approve_dependabot.cm b/downloads/automation-library/integrations/dependabot/approve_dependabot.cm new file mode 100644 index 00000000..06d156df --- /dev/null +++ b/downloads/automation-library/integrations/dependabot/approve_dependabot.cm @@ -0,0 +1,19 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_dependabot: + if: + - {{ branch.name | includes(term="dependabot") }} + - {{ branch.author | includes(term="dependabot") }} + run: + - action: approve@v1 + - action: add-label@v1 + args: + label: "approved-dependabot" + - action: merge@v1 + args: + wait_for_all_checks: true + squash_on_merge: true \ No newline at end of file diff --git a/downloads/automation-library/integrations/dependabot/approve_dependabot_minor.cm b/downloads/automation-library/integrations/dependabot/approve_dependabot_minor.cm new file mode 100644 index 00000000..247dd9f5 --- /dev/null +++ b/downloads/automation-library/integrations/dependabot/approve_dependabot_minor.cm @@ -0,0 +1,29 @@ +manifest: + version: 1.0 + +automations: + merge_dependabot_minor: + if: + - {{ bump == 'minor' }} + - {{ branch.name | includes(term="dependabot") }} + - {{ branch.author | includes(term="dependabot") }} + run: + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + Dependabot `minor` version bumps are approved automatically. + merge_dependabot_minor_patch: + if: + - {{ bump == 'patch' }} + - {{ branch.name | includes(term="dependabot") }} + - {{ branch.author | includes(term="dependabot") }} + run: + - action: approve@v1 + - action: merge@v1 + - action: add-comment@v1 + args: + comment: | + Dependabot `patch` version bumps are approved and merged automatically. + +bump: {{ pr.description | extractDependabotVersionBump | compareSemver }} \ No newline at end of file diff --git a/downloads/automation-library/integrations/devcycle/label-ff-devcycle/label_ff_devcycle.cm b/downloads/automation-library/integrations/devcycle/label-ff-devcycle/label_ff_devcycle.cm new file mode 100644 index 00000000..448049d9 --- /dev/null +++ b/downloads/automation-library/integrations/devcycle/label-ff-devcycle/label_ff_devcycle.cm @@ -0,0 +1,30 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + + {% for item in feature_flags %} + label_ff_devcycle_{{ item.name }}: + if: + - {{ source.diff.files | matchDiffLines(regex=r/key = '/) | some }} + - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }} + run: + - action: add-label@v1 + args: + label: {{ item.name }} + color: {{ colors.yellow }} + {% endfor %} + +feature_flags: + - name: engineering_rollback_plan_activated + regex: r/engineering_rollback_plan_activated/ + - name: marketing_premium_plan_features_unlocked + regex: r/marketing_premium_plan_features_unlocked/ + - name: mobile_push_notifications_enabled + regex: r/mobile_push_notifications_enabled/ + +colors: + yellow: 'ffb300' + + diff --git a/downloads/automation-library/integrations/flagr/label-ff-flagr/label_ff_flagr.cm b/downloads/automation-library/integrations/flagr/label-ff-flagr/label_ff_flagr.cm new file mode 100644 index 00000000..8182508d --- /dev/null +++ b/downloads/automation-library/integrations/flagr/label-ff-flagr/label_ff_flagr.cm @@ -0,0 +1,30 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + + {% for item in feature_flags %} + label_ff_flagr_{{ item.name }}: + if: + - {{ source.diff.files | matchDiffLines(regex=r/evaluation_result.variant_id ==/) | some }} + - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }} + run: + - action: add-label@v1 + args: + label: {{ item.name }} + color: {{ colors.yellow }} + {% endfor %} + +feature_flags: + - name: engineering_rollback_plan_activated + regex: r/engineering_rollback_plan_activated/ + - name: marketing_premium_plan_features_unlocked + regex: r/marketing_premium_plan_features_unlocked/ + - name: mobile_push_notifications_enabled + regex: r/mobile_push_notifications_enabled/ + +colors: + yellow: 'ffb300' + + diff --git a/downloads/automation-library/integrations/flagsmith/label-ff-flagsmith/label_ff_flagsmith.cm b/downloads/automation-library/integrations/flagsmith/label-ff-flagsmith/label_ff_flagsmith.cm new file mode 100644 index 00000000..61661a2b --- /dev/null +++ b/downloads/automation-library/integrations/flagsmith/label-ff-flagsmith/label_ff_flagsmith.cm @@ -0,0 +1,30 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + + {% for item in feature_flags %} + label_ff_flagsmith_{{ item.name }}: + if: + - {{ source.diff.files | matchDiffLines(regex=r/flagsmith.hasFeature\(/) | some }} + - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }} + run: + - action: add-label@v1 + args: + label: {{ item.name }} + color: {{ colors.yellow }} + {% endfor %} + +feature_flags: + - name: engineering_rollback_plan_activated + regex: r/engineering_rollback_plan_activated/ + - name: marketing_premium_plan_features_unlocked + regex: r/marketing_premium_plan_features_unlocked/ + - name: mobile_push_notifications_enabled + regex: r/mobile_push_notifications_enabled/ + +colors: + yellow: 'ffb300' + + diff --git a/downloads/automation-library/integrations/github-actions/dispatch-github-action/dispatch_github_action_branch.cm b/downloads/automation-library/integrations/github-actions/dispatch-github-action/dispatch_github_action_branch.cm new file mode 100644 index 00000000..5cf122fe --- /dev/null +++ b/downloads/automation-library/integrations/github-actions/dispatch-github-action/dispatch_github_action_branch.cm @@ -0,0 +1,35 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +on: + - pr_created + - commit + +automations: + {% for item in pipelines %} + # Change pr.target to branch.name if you want to trigger on the source branch rather then the target branch. + dispatch_github_action_{{ item.name }}: + if: + - {{ pr.target | includes(term=item.branch_prefix) }} + run: + - action: run-github-workflow@v1 + args: + workflow: .github/workflows/{{ item.workflow }} + check_name: {{ item.name }} + - action: add-label@v1 + args: + label: {{ item.label }} + {% endfor %} + + +pipelines: + - name: mobile_ci + label: Mobile CI + branch_prefix: 'mobile-' + workflow: mobile.yml + - name: backend_ci + label: Backend CI + branch_prefix: 'backend-' + workflow: 'backend.yml' diff --git a/downloads/automation-library/integrations/github-actions/dispatch-github-action/dispatch_github_action_label.cm b/downloads/automation-library/integrations/github-actions/dispatch-github-action/dispatch_github_action_label.cm new file mode 100644 index 00000000..547a031e --- /dev/null +++ b/downloads/automation-library/integrations/github-actions/dispatch-github-action/dispatch_github_action_label.cm @@ -0,0 +1,28 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +on: + - label_added + - label_removed + +automations: + {% for item in pipelines %} + dispatch_github_action_{{ item.name }}: + if: + - {{ pr.labels | match(term=item.label) | some }} + run: + - action: run-github-workflow@v1 + args: + workflow: .github/workflows/{{ item.workflow }} + check_name: {{ item.name }} + {% endfor %} + +pipelines: + - name: mobile-ci + label: Mobile CI + workflow: mobile.yml + - name: backend-ci + label: Backend CI + workflow: 'backend.yml' diff --git a/downloads/automation-library/integrations/github-actions/dispatch-github-action/dispatch_github_action_resource.cm b/downloads/automation-library/integrations/github-actions/dispatch-github-action/dispatch_github_action_resource.cm new file mode 100644 index 00000000..451a0d15 --- /dev/null +++ b/downloads/automation-library/integrations/github-actions/dispatch-github-action/dispatch_github_action_resource.cm @@ -0,0 +1,43 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +on: + - pr_created + - commit + +automations: + {% for item in pipelines %} + dispatch_github_action_{{ item.name }}: + if: + - {{ files | match(list=item.resources) | some }} + run: + - action: run-github-workflow@v1 + args: + workflow: .github/workflows/{{ item.workflow }} + check_name: {{ item.name }} + - action: add-label@v1 + args: + label: {{ item.label }} + {% endfor %} + + +pipelines: + - name: mobile-ci + label: Mobile CI + resources: + - 'src/android/' + - 'src/ios/' + workflow: mobile.yml + - name: backend-ci + label: Backend CI + resources: + - 'src/api/' + - 'src/services' + workflow: 'backend.yml' + - name: frontend-ci + label: Frontend CI + resources: + - 'src/app/' + workflow: 'frontend.yml' diff --git a/downloads/automation-library/integrations/github-actions/skip-github-action/skip_github_action_branch.cm b/downloads/automation-library/integrations/github-actions/skip-github-action/skip_github_action_branch.cm new file mode 100644 index 00000000..324b7a47 --- /dev/null +++ b/downloads/automation-library/integrations/github-actions/skip-github-action/skip_github_action_branch.cm @@ -0,0 +1,24 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +on: + - pr_created + - commit + +# Optionally, you can change pr.target to branch.name +# if you want to trigger based on the source branch name rather then the target branch name. +automations: + skip_github_action_branch: + if: + - {{ pr.target | includes(term='release') }} + run: + - action: add-github-check@v1 + args: + check_name: staging-ci + conclusion: skipped + - action: add-comment@v1 + args: + comment: | + [gitStream](https://docs.gitstream.cm) automatically skipped staging CI pipelines because this PR targets the release branch. diff --git a/downloads/automation-library/integrations/github-actions/skip-github-action/skip_github_action_label.cm b/downloads/automation-library/integrations/github-actions/skip-github-action/skip_github_action_label.cm new file mode 100644 index 00000000..86d1eb45 --- /dev/null +++ b/downloads/automation-library/integrations/github-actions/skip-github-action/skip_github_action_label.cm @@ -0,0 +1,22 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +on: + - label_added + - label_removed + +automations: + skip_github_action_label: + if: + - {{ pr.labels | match(term='experimental') | some }} + run: + - action: add-github-check@v1 + args: + check_name: production-ci + conclusion: skipped + - action: add-comment@v1 + args: + comment: | + [gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this is labeled for experimental release. diff --git a/downloads/automation-library/integrations/github-actions/skip-github-action/skip_github_action_resource.cm b/downloads/automation-library/integrations/github-actions/skip-github-action/skip_github_action_resource.cm new file mode 100644 index 00000000..9bd984fa --- /dev/null +++ b/downloads/automation-library/integrations/github-actions/skip-github-action/skip_github_action_resource.cm @@ -0,0 +1,26 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +on: + - pr_created + - commit + +automations: + skip_github_action_resource: + if: + - {{ files | match(term='docs/') | every }} + run: + - action: add-github-check@v1 + args: + check_name: release-ci + conclusion: skipped + - action: add-github-check@v1 + args: + check_name: mobile-ci + conclusion: skipped + - action: add-comment@v1 + args: + comment: | + [gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this PR only contains docs changes. diff --git a/downloads/automation-library/integrations/godoc/review_godoc.cm b/downloads/automation-library/integrations/godoc/review_godoc.cm new file mode 100644 index 00000000..8fef70a9 --- /dev/null +++ b/downloads/automation-library/integrations/godoc/review_godoc.cm @@ -0,0 +1,22 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + #Assign PRs that only affect godocs to the technical writing team and add docs label + review_godoc: + if: + - {{ source.diff.files | match(attr='diff', regex=r/^\/\/.*/) | every }} + - {{ files | extensions | match(regex=r/go/) | every }} + + run: + - action: add-label@v1 + args: + label: "📓godoc Only" + color: {{ colors.green }} + - action: add-reviewers@v1 + args: + reviewers: [org/tech-writers] + - action: approve@v1 + +colors: + green: '0e8a16' diff --git a/downloads/automation-library/integrations/godoc/review_godoc_large.cm b/downloads/automation-library/integrations/godoc/review_godoc_large.cm new file mode 100644 index 00000000..db58a497 --- /dev/null +++ b/downloads/automation-library/integrations/godoc/review_godoc_large.cm @@ -0,0 +1,30 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + #Require more extensive reviews for large Golang changes that lack Godoc updates. + review_godoc_large: + if: + - {{ changes.additions > 100}} + - {{ source.diff.files | matchDiffLines(regex=r/^\/\/.*/) | nope }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Godoc" + color: {{ colors.yellow }} + - action: add-comment@v1 + args: + comment: | + This PR makes major changes to Golang classes, but is missing updates to Godoc. Please double check for any necessary Godoc updates. + - action: add-reviewers@v1 + args: + reviewers: [fourth-organization/tech-writers] + +changes: + # Sum all the lines added/edited in the PR + additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }} + +colors: + yellow: 'fbca04' diff --git a/downloads/automation-library/integrations/godoc/review_godoc_new_class.cm b/downloads/automation-library/integrations/godoc/review_godoc_new_class.cm new file mode 100644 index 00000000..9f4ebf4c --- /dev/null +++ b/downloads/automation-library/integrations/godoc/review_godoc_new_class.cm @@ -0,0 +1,24 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + review_godoc_new_class: + if: + - {{ is.go and is.new }} + - {{ source.diff.files | match(attr='diff', regex=r/\/*[\s\S]*?\//) | nope }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing godoc" + color: {{ colors.yellow }} + - action: add-comment@v1 + args: + comment: | + godoc is required for all Golang classes. Please add godoc to all new classes in this PR. + +is: + go: {{ files | extensions | match(regex=r/go/) | every }} + new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }} + +colors: + yellow: 'fbca04' diff --git a/downloads/automation-library/integrations/javadoc/review_javadoc_changes.cm b/downloads/automation-library/integrations/javadoc/review_javadoc_changes.cm new file mode 100644 index 00000000..457b2a52 --- /dev/null +++ b/downloads/automation-library/integrations/javadoc/review_javadoc_changes.cm @@ -0,0 +1,21 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + # Assign PRs that only affect JavaDocs to the technical writing team and add docs label + review_javadoc: + if: + - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | every }} + - {{ source.diff.files | matchDiffLines(regex=r/\b(public|protected|private|static|final|synchronized)?\s+\w+\s+\w+\s*\(([^)]*)\)\s*\{/) | nope }} + run: + - action: add-label@v1 + args: + label: "📓 Javadoc Only" + color: {{ colors.green }} + - action: add-reviewers@v1 + args: + reviewers: [org/tech-writers] + - action: approve@v1 + +colors: + green: '0e8a16' diff --git a/downloads/automation-library/integrations/javadoc/review_javadoc_input_parameters.cm b/downloads/automation-library/integrations/javadoc/review_javadoc_input_parameters.cm new file mode 100644 index 00000000..ca47a632 --- /dev/null +++ b/downloads/automation-library/integrations/javadoc/review_javadoc_input_parameters.cm @@ -0,0 +1,13 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + review_javadoc_input_parameters: + if: + - {{ source.diff.files | matchDiffLines(regex=r/\*\s@param/) | nope }} + - {{ source.diff.files | matchDiffLines(regex=r/\b(public|protected|private|static|final|synchronized)?\s+\w+\s+\w+\s*\(([^)]*)\)\s*\{/) | some }} + run: + - action: add-comment@v1 + args: + comment: | + This PR modifies method input parameters, but is missing Javadoc changes. Please check to ensure no Javadoc changes are necessary. \ No newline at end of file diff --git a/downloads/automation-library/integrations/javadoc/review_javadoc_large_change.cm b/downloads/automation-library/integrations/javadoc/review_javadoc_large_change.cm new file mode 100644 index 00000000..6cd9f5aa --- /dev/null +++ b/downloads/automation-library/integrations/javadoc/review_javadoc_large_change.cm @@ -0,0 +1,34 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + #Require more extensive reviews for large Java changes that lack Javadoc updates. + review_javadoc_large: + if: + - {{ changes.ratio > 25}} + - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Javadoc" + color: {{ colors.yellow }} + - action: add-comment@v1 + args: + comment: | + This PR makes major changes to Java classes, but is missing updates to Javadoc. Please double check for any necessary Javadoc updates. + - action: add-reviewers@v1 + args: + reviewers: [fourth-organization/tech-writers] + +changes: + # Sum all the lines added/edited in the PR + additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }} + # Sum all the line removed in the PR + deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }} + # Calculate the ratio of new code + ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }} + +colors: + yellow: 'fbca04' \ No newline at end of file diff --git a/downloads/automation-library/integrations/javadoc/review_new_class_javadoc.cm b/downloads/automation-library/integrations/javadoc/review_new_class_javadoc.cm new file mode 100644 index 00000000..8a2c7f89 --- /dev/null +++ b/downloads/automation-library/integrations/javadoc/review_new_class_javadoc.cm @@ -0,0 +1,25 @@ +manifest: + version: 1.0 + +automations: + review_new_class_javadoc: + # Triggered for new Java files that lack Javadoc content. + if: + - {{ is.java and is.new }} + - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Javadoc" + color: {{ colors.yellow }} + - action: request-changes@v1 + args: + comment: | + This PR creates new Java classes, but is missing updates to Javadoc. Please double check for any necessary Javadoc updates. + +is: + java: {{ files | extensions | match(term='java') | every }} + new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }} + +colors: + yellow: 'fbca04' \ No newline at end of file diff --git a/downloads/automation-library/integrations/jira/create_jira_issue.cm b/downloads/automation-library/integrations/jira/create_jira_issue.cm new file mode 100644 index 00000000..9b6d638d --- /dev/null +++ b/downloads/automation-library/integrations/jira/create_jira_issue.cm @@ -0,0 +1,55 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + + +###### ** Configure This Section ** ###### + +# Configure this for your Jira instance and the email associated with your API key. +# You can safely use these values because only your API key is sensitive. +jiraSpaceName: "my-company" # e.g. my-company.atlassian.net +email: "my.email@example.com" +# If you're concerned about exposing this information, +# we recommend using environment variables for your production environment. + +# ----------- + +# Pass the API token associated with the email above to gitStream via an environment variable. +jiraAuth: {{ env.JIRA_API_TOKEN }} +# Learn more about env: https://docs.gitstream.cm/context-variables/#env + +# ----------- + +# Change this to the Jira field you want to match the input string against. +jiraField: "myField" +# If you want to search a custom field, you should provide the ID like so: +# jiraField: "cf[XXXXX]" +# Replace XXXXX with the ID of the custom field you want to search. +# More information: +# Using JQL to search the Jira API: https://support.atlassian.com/jira-service-management-cloud/docs/jql-fields/ +# How to find the ID of a custom field: https://confluence.atlassian.com/jirakb/how-to-find-any-custom-field-s-ids-744522503.html + +# ----------- + +###### ** Automation ** ###### +# You may want to update the text in the comment gitStream posts; +# otherwise, this section shouldn't need to be changed. +prUrl: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}" +has_jira_issue: {{ prUrl | hasJiraIssue(jiraAuth, jiraField, jiraSpaceName, email) }} + +automations: + automatic_jira_task: + if: + - {{ not has_jira_issue }} + - {{ pr.description | includes(regex=r/\- \[x\] Auto-create Jira Task/)}} + run: + - action: send-http-request@v1 + args: + url: {{ env.JIRA_WEBHOOK }} + method: POST + headers: '{"Content-type": "application/json"}' + body: '{"data":{"pr_url": "{{ prUrl }}","title":"{{ pr.title }}"}}' + - action: add-comment@v1 + args: + comment: "gitStream automatically created a Jira task for this PR" \ No newline at end of file diff --git a/downloads/automation-library/integrations/jira/jira_assign.cm b/downloads/automation-library/integrations/jira/jira_assign.cm new file mode 100644 index 00000000..d1510bcb --- /dev/null +++ b/downloads/automation-library/integrations/jira/jira_assign.cm @@ -0,0 +1,33 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +assigneeRegex: r/(?<=\/gitstream assign-jira ).*(?=
)/ + +{% set ticketid = "" %} +{% for ticket in tickets %} +{% if (ticket | includes(regex=r/.+/)) %} +{% set ticketid = ticket %} +{% endif %} +{% endfor %} + +automations: + jira_assign: + if: + - {{ pr.description | includes(regex=assigneeRegex) }} + run: + - action: send-http-request@v1 + args: + url: "{{ env.JIRA_WEBHOOK }}}" + method: POST + headers: '{"Content-type": "application/json"}' + body: '{"issues":["{{ticketid}}"],"data":{"assignee":"{{pr.description | capture(regex=assigneeRegex)}}"}}' + +has: + jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} + jira_ticket_in_branch: {{ branch.name | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} + +tickets: + - {{branch.name | capture(regex=r/\b[A-Za-z]+-\d+\b/)}} + - {{pr.title | capture(regex=r/\b[A-Za-z]+-\d+\b/)}} diff --git a/downloads/automation-library/integrations/jira/jira_change_status.cm b/downloads/automation-library/integrations/jira/jira_change_status.cm new file mode 100644 index 00000000..2ef50ff5 --- /dev/null +++ b/downloads/automation-library/integrations/jira/jira_change_status.cm @@ -0,0 +1,34 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +on: + - pr_created + +{% set ticketid = "\b[A-Za-z]+-\d+\b" %} +{% for ticket in tickets %} +{% if (ticket | includes(regex=r/.+/)) %} +{% set ticketid = ticket %} +{% endif %} +{% endfor %} + +automations: + jira_change_status: + if: + - {{ has.jira_ticket_in_title or has.jira_ticket_in_desc }} + run: + - action: send-http-request@v1 + args: + url: "{{ env.JIRA_CHANGE_STATUS_WEBHOOK }}" + method: POST + headers: '{"Content-type": "application/json"}' + body: '{"issues":["{{ticketid}}"],"data":{"pr_url":"https://github.com/{{repo.owner}}/{{repo.name}}/pull/{{pr.number}}"}}' + +has: + jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} + jira_ticket_in_branch: {{ branch.name | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} + +tickets: + - {{branch.name | capture(regex=r/\b[A-Za-z]+-\d+\b/)}} + - {{pr.title | capture(regex=r/\b[A-Za-z]+-\d+\b/)}} \ No newline at end of file diff --git a/downloads/automation-library/integrations/jira/jira_update_field.cm b/downloads/automation-library/integrations/jira/jira_update_field.cm new file mode 100644 index 00000000..85b009ef --- /dev/null +++ b/downloads/automation-library/integrations/jira/jira_update_field.cm @@ -0,0 +1,30 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +on: + - pr_created + +{% set ticketid = "\b[A-Za-z]+-\d+\b" %} +{% for ticket in tickets %} +{% if (ticket | includes(regex=r/.+/)) %} +{% set ticketid = ticket %} +{% endif %} +{% endfor %} + +automations: + jira_update_field: + if: + - {{ has.jira_ticket_in_title or has.jira_ticket_in_branch }} + run: + - action: send-http-request@v1 + args: + url: "{{ env.JIRA_UPDATE_PR_FIELD_WEBHOOK }}" + method: POST + headers: '{"Content-type": "application/json"}' + body: '{"issues":["{{ticketid}}"],"data":{"pr_url":"https://github.com/{{repo.owner}}/{{repo.name}}/pull/{{pr.number}}"}}' + +has: + jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} + jira_ticket_in_branch: {{ branch.name | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} diff --git a/downloads/automation-library/integrations/jira/label_missing_jira_info.cm b/downloads/automation-library/integrations/jira/label_missing_jira_info.cm new file mode 100644 index 00000000..38005c9d --- /dev/null +++ b/downloads/automation-library/integrations/jira/label_missing_jira_info.cm @@ -0,0 +1,20 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + label_missing_jira_info: + # Triggered for PRs that don't have either a Jira ticket number in the title, + # or a link to a Jira ticket in the PR description. + if: + - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }} + run: + - action: add-label@v1 + args: + label: "missing-jira" + color: 'F6443B' + +has: + jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} + jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }} diff --git a/downloads/automation-library/integrations/jira/link_jira.cm b/downloads/automation-library/integrations/jira/link_jira.cm new file mode 100644 index 00000000..48ab36e0 --- /dev/null +++ b/downloads/automation-library/integrations/jira/link_jira.cm @@ -0,0 +1,38 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +provider: jira + +# Change this to the name of your Jira organization +orgName: org + +{% set ticketid = "" %} +{% for ticket in tickets %} +{% if (ticket | includes(regex=r/.+/)) %} +{% set ticketid = ticket %} +{% endif %} +{% endfor %} + +automations: + link_jira: + if: + - {{ has.ticket_in_title or has.ticket_in_branch }} + run: + - action: add-comment@v1 + args: + comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}}) + +has: + ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }} + ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }} + +tracker: + jira: + baseurl: https://[orgName].atlassian.net/browse/ + pattern: r/\b[A-Za-z]+-\d+\b/ + +tickets: + - {{branch.name | capture(regex=tracker[provider].pattern)}} + - {{pr.title | capture(regex=tracker[provider].pattern)}} diff --git a/downloads/automation-library/integrations/jit/label_jit_alerts.cm b/downloads/automation-library/integrations/jit/label_jit_alerts.cm new file mode 100644 index 00000000..66e57248 --- /dev/null +++ b/downloads/automation-library/integrations/jit/label_jit_alerts.cm @@ -0,0 +1,31 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + {% for item in reports %} + label_jit_{{ item.name }}: + if: + - {{ item.count > 0}} + run: + - action: add-label@v1 + args: + label: 'Jit: {{ item.count }} {{ item.name }} vulnerabilities' + color: {{ colors.red if (item.name == 'high') else (colors.orange if (item.name == 'medium' ) else colors.yellow) }} + {% endfor %} + +jit: {{ pr | extractJitFindings }} + +reports: + - name: high + count: {{ jit.metrics.HIGH }} + - name: medium + count: {{ jit.metrics.MEDIUM }} + - name: low + count: {{ jit.metrics.LOW }} + +colors: + red: 'b60205' + orange: 'd93f0b' + yellow: 'fbca04' \ No newline at end of file diff --git a/downloads/automation-library/integrations/jit/review_jit_alerts.cm b/downloads/automation-library/integrations/jit/review_jit_alerts.cm new file mode 100644 index 00000000..c15d9de5 --- /dev/null +++ b/downloads/automation-library/integrations/jit/review_jit_alerts.cm @@ -0,0 +1,34 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + review_jit_high_alerts: + if: + - {{ jit.metrics.HIGH > 0 }} + run: + - action: require-reviewers@v1 + args: + reviewers: [my-organization/security-team] + - action: set-required-approvals@v1 + args: + approvals: 2 + - action: add-comment@v1 + args: + comment: | + This PR requires additional review because Jit reported one or more high risk vulnerabilities. + review_jit_medium_alerts: + if: + - {{ jit.metrics.MEDIUM > 0 }} + run: + - action: set-required-approvals@v1 + args: + approvals: 2 + - action: add-comment@v1 + args: + comment: | + This PR requires additional reviewers because Jit reported one or more medium risk vulnerabilities. + + +jit: {{ pr | extractJitFindings }} diff --git a/downloads/automation-library/integrations/jit/review_jit_ignore_accept.cm b/downloads/automation-library/integrations/jit/review_jit_ignore_accept.cm new file mode 100644 index 00000000..02a5717d --- /dev/null +++ b/downloads/automation-library/integrations/jit/review_jit_ignore_accept.cm @@ -0,0 +1,23 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + review_jit_ignore_accept: + if: + - {{ pr.conversations | reject(attr='commenter', term='jit-ci') | filter(attr='content', term='#jit_ignore_accept') | some }} + run: + + - action: add-reviewers@v1 + args: + reviewers: [my-organziation/security] + - action: add-label@v1 + args: + label: '❕ Jit: Ignore - Accept Risk' + - action: add-comment@v1 + args: + comment: | + The security team has been assigned for optional review because this PR ignores a Jit alert and accepts the associated risks. + +jit: {{ pr | extractJitFindings }} diff --git a/downloads/automation-library/integrations/jit/review_jit_secret.cm b/downloads/automation-library/integrations/jit/review_jit_secret.cm new file mode 100644 index 00000000..e68e311a --- /dev/null +++ b/downloads/automation-library/integrations/jit/review_jit_secret.cm @@ -0,0 +1,22 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + review_jit_secret: + if: + - true + - {{ jit.vulnerabilities | match(attr='security_control', term='Secret Detection') | some }} + run: + - action: add-comment@v1 + args: + comment: | + Jit detects secrets in this PR. Please complete the following steps: + 1. Undo the commit with git reset and remove all secrets from the files you modified. + 2. Deactivate the secret in any locations its used and replace it with a new key + 3. Commit your changes and resubmit your PR. + - action: close@v1 + + +jit: {{ pr | extractJitFindings }} diff --git a/downloads/automation-library/integrations/jsdoc/review_jsdoc.cm b/downloads/automation-library/integrations/jsdoc/review_jsdoc.cm new file mode 100644 index 00000000..58acd587 --- /dev/null +++ b/downloads/automation-library/integrations/jsdoc/review_jsdoc.cm @@ -0,0 +1,21 @@ + +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + #Assign PRs that only affect JSDocs to the technical writing team and add docs label + review_jsdoc: + if: + - {{ source.diff.files | match(attr='diff', regex=r/\/*\*[\s\S]*?\//) | every }} + run: + - action: add-label@v1 + args: + label: "📓JSDoc Only" + color: {{ colors.green }} + - action: add-reviewers@v1 + args: + reviewers: [fourth-organization/tech-writers] + - action: approve@v1 + +colors: + green: '0e8a16' \ No newline at end of file diff --git a/downloads/automation-library/integrations/jsdoc/review_jsdoc_input.cm b/downloads/automation-library/integrations/jsdoc/review_jsdoc_input.cm new file mode 100644 index 00000000..5f835c07 --- /dev/null +++ b/downloads/automation-library/integrations/jsdoc/review_jsdoc_input.cm @@ -0,0 +1,16 @@ + +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + review_jsdoc_input: + if: + - {{ source.diff.files | matchDiffLines(regex=r/.*\s@param/) | nope }} + - {{ source.diff.files | matchDiffLines(regex=r/\((?:.*\:.*\))/) | some }} + + run: + - action: add-comment@v1 + args: + comment: | + This PR appears to modify method input parameters, but is missing JSDoc changes. Please check to ensure no JSDoc changes are necessary. + diff --git a/downloads/automation-library/integrations/jsdoc/review_jsdoc_large.cm b/downloads/automation-library/integrations/jsdoc/review_jsdoc_large.cm new file mode 100644 index 00000000..d99e94ed --- /dev/null +++ b/downloads/automation-library/integrations/jsdoc/review_jsdoc_large.cm @@ -0,0 +1,34 @@ + +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + #Require more extensive reviews for large Javascript changes that lack JSDoc updates. + review_jsdoc_large: + if: + - {{ changes.ratio > 25}} + - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }} + run: + - action: add-label@v1 + args: + label: "⚠️ No JSDoc" + color: {{ colors.yellow }} + - action: add-comment@v1 + args: + comment: | + This PR makes major changes to JavaScript classes, but is missing updates to JSDoc. Please double check for any necessary JSDoc updates. + + - action: add-reviewers@v1 + args: + reviewers: [fourth-organization/tech-writers] + +changes: + # Sum all the lines added/edited in the PR + additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }} + # Sum all the line removed in the PR + deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }} + # Calculate the ratio of new code + ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }} + +colors: + yellow: 'fbca04' \ No newline at end of file diff --git a/downloads/automation-library/integrations/jsdoc/review_jsdoc_new_class.cm b/downloads/automation-library/integrations/jsdoc/review_jsdoc_new_class.cm new file mode 100644 index 00000000..a92a5f93 --- /dev/null +++ b/downloads/automation-library/integrations/jsdoc/review_jsdoc_new_class.cm @@ -0,0 +1,25 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + review_jsdoc_new_class: + if: + - {{ is.javascript and is.new }} + - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing JSDoc" + color: {{ colors.yellow }} + - action: request-changes@v1 + args: + comment: | + JSDoc is required for all JavaScript classes. Please add JSDoc to all new classes in this PR. + +is: + javascript: {{ files | extensions | match(list=['js', 'ts']) | every }} + new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }} + +colors: + yellow: 'fbca04' + diff --git a/downloads/automation-library/integrations/launch-darkly/label-ff-launch-darkly/label_ff_launch_darkly.cm b/downloads/automation-library/integrations/launch-darkly/label-ff-launch-darkly/label_ff_launch_darkly.cm new file mode 100644 index 00000000..4a4e9085 --- /dev/null +++ b/downloads/automation-library/integrations/launch-darkly/label-ff-launch-darkly/label_ff_launch_darkly.cm @@ -0,0 +1,30 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + + {% for item in feature_flags %} + label_ff_launchdarkly_{{ item.name }}: + if: + - {{ source.diff.files | matchDiffLines(regex=r/var flagValue = ldclient/) | some }} + - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }} + run: + - action: add-label@v1 + args: + label: {{ item.name }} + color: {{ colors.yellow }} + {% endfor %} + +feature_flags: + - name: engineering_rollback_plan_activated + regex: r/engineering_rollback_plan_activated/ + - name: marketing_premium_plan_features_unlocked + regex: r/marketing_premium_plan_features_unlocked/ + - name: mobile_push_notifications_enabled + regex: r/mobile_push_notifications_enabled/ + +colors: + yellow: 'ffb300' + + diff --git a/downloads/automation-library/integrations/orca/label_orca_scan_results.cm b/downloads/automation-library/integrations/orca/label_orca_scan_results.cm new file mode 100644 index 00000000..036505ae --- /dev/null +++ b/downloads/automation-library/integrations/orca/label_orca_scan_results.cm @@ -0,0 +1,28 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + {% for item in reports %} + label_orca_{{ item.name }}: + if: + - {{ item.count > 0 }} + run: + - action: add-label@v1 + args: + label: 'orca:{{ item.name }}' + {% endfor %} + +orca: {{ pr | extractOrcaFindings }} + +reports: + - name: introduced-cves + count: {{ orca.vulnerabilities.count }} + - name: iac-misconfigurations + count: {{ orca.infrastructure_as_code.count }} + - name: exposed-secrets + count: {{ orca.secrets.count }} + +colors: + red: 'b60205' diff --git a/downloads/automation-library/integrations/orca/review_orca_alerts.cm b/downloads/automation-library/integrations/orca/review_orca_alerts.cm new file mode 100644 index 00000000..2a2c4c84 --- /dev/null +++ b/downloads/automation-library/integrations/orca/review_orca_alerts.cm @@ -0,0 +1,23 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 +automations: + review_orca_alerts: + if: + - {{ has.vulnerability or has.iac_violation or has.secret }} + run: + - action: require-reviewers@v1 + args: + reviewers: [my-organization/security-team] + - action: add-comment@v1 + args: + comment: | + This PR requires additional review because it fails to meet Orca Security safe code standards. + +orca: {{ pr | extractOrcaFindings }} + +has: + vulnerability: {{ orca.vulnerabilities.priority == 'High' or orca.vulnerabilities.priority == 'Medium' }} + iac_violation: {{ orca.infrastructure_as_code.priority == 'High' or orca.infrastructure_as_code.priority == 'Medium' }} + secret: {{ orca.secrets.priority == 'High' or orca.secrets.priority == 'Medium' }} \ No newline at end of file diff --git a/downloads/automation-library/integrations/rdoc/review_rdoc.cm b/downloads/automation-library/integrations/rdoc/review_rdoc.cm new file mode 100644 index 00000000..7b6f8d94 --- /dev/null +++ b/downloads/automation-library/integrations/rdoc/review_rdoc.cm @@ -0,0 +1,19 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + review_rdoc: + if: + - {{ source.diff.files | match(attr='diff', regex=r/^[\s\t]*#.*/) | every }} + run: + - action: add-label@v1 + args: + label: "📓RDoc Only" + color: {{ colors.green }} + - action: add-reviewers@v1 + args: + reviewers: [org/tech-writers] + - action: approve@v1 + +colors: + green: '0e8a16' diff --git a/downloads/automation-library/integrations/rdoc/review_rdoc_input.cm b/downloads/automation-library/integrations/rdoc/review_rdoc_input.cm new file mode 100644 index 00000000..38d99930 --- /dev/null +++ b/downloads/automation-library/integrations/rdoc/review_rdoc_input.cm @@ -0,0 +1,14 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + review_rdoc_input: + if: + - {{ source.diff.files | match(attr='diff', regex=r/(\#.*\n.*)*def/) | nope }} + - {{ source.diff.files | match(attr='diff', regex=r/def.*\(.*\)/ | some }} + run: + - action: add-comment@v1 + args: + comment: | + This PR modifies method input parameters, but is missing RDoc changes. Please check to ensure no RDoc changes are necessary. + diff --git a/downloads/automation-library/integrations/rdoc/review_rdoc_large.cm b/downloads/automation-library/integrations/rdoc/review_rdoc_large.cm new file mode 100644 index 00000000..88158cda --- /dev/null +++ b/downloads/automation-library/integrations/rdoc/review_rdoc_large.cm @@ -0,0 +1,31 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + #Require more extensive reviews for large Ruby changes that lack RDoc updates. + review_rdoc_large: + if: + - {{ changes.additions > 150}} + - {{ source.diff.files | matchDiffLines(regex=r/(\#.*\n.*)*def/) | nope }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing RDoc" + color: {{ colors.yellow }} + - action: add-comment@v1 + args: + comment: | + This PR makes major changes to Ruby methods, but is missing updates to RDoc. Please double check for any necessary RDoc updates. + - action: add-reviewers@v1 + args: + reviewers: [fourth-organization/tech-writers] + +changes: + # Sum all the lines added/edited in the PR + additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }} + + +colors: + yellow: 'fbca04' diff --git a/downloads/automation-library/integrations/rdoc/review_rdoc_new_class.cm b/downloads/automation-library/integrations/rdoc/review_rdoc_new_class.cm new file mode 100644 index 00000000..5769e18b --- /dev/null +++ b/downloads/automation-library/integrations/rdoc/review_rdoc_new_class.cm @@ -0,0 +1,24 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + review_rdoc_new_class: + if: + - {{ is.rb and is.new }} + - {{ source.diff.files | match(attr='diff', regex=r/(\#.*\n.*)*def/) | nope }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing RDoc" + color: {{ colors.yellow }} + - action: add-comment@v1 + args: + comment: | + RDoc is required for all Ruby classes. Please add documentation for this PR. + +is: + rb: {{ files | extensions | match(regex=r/rb/) | every }} + new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }} + +colors: + yellow: 'fbca04' diff --git a/downloads/automation-library/integrations/renovate/approve_renovate.cm b/downloads/automation-library/integrations/renovate/approve_renovate.cm new file mode 100644 index 00000000..8668b096 --- /dev/null +++ b/downloads/automation-library/integrations/renovate/approve_renovate.cm @@ -0,0 +1,18 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_renovate: + if: + - {{ branch.author | includes(term="renovate") }} + run: + - action: approve@v1 + - action: add-label@v1 + args: + label: "approved-renovate" + - action: merge@v1 + args: + wait_for_all_checks: true + squash_on_merge: true diff --git a/downloads/automation-library/integrations/renovate/approve_renovate_minor.cm b/downloads/automation-library/integrations/renovate/approve_renovate_minor.cm new file mode 100644 index 00000000..fdc92673 --- /dev/null +++ b/downloads/automation-library/integrations/renovate/approve_renovate_minor.cm @@ -0,0 +1,30 @@ +manifest: + version: 1.0 + +automations: + merge_renovate_minor: + if: + - {{ bump == 'minor' }} + - {{ branch.name | includes(term="renovate") }} + - {{ branch.author | includes(term="renovate") }} + run: + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + Renovate `minor` version bumps are approved automatically. + + merge_renovate_minor_patch: + if: + - {{ bump == 'patch' }} + - {{ branch.name | includes(term="renovate") }} + - {{ branch.author | includes(term="renovate") }} + run: + - action: approve@v1 + - action: merge@v1 + - action: add-comment@v1 + args: + comment: | + Renovate `patch` version bumps are approved and merged automatically. + +bump: {{ pr.description | extractRenovateVersionBump | compareMultiSemver }} diff --git a/downloads/automation-library/integrations/shortcut/label_missing_shortcut.cm b/downloads/automation-library/integrations/shortcut/label_missing_shortcut.cm new file mode 100644 index 00000000..2fa20a14 --- /dev/null +++ b/downloads/automation-library/integrations/shortcut/label_missing_shortcut.cm @@ -0,0 +1,25 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + label_missing_shortcut: + if: + - {{not (has.shortcut.ticket_in_title or has.shortcut.ticket_in_desc)}} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Shortcut Link" + color: {{ colors.red }} + - action: add-comment@v1 + args: + comment: Please provide a link to the associated Shortcut resource. + +has: + shortcut: + ticket_in_title: {{ pr.title | includes(regex=r/(\w+)\/sc-(\d+)/) }} + ticket_in_desc: {{ pr.description | includes(regex=r/(app\.shortcut\.com)\/(\w+)\/story\/(\d+)\/(\w+)/) }} + +colors: + red: 'b60205' \ No newline at end of file diff --git a/downloads/automation-library/integrations/shortcut/link_shortcut.cm b/downloads/automation-library/integrations/shortcut/link_shortcut.cm new file mode 100644 index 00000000..1e27cca4 --- /dev/null +++ b/downloads/automation-library/integrations/shortcut/link_shortcut.cm @@ -0,0 +1,39 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +# Configure these to match your organization. +provider: jira + +# Change this to match the name of your Shortcut organization. This is used in tracker.shortcut.baseurl +orgName: org + +{% set ticketid = "" %} +{% for ticket in tickets %} +{% if (ticket | includes(regex=r/.+/)) %} +{% set ticketid = ticket %} +{% endif %} +{% endfor %} + +automations: + link_shortcut: + if: + - {{ has.ticket_in_title or has.ticket_in_branch }} + run: + - action: add-comment@v1 + args: + comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}}) + +has: + ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }} + ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }} + +tracker: + shortcut: + baseurl: https://app.shortcut.com/[orgName]/story/ + pattern: r/(\w+)\/sc-(\d+)/ + +tickets: + - {{branch.name | capture(regex=tracker[provider].pattern)}} + - {{pr.title | capture(regex=tracker[provider].pattern)}} diff --git a/downloads/automation-library/integrations/slack/slack_auto_recognition.cm b/downloads/automation-library/integrations/slack/slack_auto_recognition.cm new file mode 100644 index 00000000..2e6536bb --- /dev/null +++ b/downloads/automation-library/integrations/slack/slack_auto_recognition.cm @@ -0,0 +1,17 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + slack_auto_recognition: + if: + - {{ files | match(regex=r/(test|spec)/) | some }} # this pr has at least 1 test + - {{ files | length <= 5 }} # this pr has 5 or less files + - {{ branch.name | includes(regex=r/[A-Z]{2,}-\d+.*/) }} # this branch has the Jira ticket prefix + - {{ branch.diff.size <= 150 }} # this branch has 150 lines of code or less changed + run: + - action: send-slack-message@v1 + args: + webhook_url: "{{ env.SLACK_WEBHOOK }}" + message: ":tada: Congrats to {{ pr.author }} for the amazing new PR, '{{ pr.title }}'! Check it out at https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}" \ No newline at end of file diff --git a/downloads/automation-library/integrations/slack/slack_send_notification.cm b/downloads/automation-library/integrations/slack/slack_send_notification.cm new file mode 100644 index 00000000..113c0bd2 --- /dev/null +++ b/downloads/automation-library/integrations/slack/slack_send_notification.cm @@ -0,0 +1,33 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + send_slack_security: + # use your custom logic here to determine whether this needs a security review + if: + - true + run: + - action: send-slack-message@v1 + args: + webhook_url: "{{ env.SLACK_WEBHOOK_SECURITY }}" + message: "A PR requires a security review. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}" + send_slack_qa: + # use your custom logic here to determine whether this needs a qa review + if: + - {{ not (files | match(regex=r/(test|spec)/) | some) }} + run: + - action: send-slack-message@v1 + args: + webhook_url: "{{ env.SLACK_WEBHOOK_QA }}" + message: "A PR was submitted without tests. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}" + send_slack_docs: + # use your custom logic here to determine whether this needs a docs review + if: + - {{ files | match(regex=r/(docs)/) | some }} + run: + - action: send-slack-message@v1 + args: + webhook_url: "{{ env.SLACK_WEBHOOK_DOCS }}" + message: "A PR has modified the docs. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}" diff --git a/downloads/automation-library/integrations/snyk/approve-snyk/approve_snyk.cm b/downloads/automation-library/integrations/snyk/approve-snyk/approve_snyk.cm new file mode 100644 index 00000000..3ff5d1f8 --- /dev/null +++ b/downloads/automation-library/integrations/snyk/approve-snyk/approve_snyk.cm @@ -0,0 +1,18 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_snyk: + if: + - {{ branch.author | includes(term="snyk") }} + run: + - action: approve@v1 + - action: add-label@v1 + args: + label: "approved-snyk" + - action: merge@v1 + args: + wait_for_all_checks: true + squash_on_merge: true diff --git a/downloads/automation-library/integrations/sonar/approve_sonar_clean_code.cm b/downloads/automation-library/integrations/sonar/approve_sonar_clean_code.cm new file mode 100644 index 00000000..72c8fe6d --- /dev/null +++ b/downloads/automation-library/integrations/sonar/approve_sonar_clean_code.cm @@ -0,0 +1,27 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 +automations: + approve_sonar_clean_code: + if: + - {{ sonar.bugs.rating == 'A' }} + - {{ sonar.code_smells.rating == 'A' }} + - {{ sonar.vulnerabilities.rating == 'A' }} + - {{ sonar.security_hotspots.rating == 'A' }} + - {{ sonar.duplications == null or sonar.duplications == 0 }} + run: + - action: add-label@v1 + args: + label: '✅ Sonar: Clean Code' + color: {{ colors.green }} + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + This PR passes the SonarCloud quality gate check and as been automatically approved. + +sonar: {{ pr | extractSonarFindings }} + +colors: + green: '0e8a16' \ No newline at end of file diff --git a/downloads/automation-library/integrations/sonar/label_sonar.cm b/downloads/automation-library/integrations/sonar/label_sonar.cm new file mode 100644 index 00000000..6110932d --- /dev/null +++ b/downloads/automation-library/integrations/sonar/label_sonar.cm @@ -0,0 +1,41 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + {% for item in reports %} + label_sonar_{{ item.name }}: + if: + - {{ item.count > 0}} + run: + - action: add-label@v1 + args: + label: '{{ item.icon }} sonar:{{ item.name }}-{{ item.rating }}' + color: {{ colors.red if (item.rating == 'E' or item.rating == 'D') else (colors.orange if (item.rating == 'C' ) else colors.yellow) }} + {% endfor %} + +sonar: {{ pr | extractSonarFindings }} + +reports: + - name: vulnerabilities + count: {{ sonar.vulnerabilities.count }} + icon: 🔓 + rating: {{ sonar.vulnerabilities.rating }} + - name: code smells + count: {{ sonar.code_smells.count }} + icon: ☣️ + rating: {{ sonar.code_smells.rating }} + - name: security hotspots + count: {{ sonar.security_hotspots.count }} + icon: 🛡️ + rating: {{ sonar.security_hotspots.rating }} + - name: bugs + count: {{ sonar.bugs.count }} + icon: 🪲 + rating: {{ sonar.bugs.rating }} + +colors: + red: 'b60205' + orange: 'd93f0b' + yellow: 'fbca04' diff --git a/downloads/automation-library/integrations/sonar/review_sonar_alerts.cm b/downloads/automation-library/integrations/sonar/review_sonar_alerts.cm new file mode 100644 index 00000000..25751f49 --- /dev/null +++ b/downloads/automation-library/integrations/sonar/review_sonar_alerts.cm @@ -0,0 +1,18 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 +automations: + review_sonar_alerts: + if: + - {{ sonar.code_smells.rating != 'A' or sonar.vulnerabilities.rating != 'A' or sonar.security_hotspots.rating != 'A'}} + run: + - action: require-reviewers@v1 + args: + reviewers: [my-organization/security-team] + - action: add-comment@v1 + args: + comment: | + This PR requires additional review because it fails to meet SonarCloud clean code standards. + +sonar: {{ pr | extractSonarFindings }} diff --git a/downloads/automation-library/integrations/sonar/review_sonar_duplications.cm b/downloads/automation-library/integrations/sonar/review_sonar_duplications.cm new file mode 100644 index 00000000..774c2daa --- /dev/null +++ b/downloads/automation-library/integrations/sonar/review_sonar_duplications.cm @@ -0,0 +1,22 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 +automations: + review_sonar_duplications: + if: + - {{ sonar.duplications > 3 }} + run: + - action: add-label@v1 + args: + label: 'Sonar: {{ sonar.duplications}}% duplication' + color: {{ colors.yellow }} + - action: request-changes@v1 + args: + comment: | + Sonar reports an excessive level of code duplication. Please consider refactoring your PR to reduce duplications. + +sonar: {{ pr | extractSonarFindings }} + +colors: + yellow: 'fbca04' \ No newline at end of file diff --git a/downloads/automation-library/integrations/swimm/approve_swimm.cm b/downloads/automation-library/integrations/swimm/approve_swimm.cm new file mode 100644 index 00000000..e37132f4 --- /dev/null +++ b/downloads/automation-library/integrations/swimm/approve_swimm.cm @@ -0,0 +1,21 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_swimm_changes: + # Triggered for any changes to Swimm documentation + if: + - {{ branch.diff.files_metadata | match(attr='file', regex=r/\.swm\//) | every }} + # Apply a swimm-docs-only label, approve the PR and explain why in a comment. + run: + - action: add-label@v1 + args: + label: 'swimm-docs-only' + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + This PR is considered a safe change as it only affects Swimm Docs. + It has been automatically approved. diff --git a/downloads/automation-library/integrations/teams/teams_auto_recognition.cm b/downloads/automation-library/integrations/teams/teams_auto_recognition.cm new file mode 100644 index 00000000..2a6407e8 --- /dev/null +++ b/downloads/automation-library/integrations/teams/teams_auto_recognition.cm @@ -0,0 +1,19 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + teams_auto_recognition: + if: + - {{ files | match(regex=r/(test|spec)/) | some }} # this pr has at least 1 test + - {{ files | length <= 5 }} # this pr has 5 or less files + - {{ branch.name | includes(regex=r/[A-Z]{2,}-\d+.*/) }} # this branch has the Jira ticket prefix + - {{ branch.diff.size <= 150 }} # this branch has 150 lines of code or less changed + run: + - action: send-http-request@v1 + args: + method: "POST" + headers: '{"Content-type": "application/json"}' + url: "{{ env.MS_TEAMS_WEBHOOK }}" + body: '{"text": "Congrats to {{ pr.author }} for the amazing new PR, {{ pr.title }}! Check it out at https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}' diff --git a/downloads/automation-library/integrations/teams/teams_send_notification.cm b/downloads/automation-library/integrations/teams/teams_send_notification.cm new file mode 100644 index 00000000..1f1c9eab --- /dev/null +++ b/downloads/automation-library/integrations/teams/teams_send_notification.cm @@ -0,0 +1,39 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + send_teams_security: + if: + # use your custom logic here to determine whether this needs a security review + - true + run: + - action: send-http-request@v1 + args: + method: "POST" + headers: '{"Content-type": "application/json"}' + url: "{{ env.MS_TEAMS_WEBHOOK_SECURITY }}" + body: '{"text": "A PR requires a security review. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}' + send_teams_qa: + if: + # use your custom logic here to determine whether this needs a qa review + - {{ not (files | match(regex=r/(test|spec)/) | some) }} + run: + - action: send-http-request@v1 + args: + method: "POST" + headers: '{"Content-type": "application/json"}' + url: "{{ env.MS_TEAMS_WEBHOOK_QA }}" + body: '{"text": "A PR was submitted without tests. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}' + send_teams_docs: + if: + # use your custom logic here to determine whether this needs a docs review + - {{ files | match(regex=r/(docs)/) | some }} + run: + - action: send-http-request@v1 + args: + method: "POST" + headers: '{"Content-type": "application/json"}' + url: "{{ env.MS_TEAMS_WEBHOOK_DOCS }}" + body: '{"text": "A PR has modified the docs. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}' diff --git a/downloads/automation-library/integrations/terraform/review_new_module.cm b/downloads/automation-library/integrations/terraform/review_new_module.cm new file mode 100644 index 00000000..7938610b --- /dev/null +++ b/downloads/automation-library/integrations/terraform/review_new_module.cm @@ -0,0 +1,44 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +{% set misslist = [] %} +{% for pattern in terraform %} +{% if (newfilesinpr | match(term=pattern) | nope) %} +{% set misslist = misslist + [pattern+' '] %} +{% endif %} +{% endfor %} + +automations: + review_new_terraform_module: + if: + - {{misslist | match(regex=r/.*/) | some}} + - {{is.mainfile and is.mainfilenotinroot }} + run: + - action: add-comment@v1 + args: + comment: | + New terraform modules must contain all required components before merging. Please update your PR with the required components and gitStream will automatically remove this comment once completed. + + Here are the required components, {{misslist}} should be customized appropriately: + my_module/ + ├── main.tf + ├── outputs.tf + ├── providers.tf + - action: add-label@v1 + args: + label: '⚠️ Missing Terraform Components' + color: '#FFA500' + +resources: + module_directory: 'modules' +terraform: + - main.tf + - outputs.tf + - providers.tf +is: + mainfile: {{newfilesinpr | match(term = "main.tf") | some}} + mainfilenotinroot: {{source.diff.files | map(attr='original_file') | match(term = "main.tf") | nope }} +newfilesinpr: + {{ branch.diff.files_metadata | map(attr='new_file')}} \ No newline at end of file diff --git a/downloads/automation-library/integrations/terraform/review_terraform.cm b/downloads/automation-library/integrations/terraform/review_terraform.cm new file mode 100644 index 00000000..ac735424 --- /dev/null +++ b/downloads/automation-library/integrations/terraform/review_terraform.cm @@ -0,0 +1,19 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + review_terraform: + # Triggered for any changes to Terraform files + if: + - {{ files | match(regex=r/.*\.tf.*/) | some }} + # Assign infrastructure team as reviewer for change in Terraform files + run: + - action: require-reviewers@v1 + args: + reviewers: [org/infrastructure] + - action: add-comment@v1 + args: + comment: | + This PR affects Terraform configurations and requires a review from the Infra team. diff --git a/downloads/automation-library/integrations/terraform/review_terraform_module_name.cm b/downloads/automation-library/integrations/terraform/review_terraform_module_name.cm new file mode 100644 index 00000000..7ea55bab --- /dev/null +++ b/downloads/automation-library/integrations/terraform/review_terraform_module_name.cm @@ -0,0 +1,42 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +# Prefix Check Logic +{% set prefixcheck = [] %} +{% for pattern in terraform.prefixes %} +{% if(newfilesinpr | match(term=module_location + pattern) | some) %} +{% set prefixcheck = prefixcheck + [true]%} +{% else %} +{% set prefixcheck = prefixcheck + [false] %} +{% endif %} +{% endfor %} + +automations: + review_new_terraform_module: + if: + - {{is.mainfile and is.mainfilenotinroot}} + - {{module_name_checks.prefix or module_name_checks.keyword}} + run: + - action: request-changes@v1 + args: + comment: | + Terraform module names must contain a required prefix and keyword: + * Prefixes: {{ terraform.prefixes }} + * Keywords: {{ terraform.keywords }} + +module_name_checks: + prefix: {{prefixcheck | match(term='true') | nope}} + keyword: {{newfilesinpr | match(list=terraform.keywords) | nope}} + +module_location: infrastructure/modules/ +terraform: + prefixes: ['aws', 'gcp', 'azure'] + keywords: ['db', 'networking', 'security'] + +is: + mainfile: {{newfilesinpr | match(term = "main.tf") | some}} + mainfilenotinroot: {{source.diff.files | map(attr='original_file') | match(term = "main.tf") | nope }} +newfilesinpr: + {{ branch.diff.files_metadata | map(attr='new_file')}} \ No newline at end of file diff --git a/downloads/automation-library/integrations/terraform/review_terraform_source_version.cm b/downloads/automation-library/integrations/terraform/review_terraform_source_version.cm new file mode 100644 index 00000000..54de0a0b --- /dev/null +++ b/downloads/automation-library/integrations/terraform/review_terraform_source_version.cm @@ -0,0 +1,22 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + review_terraform_source_version: + # Check if New Content contains a source URL, the URL is not part of allow list and lacks version reference + if: + - {{ source.diff.files | match(attr='new_content', regex=r/source.*?=.*\".*(http|https).*\"/) | some }} + - {{ source.diff.files | match(attr='new_content', list=allowlist) | nope }} + - {{ source.diff.files | match(attr='new_content', regex=r/source.*?=.*\?ref=v.*/) | nope }} + run: + - action: request-changes@v1 + args: + comment: | + You must reference a specific version when accessing Terraform module sources via URL, e.g. `?ref=v1.0.0`. Please update your Terraform files to follow this practice. + +allowlist: + - 'https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git' + - 'https://github.com/terraform-aws-modules/terraform-aws-vpc.git' + - 'https://github.com/terraform-aws-modules/terraform-aws-eks.git' \ No newline at end of file diff --git a/downloads/automation-library/integrations/unleash/label-ff-unleash/label_ff_unleash.cm b/downloads/automation-library/integrations/unleash/label-ff-unleash/label_ff_unleash.cm new file mode 100644 index 00000000..8f3a0de4 --- /dev/null +++ b/downloads/automation-library/integrations/unleash/label-ff-unleash/label_ff_unleash.cm @@ -0,0 +1,30 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + + {% for item in feature_flags %} + label_ff_unleash_{{ item.name }}: + if: + - {{ source.diff.files | matchDiffLines(regex=r/const notificationBadgeEnabled = useFlag/) | some }} + - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }} + run: + - action: add-label@v1 + args: + label: {{ item.name }} + color: {{ colors.yellow }} + {% endfor %} + +feature_flags: + - name: engineering_rollback_plan_activated + regex: r/engineering_rollback_plan_activated/ + - name: marketing_premium_plan_features_unlocked + regex: r/marketing_premium_plan_features_unlocked/ + - name: mobile_push_notifications_enabled + regex: r/mobile_push_notifications_enabled/ + +colors: + yellow: 'ffb300' + + diff --git a/downloads/automation-library/integrations/zapier/zapier_export_pr_description_title_url.cm b/downloads/automation-library/integrations/zapier/zapier_export_pr_description_title_url.cm new file mode 100644 index 00000000..a62842e6 --- /dev/null +++ b/downloads/automation-library/integrations/zapier/zapier_export_pr_description_title_url.cm @@ -0,0 +1,21 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +pr_url: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}" + +on: + - pr_created + +automations: + zapier_export_pr_description_title_url: + if: + - true + run: + - action: send-http-request@v1 + args: + url: "{{ ZAPIER_WEBHOOK }}" + method: POST + headers: '{"Content-type": "application/json"}' + body: '{ "pr_description":"{{ pr.description }}", "pr_title":"{{ pr.title }}", "pr_url":"{{ pr_url }}" }' diff --git a/downloads/automation-library/integrations/zapier/zapier_export_pr_number.cm b/downloads/automation-library/integrations/zapier/zapier_export_pr_number.cm new file mode 100644 index 00000000..756b9341 --- /dev/null +++ b/downloads/automation-library/integrations/zapier/zapier_export_pr_number.cm @@ -0,0 +1,16 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + zapier_export_pr_number: + if: + - true + run: + - action: send-http-request@v1 + args: + url: "{{ ZAPIER_WEBHOOK }}" + method: POST + headers: '{"Content-type": "application/json"}' + body: '{ "pr_number":"{{ pr.number }}" }' \ No newline at end of file diff --git a/downloads/automation-library/integrations/zapier/zapier_export_pr_number_title_url.cm b/downloads/automation-library/integrations/zapier/zapier_export_pr_number_title_url.cm new file mode 100644 index 00000000..1c7236ce --- /dev/null +++ b/downloads/automation-library/integrations/zapier/zapier_export_pr_number_title_url.cm @@ -0,0 +1,21 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + + pr_url: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}" + +on: + - pr_created + +automations: + zapier_export_pr_number_title_url: + if: + - true + run: + - action: send-http-request@v1 + args: + url: "{{ ZAPIER_WEBHOOK }}" + method: POST + headers: '{"Content-type": "application/json"}' + body: '{ "pr_number":"{{ pr.number }}", "pr_title":"{{ pr.title }}", "pr_url":"{{ pr_url }}" }' diff --git a/downloads/automation-library/integrations/zapier/zapier_export_pr_reviewers.cm b/downloads/automation-library/integrations/zapier/zapier_export_pr_reviewers.cm new file mode 100644 index 00000000..89fdc7f4 --- /dev/null +++ b/downloads/automation-library/integrations/zapier/zapier_export_pr_reviewers.cm @@ -0,0 +1,18 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +pr_url: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}" + +automations: + zapier_export_pr_reviewers: + if: + - true + run: + - action: send-http-request@v1 + args: + url: "{{ env.ZAPIER_WEBHOOK }}" + method: "POST" + headers: '{"Content-type": "application/json"}' + body: '{ "reviewers": "{{ pr.reviewers }}" }' diff --git a/downloads/automation-library/label_deleted_files.cm b/downloads/automation-library/label_deleted_files.cm new file mode 100644 index 00000000..918300c2 --- /dev/null +++ b/downloads/automation-library/label_deleted_files.cm @@ -0,0 +1,19 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Apply a label that indicates when a PR deletes files + # This uses the `has` custom expression found at the bottom of this file + label_deleted_files: + if: + - {{ has.deleted_files }} + run: + - action: add-label@v1 + args: + label: 'deleted-files' + color: '#DF9C04' + +# This is used in the `label_deleted_files` automation +has: + deleted_files: {{ source.diff.files | map(attr='new_file') | match(term='/dev/null') | some }} diff --git a/downloads/automation-library/label_missing_project_tracker.cm b/downloads/automation-library/label_missing_project_tracker.cm new file mode 100644 index 00000000..59b3adad --- /dev/null +++ b/downloads/automation-library/label_missing_project_tracker.cm @@ -0,0 +1,33 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + label_missing_project_tracker: + if: + - {{not (has[provider].ticket_in_title or has[provider].ticket_in_desc)}} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Project Tracker" + color: 'F6443B' + - action: add-comment@v1 + args: + comment: Please provide a link to the associated resource in your team's project tracker. + +has: + jira: + ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} + ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }} + asana: + ticket_in_title: {{ pr.title | includes(regex=r/asana-(\d+)/) }} + ticket_in_desc: {{ pr.description | includes(regex=r/app\.asana.\com\/(\d+)\/(\d+)\/(\d+)\/(\d+)\/(\d+)/) }} + azure: + ticket_in_title: {{ pr.title | includes(regex=r/(\w+)-(\w+)-(\d+)/) }} + ticket_in_desc: {{ pr.description | includes(regex=r/(dev\.azure\.com|(\w+)\.visualstudio\.com)\/(\w+)\/(\w+)\/_workitems\/edit\/(\d+)/) }} + shortcut: + ticket_in_title: {{ pr.title | includes(regex=r/(\w+)\/sc-(\d+)/) }} + ticket_in_desc: {{ pr.description | includes(regex=r/(app\.shortcut\.com)\/(\w+)\/story\/(\d+)\/(\w+)/) }} + +provider: jira diff --git a/downloads/automation-library/label_prs_without_tests.cm b/downloads/automation-library/label_prs_without_tests.cm new file mode 100644 index 00000000..b6d86f03 --- /dev/null +++ b/downloads/automation-library/label_prs_without_tests.cm @@ -0,0 +1,14 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + label_prs_without_tests: + if: + - {{ files | match(regex=r/[^a-zA-Z0-9](spec|test|tests)[^a-zA-Z0-9]/) | nope }} + run: + - action: add-label@v1 + args: + label: 'missing-tests' + color: '#E94637' diff --git a/downloads/automation-library/languages/css/review_css_important.cm b/downloads/automation-library/languages/css/review_css_important.cm new file mode 100644 index 00000000..80689905 --- /dev/null +++ b/downloads/automation-library/languages/css/review_css_important.cm @@ -0,0 +1,23 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + review_css_important: + if: + - {{ files | extensions | match(term='css') | some }} + - {{ source.diff.files | matchDiffLines(regex=r/!important/) | some }} + run: + - action: add-label@v1 + args: + label: '⚠️ Includes !important tag' + color: '{{ colors.orange }}' + - action: request-changes@v1 + args: + comment: | + Please remove the `!important` tag from your CSS. + + +colors: + orange: 'd93f0b' diff --git a/downloads/automation-library/languages/golang/approve_golang_log_output.cm b/downloads/automation-library/languages/golang/approve_golang_log_output.cm new file mode 100644 index 00000000..b4fe371f --- /dev/null +++ b/downloads/automation-library/languages/golang/approve_golang_log_output.cm @@ -0,0 +1,20 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_golang_log_output: + # Triggered for Golang changes that only affect the console.log() method + if: + - {{ files | extensions | match(term='go') | every }} + - {{ source.diff.files | matchDiffLines(regex=r/^.*log\.Println/, ignoreWhiteSpaces=true) | every }} + run: + - action: add-label@v1 + args: + label: 'log-output-only' + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + This PR has been approved because it only contains changes to log output \ No newline at end of file diff --git a/downloads/automation-library/languages/golang/review_golang_test_name.cm b/downloads/automation-library/languages/golang/review_golang_test_name.cm new file mode 100644 index 00000000..7d666640 --- /dev/null +++ b/downloads/automation-library/languages/golang/review_golang_test_name.cm @@ -0,0 +1,14 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + review_golang_test_name: + if: + - {{ source.diff.files | matchDiffLines(regex=r/\*testing.T/) | some }} # Golang test files are created in a separate test directory, so this how we check if it is a test file. + - {{ source.diff.files | match(attr='new_file', regex=r/_test.go$/) | nope }} + run: + - action: request-changes@v1 + args: + comment: | + The test file name does not follow the Golang test name conventions. A test file name needs to have the suffix _test after class name. For example, if you are testing a class file called data.go then the test file name has to be data_test.go. diff --git a/downloads/automation-library/languages/golang/review_missing_golang_tests.cm b/downloads/automation-library/languages/golang/review_missing_golang_tests.cm new file mode 100644 index 00000000..5cdb67d7 --- /dev/null +++ b/downloads/automation-library/languages/golang/review_missing_golang_tests.cm @@ -0,0 +1,31 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^(pkg|internal)\/(?!.*\_test\.go$).*\.go$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }} +newTests: {{ source.diff.files | filter(attr='new_file', regex=r/.*\_test\.go$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }} + +newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^(pkg|internal)\/(?!.*\_test\.go$).*\.go$/) | filter(attr='original_file', regex=r/^$/) | length }} +newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/.*\_test\.go$/) | filter(attr='original_file', regex=r/^$/) | length }} + +automations: + review_missing_golang_tests: + if: + - {{ newFilesCount != newTestsCount }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Tests" + color: {{ colors.orange }} + - action: request-changes@v1 + args: + comment: | + Some of your new Golang files are missing corresponding tests. Please ensure that all new files have a corresponding test file. + + **New Files**: {{ newFilesCount }} + {{ newFiles }} + + **New Tests**: {{ newTestsCount }} + {{ newTests }} +colors: + orange: 'd93f0b' diff --git a/downloads/automation-library/languages/html/enforce_html_title_length.cm b/downloads/automation-library/languages/html/enforce_html_title_length.cm new file mode 100644 index 00000000..0cdc0b53 --- /dev/null +++ b/downloads/automation-library/languages/html/enforce_html_title_length.cm @@ -0,0 +1,13 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + enforce_html_title_length: + if: + - {{ source.diff.files | matchDiffLines(regex=r/(([\w\W]{1,29})<\/title>)|(<title>([\w\W]{61,})<\/title>)/) | some }} + run: + - action: request-changes@v1 + args: + comment: | + Please ensure that all HTML titles are between 30 and 60 characters. diff --git a/downloads/automation-library/languages/html/enforce_image_alt.cm b/downloads/automation-library/languages/html/enforce_image_alt.cm new file mode 100644 index 00000000..d4f4a55d --- /dev/null +++ b/downloads/automation-library/languages/html/enforce_image_alt.cm @@ -0,0 +1,22 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + enforce_image_alt: + if: + - {{ source.diff.files | matchDiffLines(regex=r/<img src/) | some }} + - {{ source.diff.files | matchDiffLines(regex=r/<img src.*alt=/) | nope}} + + run: + - action: add-label@v1 + args: + label: "⚠️ Missing alt label" + color: {{ colors.yellow }} + - action: request-changes@v1 + args: + comment: | + Please ensure that all images in HTML files have an alt attribute. For example: <img alt="Alt Message"> + +colors: + yellow: 'fbca04' diff --git a/downloads/automation-library/languages/html/flag_duplicate_h1.cm b/downloads/automation-library/languages/html/flag_duplicate_h1.cm new file mode 100644 index 00000000..e02ed4ad --- /dev/null +++ b/downloads/automation-library/languages/html/flag_duplicate_h1.cm @@ -0,0 +1,15 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + flag_duplicate_h1: + if: + - {{ duplicateH1 > 0 }} + run: + - action: request-changes@v1 + args: + comment: | + This PR contains HTML files with multiple H1 tags. Please ensure that each HTML file has only one H1 tag. + +duplicateH1: {{ source.diff.files | filter(attr='new_content', regex=r/<h1>(.|\n)*<h1>/) | length }} diff --git a/downloads/automation-library/languages/html/flag_missing_html_tags.cm b/downloads/automation-library/languages/html/flag_missing_html_tags.cm new file mode 100644 index 00000000..d2015b01 --- /dev/null +++ b/downloads/automation-library/languages/html/flag_missing_html_tags.cm @@ -0,0 +1,26 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + flag_missing_html_tags: + if: + - {{ is.html and is.new }} + - {{ source.diff.files | matchDiffLines(regex=r/rel="canonical"/) | nope }} + - {{ source.diff.files | matchDiffLines(regex=r/meta name="robots"/) | nope }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Required Tag" + color: {{ colors.yellow }} + - action: request-changes@v1 + args: + comment: | + Please ensure new HTML files contain canonical and robots meta tags. + +is: + html: {{ files | extensions | match(term='html') | every }} + new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }} + +colors: + yellow: 'fbca04' diff --git a/downloads/automation-library/languages/java/approve_java_log_output.cm b/downloads/automation-library/languages/java/approve_java_log_output.cm new file mode 100644 index 00000000..664f4c6c --- /dev/null +++ b/downloads/automation-library/languages/java/approve_java_log_output.cm @@ -0,0 +1,20 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_java_log_output: + # Triggered for Java changes that only affect the logger method + if: + - {{ files | extensions | match(term='java') | every }} + - {{ source.diff.files | matchDiffLines(regex=r/^.*logger\.(trace|fatal|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }} + run: + - action: add-label@v1 + args: + label: 'log-output-only' + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + This PR has been approved because it only contains changes to log output diff --git a/downloads/automation-library/languages/java/review_java_test_name.cm b/downloads/automation-library/languages/java/review_java_test_name.cm new file mode 100644 index 00000000..fde894d0 --- /dev/null +++ b/downloads/automation-library/languages/java/review_java_test_name.cm @@ -0,0 +1,17 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/test\/) }} +newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/test\/) | length }} + +automations: + review_java_test_name: + if: + - {{ newTestsCount > 0}} + - {{ source.diff.files | filter(attr='new_file', regex=r/^src\/test\/) | match(attr='new_file', regex=r/Test.java$/) | nope }} + + run: + - action: request-changes@v1 + args: + comment: | + The test file name does not follow the Java test name conventions. A test file name needs to have the word Test at the end of class name. For example, if you are testing a class called Data then the test file name has to be DataTest.java. diff --git a/downloads/automation-library/languages/java/review_missing_java_tests.cm b/downloads/automation-library/languages/java/review_missing_java_tests.cm new file mode 100644 index 00000000..f21cf9ce --- /dev/null +++ b/downloads/automation-library/languages/java/review_missing_java_tests.cm @@ -0,0 +1,31 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*Test\.java$).*\.java$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }} +newTests: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*Test\.java$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }} + +newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*Test\.java$).*\.java$/) | filter(attr='original_file', regex=r/^$/) | length }} +newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*Test\.java$/) | filter(attr='original_file', regex=r/^$/) | length }} + +automations: + review_missing_java_tests: + if: + - {{ newFilesCount != newTestsCount }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Tests" + color: {{ colors.orange }} + - action: request-changes@v1 + args: + comment: | + Some of your new Java files are missing corresponding tests. Please ensure that all new files have a corresponding test file. + + **New Files**: {{ newFilesCount }} + {{ newFiles }} + + **New Tests**: {{ newTestsCount }} + {{ newTests }} +colors: + orange: 'd93f0b' diff --git a/downloads/automation-library/languages/javascript/review_javascript_test_name.cm b/downloads/automation-library/languages/javascript/review_javascript_test_name.cm new file mode 100644 index 00000000..bfbfe2d9 --- /dev/null +++ b/downloads/automation-library/languages/javascript/review_javascript_test_name.cm @@ -0,0 +1,18 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^test/) }} +newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^test/) | length }} + +automations: + review_javascript_test_name: + if: + + - {{ newTestsCount > 0}} + - {{ source.diff.files | filter(attr='new_file', regex=r/^test/) | match(attr='new_file', regex=r/.test.js$/) | nope }} + + run: + - action: request-changes@v1 + args: + comment: | + The test file name does not follow the JavaScript test name conventions. A test file name needs to have the suffix .test after class name. For example, if you are testing a class file called Data.js then the test file name has to be data.test.js. diff --git a/downloads/automation-library/languages/javascript/review_missing_javascript_tests.cm b/downloads/automation-library/languages/javascript/review_missing_javascript_tests.cm new file mode 100644 index 00000000..6914689e --- /dev/null +++ b/downloads/automation-library/languages/javascript/review_missing_javascript_tests.cm @@ -0,0 +1,31 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*\.test\.js$).*\.js$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }} +newTests: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*\.test\.js$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }} + +newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!.*\.test\.js$).*\.js$/) | filter(attr='original_file', regex=r/^$/) | length }} +newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/src\/.*\.test\.js$/) | filter(attr='original_file', regex=r/^$/) | length }} + +automations: + review_missing_javascript_tests: + if: + - {{ newFilesCount != newTestsCount }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Tests" + color: {{ colors.orange }} + - action: request-changes@v1 + args: + comment: | + Some of your new JavaScript files are missing corresponding tests. Please ensure that all new files have a corresponding test file. + + **New Files**: {{ newFilesCount }} + {{ newFiles }} + + **New Tests**: {{ newTestsCount }} + {{ newTests }} +colors: + orange: 'd93f0b' diff --git a/downloads/automation-library/languages/python/review_missing_python_tests.cm b/downloads/automation-library/languages/python/review_missing_python_tests.cm new file mode 100644 index 00000000..6c427102 --- /dev/null +++ b/downloads/automation-library/languages/python/review_missing_python_tests.cm @@ -0,0 +1,31 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!test_.*\.py$).*\.py$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }} +newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^tests\/test_.*\.py$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }} + +newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\/(?!test_.*\.py$).*\.py$/) | filter(attr='original_file', regex=r/^$/) | length }} +newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^tests\/test_.*\.py$/) | filter(attr='original_file', regex=r/^$/) | length }} + +automations: + review_missing_python_tests: + if: + - {{ newFilesCount != newTestsCount }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Tests" + color: {{ colors.orange }} + - action: request-changes@v1 + args: + comment: | + Some of your new Python files are missing corresponding tests. Please ensure that all new files have a corresponding test file. + + **New Files**: {{ newFilesCount }} + {{ newFiles }} + + **New Tests**: {{ newTestsCount }} + {{ newTests }} +colors: + orange: 'd93f0b' diff --git a/downloads/automation-library/languages/python/review_python_test_name.cm b/downloads/automation-library/languages/python/review_python_test_name.cm new file mode 100644 index 00000000..b417688e --- /dev/null +++ b/downloads/automation-library/languages/python/review_python_test_name.cm @@ -0,0 +1,17 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) }} +newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) | length }} + +automations: + review_python_test_name: + if: + - {{ newTestsCount > 0}} + - {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) | match(attr='new_file', regex=r/test_.*\.py$/) | nope }} + run: + - action: request-changes@v1 + args: + comment: | + The test file name does not follow the Python test name conventions. A test file name needs to have the prefix test_ before class name. For example, if you are testing a class file called Data.py then the test file name has to be test_data.py. diff --git a/downloads/automation-library/languages/ruby/approve_ruby_log_output.cm b/downloads/automation-library/languages/ruby/approve_ruby_log_output.cm new file mode 100644 index 00000000..fa53467a --- /dev/null +++ b/downloads/automation-library/languages/ruby/approve_ruby_log_output.cm @@ -0,0 +1,20 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_ruby_log_output: + # Triggered for Ruby changes that only affect the logger method + if: + - {{ files | extensions | match(term='rb') | every }} + - {{ source.diff.files | matchDiffLines(regex=r/^.*logger\.(fatal|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }} + run: + - action: add-label@v1 + args: + label: 'log-output-only' + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + This PR has been approved because it only contains changes to log output diff --git a/downloads/automation-library/languages/ruby/review_missing_ruby_tests.cm b/downloads/automation-library/languages/ruby/review_missing_ruby_tests.cm new file mode 100644 index 00000000..ba913c51 --- /dev/null +++ b/downloads/automation-library/languages/ruby/review_missing_ruby_tests.cm @@ -0,0 +1,31 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +newFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^app\/(?!.*\_spec\.rb$).*\.rb$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }} +newTests: {{ source.diff.files | filter(attr='new_file', regex=r/spec\/.*\_spec\.rb$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }} + +newFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^app\/(?!.*\_spec\.rb$).*\.rb$/) | filter(attr='original_file', regex=r/^$/) | length }} +newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/spec\/.*\_spec\.rb$/) | filter(attr='original_file', regex=r/^$/) | length }} + +automations: + review_missing_ruby_tests: + if: + - {{ newFilesCount != newTestsCount }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Tests" + color: {{ colors.orange }} + - action: request-changes@v1 + args: + comment: | + Some of your new Ruby files are missing corresponding tests. Please ensure that all new files have a corresponding test file. + + **New Files**: {{ newFilesCount }} + {{ newFiles }} + + **New Tests**: {{ newTestsCount }} + {{ newTests }} +colors: + orange: 'd93f0b' diff --git a/downloads/automation-library/languages/ruby/review_ruby_test_name.cm b/downloads/automation-library/languages/ruby/review_ruby_test_name.cm new file mode 100644 index 00000000..7603fffd --- /dev/null +++ b/downloads/automation-library/languages/ruby/review_ruby_test_name.cm @@ -0,0 +1,16 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) }} +newTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) | length }} + +automations: + review_ruby_test_name: + if: + - {{ newTestsCount > 0}} + - {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) | match(attr='new_file', regex=r/_spec.rb$/) | nope }} + run: + - action: request-changes@v1 + args: + comment: | + The test file name does not follow the Ruby test name conventions. A test file name needs to have the suffix _spec after class name. For example, if you are testing a class file called data.rb then the test file name has to be data_spec.rb. diff --git a/downloads/automation-library/languages/rust/approve_rust_log_output.cm b/downloads/automation-library/languages/rust/approve_rust_log_output.cm new file mode 100644 index 00000000..d498442f --- /dev/null +++ b/downloads/automation-library/languages/rust/approve_rust_log_output.cm @@ -0,0 +1,20 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_rust_log_output: + # Triggered for Rust changes that only affect the logging macros + if: + - {{ files | extensions | match(term='rs') | every }} + - {{ source.diff.files | matchDiffLines(regex=r/^.*\b(println|print|dbg|error|warn|info|debug|trace)\b!/, ignoreWhiteSpaces=true) | every }} + run: + - action: add-label@v1 + args: + label: 'log-output-only' + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + This PR has been approved because it only contains changes to log output \ No newline at end of file diff --git a/downloads/automation-library/percent_new_code.cm b/downloads/automation-library/percent_new_code.cm new file mode 100644 index 00000000..5b6ae8ce --- /dev/null +++ b/downloads/automation-library/percent_new_code.cm @@ -0,0 +1,22 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + percent_new_code: + if: + - true + run: + - action: add-comment@v1 + args: + comment: | + This PR is {{ changes.ratio }}% new code. + +changes: + # Sum all the lines added/edited in the PR + additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }} + # Sum all the line removed in the PR + deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }} + # Calculate the ratio of new code + ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }} \ No newline at end of file diff --git a/downloads/automation-library/provide_estimated_time_to_review.cm b/downloads/automation-library/provide_estimated_time_to_review.cm new file mode 100644 index 00000000..b391f4bf --- /dev/null +++ b/downloads/automation-library/provide_estimated_time_to_review.cm @@ -0,0 +1,23 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + estimated_time_to_review: + if: + - true + run: + - action: add-label@v1 + args: + label: "{{ calc.etr }} min review" + color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }} + +calc: + etr: {{ branch | estimatedReviewTime }} + + +colors: + red: 'b60205' + yellow: 'fbca04' + green: '0e8a16' \ No newline at end of file diff --git a/downloads/automation-library/request_screenshot.cm b/downloads/automation-library/request_screenshot.cm new file mode 100644 index 00000000..67c8ada4 --- /dev/null +++ b/downloads/automation-library/request_screenshot.cm @@ -0,0 +1,23 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + request_screenshot: + # Triggered for PRs that lack an image file or link to an image in the PR description + if: + - {{ not (has.screenshot_link or has.image_uploaded) }} + run: + - action: add-label@v1 + args: + label: 'no-screenshot' + color: '#FF000A' + - action: add-comment@v1 + args: + comment: | + Be a life saver 🛟 by adding a screenshot of the changes you made. + +has: + screenshot_link: {{ pr.description | includes(regex=r/!\[.*\]\(.*(jpg|svg|png|gif|psd).*\)/) }} + image_uploaded: {{ pr.description | includes(regex=r/<img.*src.*(jpg|svg|png|gif|psd).*>/) }} \ No newline at end of file diff --git a/downloads/automation-library/standard/branch-management/enforce_branch_name.cm b/downloads/automation-library/standard/branch-management/enforce_branch_name.cm new file mode 100644 index 00000000..2100fac8 --- /dev/null +++ b/downloads/automation-library/standard/branch-management/enforce_branch_name.cm @@ -0,0 +1,26 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + enforce_branch_name: + if: + - {{ not has.requiredBranchPrefix }} + - {{ not has.requiredBranchKeyword }} + - {{ not ignoreList }} + run: + - action: add-label@v1 + args: + label: "❗ Incorrect Branch Name" + color: {{ colors.red }} + - action: add-comment@v1 + args: + comment: | + All PR branch names must be prefixed by feature, stable, or fix, and must contain a reference to a Jira ticket. E.g. 'feature-abc-1234' + Please move your changes to a new branch that meets these requirements and open a new PR. + - action: close@v1 + +has: + requiredBranchPrefix: {{ branch.name | includes(regex=r/^(feature|stable|fix)/) }} + requiredBranchKeyword: {{ branch.name | includes(regex=r/abc+-\d+/) }} + +ignoreList: {{ branch.name | match(regex=r/^(development|staging)/) }} diff --git a/downloads/automation-library/standard/enforce_copyright_header.cm b/downloads/automation-library/standard/enforce_copyright_header.cm new file mode 100644 index 00000000..885fd3a7 --- /dev/null +++ b/downloads/automation-library/standard/enforce_copyright_header.cm @@ -0,0 +1,19 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + enforce_copyright_header: + if: + - {{ source.diff.files | filter(attr='new_file', regex=r/src\//) | map(attr='original_file') | match(regex=r/^$/) | some }} + - {{ source.diff.files | matchDiffLines(regex=licence.licenceRegex) | nope }} + + run: + - action: add-comment@v1 + args: + comment: | + All new files in the '/src' directory must include the required copyright header at the top of the file. For example: + // Copyright (c) ORG and contributors. All rights reserved. + // Licensed under the MIT license. See LICENSE file in the project root for details. + +licence: + licenceRegex: r/(Copyright \(c\) )|(Licensed under the MIT license)/ \ No newline at end of file diff --git a/downloads/automation-library/standard/enforce_pr_title.cm b/downloads/automation-library/standard/enforce_pr_title.cm new file mode 100644 index 00000000..db9ba8ee --- /dev/null +++ b/downloads/automation-library/standard/enforce_pr_title.cm @@ -0,0 +1,30 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + enforce_pr_title: + if: + - {{ pr.title | match(regex=titlePolicy.titleRegex) | nope }} + run: + - action: request-changes@v1 + args: + comment: | + All PRs must be titled according to our semantic naming policy: `<type>(<scope>): <short summary>` + + Type must be one of the following: + + * build + * ci + * docs + * feature + * fix + + Scope must be one of the following: + + * common + * core + * elements + * forms + * http +titlePolicy: + titleRegex: r/\b(build|ci|docs|feature|fix)\b\s*\((common|core|elements|forms|http)\):\s*\w+.*/ \ No newline at end of file diff --git a/downloads/automation-library/standard/explain_code_experts.cm b/downloads/automation-library/standard/explain_code_experts.cm new file mode 100644 index 00000000..a5f1a382 --- /dev/null +++ b/downloads/automation-library/standard/explain_code_experts.cm @@ -0,0 +1,13 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + explain_code_experts: + if: + - {{ pr.labels | match(term='suggest-reviewer') | some }} + run: + - action: explain-code-experts@v1 + args: + gt: 10 \ No newline at end of file diff --git a/downloads/automation-library/standard/flag_merged_no_review.cm b/downloads/automation-library/standard/flag_merged_no_review.cm new file mode 100644 index 00000000..45613309 --- /dev/null +++ b/downloads/automation-library/standard/flag_merged_no_review.cm @@ -0,0 +1,39 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 +on: + - merge + +# https://docs.gitstream.cm/automation-actions/#send-slack-message +slack_webhook: {{ env.SLACK_WEBHOOK }} + +# Update security_team to match your organization +security_team: 'my-org/app-sec' + +automations: + flag_merged_no_review: + if: + - {{ pr.approvals | length == 0 }} + run: + - action: add-label@v1 + args: + label: "DCF5-merged-without-review" + color: {{ colors.red }} + + - action: send-slack-message@v1 + args: + message: "PR #{{ pr.number }} - {{ pr.title }} - was merged without peer reviews. SOC2 requires code reviews for every code change. _SOC2 ref: CC8.1_" + webhook_url: "{{ slack_webhook }}" + + - action: add-comment@v1 + args: + comment: | + This PR was merged without peer reviews. SOC2 requires code reviews for every code change. + _SOC2 ref: CC8.1_ + + @{{ security_team }} + + +colors: + red: 'F6443B' diff --git a/downloads/automation-library/standard/label-management/enforce_required_labels.cm b/downloads/automation-library/standard/label-management/enforce_required_labels.cm new file mode 100644 index 00000000..2a01ebe3 --- /dev/null +++ b/downloads/automation-library/standard/label-management/enforce_required_labels.cm @@ -0,0 +1,11 @@ +manifest: + version: 1.0 + +automations: + enforce_required_labels: + if: + - {{ pr.labels | match(list=['Core', 'Mobile', 'UI']) | nope }} + run: + - action: request-changes@v1 + args: + comment: Please ensure that your PR is labeled with either 'Core', 'Mobile', or 'UI'. These labels help us to better track and manage your contribution. Thank you. diff --git a/downloads/automation-library/standard/label-management/label_approvals.cm b/downloads/automation-library/standard/label-management/label_approvals.cm new file mode 100644 index 00000000..2178f1dd --- /dev/null +++ b/downloads/automation-library/standard/label-management/label_approvals.cm @@ -0,0 +1,11 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + label_approvals: + if: + - {{ pr.approvals | length > 0 }} + run: + - action: add-label@v1 + args: + label: {{ pr.approvals | length }} Approved Review(s) \ No newline at end of file diff --git a/downloads/automation-library/standard/label-management/label_modified_resources.cm b/downloads/automation-library/standard/label-management/label_modified_resources.cm new file mode 100644 index 00000000..14d67127 --- /dev/null +++ b/downloads/automation-library/standard/label-management/label_modified_resources.cm @@ -0,0 +1,26 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + {% for item in labels %} + label_resource_{{ item.name }}: + if: + -{{ branch.name | includes(regex=item.branch) or files | match(list=item.resources) }} + run: + - action: add-label@v1 + args: + label: {{ item.name }} + {% endfor %} + +labels: + - name: Core + resources: + - src/app + branch: r/^core-/ + - name: mobile + resources: + - src/android + - src/ios + branch: r/^mobile-/ + diff --git a/downloads/automation-library/standard/label-management/label_prs_by_language.cm b/downloads/automation-library/standard/label-management/label_prs_by_language.cm new file mode 100644 index 00000000..82351e3d --- /dev/null +++ b/downloads/automation-library/standard/label-management/label_prs_by_language.cm @@ -0,0 +1,33 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + {% for item in labels %} + label_{{ item.name }}_pr: + if: + - {{ files | match(regex=item.resources) | some }} + run: + - action: add-label@v1 + args: + label: '{{ item.name }}' + {% endfor %} + +labels: + - name: Java + resources: r/.java$/ + - name: Rust + resources: r/.rs$/ + - name: HTML + resources: r/.html$/ + - name: JavaScript + resources: r/.js$/ + - name: Python + resources: r/.py$/ + - name: Golang + resources: r/.go$/ + - name: Ruby + resources: r/.rb$/ + - name: CSS + resources: r/.css/ + diff --git a/downloads/automation-library/standard/label-management/label_resources_percent.cm b/downloads/automation-library/standard/label-management/label_resources_percent.cm new file mode 100644 index 00000000..83fa9a3c --- /dev/null +++ b/downloads/automation-library/standard/label-management/label_resources_percent.cm @@ -0,0 +1,38 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + {% for item in labels %} + label_resource_percent_{{ item.name }}: + if: + - {{ files | match(list=item.resources) | some }} + run: + - action: add-label@v1 + args: + label: '{{ item.additions | round }}% {{ item.name }}' + {% endfor %} + +resources: + core: + - src/app + - src/core + mobile: + - src/android + - src/ios + docs: + - docs/ + +labels: + - name: Core + resources: {{ resources.core }} + additions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.core ) | map(attr='additions') | sum / total.additions * 100 }} + - name: Mobile + resources: {{ resources.mobile }} + additions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.mobile ) | map(attr='additions') | sum / total.additions * 100 }} + - name: Docs + resources: {{ resources.docs }} + additions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.docs ) | map(attr='additions') | sum / total.additions * 100 }} + +total: + additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }} \ No newline at end of file diff --git a/downloads/automation-library/standard/label-management/label_unresolved_threads.cm b/downloads/automation-library/standard/label-management/label_unresolved_threads.cm new file mode 100644 index 00000000..6968af18 --- /dev/null +++ b/downloads/automation-library/standard/label-management/label_unresolved_threads.cm @@ -0,0 +1,15 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + label_unresolved_threads: + if: + - {{ pr.unresolved_threads }} + run: + - action: add-label@v1 + args: + label: {{ pr.unresolved_threads }} Unresolved Thread(s) + color: {{ colors.yellow }} + +colors: + yellow: 'fbca04' \ No newline at end of file diff --git a/downloads/automation-library/standard/label-management/suggest_labels.cm b/downloads/automation-library/standard/label-management/suggest_labels.cm new file mode 100644 index 00000000..c1978ff0 --- /dev/null +++ b/downloads/automation-library/standard/label-management/suggest_labels.cm @@ -0,0 +1,17 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + suggest_labels: + if: + - {{ pr.labels | length == 0}} + run: + - action: add-comment@v1 + args: + comment: | + All PRs must contain labels that indicate which CI/CD systems must be run. PLease update your PR to include one of the following labels: `Build: Mobile`, `Build: UI`, `Build: All`, `Build: None` + + Additionally, Here are some labels you can apply to this PR that may be helpful: + * Suggest Reviewer - Use this if you aren't sure who to assign as the reviewer. + * WIP - Indicate this is a work in progress that shouldn't be merged. + diff --git a/downloads/automation-library/standard/label_automation.cm b/downloads/automation-library/standard/label_automation.cm new file mode 100644 index 00000000..1d1ad735 --- /dev/null +++ b/downloads/automation-library/standard/label_automation.cm @@ -0,0 +1,96 @@ +# -*- mode: yaml -*- +# +----------------------------------------------------------------------------+ +# | /:\ gitStream: Workflow automation for the code review process. | +# +----------------------------------------------------------------------------+ +# | This file contains one or more /:\ gitStream automations: | +# | https:// docs.gitstream.cm | +# | | +# | gitStream uses YAML syntax with nunjucks templating via Jinja 2. | +# | | +# | Automations follow an "if this, then that" execution format. | +# | More info here: https://docs.gitstream.cm/how-it-works/ | +# | | +# +----------------------------------------------------------------------------+ + +# /:\ gitStream Reference Docs: +# Context Variables: https://docs.gitstream.cm/context-variables/ +# Filter Functions: https://docs.gitstream.cm/filter-functions/ +# Automation Actions: https://docs.gitstream.cm/automation-actions/ + +manifest: + version: 1.0 + +# +----------------------------------------------------------------------------+ +# | Automations +# +----------------------------------------------------------------------------+ + +automations: + # Apply color coded labels to PRs based on the estimated time to review. + # https://docs.gitstream.cm/automations/provide-estimated-time-to-review/ + estimated_time_to_review: + if: + - true + run: + - action: add-label@v1 + args: + label: "{{ calc.etr }} min review" + color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }} + + # Flag PRs that are missing a Jira ticket reference in the title or description. + # https://docs.gitstream.cm/integrations/jira/ + label_missing_jira_info: + if: + - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }} + run: + - action: add-label@v1 + args: + label: "missing-jira" + color: {{ colors.red }} + + # Flag PRs that have unresolved comment threads. + # https://docs.gitstream.cm/automations/standard/label-management/label-unresolved-threads/ + label_unresolved_threads: + if: + - {{ pr.status == 'open' }} + - {{ pr.unresolved_threads }} + run: + - action: add-label@v1 + args: + label: 🚨 {{ pr.unresolved_threads }} Unresolved Thread(s) + color: {{ colors.yellow }} + + # Flag PRs that delete files to highlight potential refactors that need extra scrutiny. + # https://docs.gitstream.cm/automations/label-deleted-files/ + flag_deleted_files: + if: + - {{ has.deleted_files }} + run: + - action: add-label@v1 + args: + label: 🗑️ Deleted files + color: {{ colors.orange }} + + +# +----------------------------------------------------------------------------+ +# | Custom Expressions | +# | https://docs.gitstream.cm/how-it-works/#custom-expressions | +# +----------------------------------------------------------------------------+ + +# https://docs.gitstream.cm/filter-functions/#estimatedreviewtime +calc: + etr: {{ branch | estimatedReviewTime }} + +has: + jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} + jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }} + deleted_files: {{ source.diff.files | map(attr='new_file') | match(term='/dev/null') | some }} + + +# These are all of the colors in GitHub's default label color palette. +colors: + red: 'b60205' + orange: 'd93f0b' + yellow: 'fbca04' + green: '0e8a16' + blue: '1d76db' + purple: '5319e7' \ No newline at end of file diff --git a/downloads/automation-library/standard/link_issue_tracker.cm b/downloads/automation-library/standard/link_issue_tracker.cm new file mode 100644 index 00000000..ffabc252 --- /dev/null +++ b/downloads/automation-library/standard/link_issue_tracker.cm @@ -0,0 +1,48 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +# Configure these to match your organization. +provider: jira +orgName: org +asanaProject: 1234 +azureProject: my_project + +{% set ticketid = "" %} +{% for ticket in tickets %} +{% if (ticket | includes(regex=r/.+/)) %} +{% set ticketid = ticket %} +{% endif %} +{% endfor %} + +automations: + comment_issue_tracker: + if: + - {{ has.ticket_in_title or has.ticket_in_branch }} + run: + - action: add-comment@v1 + args: + comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}}) + +has: + ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }} + ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }} + +tracker: + jira: + baseurl: https://[orgName].atlassian.net/browse/ + pattern: r/\b[A-Za-z]+-\d+\b/ + asana: + baseurl: https://app.asana.com/0/[asanaProject]/0/ + pattern: r/asana-(\d+)/ + azure: + baseurl: https://dev.azure.com/[orgName]/[azureProject]/_workitems/ + pattern: r/(\w+)-(\w+)-(\d+)/ + shortcut: + baseurl: https://app.shortcut.com/[orgName]/story/ + pattern: r/(\w+)\/sc-(\d+)/ + +tickets: + - {{branch.name | capture(regex=tracker[provider].pattern)}} + - {{pr.title | capture(regex=tracker[provider].pattern)}} diff --git a/downloads/automation-library/standard/review-assignment/assign_code_experts.cm b/downloads/automation-library/standard/review-assignment/assign_code_experts.cm new file mode 100644 index 00000000..72323d7b --- /dev/null +++ b/downloads/automation-library/standard/review-assignment/assign_code_experts.cm @@ -0,0 +1,19 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + assign_code_experts: + # Triggered when someone applies a suggest-reviewer label to a PR. + if: + - {{ pr.labels | match(term='suggest-reviewer') | some }} + # More info about code experts + # https://docs.gitstream.cm/filter-functions/#codeexperts + run: + - action: add-reviewers@v1 + args: + reviewers: {{ repo | codeExperts(gt=10) }} + - action: explain-code-experts@v1 + args: + gt: 10 diff --git a/downloads/automation-library/standard/review-assignment/notify_watcher.cm b/downloads/automation-library/standard/review-assignment/notify_watcher.cm new file mode 100644 index 00000000..e077a706 --- /dev/null +++ b/downloads/automation-library/standard/review-assignment/notify_watcher.cm @@ -0,0 +1,53 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +## change orgName to match your git organization name. +orgName: company + +automations: + {% for item in watchers %} + notify_watcher_{{ item.owner if item.owner else item.team }}: + if: + - {{ (files | match(list=item.files) | some) or (source.diff.files | match(attr="diff", list=item.diffs) | some) }} + run: + - action: add-comment@v1 + args: + comment: | + @{{ item.owner if item.owner else (["{{ orgName }}/", item.team] | join) }} - this PR has changes you're watching + + {% if files | match(list=item.files) | some -%} + files: + {%- for file in files | filter(list=item.files) %} + - {{ file }} + {%- endfor -%} + {%- endif %} + + {% if source.diff.files | match(attr="diff", list=item.diffs) | some -%} + diffs: + {%- for diff in item.diffs -%} + {%- if source.diff.files | match(attr="diff", list=diff) | some %} + - {{ diff }} + {%- for file in source.diff.files | filter(attr="diff", list=diff) | map(attr="new_file") %} + - {{ file }} + {%- endfor -%} + {%- endif -%} + {%- endfor -%} + {%- endif %} + - action: add-reviewers@v1 + args: + reviewers: {{ item.owner }} + team_reviewers: {{ item.team }} + {% endfor %} + + + +watchers: + - owner: juliaspencer + files: + - src/auth + - team: release + files: + - package.json + - yarn.lock diff --git a/downloads/automation-library/standard/review-assignment/review_sensitive_files.cm b/downloads/automation-library/standard/review-assignment/review_sensitive_files.cm new file mode 100644 index 00000000..52cd1dcb --- /dev/null +++ b/downloads/automation-library/standard/review-assignment/review_sensitive_files.cm @@ -0,0 +1,31 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Assign special teams to review sensitive files. + # This requires the `sensitive` custom expression found at the bottom of this file. + review_sensitive_files: + # For all files listed in the sensitive custom expression. + if: + - {{ files | match(list=sensitive_files) | some }} + run: + # Add reviewers from the dev-leads team, and require two approvals + # Modify `my-organization/security` to match your organization. + - action: add-reviewers@v1 + args: + reviewers: [my-organization/security] + - action: set-required-approvals@v1 + args: + approvals: 2 + - action: add-comment@v1 + args: + comment: | + This PR affects one or more sensitive files and requires review from the security team. + +# The `sensitive_file_review` automation requires this custom expression. +# Modify this list to suit your security needs. +sensitive_files: + - src/app/auth/ + - src/app/routing/ + - src/app/resources/ \ No newline at end of file diff --git a/downloads/automation-library/standard/review-assignment/review_source_branch.cm b/downloads/automation-library/standard/review-assignment/review_source_branch.cm new file mode 100644 index 00000000..5b251c4d --- /dev/null +++ b/downloads/automation-library/standard/review-assignment/review_source_branch.cm @@ -0,0 +1,28 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + {% for item in branches %} + review_source_branch{{ item.name }}: + if: + - {{ branch.name | match(regex=item.prefix) }} + run: + - action: set-required-approvals@v1 + args: + approvals: {{ item.reviews }} + - action: add-comment@v1 + args: + comment: | + Reviewers from the {{ item.name }} team have automatically been assigned to this PR. + - action: add-reviewers@v1 + args: + reviewers: [{{ item.reviewers }}] + {% endfor %} + +branches: + - prefix: r/^ABC/ + reviewers: org/a-team + name: ABC + - prefix: r/^XYZ-/ + reviewers: org/x-team + name: XYZ diff --git a/downloads/automation-library/standard/review-assignment/review_target_branch.cm b/downloads/automation-library/standard/review-assignment/review_target_branch.cm new file mode 100644 index 00000000..548f6c8d --- /dev/null +++ b/downloads/automation-library/standard/review-assignment/review_target_branch.cm @@ -0,0 +1,28 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + {% for item in branches %} + review_target_branch_{{ item.name }}: + if: + - {{ pr.target| match(regex=item.prefix) }} + run: + - action: set-required-approvals@v1 + args: + approvals: {{ item.reviews }} + - action: add-comment@v1 + args: + comment: | + PRs to the {{ item.name }} branch require {{ item.reviews }} review(s). + - action: add-reviewers@v1 + args: + reviewers: [{{ item.reviewers }}] + {% endfor %} + +branches: + - prefix: r/^release/ + reviews: 4 + name: Release + - prefix: r/^experimental-/ + reviews: 1 + name: Experimental \ No newline at end of file diff --git a/downloads/automation-library/standard/review-assignment/review_team.cm b/downloads/automation-library/standard/review-assignment/review_team.cm new file mode 100644 index 00000000..bf51466b --- /dev/null +++ b/downloads/automation-library/standard/review-assignment/review_team.cm @@ -0,0 +1,26 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + {% for item in teams %} + review_team_{{ item.name }}: + if: + - {{ pr.author_teams | match(regex=item.regex) }} + run: + - action: add-reviewers@v1 + args: + reviewers: [{{ item.team }}] + - action: add-comment@v1 + args: + comment: | + This {{ item.name }} team has been automatically assigned to review this PR. + {% endfor %} + +teams: + - regex: r/ui-team/ + name: UI Team + team: org/ui-team + - regex: r/mobile-team/ + name: Mobile + team: org/mobile-team \ No newline at end of file diff --git a/downloads/automation-library/standard/review-assignment/share_knowledge.cm b/downloads/automation-library/standard/review-assignment/share_knowledge.cm new file mode 100644 index 00000000..9713d613 --- /dev/null +++ b/downloads/automation-library/standard/review-assignment/share_knowledge.cm @@ -0,0 +1,17 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + share_knowledge: + if: + - {{ pr.labels | match(term='Share Knowledge') | some }} + run: + - action: add-reviewers@v1 + args: + reviewers: {{ repo | codeExperts(gt=30, lt=60) | random }} + - action: add-comment@v1 + args: + comment: | + gitStream has assigned a reviewer to increase knowledge sharing on this PR. diff --git a/downloads/automation-library/standard/review-todo-comments/review_todo_comments.cm b/downloads/automation-library/standard/review-todo-comments/review_todo_comments.cm new file mode 100644 index 00000000..d48fa281 --- /dev/null +++ b/downloads/automation-library/standard/review-todo-comments/review_todo_comments.cm @@ -0,0 +1,12 @@ +manifest: + version: 1.0 + +automations: + review_todo_comments: + if: + - {{ source.diff.files | matchDiffLines(regex=r/^[+].*(TODO|todo)/) | some }} + run: + - action: request-changes@v1 + args: + comment: | + This PR contains a TODO statement. Please check to see if they should be removed. diff --git a/downloads/automation-library/standard/review_changelog.cm b/downloads/automation-library/standard/review_changelog.cm new file mode 100644 index 00000000..59d6dfd2 --- /dev/null +++ b/downloads/automation-library/standard/review_changelog.cm @@ -0,0 +1,21 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 +automations: + # Request changes for new features that lack changelog updates. + review_changelog: + if: + - {{ branch.name | includes(term="feature") }} + - {{ files | match(regex=r/^docs\/changelog\.md$/) | nope }} + run: + - action: add-label@v1 + args: + label: "⚠️ Missing Changelog" + color: {{ colors.yellow }} + - action: add-comment@v1 + args: + comment: | + All new features require an update to the changelog. Please modify your PR to include any relevant changelog updates. + +colors: + yellow: 'fbca04' diff --git a/downloads/automation-library/standard/review_routing.cm b/downloads/automation-library/standard/review_routing.cm new file mode 100644 index 00000000..5bf2fc12 --- /dev/null +++ b/downloads/automation-library/standard/review_routing.cm @@ -0,0 +1,176 @@ +# -*- mode: yaml -*- +# +----------------------------------------------------------------------------+ +# | WARNING: This file controls repo automations, use caution when modifying | +# +----------------------------------------------------------------------------+ +# | This file contains one or more /:\ gitStream automations: | +# | https:// docs.gitstream.cm | +# | | +# | gitStream uses YAML syntax with nunjucks templating via Jinja 2. | +# | | +# | Automations follow an "if this, then that" execution format. | +# | More info here: https://docs.gitstream.cm/how-it-works/ | +# | | +# +----------------------------------------------------------------------------+ + +# /:\ gitStream Reference Docs: +# Context Variables: https://docs.gitstream.cm/context-variables/ +# Filter Functions: https://docs.gitstream.cm/filter-functions/ +# Automation Actions: https://docs.gitstream.cm/automation-actions/ + +manifest: + version: 1.0 + +# +----------------------------------------------------------------------------+ +# | Customize This Section | +# +----------------------------------------------------------------------------+ + +# Change review_team to match your organization or repo's primary review team. +# The format is Git Organization Name / Team Name +review_team: 'my-org/team-name' + +# List of files that should trigger a sensitive file change review. +sensitive: + - App.tsx + - AppRoot.tsx + +# Files to exclude from gitStream automations. +config: + ignore_files: + - 'yarn.lock' + - 'ios/*.lock' + - 'android/*.lock' + +# Set long_review_threshold to the number of minutes that should trigger extra review requirements. +long_review_threshold: 5 + +# +----------------------------------------------------------------------------+ +# | Automations +# +----------------------------------------------------------------------------+ + +automations: + + # Post a comment that recommends reviewers based on their knowledge of the files in the PR. + # https://docs.gitstream.cm/automations/standard/explain-code-experts/ + explain_code_experts: + # Alternatively, if you only want to trigger when the slash command `/gitstream suggest-reviewers` is included in a comment, + # change '- true' to '- {{ (pr.comments | match(attr='content', term='/gitstream suggest-reviewers') | some) }}' + if: + - true + run: + - action: explain-code-experts@v1 + args: + gt: 10 + + # Automatically approve changes that only affect formatting, documentation, tests, or images + # https://docs.gitstream.cm/automations/approve-safe-changes/ + approve_safe_changes: + if: + - {{ is.safe_change }} + # Apply a safe change label, approve the PR and explain why in a comment. + run: + - action: add-label@v1 + args: + label: 'Safe Change' + color: {{ colors.green }} + - action: approve@v1 + - action: add-comment@v1 + args: + comment: | + This PR is considered a safe change and has been automatically approved. + + # Set criteria for PRs that only need one reviewer. + # This helps reduce the review burden for low-risk PRs. + require_one_review: + if: + - {{ not has.sensitive_files }} + - {{ is.quick_review }} + - {{ approvals.zero }} + run: + - action: add-label@v1 + args: + label: ⏳ Waiting for 1 reviewer + color: {{ colors.yellow }} + - action: add-reviewers@v1 + args: + reviewers: [{{ review_team }}] + unless_reviewers_set: true + - action: set-required-approvals@v1 + args: + approvals: 1 + + # Set criteria for PRs that need extra reviewers. + # This helps bring in extra scrutiny for large PRs or PRs that touch sensitive parts of the code. + require_two_reviews: + if: + - {{ is.long_review or has.sensitive_files }} + - {{ approvals.ltTwo }} + run: + - action: add-label@v1 + args: + label: {{ '⏳ Waiting for 2 reviewers' if (approvals.zero) else '⏳ Waiting for 1 reviewer' }} + color: {{ colors.yellow }} + - action: add-reviewers@v1 + args: + reviewers: [{{ review_team }}] + unless_reviewers_set: true + - action: set-required-approvals@v1 + args: + approvals: 2 + + # Flag low-risk PRs that are ready to merge. + flag_quick_review_merge: + if: + - {{ not has.sensitive_files }} + - {{ is.quick_review }} + - {{ not has.do_not_merge_label }} + - {{ approvals.gtZero }} + run: + - action: add-label@v1 + args: + label: ✌️ Ready to merge + color: {{ colors.green }} + + # Flag higher risk PRs that are ready to merge. + flag_large_review_merge: + if: + - {{ is.long_review or has.sensitive_files }} + - {{ approvals.gtOne }} + run: + - action: add-label@v1 + args: + label: ✌️ Ready to merge + color: {{ colors.green }} + + +# +----------------------------------------------------------------------------+ +# | Custom Expressions | +# | https://docs.gitstream.cm/how-it-works/#custom-expressions | +# +----------------------------------------------------------------------------+ + +# https://docs.gitstream.cm/filter-functions/#estimatedreviewtime +calc: + etr: {{ branch | estimatedReviewTime }} + +has: + sensitive_files: {{ files | match(list=sensitive) | some }} + do_not_merge_label: {{ pr.labels | match(term='Do not merge') | some }} + +is: + safe_change: {{ (source.diff.files | isFormattingChange) or (files | allDocs) or (files | allTests) or (files | allImages) }} + quick_review: {{ files | length <= 7 and calc.etr <= long_review_threshold }} + long_review: {{ files | length > 7 or calc.etr > long_review_threshold }} + +approvals: + zero: {{ pr.approvals | length == 0 }} + gtZero: {{ pr.approvals | length > 0 }} + gtOne: {{ pr.approvals | length > 1 }} + ltTwo: {{ pr.approvals | length < 2 }} + +# These are all of the colors in GitHub's default label color palette. +colors: + red: 'b60205' + orange: 'd93f0b' + yellow: 'fbca04' + green: '0e8a16' + blue: '1d76db' + purple: '5319e7' \ No newline at end of file diff --git a/downloads/automation-library/standard/summarize_language_changes.cm b/downloads/automation-library/standard/summarize_language_changes.cm new file mode 100644 index 00000000..e8cb900d --- /dev/null +++ b/downloads/automation-library/standard/summarize_language_changes.cm @@ -0,0 +1,63 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +on: + - pr_created + +automations: + summarize_language_changes: + if: + - true + run: + - action: add-comment@v1 + args: + comment: + <h3>Summary of Changes by Language</h3> + <table> + <tr> + <td>Language</td> + <td>Language Change Percentage</td> + </tr> + <tr> + <td>Java</td> + <td>{{ total.java | round }}%</td> + </tr> + <tr> + <td>JavaScript</td> + <td>{{ total.javascript | round }}%</td> + </tr> + <td>Rust</td> + <td>{{ total.rust | round }}%</td> + </tr> + <tr> + <td>Ruby</td> + <td>{{ total.ruby | round }}%</td> + </tr> + <td>HTML</td> + <td>{{ total.html | round }}%</td> + </tr> + <td>CSS</td> + <td>{{ total.css | round }}%</td> + </tr> + <tr> + <td>Golang</td> + <td>{{ total.golang | round }}%</td> + </tr> + <tr> + <td>Python</td> + <td>{{ total.python | round }}%</td> + </tr> + </table> + +total: + additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }} + java: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.java$/ ) | map(attr='additions') | sum / total.additions * 100 }} + javascript: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.js$/ ) | map(attr='additions') | sum / total.additions * 100 }} + rust: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.rs$/ ) | map(attr='additions') | sum / total.additions * 100 }} + ruby: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.rb$/ ) | map(attr='additions') | sum / total.additions * 100 }} + html: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.html$/ ) | map(attr='additions') | sum / total.additions * 100 }} + css: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.css$/ ) | map(attr='additions') | sum / total.additions * 100 }} + golang: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.go$/ ) | map(attr='additions') | sum / total.additions * 100 }} + python: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.py$/ ) | map(attr='additions') | sum / total.additions * 100 }} + diff --git a/downloads/automation-library/utilities/cm_header.cm b/downloads/automation-library/utilities/cm_header.cm new file mode 100644 index 00000000..3b8ff7e1 --- /dev/null +++ b/downloads/automation-library/utilities/cm_header.cm @@ -0,0 +1,19 @@ +# -*- mode: yaml -*- + +# +----------------------------------------------------------------------------+ +# | WARNING: This file controls repo automations, use caution when modifying | +# +----------------------------------------------------------------------------+ +# | This file contains one or more /:\ gitStream automations: | +# | https:// docs.gitstream.cm | +# | | +# | gitStream uses YAML syntax with nunjucks templating via Jinja 2. | +# | | +# | Automations follow an "if this, then that" execution format. | +# | More info here: https://docs.gitstream.cm/how-it-works/ | +# | | +# +----------------------------------------------------------------------------+ + +# /:\ gitStream Reference Docs: +# Context Variables: https://docs.gitstream.cm/context-variables/ +# Filter Functions: https://docs.gitstream.cm/filter-functions/ +# Automation Actions: https://docs.gitstream.cm/automation-actions/ \ No newline at end of file diff --git a/downloads/automation-library/utilities/colors_custom_expression.cm b/downloads/automation-library/utilities/colors_custom_expression.cm new file mode 100644 index 00000000..042a1172 --- /dev/null +++ b/downloads/automation-library/utilities/colors_custom_expression.cm @@ -0,0 +1,35 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +# This automation demonstrates all of GitHub's default label colors. +# This is meant to be used as a reference, not as an automation in your repo. +automations: + label_colors: + if: + - true + run: + - action: add-label@v1 + args: + label: "Test Label" + color: {{ colors.green }} + +# These are all of the colors in GitHub's default label color palette. +colors: + red: 'b60205' + orange: 'd93f0b' + yellow: 'fbca04' + green: '0e8a16' + teal: '006b75' + blue: '1d76db' + dark-blue: '0052cc' + purple: '5319e7' + light-red: 'e99695' + light-orange: 'f9d0c4' + light-yellow: 'fef2c0' + light-green: 'c2e0c6' + light-teal: 'bfdadc' + light-blue: 'c5def5' + light-dark-blue: 'bfd4f2' + light-purple: 'd4c5f9' diff --git a/downloads/automation-library/welcome_newcomer.cm b/downloads/automation-library/welcome_newcomer.cm new file mode 100644 index 00000000..d55a9b60 --- /dev/null +++ b/downloads/automation-library/welcome_newcomer.cm @@ -0,0 +1,27 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Help newcomers find mentors to guide them. + welcome_newcomer: + # If the PR author made their first contirbution on the current day + if: + - {{ repo.author_age < 1 and repo.age > 0 }} + # 1. Add reviewers from the team `my_organization/mentors`. Replace this string to match your organization + # 2. Apply a new-contributor label. + # 3 Post a comment that explains the next steps. + run: + - action: add-reviewers@v1 + args: + reviewers: [my_organization/mentors] + - action: add-label@v1 + args: + label: 'new-contributor' + color: '#FBBD10' + - action : add-comment@v1 + args: + comment: | + Hello {{ pr.author }} 👋 Thanks for making your first PR, and welcome to our project! + Our mentor team has automatically been assigned to review this PR and guide you through the process. + Please reach out to that team if you have questions about the next steps. diff --git a/downloads/check-ticket-in-pr.cm b/downloads/check-ticket-in-pr.cm new file mode 100644 index 00000000..a7bbdce0 --- /dev/null +++ b/downloads/check-ticket-in-pr.cm @@ -0,0 +1,18 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + jira_ticket: + if: + - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }} + run: + - action: add-label@v1 + args: + label: "missing-jira" + color: 'F6443B' + +has: + jira_ticket_in_title: {{ pr.title | includes(regex=r/^\[?\w{3,4}-\d{1,6}\]?(\s|-|_).{1,}$/) }} + jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }} diff --git a/downloads/close-prs-based-on-team-membership.cm b/downloads/close-prs-based-on-team-membership.cm new file mode 100644 index 00000000..dd8bb42a --- /dev/null +++ b/downloads/close-prs-based-on-team-membership.cm @@ -0,0 +1,16 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + close_ui_changes_by_non_ui: + if: + - {{ files | match(regex=r/src\/views/) | some }} + - {{ pr.author_teams | match(term='ui-team') | nope }} + run: + - action: add-comment@v1 + args: + comment: | + Please contact a member of `ui-team` team if you need to make changes to files in `src/views` + - action: close@v1 \ No newline at end of file diff --git a/downloads/code-experts.cm b/downloads/code-experts.cm new file mode 100644 index 00000000..fa09c823 --- /dev/null +++ b/downloads/code-experts.cm @@ -0,0 +1,80 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Assign special teams to review sensitive files. + # This requires the `sensitive` custom expression found at the bottom of this file. + sensitive_file_review: + # For all files listed in the sensitive custom expression. + if: + - {{ files | match(list=sensitive_files) | some }} + run: + # Add reviewers from the dev-leads team, and require two approvals + # Modify `my_organization/security` to match your organization. + - action: add-reviewers@v1 + args: + reviewers: [my_organization/security] + - action: set-required-approvals@v1 + args: + approvals: 2 + + # Assign up to 2 reviewers based on highest code expertise. + assign_code_experts: + # If the PR changes any files inside `/src`. + if: + - {{ files | match(regex=r/src\//) | some }} + run: + # Add a code reviewer with a minimum 10% expertise + - action: add-reviewers@v1 + args: + reviewers: {{ repo | codeExperts(gt=10) }} + # Post a comment that lists all code experts who exceed the 10% threshold + - action: explain-code-experts@v1 + args: + gt: 10 + + # Require additional reviewers for large PRs. + large_review: + # If 10 or more files are modified and the estimated review time is 30 minutes or more. + if: + - {{ files | length >= 10 }} + - {{ branch | estimatedReviewTime >= 30 }} + # Apply a requirement for two reviewers, + # and post a comment to recommend breaking this PR up into smaller contributions. + run: + - action: set-required-approvals@v1 + args: + approvals: 2 + - action: add-comment@v1 + args: + comment: | + This PR may require a significant amount of effort to review. Please consider dividing your PR up into multiple smaller contributions. + + # Help newcomers find mentors to guide them. + new_contributor_review: + # If the PR author made their first contirbution within the last 21 days. + if: + - {{ repo.author_age < 21 and (repo.age - repo.author_age) >= 21 }} + # 1. Add reviewers from the team `my_organization/mentors`. Replace this string to match your organization + # 2. Apply a new-contributor label. + # 3 Post a comment that explains the next steps. + run: + - action: add-reviewers@v1 + args: + reviewers: [my_organization/mentors] + - action: add-label@v1 + args: + label: 'new-contributor' + color: '#FBBD10' + - action : add-comment@v1 + args: + comment: | + During your first 21 days, someone from the mentor team will be assigned to review your PRs. + +# The `sensitive_file_review` automation requires this custom expression. +# Modify this list to suit your security needs. +sensitive_files: + - src/app/auth/ + - src/app/routing/ + - src/app/resources/ \ No newline at end of file diff --git a/downloads/debug.cm b/downloads/debug.cm new file mode 100644 index 00000000..3e38f956 --- /dev/null +++ b/downloads/debug.cm @@ -0,0 +1,14 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + show_changed_files: + if: + - true + run: + - action: add-comment@v1 + args: + comment: | + FILES DUMP {{ files | dump | safe }} diff --git a/downloads/define-sensitive-code-areas.cm b/downloads/define-sensitive-code-areas.cm new file mode 100644 index 00000000..d0d17443 --- /dev/null +++ b/downloads/define-sensitive-code-areas.cm @@ -0,0 +1,30 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + approve_non_sensitive: + if: + - {{ files | match(list=sensitive) | nope }} + run: + - action: add-label@v1 + args: + label: 'non-sensitive' + color: '#2CA44E' + - action: approve@v1 + require_review: + if: + - {{ files | match(list=sensitive) | some }} + run: + - action: add-reviewers@v1 + args: + reviewers: [acme/a-team] + - action: set-required-approvals@v1 + args: + approvals: 1 + +sensitive: + - src/app/auth/ + - src/app/routing/ + - src/app/resources/ diff --git a/downloads/github/gitstream.cm b/downloads/github/gitstream.cm new file mode 100644 index 00000000..5dc2c475 --- /dev/null +++ b/downloads/github/gitstream.cm @@ -0,0 +1,67 @@ +# -*- mode: yaml -*- +# This example configuration for provides basic automations to get started with gitStream. +# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/ +manifest: + version: 1.0 + +triggers: + exclude: + branch: + - r/(Dependabot|dependabot|renovate|Renovate)/ + +automations: + # Add a label that indicates how many minutes it will take to review the PR. + estimated_time_to_review: + on: + - pr_created + - commit + if: + - true + run: + - action: add-label@v1 + args: + label: "{{ calc.etr }} min review" + color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }} + # Inform PR authors when they fail to reference Jira tickets in the PR title or description. + label_missing_jira_info: + if: + - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }} + run: + - action: add-label@v1 + args: + label: "missing-jira" + color: {{ colors.red }} + - action: add-comment@v1 + args: + comment: | + This PR is missing a Jira ticket reference in the title or description. + Please add a Jira ticket reference to the title or description of this PR. + # Post a comment that lists the best experts for the files that were modified. + explain_code_experts: + on: + - pr_created + - commit + if: + - true + run: + - action: explain-code-experts@v1 + args: + gt: 10 + + +# +----------------------------------------------------------------------------+ +# | Custom Expressions | +# | https://docs.gitstream.cm/how-it-works/#custom-expressions | +# +----------------------------------------------------------------------------+ + +calc: + etr: {{ branch | estimatedReviewTime }} + +has: + jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} + jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }} + +colors: + red: 'b60205' + yellow: 'fbca04' + green: '0e8a16' diff --git a/downloads/gitlab-ci.yml b/downloads/gitlab-ci.yml new file mode 100644 index 00000000..78496206 --- /dev/null +++ b/downloads/gitlab-ci.yml @@ -0,0 +1,19 @@ +# Code generated by gitStream - DO NOT EDIT +gitstream-job: + stage: gitstream-main + image: gitstream/rules-engine:latest + only: + variables: + - $GITSTREAM_MAIN_JOB + except: + variables: + - $GITSTREAM_BLOCK_MERGE + script: + - apk update && apk add git + - mkdir /code + - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${repoUrl} /code/repo + - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${cmUrl} /code/cm + - cd /code && cd repo && git fetch --all && git checkout $base_ref && git pull && ls && git checkout $head_ref && git pull && ls + - | + HEAD_REF=$head_ref BASE_REF=$base_ref CLIENT_PAYLOAD="$client_payload" RULES_RESOLVER_URL=$resolver_url \ + RULES_RESOLVER_TOKEN=$resolver_token DEBUG_MODE=true npm run start diff --git a/downloads/gitlab-k8s-ci.yml b/downloads/gitlab-k8s-ci.yml new file mode 100644 index 00000000..754caa00 --- /dev/null +++ b/downloads/gitlab-k8s-ci.yml @@ -0,0 +1,40 @@ +# Code generated by gitStream - DO NOT EDIT +variables: + DOCKER_DRIVER: overlay2 + DOCKER_HOST: tcp://docker:2375 + DOCKER_TLS_CERTDIR: "" +stages: + - gitstream-main + +image: docker:latest +services: + - name: docker:dind + command: ["--mtu=1450", "--tls=false"] +before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + +gitstream-job: + stage: gitstream-main + tags: + - REGISTERED-TAG + only: + variables: + - $GITSTREAM_MAIN_JOB + except: + variables: + - $GITSTREAM_BLOCK_MERGE + script: + - apk update && apk add git && apk add docker + - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${repoUrl} gitstream/repo + - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${cmUrl} gitstream/cm + - cd gitstream && cd repo && git fetch --all && git checkout $base_ref && git pull && ls && git checkout $head_ref && git pull && ls + - docker pull gitstream/rules-engine:latest + - | + docker run -v $CI_PROJECT_DIR/gitstream:/code \ + -e HEAD_REF=$head_ref \ + -e BASE_REF=$base_ref \ + -e CLIENT_PAYLOAD="$client_payload" \ + -e RULES_RESOLVER_URL=$resolver_url \ + -e RULES_RESOLVER_TOKEN=$resolver_token \ + -e DEBUG_MODE=true gitstream/rules-engine:latest + diff --git a/downloads/gitlab-shell-ci.yml b/downloads/gitlab-shell-ci.yml new file mode 100644 index 00000000..b0d03a32 --- /dev/null +++ b/downloads/gitlab-shell-ci.yml @@ -0,0 +1,33 @@ +# Code generated by gitStream - DO NOT EDIT +stages: + - gitstream-main +image: docker:latest +services: + - docker:dind +before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + +gitstream-job: + stage: gitstream-main + tags: + - REGISTERED-TAG + only: + variables: + - $GITSTREAM_MAIN_JOB + except: + variables: + - $GITSTREAM_BLOCK_MERGE + script: + - apk update && apk add git && apk add docker + - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${repoUrl} gitstream/repo + - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${cmUrl} gitstream/cm + - cd gitstream && cd repo && git fetch --all && git checkout $base_ref && git pull && ls && git checkout $head_ref && git pull && ls + - docker pull gitstream/rules-engine:latest + - | + docker run -v $CI_PROJECT_DIR/gitstream:/code \ + -e HEAD_REF=$head_ref \ + -e BASE_REF=$base_ref \ + -e CLIENT_PAYLOAD="$client_payload" \ + -e RULES_RESOLVER_URL=$resolver_url \ + -e RULES_RESOLVER_TOKEN=$resolver_token \ + -e DEBUG_MODE=true gitstream/rules-engine:latest diff --git a/downloads/gitstream.cm b/downloads/gitstream.cm new file mode 100644 index 00000000..a300aa97 --- /dev/null +++ b/downloads/gitstream.cm @@ -0,0 +1,57 @@ +# -*- mode: yaml -*- +# This example configuration for provides basic automations to get started with gitStream. +# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/ +manifest: + version: 1.0 + + +automations: + # Add a label that indicates how many minutes it will take to review the PR. + estimated_time_to_review: + if: + - true + run: + - action: add-label@v1 + args: + label: "{{ calc.etr }} min review" + color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }} + # Inform PR authors when they fail to reference Jira tickets in the PR title or description. + label_missing_jira_info: + if: + - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }} + run: + - action: add-label@v1 + args: + label: "missing-jira" + color: {{ colors.red }} + - action: add-comment@v1 + args: + comment: | + This PR is missing a Jira ticket reference in the title or description. + Please add a Jira ticket reference to the title or description of this PR. + # Post a comment that lists the best experts for the files that were modified. + explain_code_experts: + if: + - true + run: + - action: explain-code-experts@v1 + args: + gt: 10 + + +# +----------------------------------------------------------------------------+ +# | Custom Expressions | +# | https://docs.gitstream.cm/how-it-works/#custom-expressions | +# +----------------------------------------------------------------------------+ + +calc: + etr: {{ branch | estimatedReviewTime }} + +has: + jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} + jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }} + +colors: + red: 'b60205' + yellow: 'fbca04' + green: '0e8a16' diff --git a/downloads/gitstream.yml b/downloads/gitstream.yml new file mode 100644 index 00000000..6ed87d76 --- /dev/null +++ b/downloads/gitstream.yml @@ -0,0 +1,49 @@ +# Code generated by gitStream GitHub app - DO NOT EDIT + +name: gitStream workflow automation +run-name: | + /:\ gitStream: PR #${{ fromJSON(fromJSON(github.event.inputs.client_payload)).pullRequestNumber }} from ${{ github.event.inputs.full_repository }} + +on: + workflow_dispatch: + inputs: + client_payload: + description: The Client payload + required: true + full_repository: + description: the repository name include the owner in `owner/repo_name` format + required: true + head_ref: + description: the head sha + required: true + base_ref: + description: the base ref + required: true + installation_id: + description: the installation id + required: false + resolver_url: + description: the resolver url to pass results to + required: true + resolver_token: + description: Optional resolver token for resolver service + required: false + default: '' + +jobs: + gitStream: + timeout-minutes: 5 + runs-on: ubuntu-latest + name: gitStream workflow automation + steps: + - name: Evaluate Rules + uses: linear-b/gitstream-github-action@v2 + id: rules-engine + with: + full_repository: ${{ github.event.inputs.full_repository }} + head_ref: ${{ github.event.inputs.head_ref }} + base_ref: ${{ github.event.inputs.base_ref }} + client_payload: ${{ github.event.inputs.client_payload }} + installation_id: ${{ github.event.inputs.installation_id }} + resolver_url: ${{ github.event.inputs.resolver_url }} + resolver_token: ${{ github.event.inputs.resolver_token }} diff --git a/downloads/images/LinearB-logo-dark.png b/downloads/images/LinearB-logo-dark.png new file mode 100644 index 00000000..147bb43e Binary files /dev/null and b/downloads/images/LinearB-logo-dark.png differ diff --git a/downloads/images/LinearB-logo-white.png b/downloads/images/LinearB-logo-white.png new file mode 100644 index 00000000..b90a68bb Binary files /dev/null and b/downloads/images/LinearB-logo-white.png differ diff --git a/downloads/images/Orca-Mark-Black.png b/downloads/images/Orca-Mark-Black.png new file mode 100644 index 00000000..f536afb1 Binary files /dev/null and b/downloads/images/Orca-Mark-Black.png differ diff --git a/downloads/images/Orca-Mark-White.png b/downloads/images/Orca-Mark-White.png new file mode 100644 index 00000000..31563409 Binary files /dev/null and b/downloads/images/Orca-Mark-White.png differ diff --git a/downloads/images/gitstream-staging-config.png b/downloads/images/gitstream-staging-config.png new file mode 100644 index 00000000..e133ee69 Binary files /dev/null and b/downloads/images/gitstream-staging-config.png differ diff --git a/downloads/images/integrations/jira/jira-change-status.png b/downloads/images/integrations/jira/jira-change-status.png new file mode 100644 index 00000000..a0a9ad77 Binary files /dev/null and b/downloads/images/integrations/jira/jira-change-status.png differ diff --git a/downloads/images/integrations/jira/jira-comment-1.png b/downloads/images/integrations/jira/jira-comment-1.png new file mode 100644 index 00000000..3bfe4ea1 Binary files /dev/null and b/downloads/images/integrations/jira/jira-comment-1.png differ diff --git a/downloads/images/integrations/jira/jira-comment-2.png b/downloads/images/integrations/jira/jira-comment-2.png new file mode 100644 index 00000000..658ff458 Binary files /dev/null and b/downloads/images/integrations/jira/jira-comment-2.png differ diff --git a/downloads/images/integrations/jira/jira-comment-3.png b/downloads/images/integrations/jira/jira-comment-3.png new file mode 100644 index 00000000..e356c09c Binary files /dev/null and b/downloads/images/integrations/jira/jira-comment-3.png differ diff --git a/downloads/images/integrations/jira/jira-pre-1.png b/downloads/images/integrations/jira/jira-pre-1.png new file mode 100644 index 00000000..22ff66c9 Binary files /dev/null and b/downloads/images/integrations/jira/jira-pre-1.png differ diff --git a/downloads/images/integrations/teams/teams-pre-1.png b/downloads/images/integrations/teams/teams-pre-1.png new file mode 100644 index 00000000..04c052ca Binary files /dev/null and b/downloads/images/integrations/teams/teams-pre-1.png differ diff --git a/downloads/images/integrations/teams/teams-pre-2.png b/downloads/images/integrations/teams/teams-pre-2.png new file mode 100644 index 00000000..a62e13a5 Binary files /dev/null and b/downloads/images/integrations/teams/teams-pre-2.png differ diff --git a/downloads/images/integrations/teams/teams-pre-3.png b/downloads/images/integrations/teams/teams-pre-3.png new file mode 100644 index 00000000..578d7a66 Binary files /dev/null and b/downloads/images/integrations/teams/teams-pre-3.png differ diff --git a/downloads/images/integrations/zapier/zap-cal-1.png b/downloads/images/integrations/zapier/zap-cal-1.png new file mode 100644 index 00000000..fd7447c3 Binary files /dev/null and b/downloads/images/integrations/zapier/zap-cal-1.png differ diff --git a/downloads/images/integrations/zapier/zap-cal-2.png b/downloads/images/integrations/zapier/zap-cal-2.png new file mode 100644 index 00000000..74aa50f3 Binary files /dev/null and b/downloads/images/integrations/zapier/zap-cal-2.png differ diff --git a/downloads/images/integrations/zapier/zap-cal-3.png b/downloads/images/integrations/zapier/zap-cal-3.png new file mode 100644 index 00000000..2ea0c0ee Binary files /dev/null and b/downloads/images/integrations/zapier/zap-cal-3.png differ diff --git a/downloads/images/integrations/zapier/zap-cal-4.png b/downloads/images/integrations/zapier/zap-cal-4.png new file mode 100644 index 00000000..cf4cdffb Binary files /dev/null and b/downloads/images/integrations/zapier/zap-cal-4.png differ diff --git a/downloads/images/integrations/zapier/zap-cal-5.png b/downloads/images/integrations/zapier/zap-cal-5.png new file mode 100644 index 00000000..c8641640 Binary files /dev/null and b/downloads/images/integrations/zapier/zap-cal-5.png differ diff --git a/downloads/images/integrations/zapier/zap-pm-1.png b/downloads/images/integrations/zapier/zap-pm-1.png new file mode 100644 index 00000000..0803024d Binary files /dev/null and b/downloads/images/integrations/zapier/zap-pm-1.png differ diff --git a/downloads/images/integrations/zapier/zap-pm-2.png b/downloads/images/integrations/zapier/zap-pm-2.png new file mode 100644 index 00000000..f0575e65 Binary files /dev/null and b/downloads/images/integrations/zapier/zap-pm-2.png differ diff --git a/downloads/images/integrations/zapier/zap-pre-1.png b/downloads/images/integrations/zapier/zap-pre-1.png new file mode 100644 index 00000000..3b5d5600 Binary files /dev/null and b/downloads/images/integrations/zapier/zap-pre-1.png differ diff --git a/downloads/images/integrations/zapier/zap-pre-2.png b/downloads/images/integrations/zapier/zap-pre-2.png new file mode 100644 index 00000000..1051d667 Binary files /dev/null and b/downloads/images/integrations/zapier/zap-pre-2.png differ diff --git a/downloads/images/integrations/zapier/zap-table-1.png b/downloads/images/integrations/zapier/zap-table-1.png new file mode 100644 index 00000000..af3b0118 Binary files /dev/null and b/downloads/images/integrations/zapier/zap-table-1.png differ diff --git a/downloads/images/integrations/zapier/zap-table-2.png b/downloads/images/integrations/zapier/zap-table-2.png new file mode 100644 index 00000000..506ca4ce Binary files /dev/null and b/downloads/images/integrations/zapier/zap-table-2.png differ diff --git a/downloads/images/integrations/zapier/zap-table-4.png b/downloads/images/integrations/zapier/zap-table-4.png new file mode 100644 index 00000000..f4cf79ec Binary files /dev/null and b/downloads/images/integrations/zapier/zap-table-4.png differ diff --git a/downloads/images/linearb-symbol-dark.png b/downloads/images/linearb-symbol-dark.png new file mode 100644 index 00000000..d122ebce Binary files /dev/null and b/downloads/images/linearb-symbol-dark.png differ diff --git a/downloads/images/linearb-symbol-white.png b/downloads/images/linearb-symbol-white.png new file mode 100644 index 00000000..a26eeba6 Binary files /dev/null and b/downloads/images/linearb-symbol-white.png differ diff --git a/downloads/javascript.cm b/downloads/javascript.cm new file mode 100644 index 00000000..352a25ed --- /dev/null +++ b/downloads/javascript.cm @@ -0,0 +1,28 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Uses the isFormattingChange filter function to automatically approve non-functional changes. + approve_formatting_changes: + if: + - {{ files | extensions | match(list=['js', 'ts']) | every }} + - {{ source.diff.files | isFormattingChange }} + run: + - action: approve@v1 + - action: add-label@v1 + args: + label: code-formatting + + # Approve PRs that only change logging functionality. + approve_javascript_logging_changes: + # Triggered for PRs to JavaScript files that only modify logging functions. + if: + - {{ files | match(regex=r/\.js$|\.ts$/) | every }} + - {{ files | length == 1 }} + - {{ source.diff.files | matchDiffLines(regex=r/^[+-].*console\.log/, ignoreWhiteSpaces=true) | every }} + run: + - action: add-label@v1 + args: + label: 'prints-changes' + - action: approve@v1 \ No newline at end of file diff --git a/downloads/label-prs-by-complexity.cm b/downloads/label-prs-by-complexity.cm new file mode 100644 index 00000000..5776be08 --- /dev/null +++ b/downloads/label-prs-by-complexity.cm @@ -0,0 +1,20 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + estimated_time_to_review: + if: + - true + run: + - action: add-label@v1 + args: + label: "{{ calc.etr }} min review" + color: {{ 'E94637' if (calc.etr >= 20) else ('FBBD10' if (calc.etr >= 5) else '36A853') }} + +# To simplify the automation, this calculation is placed under a unique YAML key. +# The result is assigned to `calc.etr` which is used in the automation above. +# You can add as many keys as you like. +calc: + etr: {{ branch | estimatedReviewTime }} \ No newline at end of file diff --git a/downloads/labels.cm b/downloads/labels.cm new file mode 100644 index 00000000..400826f3 --- /dev/null +++ b/downloads/labels.cm @@ -0,0 +1,67 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Apply an update labels that indicate how long it takes to review the PR + # This uses the `calc` custom expression found at the bottom of this file. + estimated_time_to_review: + # Triggered for all new PRs and PR changes + if: + - true + # Apply a color-coded label that indicates how long it would take someone to review the PR + run: + - action: add-label@v1 + args: + label: "{{ calc.etr }} min review" + color: {{ 'E94637' if (calc.etr >= 20) else ('FBBD10' if (calc.etr >= 5) else '36A853') }} + + # Label PRs that are missing tests. + label_missing_tests: + # Triggered for changes that lack a change to a test. + if: + - {{ files | match(regex=r/[^a-zA-Z0-9](tests)[^a-zA-Z0-9]/) | nope }} + run: + - action: add-label@v1 + args: + label: 'no-tests' + color: '#E94637' + + # Apply a label that indicates when a PR deletes files + # This uses the `has` custom expression found at the bottom of this file + label_deleted_files: + if: + - {{ has.deleted_files }} + run: + - action: add-label@v1 + args: + label: 'deleted-files' + color: '#DF9C04' + + # Label PRs that are missing references to associated Jira tickets. + # Requires the `jira` custom expression at the bottom of this file + jira_ticket: + # Triggered when a PR doesn't list a Jira ticket number in the title or description + if: + - {{ not (jira.ticket_in_title or jira.ticket_in_desc) }} + # Apply a "missing-jira" label. + run: + - action: add-label@v1 + args: + label: "missing-jira" + color: '#F6443B' + +# This is used in the `estimated_time_to_review` +calc: + etr: {{ branch | estimatedReviewTime }} + +# This is used in the `label_deleted_files` automation +has: + deleted_files: {{ source.diff.files | map(attr='new_file') | match(term='/dev/null') | some }} + +# Evaluates PR titles and descriptions to find strings that match Jira ticket number formatting. +# This is used in the `jira_ticket` automation. +jira: + ticket_in_title: {{ pr.title | includes(regex=r/^\[?\w{3,4}-\d{1,6}\]?(\s|-|_).{1,}$/) }} + ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }} + diff --git a/downloads/mark-prs-with-deleted-files.cm b/downloads/mark-prs-with-deleted-files.cm new file mode 100644 index 00000000..ff7508f6 --- /dev/null +++ b/downloads/mark-prs-with-deleted-files.cm @@ -0,0 +1,17 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + deleted: + if: + - {{ has.deleted_files }} + run: + - action: add-label@v1 + args: + label: 'deleted-files' + color: '#DF9C04' + +has: + deleted_files: {{ source.diff.files | map(attr='new_file') | match(term='/dev/null') | some }} diff --git a/downloads/mark-prs-without-tests.cm b/downloads/mark-prs-without-tests.cm new file mode 100644 index 00000000..72a8cb4c --- /dev/null +++ b/downloads/mark-prs-without-tests.cm @@ -0,0 +1,14 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + no_tests: + if: + - {{ files | match(regex=r/[^a-zA-Z0-9](spec|test|tests)[^a-zA-Z0-9]/) | nope }} + run: + - action: add-label@v1 + args: + label: 'missing-tests' + color: '#E94637' \ No newline at end of file diff --git a/downloads/more-approvals-for-complex-changes.cm b/downloads/more-approvals-for-complex-changes.cm new file mode 100644 index 00000000..dd830394 --- /dev/null +++ b/downloads/more-approvals-for-complex-changes.cm @@ -0,0 +1,15 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + double_review: + if: + - {{ branch | estimatedReviewTime >= 30 }} + - {{ files | length >= 10 }} + - {{ files | match(regex=r/src\//) | some }} + run: + - action: set-required-approvals@v1 + args: + approvals: 2 \ No newline at end of file diff --git a/downloads/organization.cm b/downloads/organization.cm new file mode 100644 index 00000000..aaea4f7e --- /dev/null +++ b/downloads/organization.cm @@ -0,0 +1,16 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Assign reviewers at random to spread knowledge of a particular repo. + share_knowledge: + # Triggered for PRs to the `new-repo` repository. + if: + - {{ repo.name | match(term='new-repo') }} + # Assign reviewers at random from a list of previous contributors + # who are under the 50% expertise threshold + run: + - action: add-reviewers@v1 + args: + reviewers: {{ repo | rankByGitBlame(lt=50) | random }} \ No newline at end of file diff --git a/downloads/python.cm b/downloads/python.cm new file mode 100644 index 00000000..1acf800d --- /dev/null +++ b/downloads/python.cm @@ -0,0 +1,17 @@ +# -*- mode: yaml -*- +manifest: + version: 1.0 + +automations: + # Approve PRs that only change logging functionality. + approve_python_logging_changes: + # Triggered for PRs to python files that only modify logging functions. + if: + - {{ files | match(regex=r/\.py$/) | every }} + - {{ files | length == 1 }} + - {{ source.diff.files | matchDiffLines(regex=r/^[+-].*logger\.(trace|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }} + run: + - action: add-label@v1 + args: + label: 'logging-changes' + - action: approve@v1 \ No newline at end of file diff --git a/downloads/request-changes-on-deprecated-apis.cm b/downloads/request-changes-on-deprecated-apis.cm new file mode 100644 index 00000000..831f2fed --- /dev/null +++ b/downloads/request-changes-on-deprecated-apis.cm @@ -0,0 +1,30 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + {% for item in deprecated %} + # Automation names should be unique, therefore the iteration number postfix + catch_deprecated_components_{{ loop.index }}: + if: + - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }} + run: + - action: add-label@v1 + args: + label: 'deprecated-component' + color: '#FF0000' + - action: request-changes@v1 + args: + comment: | + `{{ item.old }}` component is deprecated, use `{{ item.new }}` instead + {% endfor %} + +# This list includes the deprecated items +deprecated: + - regex: r/callElvis/ + old: Elvis + new: Gaga + - regex: r/callOldAPI/ + old: callOldAPI + new: callBetterAPI \ No newline at end of file diff --git a/downloads/sales_demo.cm b/downloads/sales_demo.cm new file mode 100644 index 00000000..1cdbc887 --- /dev/null +++ b/downloads/sales_demo.cm @@ -0,0 +1,72 @@ +# -*- mode: yaml -*- +# This example configuration for provides basic automations to get started with gitStream. +# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/ +manifest: + version: 1.0 + + +automations: + # Add a label that indicates how many minutes it will take to review the PR. + estimated_time_to_review: + if: + - true + run: + - action: add-label@v1 + args: + label: "{{ calc.etr }} min review" + color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }} + # Inform PR authors when they fail to reference Jira tickets in the PR title or description. + label_missing_jira_info: + if: + - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }} + run: + - action: add-label@v1 + args: + label: "missing-jira" + color: {{ colors.red }} + - action: add-comment@v1 + args: + comment: | + This PR is missing a Jira ticket reference in the title or description. + Please add a Jira ticket reference to the title or description of this PR. + label_copilot: + # Detect PRs that contain the text '#copilot#' in the title, description, comments, or commit messages + if: + - {{ copilot_tag.pr_title or copilot_tag.pr_desc or copilot_tag.pr_comments or copilot_tag.commit_messages }} + # Apply a label indicating the user has adopted Copilot + run: + - action: add-label@v1 + args: + label: '🤖 Copilot' + # Post a comment that lists the best experts for the files that were modified. + explain_code_experts: + if: + - true + run: + - action: explain-code-experts@v1 + args: + gt: 10 + + +# +----------------------------------------------------------------------------+ +# | Custom Expressions | +# | https://docs.gitstream.cm/how-it-works/#custom-expressions | +# +----------------------------------------------------------------------------+ + +calc: + etr: {{ branch | estimatedReviewTime }} + +has: + jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} + jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }} + +copilot_tag: + pr_title: {{ pr.title | includes(regex=r/#copilot#/) }} + pr_desc: {{pr.description | includes(regex=r/#copilot#/) }} + pr_comments: {{ pr.comments | map(attr='content') | match(regex=r/#copilot#/) | some }} + commit_messages: {{ branch.commits.messages | match(regex=r/#copilot#/) | some }} + +colors: + red: 'b60205' + yellow: 'fbca04' + green: '0e8a16' diff --git a/downloads/validate-formatting-changes-for-js-ts.cm b/downloads/validate-formatting-changes-for-js-ts.cm new file mode 100644 index 00000000..f06b9cd4 --- /dev/null +++ b/downloads/validate-formatting-changes-for-js-ts.cm @@ -0,0 +1,15 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + allow_formatting: + if: + - {{ files | extensions | match(list=['js', 'ts']) | every }} + - {{ source.diff.files | isFormattingChange }} + run: + - action: approve@v1 + - action: add-label@v1 + args: + label: code-formatting \ No newline at end of file diff --git a/dry-run-mode/index.html b/dry-run-mode/index.html new file mode 100644 index 00000000..53749b59 --- /dev/null +++ b/dry-run-mode/index.html @@ -0,0 +1 @@ +<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="Use gitStream dry-run mode to test your automations before implementing them."><meta name=author content=LinearB><link href=../quick-start/ rel=prev><link href=../examples/ rel=next><link rel=icon href=../assets/images/favicon.png><meta name=generator content="mkdocs-1.5.3, mkdocs-material-9.1.0"><title>How to Test gitStream Automations - gitStream Documentation

How to Test Your Automation

By default, gitStream runs all applicable automations for every new PR and change to existing PR. If you want to test and experiment with new rules, gitStream supports a dry-run mode that will avoid making changes to your PRs. When you commit changes to any CM files found inside your repo's .cm/ directory, gitStream will switch to dry-run mode.

In dry-run mode, gitStream won't execute any automation rules on the PR. Instead, gitStream will parse all applicable automation rules and post a comment to the PR discussion that describes the actions that will be taken for normal PRs. A new comment will be added after every new commit.

dry-run mode

Note

When in dry-run mode, incoming changes to the CM files are ignored. In other words, new automations and configurations won't take effect until you merge the PR.

Once you are satisfied with the results, you can merge your CM changes into the main branch to enable the new configurations.

\ No newline at end of file diff --git a/examples/index.html b/examples/index.html new file mode 100644 index 00000000..cee40665 --- /dev/null +++ b/examples/index.html @@ -0,0 +1,273 @@ + gitStream Quickstart - gitStream Documentation

gitStream Quickstart

This page contains common gitStream configurations that are a great place to begin adopting a continuous merge mindset with gitStream. If you haven't already, you'll need to install gitStream to your GitHub or GitLab organization before you can use these automations

Build your first gitStream automation in as little as two minutes.

These example are complete gitStream configuration files that you can download directly via the buttons below the examples and upload to the .cm directory of your repo. Alternatively, you can copy and paste the individual automations, but make sure you include all required declarations and any related custom expressions from the configuration to ensure everything works properly.

Improve PR Context with Label Automation

This CM automation contains a collection of workflows to automatically apply labels that to provide deeper context to code reviewers to help them more quickly triage and address incoming requests for reviews. Ideally, you should implement these automations across your entire git organization to maximize developer usage.

The following example includes workflow automations to do the following:

Label management quickstart

Label Management with gitStream

# -*- mode: yaml -*-
+# +----------------------------------------------------------------------------+
+# | /:\ gitStream: Workflow automation for the code review process.            |
+# +----------------------------------------------------------------------------+
+# | This file contains one or more /:\ gitStream automations:                  |
+# | https:// docs.gitstream.cm                                                 |
+# |                                                                            |
+# | gitStream uses YAML syntax with nunjucks templating via Jinja 2.           |
+# |                                                                            |
+# | Automations follow an "if this, then that" execution format.               |
+# | More info here: https://docs.gitstream.cm/how-it-works/                    |
+# |                                                                            |
+# +----------------------------------------------------------------------------+
+
+# /:\ gitStream Reference Docs: 
+#    Context Variables: https://docs.gitstream.cm/context-variables/
+#    Filter Functions: https://docs.gitstream.cm/filter-functions/
+#    Automation Actions: https://docs.gitstream.cm/automation-actions/
+
+manifest:
+  version: 1.0
+
+# +----------------------------------------------------------------------------+
+# | Automations
+# +----------------------------------------------------------------------------+
+
+automations:
+  # Apply color coded labels to PRs based on the estimated time to review.
+  # https://docs.gitstream.cm/automations/provide-estimated-time-to-review/
+  estimated_time_to_review:
+    if:
+      - true
+    run:
+      - action: add-label@v1
+        args:
+          label: "{{ calc.etr }} min review"
+          color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}
+
+  # Flag PRs that are missing a Jira ticket reference in the title or description.
+  # https://docs.gitstream.cm/integrations/jira/
+  label_missing_jira_info:
+    if:
+      - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "missing-jira"
+          color: {{ colors.red }}
+
+  # Flag PRs that have unresolved comment threads.
+  # https://docs.gitstream.cm/automations/standard/label-management/label-unresolved-threads/
+  label_unresolved_threads:  
+    if:
+      - {{ pr.status == 'open' }}  
+      - {{ pr.unresolved_threads }}
+    run:
+      - action: add-label@v1
+        args:
+          label: 🚨 {{ pr.unresolved_threads }} Unresolved Thread(s)
+          color: {{ colors.yellow }}  
+
+  # Flag PRs that delete files to highlight potential refactors that need extra scrutiny.
+  # https://docs.gitstream.cm/automations/label-deleted-files/
+  flag_deleted_files:
+    if:
+      - {{ has.deleted_files }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 🗑️ Deleted files
+          color: {{ colors.orange }}
+
+
+# +----------------------------------------------------------------------------+
+# | Custom Expressions                                                         |
+# | https://docs.gitstream.cm/how-it-works/#custom-expressions                 |
+# +----------------------------------------------------------------------------+
+
+# https://docs.gitstream.cm/filter-functions/#estimatedreviewtime
+calc:
+  etr: {{ branch | estimatedReviewTime }}
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }}
+  deleted_files: {{ source.diff.files | map(attr='new_file') | match(term='/dev/null') | some }}
+
+
+# These are all of the colors in GitHub's default label color palette.
+colors:
+  red: 'b60205'
+  orange: 'd93f0b'
+  yellow: 'fbca04'
+  green: '0e8a16'
+  blue: '1d76db'
+  purple: '5319e7'
+

Automatically Route PR Reviews

If you're ready to begin automatically routing PRs for review, the best solution is to classify PRs according to the amount of risk they create. This next example classifies PRs into one of three categories based on the changes they contain and automatically establishes review criteria.

The following example includes workflow automations to do the following:

Assign Code Experts Examples

Review Routing with gitStream

# -*- mode: yaml -*-
+# +----------------------------------------------------------------------------+
+# | WARNING: This file controls repo automations, use caution when modifying   |
+# +----------------------------------------------------------------------------+
+# | This file contains one or more /:\ gitStream automations:                  |
+# | https:// docs.gitstream.cm                                                 |
+# |                                                                            |
+# | gitStream uses YAML syntax with nunjucks templating via Jinja 2.           |
+# |                                                                            |
+# | Automations follow an "if this, then that" execution format.               |
+# | More info here: https://docs.gitstream.cm/how-it-works/                    |
+# |                                                                            |
+# +----------------------------------------------------------------------------+
+
+# /:\ gitStream Reference Docs: 
+#    Context Variables: https://docs.gitstream.cm/context-variables/
+#    Filter Functions: https://docs.gitstream.cm/filter-functions/
+#    Automation Actions: https://docs.gitstream.cm/automation-actions/
+
+manifest:
+  version: 1.0
+
+# +----------------------------------------------------------------------------+
+# | Customize This Section                                                     |
+# +----------------------------------------------------------------------------+
+
+# Change review_team to match your organization or repo's primary review team. 
+# The format is Git Organization Name / Team Name
+review_team: 'my-org/team-name'
+
+# List of files that should trigger a sensitive file change review.
+sensitive:
+  - App.tsx
+  - AppRoot.tsx
+
+# Files to exclude from gitStream automations.
+config:
+  ignore_files:
+    - 'yarn.lock'
+    - 'ios/*.lock'
+    - 'android/*.lock'
+
+# Set long_review_threshold to the number of minutes that should trigger extra review requirements.
+long_review_threshold: 5
+
+# +----------------------------------------------------------------------------+
+# | Automations
+# +----------------------------------------------------------------------------+
+
+automations:
+
+  # Post a comment that recommends reviewers based on their knowledge of the files in the PR.
+  # https://docs.gitstream.cm/automations/standard/explain-code-experts/
+  explain_code_experts:
+    # Alternatively, if you only want to trigger when the slash command `/gitstream suggest-reviewers` is included in a comment,
+    # change '- true' to '- {{ (pr.comments | match(attr='content', term='/gitstream suggest-reviewers') | some) }}'
+    if:
+      - true
+    run:
+      - action: explain-code-experts@v1 
+        args:
+          gt: 10
+
+  # Automatically approve changes that only affect formatting, documentation, tests, or images
+  # https://docs.gitstream.cm/automations/approve-safe-changes/
+  approve_safe_changes:
+    if:
+      - {{ is.safe_change }}
+    # Apply a safe change label, approve the PR and explain why in a comment.
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'Safe Change'
+          color: {{ colors.green }}
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR is considered a safe change and has been automatically approved.
+
+  # Set criteria for PRs that only need one reviewer.
+  # This helps reduce the review burden for low-risk PRs.
+  require_one_review:
+    if:
+      - {{ not has.sensitive_files }}
+      - {{ is.quick_review }}
+      - {{ approvals.zero }}
+    run:
+      - action: add-label@v1
+        args: 
+          label: ⏳ Waiting for 1 reviewer
+          color: {{ colors.yellow }}
+      - action: add-reviewers@v1
+        args:
+          reviewers: [{{ review_team }}]
+          unless_reviewers_set: true
+      - action: set-required-approvals@v1
+        args:
+          approvals: 1
+
+  # Set criteria for PRs that need extra reviewers.
+  # This helps bring in extra scrutiny for large PRs or PRs that touch sensitive parts of the code.
+  require_two_reviews:
+    if:
+      - {{ is.long_review or has.sensitive_files }}
+      - {{ approvals.ltTwo }}
+    run:
+      - action: add-label@v1
+        args: 
+          label: {{ '⏳ Waiting for 2 reviewers' if (approvals.zero) else '⏳ Waiting for 1 reviewer' }}
+          color: {{ colors.yellow }}
+      - action: add-reviewers@v1
+        args:
+          reviewers: [{{ review_team }}]
+          unless_reviewers_set: true
+      - action: set-required-approvals@v1
+        args:
+          approvals: 2
+
+  # Flag low-risk PRs that are ready to merge.
+  flag_quick_review_merge:
+    if:
+      - {{ not has.sensitive_files }}
+      - {{ is.quick_review }}
+      - {{ not has.do_not_merge_label }}
+      - {{ approvals.gtZero }}
+    run:
+      - action: add-label@v1
+        args:
+          label: ✌️ Ready to merge
+          color: {{ colors.green }}
+
+  # Flag higher risk PRs that are ready to merge.
+  flag_large_review_merge:
+    if:
+      - {{ is.long_review or has.sensitive_files }}
+      - {{ approvals.gtOne }}
+    run:
+      - action: add-label@v1
+        args:
+          label: ✌️ Ready to merge
+          color: {{ colors.green }}
+
+
+# +----------------------------------------------------------------------------+
+# | Custom Expressions                                                         |
+# | https://docs.gitstream.cm/how-it-works/#custom-expressions                 |
+# +----------------------------------------------------------------------------+
+
+# https://docs.gitstream.cm/filter-functions/#estimatedreviewtime
+calc:
+  etr: {{ branch | estimatedReviewTime }}
+
+has:
+  sensitive_files: {{ files | match(list=sensitive) | some }}
+  do_not_merge_label: {{ pr.labels | match(term='Do not merge') | some }}
+
+is:
+  safe_change: {{ (source.diff.files | isFormattingChange) or (files | allDocs) or (files | allTests) or (files | allImages) }}
+  quick_review: {{ files | length <= 7 and calc.etr <= long_review_threshold }}
+  long_review: {{ files | length > 7 or calc.etr > long_review_threshold }}
+
+approvals:
+  zero: {{ pr.approvals | length == 0 }}
+  gtZero: {{ pr.approvals | length > 0 }}
+  gtOne: {{ pr.approvals | length > 1 }}
+  ltTwo: {{ pr.approvals | length < 2 }}
+
+# These are all of the colors in GitHub's default label color palette.
+colors:
+  red: 'b60205'
+  orange: 'd93f0b'
+  yellow: 'fbca04'
+  green: '0e8a16'
+  blue: '1d76db'
+  purple: '5319e7'
+

Next Step

For a more detailed list of automations, check out the gitStream integrations page or automation library.

\ No newline at end of file diff --git a/execution-model/index.html b/execution-model/index.html new file mode 100644 index 00000000..4b681d61 --- /dev/null +++ b/execution-model/index.html @@ -0,0 +1,67 @@ + Execution - gitStream Documentation

Execution Model

gitStream is triggered on new pull requests (PRs) for repositories that have gitStream installed. Upon triggering, gitStream collects context variables and evaluates the automation rules to determine which ones are relevant.

Organization-level rules and repository rules

When a central cm repository is set with the CI/CD runner, the events for PRs from all installed repositories shall be evaluated in the cm repository pipeline, considering the organization-level and PR repository rules.

Triggering Mechanism

gitStream automations are triggered by events related to pull requests (PRs). You can specify triggers to fine-tune which events should initiate automations.

Implicit triggers

By default, gitStream evaluates any new commit pushed to the PR, triggering automation evaluation.

Additionally, if any of the automation rules reference the following pr context variables: pr.comments, pr.title, pr.description, or pr.labels, gitStream shall trigger and will initiate automation rules evaluation where there are changes to the PR comments, title, description, or labels respectfully.

This allows for greater flexibility in the automation process, ensuring that the relevant automation rules are evaluated and triggered when necessary. The execution model ensures the automation process is streamlined, efficient, and effective.

Explicit triggers

gitstream supports an explicit triggering mechanism. When using explicit triggers, the automations will run only according to the defined triggers, which means the Implicit triggers will not work. Automations triggered by explicit triggers will also be invoked on draft PRs

Triggers can be defined globally at the file level or specifically for each automation. Triggers are applied only to the file(s) where they are declared.

triggers section

Use explicit triggers to enhance the control and customization of automations in gitStream, when you need to define precisely when and how automations should be triggered based on various events and actions within pull requests.

The triggers is section specifies when automations are executed, supporting include and exclude lists for branch and repository patterns at the file level.

The on keyword can also be used within individual automations to define specific events that trigger those automations. Add the on keyword under the triggers key in the file and/or to a specific automation to define explicit triggers.

Key Type Description
triggers.on [String] Specifies the explicit triggers that initiate the automations.
triggers.include.branch [String or regex] Branches that match will trigger the automation.
triggers.exclude.branch [String or regex] Branches that match will not trigger the automation.
triggers.include.repository [String or regex] Repositories that match will trigger the automation.
triggers.exclude.repository [String or regex] Repositories that match will not trigger the automation.

The table below lists supported explicit triggers, categorized into those enabled by default and those that require manual activation.

Triggering event Explicit Trigger Default (implicit triggers)
Creating a PR pr_created on
Commit commit on
Adding label label_added when pr.label in .cm
Removing label label_removed when pr.label in .cm
Merging the PR merge off
Adding new comment comment_added when pr.comment in .cm
Editing an existing comment - when pr.comment in .cm
Title change - when pr.title in .cm
Description change - when pr.description in .cm
Transition from draft to ready for review pr_ready_for_review off
transition from any state to closed pr_closed off
transition from closed to open pr_reopened off

Explicit triggers are set independently per each automation block and can be configured at the file level, specific to each automation separately or in combination. If triggers are listed at the file level and specific automation, the automation will be triggered according to both triggers. If an automation block does not have explicit triggers configured, it will be triggered according to the default (implicit) triggers.

Usage example:

triggers:
+  on:
+    - pr_created
+    - commit
+  exclude:
+    branch:
+      - hotfix
+
+automations:
+  skip_github_action_label:
+    on:
+      - label_added
+    if:
+      - {{ pr.labels | match(term='experimental') | some }}
+    run:
+      - action: add-github-check@v1
+        args:
+          check_name: production-ci
+          conclusion: skipped
+

Note on Matching:

  • When using a String as the matching type, the values in triggers.include.* and triggers.exclude.* require exact matches. This means that the names of branches or repositories must exactly match the specified string to either trigger or prevent triggering the automation.
  • For more precise control, use a regular expression (regex) format: r/REGEX_PATTERN/.

Default Behavior:

  • Implicit triggers are the default behavior if the automation doesn't have explicit triggers configured.
  • The automation runs for all branches and repositories if neither include nor exclude is specified.

Exclude/Include prioritization

  • Exclude overrides the include option. Thus, a repo will be excluded when a it matches both the include and exclude lists.

    In the following example, the automations in the file will be triggered for all repositories that contain the string feature, except for the repository my_feature

    triggers:
    +  include:
    +    repository:
    +      - r/feature/
    +  exclude:
    +    repository:
    +      - my_feature
    +

Examples

  • Assign code expert reviewer when the PR is created and after each commit. Ignore branches with the string "hotfix" in them

    triggers:
    +  on:
    +    - pr_created
    +    - commit
    +  exclude:
    +    branch:
    +      - hotfix
    +
    +automations:
    +  assign_code_experts:
    +    if:
    +      - true
    +    run:
    +      - action: add-reviewers@v1
    +        args:
    +          reviewers: {{ repo | codeExperts(gt=10) }}
    +

  • Explain code experts only if the label “suggest-reviewer” exists. The automation will be triggered after each commit and after each label addition. If the label “suggest-reviewer” exists, it will trigger the explain-code-experts automation

    triggers:
    +  on:
    +    - commit
    +
    +automations:
    +  explain_code_experts:
    +    on:
    +      - label_added
    +    if:
    +      - {{ pr.labels | match(term='suggest-reviewer') | some }}
    +    run:
    +      - action: explain-code-experts@v1
    +        args:
    +          gt: 10
    +

  • Trigger only specific automations branch pattern A, and trigger other automation for all other branches except those that fit the pattern REGEX_PATTERN

    # Automation in this file will trigger only for branch pattern REGEX_PATTERN
    +triggers:
    +  include:
    +    branch:
    +      - r/REGEX_PATTERN/
    +
    # Automations in this file will trigger for all branches except pattern REGEX_PATTERN
    +triggers:
    +  exclude:
    +    branch:
    +      - r/REGEX_PATTERN/
    +

\ No newline at end of file diff --git a/faq/index.html b/faq/index.html new file mode 100644 index 00000000..8608655b --- /dev/null +++ b/faq/index.html @@ -0,0 +1,2 @@ + gitStream Frequently Asked Questions - gitStream Documentation

FAQ

What permissions are needed?

In your repo permissions, make sure GitHub actions are permitted:

Go to Repo's settings > Actions > General > Actions permissions

Choose which repositories are permitted to use GitHub Actions.

[x] Allow all actions and reusable workflows

Does gitStream services have access to my code?

Like any other CI/CD automation, the source code is being scanned in the repo and is not shared with any external services. Only metadata that relates and affects the workflow is shared to allow rule based automation on the repo.

Why does gitStream require permission to write code?

In order to support automations that either Approve or Merge PRs, GitHub API requires code write scope.

What repos are supported?

Any repo in GitHub is supported. More Git providers are planned soon.

Can I use gitStream with Merge Queues?

Yes. When a merge queue is used, and gitStream is set as a required check, gitStream automation will be invoked with the merge event. The automation will set gitStream to a Completed status and Skipped conclusion to allow the PR merge. gitStream with Merge Queue

Custom filter functions

Coming soon.

Is there .cm syntax highlighting?

The .cm file use YAML with JINJA2, in order for your favorite editor to choose automatically the right syntax, you can use modelines.

Add the following line to the top of the .cm file (the default has it already):

# -*- mode: yaml -*-
+

Get a plug-in that enable modelines, popular ones are:

I have an issue I can't seem to solve, what should I do?

Go to our issues page and check if there are any similar issues already reported. If not, create a new issue with all the details so we can take a look.

Found a bug? Create a new item in the project's issues

\ No newline at end of file diff --git a/filter-function-plugins/index.html b/filter-function-plugins/index.html new file mode 100644 index 00000000..9d2a8b39 --- /dev/null +++ b/filter-function-plugins/index.html @@ -0,0 +1,661 @@ + Filter Function Plugin Library - gitStream Documentation

Filter Function Plugin Library

JavaScript plugins that enable custom filter functions for gitStream. To learn how to use these examples, read our guide on how to use gitStream plugins.

compareMultiSemver

Processes a list of pairs of semantic version numbers and determines the most significant change among them.

Returns: string - It returns a string of either: 'major' if any pair has a major version increment. 'minor' if no pair has a major version increment but has a minor version increment. 'patch' if no pair has major or minor version increments but has a patch version increment. 'downgrade' if no pairs have a higher version. 'equal' if all pairs are equal. 'error' if the comparison is abnormal or cannot be determined.

License: MIT

Param Type Default Description
listOfPairs Array.<Array> An array of version pairs, where each pair is an array of two semantic version strings.

Example

{{ [["1.2.3", "0.2.1"], ["1.3.1", "1.2.3"]] | compareMultiSemver  == "major" }}
+

Plugin Code: compareMultiSemver

/**
+ * @module compareMultiSemver
+ * @description Processes a list of pairs of semantic version numbers and determines the most significant change among them.
+ * Each pair consists of two versions to be compared.
+ * @param {string[][]} listOfPairs - An array of version pairs, where each pair is an array of two semantic version strings.
+ * @returns {string} It returns a string of either:
+ * 'major' if any pair has a major version increment.
+ * 'minor' if no pair has a major version increment but has a minor version increment.
+ * 'patch' if no pair has major or minor version increments but has a patch version increment.
+ * 'downgrade' if no pairs have a higher version.
+ * 'equal' if all pairs are equal.
+ * 'error' if the comparison is abnormal or cannot be determined.
+ * @example {{ [["1.2.3", "1.2.1"], ["1.3.1", "1.2.3"]] | compareMultiSemver  == "minor" }}
+ * @license MIT
+ */
+
+
+const compareSemver = require('../compareSemver/index.js');
+
+module.exports = (listOfPairs) => {
+
+  const priority = {
+    'major': 3,
+    'minor': 2,
+    'patch': 1,
+    'downgrade': 0,
+    'equal': -1,
+    'error': -2
+  };
+
+  let mostSignificantChange = 'equal';
+
+  listOfPairs.forEach(pair => {
+    const result = compareSemver(pair);
+    if (priority[result] > priority[mostSignificantChange]) {
+      mostSignificantChange = result;
+    }
+  });
+
+  return mostSignificantChange;
+}
+
+
+const compareMultiSemver = require('./index.js');
+console.assert(compareMultiSemver([["1.2.3", "1.2.1"], ["1.3.1", "1.2.3"]]) === 'minor', `compareSemver([["1.2.3", "1.2.1"], ["1.3.1", "1.2.3"]]) == 'minor'`);
+console.assert(compareMultiSemver([["1.2.3", "0.2.1"], ["1.3.1", "1.2.3"]]) === 'major', `compareMultiSemver([["1.2.3", "0.2.1"], ["1.3.1", "1.2.3"]]) === 'major'`);
+console.assert(compareMultiSemver([["2.2.3", "0.2.1"], ["1.3.1", "1.2.3"]]) === 'major', `compareMultiSemver([["2.2.3", "0.2.1"], ["1.3.1", "1.2.3"]]) === 'major'`);
+console.assert(compareMultiSemver([["1.2.3", "1.2.1"], ["1.2.4", "1.2.3"]]) === 'patch', `compareMultiSemver([["1.2.3", "1.2.1"], ["1.2.4", "1.2.3"]]) === 'patch'`);
+

gitStream CM Example: compareMultiSemver

manifest:
+  version: 1.0
+
+automations:
+  bump_minor:
+    if:
+      - {{ bump == 'minor' }}
+    run:
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            bot `minor` version bumps are approved automatically.
+
+  bump_patch:
+    if:
+      - {{ bump == 'patch' }}
+    run:
+      - action: approve@v1
+      - action: merge@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            bot `patch` version bumps are approved and merged automatically.
+
+bump: {{ [["1.2.3", "1.2.1"], ["1.3.1", "1.2.3"]] | compareMultiSemver }}
+

Download Source Code

compareSemver

Compares two software version numbers (e.g., "1.2.1" or "1.2b") and determines the type of version change. The first version to be compared, and the second are passed as argument 1 and 2 or as array of 2 items. When V1 > V2 the it means and upgrade.

Returns: string - It returns a string of either: 'major' if the major version is incremented. 'minor' if the minor version is incremented. 'patch' if the patch version is incremented. 'downgrade' if the second version is lower than the first. 'equal' if both versions are equal. 'error' if the comparison is abnormal or cannot be determined.
License: MIT

Param Type Default Description
versions Array.<string> V1 and V2 in Semver format
[lexicographical] boolean false compares each part of the version strings lexicographically instead of naturally; this allows suffixes such as "b" or "dev" but will cause "1.10" to be considered smaller than "1.2".
[zeroExtend] boolean true changes the result if one version string has less parts than the other. In this case the shorter string will be padded with "zero" parts instead of being considered smaller.

Example

{{ ["1.2.1", "1.2.3"] | compareSemver  == "patch" }}
+

Plugin Code: compareSemver

/**
+ * @module compareSemver
+ * @description Compares two software version numbers (e.g., "1.2.1" or "1.2b") and determines the type of version change.
+ * The first version to be compared, and the second are passed as argument 1 and 2 or as array of 2 items.
+ * When V1 > V2 the it means and upgrade.
+ * @param {string[]} versions - V1 and V2 in Semver format
+ * @returns {string} It returns a string of either:
+ * 'major' if the major version is incremented.
+ * 'minor' if the minor version is incremented.
+ * 'patch' if the patch version is incremented.
+ * 'downgrade' if the second version is lower than the first.
+ * 'equal' if both versions are equal.
+ * 'error' if the comparison is abnormal or cannot be determined.
+ * @example {{ ["1.2.3", "1.2.1"] | compareSemver  == "patch" }}
+ * @license MIT
+**/
+
+
+module.exports = (v1, v2) => {
+  const lexicographical = false;
+  const zeroExtend = true;
+
+  // support array as input
+  if (Array.isArray(v1) && v2 === undefined) {
+    [v1, v2] = v1; // Destructure the first two elements of the array into v1 and v2
+  }
+
+  let v1parts = (v1 || "0").split('.');
+  let v2parts = (v2 || "0").split('.');
+
+  const isValidPart = x => lexicographical ? /^\d+[A-Za-zαß]*$/.test(x) : /^\d+[A-Za-zαß]?$/.test(x);
+
+  if (!v1parts.every(isValidPart) || !v2parts.every(isValidPart)) {
+    return 'error';
+  }
+
+  if (zeroExtend) {
+    const maxLength = Math.max(v1parts.length, v2parts.length);
+    v1parts = [...v1parts, ...Array(maxLength - v1parts.length).fill("0")];
+    v2parts = [...v2parts, ...Array(maxLength - v2parts.length).fill("0")];
+  }
+
+  const convertPart = x => {
+    const match = /[A-Za-zαß]/.exec(x);
+    return Number(match ? x.replace(match[0], "." + x.charCodeAt(match.index)) : x);
+  };
+
+  if (!lexicographical) {
+    v1parts = v1parts.map(convertPart);
+    v2parts = v2parts.map(convertPart);
+  }
+
+  for (let i = 0; i < v1parts.length; i++) {
+    if (v1parts[i] !== v2parts[i]) {
+      if (v1parts[i] < v2parts[i]) {
+        return 'downgrade';
+      }
+      switch (i) {
+        case 0: return 'major';
+        case 1: return 'minor';
+        case 2: return 'patch';
+        default: return 'error';
+      }
+    }
+  }
+
+  return 'equal';
+}
+
+
+const compareSemver = require('./index.js');
+console.assert(compareSemver(["1.2.3", "1.2.1"]) === 'patch', `compareSemver(["1.2.3", "1.2.1"]) == 'patch'`);
+console.assert(compareSemver(["1.2.0", "1.2.1"]) === 'downgrade', `compareSemver(["1.2.0", "1.2.1"]) === downgrade'`);
+console.assert(compareSemver(["1.3.0", "1.2.1"]) === 'minor', `compareSemver(["1.3.0", "1.2.1"]) == 'minor'`);
+console.assert(compareSemver(["2.0.0", "1.2.1"]) === 'major', `compareSemver(["2.0.0", "1.2.1"]) == 'major'`);
+console.assert(compareSemver(["1.2.1", "1.2.1"]) === 'equal', `compareSemver(["1.2.1", "1.2.1"]) == 'equal'`);
+console.assert(compareSemver(["1.2b", "1.2.1"]) === 'minor', `compareSemver(["1.2b", "1.2.1"]) == 'error'`);
+console.assert(compareSemver(["1.2.0", "1.2"]) === 'equal', `compareSemver(["1.2.0", "1.2"]) == 'equal'`);
+console.assert(compareSemver(["1.2.1.0", "1.2.1"]) === 'equal', `compareSemver(["1.2.1.0", "1.2.1"]) == 'equal'`);
+console.assert(compareSemver(["1.2.1.0a", "1.2.1"]) === 'error', `compareSemver(["1.2.1.0a", "1.2.1"]) === downgrade'`);
+

gitStream CM Example: compareSemver

manifest:
+  version: 1.0
+
+automations:
+  bump_minor:
+    if:
+      - {{ bump == 'minor' }}
+    run:
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            bot `minor` version bumps are approved automatically.
+
+  bump_patch:
+    if:
+      - {{ bump == 'patch' }}
+    run:
+      - action: approve@v1
+      - action: merge@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            bot `patch` version bumps are approved and merged automatically.
+
+bump: {{ ["1.2.3", "1.2.1"] | compareSemver }}
+

Download Source Code

extractDependabotVersionBump

Extract version bump information from Dependabot PRs description

Returns: Array.<string> - V1 (to) and V2 (from)
License: MIT

Param Type Description
description string the PR description

Example

{{ pr.description | extractDependabotVersionBump | compareSemver }}
+

Plugin Code: extractDependabotVersionBump

/**
+ * @module extractDependabotVersionBump
+ * @description Extract version bump information from Dependabot PRs description
+ * @param {string} description - the PR description
+ * @returns {string[]} V1 (to) and V2 (from)
+ * @example {{ pr.description | extractDependabotVersionBump | compareSemver }}
+ * @license MIT
+**/
+
+
+module.exports = (desc) => {
+  if (desc && desc !== '""' && desc !== "''" ) {    
+    const matches = /Bumps.*from ([\d\.]+[A-Za-zαß]*) to ([\d\.]+[A-Za-zαß]*)/.exec(desc);
+    if (matches && matches.length == 3) {
+      var [_, from, to] = matches;
+      // remove trailing dot on to
+      if (to[to.length - 1] === ".") {
+        to = to.slice(0, -1);
+      }
+      return [to, from];
+    }
+  }
+
+  return null;
+}
+

gitStream CM Example: extractDependabotVersionBump

manifest:
+  version: 1.0
+
+automations:
+  bump_minor:
+    if:
+      - {{ bump == 'minor' }}
+      - {{ branch.name | includes(term="dependabot") }}
+      - {{ branch.author | includes(term="dependabot") }}
+    run:
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Dependabot `minor` version bumps are approved automatically.
+
+  bump_patch:
+    if:
+      - {{ bump == 'patch' }}
+      - {{ branch.name | includes(term="dependabot") }}
+      - {{ branch.author | includes(term="dependabot") }}
+    run:
+      - action: approve@v1
+      - action: merge@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Dependabot `patch` version bumps are approved and merged automatically.
+
+bump: {{ pr.description | extractDependabotVersionBump | compareSemver }}
+

Download Source Code

extractRenovateVersionBump

Extract version bump information from Renovate PRs description

Returns: Array.<string> - V1 (to) and V2 (from) License: MIT

Param Type Description
description string the PR description

Example

{{ pr.description | extractRenovateVersionBump | compareMultiSemver }}
+

Plugin Code: extractRenovateVersionBump

/**
+ * @module extractRenovateVersionBump
+ * @description Extract version bump information from Renovate PRs description
+ * @param {string} description - the PR description
+ * @returns {string[]} V1 (to) and V2 (from)
+ * @example {{ pr.description | extractRenovateVersionBump | compareMultiSemver }}
+ * @license MIT
+**/
+
+
+module.exports = (desc) => {
+  const results = [];
+  if (desc && desc !== '""' && desc !== "''") {
+    const regex =
+      /\[[\\]*`([\d\.]+[A-Za-zαß]*)[\\]*` -> [\\]*`([\d\.]+[A-Za-zαß]*)[\\]*`\]/g;
+    let matches = null;
+    do {
+      matches = regex.exec(desc);
+      if (matches?.length === 3) {
+        let [_, from, to] = matches;
+        // remove trailing dot on to
+        if (to.at(-1) === ".") {
+          to = to.slice(0, -1);
+        }
+        results.push([to, from]);
+      }
+    } while (matches !== null);
+  }
+  return results;
+}
+

gitStream CM Example: extractRenovateVersionBump

manifest:
+  version: 1.0
+
+automations:
+  bump_minor:
+    if:
+      - {{ bump == 'minor' }}
+      - {{ branch.name | includes(term="renovate") }}
+      - {{ branch.author | includes(term="renovate") }}
+    run:
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Renovate `minor` version bumps are approved automatically.
+
+  bump_patch:
+    if:
+      - {{ bump == 'patch' }}
+      - {{ branch.name | includes(term="renovate") }}
+      - {{ branch.author | includes(term="renovate") }}
+    run:
+      - action: approve@v1
+      - action: merge@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Renovate `patch` version bumps are approved and merged automatically.
+
+bump: {{ pr.description | extractRenovateVersionBump | compareMultiSemver }}
+

Download Source Code

extractSnykVersionBump

Extract version bump information from Snyk PRs description

Returns: Array.<string> - V1 (to) and V2 (from)
License: MIT

Param Type Description
description string the PR description

Example

{{ pr.description | extractSnykVersionBump | compareSemver }}
+

Plugin Code: extractSnykVersionBump

/**
+ * @module extractSnykVersionBump
+ * @description Extract version bump information from Snyk PRs description
+ * @param {string} description - the PR description
+ * @returns {string[]} V1 (to) and V2 (from)
+ * @example {{ pr.description | extractSnykVersionBump | compareSemver }}
+ * @license MIT
+**/
+
+
+
+module.exports = (desc) => {
+  if (desc && desc !== '""' && desc !== "''" ) {    
+    const matches = /Upgrade.*from ([\d\.]+[A-Za-zαß]*) to ([\d\.]+[A-Za-zαß]*)/.exec(desc);
+    if (matches && matches.length == 3) {
+      var [_, from, to] = matches;
+      // remove trailing dot on to
+      if (to[to.length - 1] === ".") {
+        to = to.slice(0, -1);
+      }
+      return [to, from];
+    }
+  }
+
+  return null;
+}
+

gitStream CM Example: extractSnykVersionBump

manifest:
+  version: 1.0
+
+automations:
+  bump_minor:
+    if:
+      - {{ bump == 'minor' }}
+      - {{ branch.name | includes(term="snyk-update"") }}
+      - {{ branch.author | includes(term="snyk-update"") }}
+    run:
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Snyk `minor` version bumps are approved automatically.
+
+  bump_patch:
+    if:
+      - {{ bump == 'patch' }}
+      - {{ branch.name | includes(term="snyk-update"") }}
+      - {{ branch.author | includes(term="snyk-update"") }}
+    run:
+      - action: approve@v1
+      - action: merge@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Snyk `patch` version bumps are approved and merged automatically.
+
+bump: {{ pr.description | extractSnykVersionBump | compareSemver }}
+

Download Source Code

extractOrcaFindings

Extract security issues information from Orca PR reviews

Returns: Object - Findings Findings.infrastructure_as_code: { count: null, priority: '' }, Findings.vulnerabilities: { count: null, priority: '' }, Findings.secrets: { count: null, priority: '' },
License: MIT

Param Type Description
PR Object the gitStream's PR context variable

Example

{{ pr | extractOrcaFindings }}
+

Usage example, that adds lables based on Orca Secuirty findings.

Plugin Code: extractOrcaFindings

/**
+ * @module extractOrcaFindings
+ * @description Extract security issues information from Orca PR reviews
+ * @param {Object} pr - the gitStream's PR context variable
+ * @returns {Object} Findings
+ * Findings.infrastructure_as_code: { count: null, priority: '' },
+ * Findings.vulnerabilities: { count: null, priority: '' },
+ * Findings.secrets: { count: null, priority: '' },
+ * @example {{ pr | extractOrcaFindings }}
+ * @license MIT
+**/
+
+
+function getOrcaPropertyRating(lines, lineIdentifierRegex, findingsCellIndex) {
+  const matches = lines.filter(x => x.match(lineIdentifierRegex));
+  const [firstMatch] = matches;
+  const cells = firstMatch.split('|');
+  const [_, high, medium, low, info] = /"High"> ([\d]+).*"Medium"> ([\d]+).*"Low"> ([\d]+).*"Info"> ([\d]+)/
+    .exec(cells[findingsCellIndex])
+    .map(x => parseInt(x));
+  return {high, medium, low, info};
+}
+
+module.exports = (pr) => {
+  let orcaObject = {
+    infrastructure_as_code: { count: null, priority: '' },
+    vulnerabilities: { count: null, priority: '' },
+    secrets: { count: null, priority: '' },
+  };
+
+  // Orca comments are added as PR review
+  const orcaComment = pr.reviews.filter(x => x.commenter.includes('orca-security'));
+
+  if (orcaComment.length) {
+    const orcaCommentArray = orcaComment[orcaComment.length - 1].content.split('\n');
+
+    var priority = getOrcaPropertyRating(orcaCommentArray, /Infrastructure as Code/, 3);
+    orcaObject.infrastructure_as_code = {
+      count: priority.high + priority.medium + priority.low + priority.info,
+      priority,
+    };
+
+    var priority = getOrcaPropertyRating(orcaCommentArray, /Vulnerabilities/, 3);
+    orcaObject.vulnerabilities = {
+      count: priority.high + priority.medium + priority.low + priority.info,
+      priority,
+    };
+
+    var priority = getOrcaPropertyRating(orcaCommentArray, /Secrets/, 3);
+    orcaObject.secrets = {
+      count: priority.high + priority.medium + priority.low + priority.info,
+      priority,
+    };
+  }
+
+  return JSON.stringify(orcaObject);
+}
+

gitStream CM Example: extractOrcaFindings

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in reports %}
+  label_orca_{{ item.name }}:
+    if:
+      - {{ item.count > 0 }}
+    run:
+      - action: add-label@v1
+        args:
+          label: 'orca:{{ item.name }}'
+  {% endfor %}
+
+orca: {{ pr | extractOrcaFindings }}
+
+reports:
+  - name: introduced-cves
+    count: {{ orca.vulnerabilities.count }}
+  - name: iac-misconfigurations
+    count: {{ orca.infrastructure_as_code.count }}
+  - name: exposed-secrets 
+    count: {{ orca.secrets.count }}
+
+colors:
+  red: 'b60205'
+

Download Source Code

getCodeowners

Resolves the PR's code owners based on the repository's CODEOWNERS file

Returns: Array.<string> - user names
License: MIT

Param Type Description
files Array.<string> the gitStream's files context variable
pr Object the gitStream's pr context variable
token string access token with repo:read scope, used to read the CODEOWNERS file

Example

{{ files | getCodeowners(pr, env.CODEOWNERS_TOKEN) }}
+

When used, create a secret TOKEN, and add it to the workflow file, in GitHub:

jobs:
+  gitStream:
+    ...
+    env:
+      CODEOWNERS: ${{ secrets.GITSTREAM_CODEOWNERS }}
+    steps:
+      - name: Evaluate Rules
+        uses: linear-b/gitstream-github-action@v2
+
Plugin Code: getCodeowners

/**
+ * @module getCodeowners
+ * @description Resolves the PR's code owners based on the repository's CODEOWNERS file
+ * @param {string[]} files - the gitStream's files context variable
+ * @param {Object} pr - the gitStream's pr context variable
+ * @param {string} token - access token with repo:read scope, used to read the CODEOWNERS file
+ * @returns {string[]} user names
+ * @example {{ files | getCodeowners(pr, env.CODEOWNERS_TOKEN) }}
+ * @license MIT
+**/
+
+
+const { Octokit } = require("@octokit/rest");
+const ignore = require('./ignore/index.js');
+
+async function loadCodeownersFile(owner, repo, auth) {
+  const octokit = new Octokit({
+    request: { fetch },
+    auth,
+  });
+
+  const res = await octokit.repos.getContent({
+    owner,
+    repo,
+    path: 'CODEOWNERS'
+  });
+
+  return Buffer.from(res.data.content, 'base64').toString()
+}
+
+function codeownersMapping(data) {
+  return data
+    .toString()
+    .split('\n')
+    .filter(x => x && !x.startsWith('#'))
+    .map(x => x.split("#")[0])
+    .map(x => {
+        const line = x.trim();
+        const [path, ...owners] = line.split(/\s+/);
+        return {path, owners};
+    });
+}
+
+function resolveCodeowner(mapping, file) {
+    const match = mapping
+      .slice()
+      .reverse()
+      .find(x =>
+          ignore()
+              .add(x.path)
+              .ignores(file)
+      );
+    if (!match) return false;
+    return match.owners;
+}
+
+module.exports = {
+   async: true,
+   filter: async (files, pr, token, callback) => {
+    const fileData = await loadCodeownersFile(pr.author, pr.repo, token);
+    const mapping = codeownersMapping(fileData);
+
+    const resolved = files
+      .map(f => resolveCodeowner(mapping, f))
+      .flat()
+      .filter(i => typeof i === 'string')
+      .map(u => u.replace(/^@/, ""));
+
+    const unique = [...new Set(resolved)];
+
+    return callback(null, unique); 
+  },
+}
+

gitStream CM Example: getCodeowners

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  senior_review:
+    if:
+      - true
+    run:
+      - action: explain-code-experts@v1
+        args:
+          gt: 10
+      - action: add-reviewers@v1
+        args:
+          reviewers: {{ experts | intersection(list=owners) }}
+
+experts: {{ repo | codeExperts(gt=10) }}
+owners: {{ files | codeowners(pr, env.CODEOWNERS) }}
+

Download Source Code

hasJiraIssue

Check to see if the input string matches a specified field for one or more Jira issues.

Returns: boolean - Returns true if the input string matches a Jira task title.
License: MIT

Param Type Description
input string The string to search for a Jira task title.
password string Your Jira API token
key string The Jira key to search for matches against the input string.
jiraSpaceName string The name of the Jira space to search for tasks.
email string The email address associated with the Jira API token.

Example

{{ "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}" | hasJiraIssue(password, key, jiraSpaceName, email) }}
+

Prerequisite Configuration

You will need to complete the following steps to use this plugin:

  1. Create an API token for your Jira account.
  2. Make the token available to gitStream via an environment variable.
Plugin Code: hasJiraIssue

/**
+ * @module hasJiraIssue
+ * @description Check to see if the input string matches a specified field for one or more Jira issues.
+ * @param {string} input - The string to search for a Jira task title.
+ * @param {string} password - Your Jira API token
+ * @param {string} key - The Jira key to search for matches against the input string.
+ * @param {string} jiraSpaceName - The name of the Jira space to search for tasks.
+ * @param {string} email - The email address associated with the Jira API token.
+ * @returns {boolean} Returns true if the input string matches a Jira task title. 
+ * @example {{ "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}" | hasJiraIssue(password, key, jiraSpaceName, email) }}
+ * @license MIT
+ */
+module.exports = {
+    async: true,
+    filter: async (inputString, password, key, jiraSpaceName, email, callback) => {
+        const jql = `"${key}" = "${inputString}"`;
+
+    const resp = await fetch(`https://${jiraSpaceName}.atlassian.net/rest/api/2/search`, {
+            method: 'POST',
+            headers: {
+                'Content-Type': 'application/json',
+                'Authorization': 'Basic ' + btoa(`${email}:${password}`)
+            },
+            body: JSON.stringify({
+                'jql': jql,
+                'maxResults': 1,
+                "fieldsByKeys": true,
+                'fields': [ 'assignee' ]
+            })
+        });
+        const results = await resp.json();
+        return callback(null,  !!results.issues?.length);
+    }
+}
+

gitStream CM Example: hasJiraIssue

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+###### ** Configure This Section ** ######
+
+# Configure this for your Jira instance and the email associated with your API key.
+# You can safely use these values because only your API key is sensitive. 
+jiraSpaceName: "my-company" # e.g. my-company.atlassian.net
+email: "my.email@example.com"
+# If you're concerned about exposing this information,
+# we recommend using environment variables for your production environment.
+
+# -----------
+
+# Pass the API token associated with the email above to gitStream via an environment variable.
+jiraAuth: {{ env.JIRA_API_TOKEN }}
+# Learn more about env: https://docs.gitstream.cm/context-variables/#env
+
+# -----------
+
+# Change this to the Jira field you want to match the input string against.
+jiraField: "myField"
+# If you want to search a custom field, you should provide the ID like so:
+# jiraField: "cf[XXXXX]"
+# Replace XXXXX with the ID of the custom field you want to search.
+# More information:
+# Using JQL to search the Jira API: https://support.atlassian.com/jira-service-management-cloud/docs/jql-fields/
+# How to find the ID of a custom field: https://confluence.atlassian.com/jirakb/how-to-find-any-custom-field-s-ids-744522503.html
+
+# -----------
+
+
+prUrl: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+has_jira_issue: {{ prUrl  | hasJiraIssue(jiraAuth, jiraField, jiraSpaceName, email) }}
+
+automations:
+  has_jira_issue: 
+    if:
+      - {{ not has_jira_issue }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: "This PR is missing a related issue in Jira. Please create a Jira task."
+

Download Source Code

isFlaggedUser

Returns true if the username that is passed to this function is specified in a predefined list of users. This is useful if you want gitStream automations to run only for specified users.

Returns: boolean - Returns true if the user is specified in the flaggedUsers list, otherwise false.
License: MIT

Param Type Description
Input string The GitHub username to check.

Example

{{ pr.author | isFlaggedUser }}
+

Plugin Code: isFlaggedUser

// Add users who you want to add to the flag list.
+const flaggedUsers = ["user1", "user2"];
+/**
+ * @module isFlaggedUser
+ * @description Returns true if the username that is passed to this function is specified in a predefined list of users. 
+ * This is useful if you want gitStream automations to run only for specified users.
+ * @param {string} Input - The GitHub username to check.
+ * @returns {boolean} Returns true if the user is specified in the flaggedUsers list, otherwise false.
+ * @example {{ pr.author | isFlaggedUser }}
+ * @license MIT
+ */
+function isFlaggedUser(username) {
+    if (flaggedUsers.includes(username)) {
+        return true;
+    } else {
+        return false;
+    }
+};
+
+function containsString(arr, str) {
+    return arr.includes(str);
+};
+
+module.exports = isFlaggedUser;
+

gitStream CM Example: isFlaggedUser

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  detect_flagged_user:
+    if:
+      - {{ pr.author | isFlaggedUser }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: {{ pr.author }} is a gitStream user.
+

Download Source Code


\ No newline at end of file diff --git a/filter-functions/index.html b/filter-functions/index.html new file mode 100644 index 00000000..c839cdf1 --- /dev/null +++ b/filter-functions/index.html @@ -0,0 +1,180 @@ + gitStream Reference - Filter Functions - gitStream Documentation

Filter functions

Filters can change the look and format of the source data, or even generate new data derived from the input values. What's important is that the original data is replaced by the result of transformations, and that's what ends up in rendered templates.

Note

Items marked with are under development and are not available yet.

Overview

The following functions are supported in addition to the built-in functions provided by Nunjucks.

Low level functions

Function Input Args Output
capture
Find and return the first occurrence of a regex in the input string
String regex [Objects]
difference
Given two lists, keep only items that are in the 1st list but not in the 2nd.
[Objects] list [Objects]
every
Checks whether all element in the list are true
[Bool] - Bool
filter
Reduce list of items into a list of same items that match the specified term
[String]
[Object]
regex, term, list, attr [String]
[Object]
includes
Check if substring match
String regex, term, list Bool
intersection
Given two lists, keep only items that are in both lists.
[Objects] list [Objects]
map
Maps each object in a list into their specified attribute value
[Object] attr [Object]
match
Maps list of items into a list of booleans that match the specified term
[String]
[Object]
regex, term, list attr [Bool]
nope
Checks whether all element in the list are false
[Bool] - Bool
reject
Inverse of filter, the result list contains non-matching items
[String]
[Object]
regex, term, list, attr [String]
[Object]
some
Checks whether at least one element in the list is true
[Bool] - Bool

High level functions

Function Input Args Output
allDocs
Checks the list includes only documents
files - Bool
allImages
Checks the list includes only images
files - Bool
allTests
Checks the list includes only tests
files - Bool
codeExperts
Get list of contributors based on expert reviewer model results
repo gt, lt [String]
estimatedReviewTime
Estimated review time in minutes
branch - Integer
extensions
Lists all the unique file extensions
[String] - [String]
extractJitFindings
Get an object with a summary of the findings found by the Jit scan
pr - Object
extractSonarFindings
Get an object with a summary of the findings found by the SonarCloud scan
pr - Object
explainRankByGitBlame
Short markdown text explaining rankByGitBlame results
repo gt, lt [String]
isFirstCommit
Checks if its the author first commit in the repo
repo.contributors String Bool
isFormattingChange
Checks that only formatting changed
[FileDiff ] - Bool
mapToEnum
return the enum value matches to the input key
String Enum object Object
matchDiffLines
Match every line in diff
[FileDiff ] regex, ignoreWhiteSpaces [Bool]
rankByGitActivity
Get list of contributors based on git-commit activity
repo gt, lt [String]
rankByGitBlame
Get list of contributors based on git-blame results
repo gt, lt [String]

Named arguments

Some functions support named arguments, many of these repeat in different functions.

term - a single string, used as a substring to match with the matched item.

list - a list of strings, trying to match any of the listed substrings with the matched item.

regex - a single string, used as a regular expression with the matched item. A regular expression can be created just like JavaScript, but needs to be prefixed with r, for example, r/^foo.*/g, for more info see Nunjucks.

attr - a key in the element to use when doing the requested operation.

For example, the following expressions provide an identical result:

- {{ 'something' | includes(regex=r/^some.*/) }}
+- {{ 'something' | includes(term='some') }}
+- {{ 'something' | includes(list=['some']) }}
+

Reference

capture

Extract the first match of the regex in the input string. If no match is found, the function returns an empty string.

Argument Usage Type Description
- Input String The string to find the match in
regex Input String Search term to match with the input string
- Output Bool The first substring that match the provided regex

For example, the following line will extract the substring "hello wo" from the input

{{ "hello world" | capture(regex=r/he.+o/) }}
+

difference

Given two lists, keep only items that are in the 1st list but not in the 2nd.

Argument Usage Type Description
- Input [Objects] List of objects to inspect.
list Input [Objects] List of objects to exclude.
- Output [Objects] Returns a list of objects containing items that exist in one input, but not in the other.

every

Checks whether all element in the list are true. In case the list of elements is empty, it will return false.

Argument Usage Type Description
- Input [Bool] List of booleans
- Output Bool Returns true when all list items are true

For example, check that all changes are in either 'src' or 'dest' directories:

{{ files | match(list=['src', 'dest']) | every }}
+

filter

Creates a shallow copy of a portion of a given list, filtered down to just the elements that match the given term. You can use either a single term, regex, or a list of terms to match with.

Argument Usage Type Description
- Input [String]
[Object]
The list of strings to match, or list of objects if attr is used
term
regex
list
Input (either) String
String
[String]
Search term to match with the input items
attr Input (optional) String match a named attribute in the input object
- Output [String]
[Object]
The list with only the matching items

Examples: Check if all changes to JavaScript files are in the tests directory:

{{ files | filter(regex=r/\.js$/) | match(regex=r/tests\//) | every }}
+

Check if all changes to JavaScript files are formatting:

{{ source.diff.files | filter(attr='new_file', regex=r/\.js$/) | isFormattingChange }}
+

Check if the PR has new Python files:

{{ branch.diff.files_metadata | filter(attr='original_file', regex=r/^$/) | filter(attr='new_file', regex=r/\.py$/) | some }}
+

includes

Determines whether a string includes a certain substring. You can use either a single term, regex, or a list of terms to match with.

Argument Usage Type Description
- Input String The string you want to check for matching substrings
term
regex
list
Input (either) String
String
[String]
Substring term to match
- Output Bool true if search terms matches

Check string matches either of the terms:

{{ 'something' | includes(list=['any', 'thing']) }}
+

intersection

Given two lists, keep only items that are in both lists.

Argument Usage Type Description
- Input [Objects] List of objects to inspect.
list Input [Objects] List of objects to check for intersection.
- Output [Objects] Returns a list of objects containing items that intersect between the two lists.

map

Creates a new list populated with the values of the selected attribute of every element in the input list.

Argument Usage Type Description
- Input [Object] The list of objects to map, see context for valid inputs
attr Input String Object attribute to select
- Output [Object] List of the selected object attributes

For example, the source.diff.files context holds a list of FileDiff , each has new_file attribute. You can create a list of all the new file names by mapping to the new_file attribute and then check if there are changes to any handler.js file:

{{ source.diff.files | map(attr='new_file') | match(term='handler.js') | some }}
+

match

Return true for each element in the list that match the search term.

Argument Usage Type Description
- Input [String]
[Object]
The list of strings or if attr used the list of objects
term
regex
list
Input (either) String
String
[String]
Search term to match
attr Input String match a named attribute in the input object
- Output [Bool] true for every matching item

For example, to check if all code changes are in the tests directory:

{{ files | match(regex=r/tests\//) | every }}
+

For example, to check if there are code changes with specific function call:

{{ source.diff.files | match(attr='diff', term='myFunction') | some }}
+

nope

The inverse of every, checks whether all elements in the list are false. In case the list of elements is empty, it will return true.

Argument Usage Type Description
- Input [Bool] List of booleans
- Output Bool Returns true when all list items are false

For example, check that no changes in either 'src' or 'dest' directories:

{{ files | match(list=['src', 'dest']) | nope }}
+

reject

Creates a shallow copy of a portion of a given list, filtered down to just the elements that do not match the given term. You can use either a single term, regex, or a list of terms to match with.

Argument Usage Type Description
- Input [String]
[Object]
The list of strings to match, or list of objects if attr is used
term
regex
list
Input (either) String
String
[String]
Search term to match with the input items
attr Input (optional) String match a named attribute in the input object
- Output [String]
[Object]
The list with only the non-matching items

For example, check if all changes, but JavaScript files are in tests directory:

{{ files | reject(regex=r/\.js$/) | match(regex=r/tests\//') | every }}
+

For example, check if all changes except for config.json files are formatting:

{{ source.diff.files | reject(attr='new_file', regex=r/config\.json$/) | isFormattingChange }}
+

some

Checks whether any element in the list is true. In case the list of elements is empty it will return false.

Argument Usage Type Description
- Input [Bool] List of booleans
- Output Bool Returns true when any of the items is true
{{ files | match(list=['src', 'dest']) | some }}
+

allDocs

Return true if the input list includes only documents based on file extensions.

Doc files extensions are: md, mkdown, txt, rst, adoc, except for requirements.txt.

Argument Usage Type Description
- Input files The list of changed files with their path
- Output Bool true if all file extensions are of docs
{{ files | allDocs }}
+

In case you want to exclude more files, like all txt under the requirements directory, add another check:

{{ (files | allDocs) and (files | match(regex=r/requirements\/.*\.txt$/) | nope ) }}
+

allImages

Return true if the input list includes only images based on file extensions.

Image file extensions are: svg, png, gif.

Argument Usage Type Description
- Input files The list of changed files with their path
- Output Bool true if all file extensions are of images
{{ files | allImages }}
+

allTests

Return true if the input list includes only tests based on the file's path and name.

To identify as test the file must include the word test or spec in its name or path, it is checked using this regex: [^a-zA-Z0-9](spec|test|tests)[^a-zA-Z0-9].

Argument Usage Type Description
- Input files The list of changed files with their path
- Output Bool true if all file tests are based on name and path
{{ files | allTests }}
+

codeExperts

When requesting a review for a pull request, it's important to select a reviewer who has a deep understanding of the relevant code area, the domain problem, and the framework being used. This ensures that the reviewer can provide specific and informed feedback, rather than general comments that may not take into account the context in which the issue was solved.

The filter provides the list of most qualified contributors based on git-blame and git-commit results to determine who has been most active in the relevant code area, and then combines this information into a score between 0 and 100. The commit activity is scored higher for recent commits, which ensures that those who are actively contributing to the codebase are given higher priority as potential reviewers. The result will be limited to 2 users and shall not include the PR author.

The output lists the Git provider users, e.g., GitHub users, which are mapped from the Git users included in the git-blame output. When gitStream cannot map the Git user to a Git provider user it will be dropped from the output list, hence the list may contain less than 100% of the lines.

Note

The codeExperts filter function calls gitStream app API with the repo context to calculate the estimated review time value.

Argument Usage Type Description
- Input repo The repo context variable
lt Input Integer Filter the user list, keeping those below the specified threshold
gt Input Integer Filter the user list, keeping those above the specified threshold
- Output [String] Up to 2 users, sorted by best match first (it won't include the PR author)

For example:

automations:
+  code_experts:
+    if:
+      - true
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: {{ repo | codeExperts(gt=10) }}
+

estimatedReviewTime

Returns the estimated review time in minutes based on statistical model. The model uses the amount of additions and deletions statistics for each file type with additional information about the commits and base branch.

Note

The estimatedReviewTime filter function calls gitStream app API with the branch context to calculate the estimated review time value.

The following files are excluded when calculating this value:

Argument Usage Type Description
- Input branch Branch meta data
- Output Integer the estimated time for review in minutes
{{ branch | estimatedReviewTime }}
+

The following files are automatically excluded from the estimated review time calculation.

File type Filter type Values
Data Extension ini csv xls xlsx xlr doc docx txt pps ppt pptx dot dotx log tar rtf dat ipynb po profile object obj dxf twb bcsymbolmap tfstate pdf rbi pem crt svg png jpeg jpg ttf
Data Regex .*dist/.*\.js$ .*public/assets/.*\.js$
Pipeline Regex .*ci\.yml$
Lock File Name Programming Language Package Manager
package-lock.json JavaScript npm
yarn.lock JavaScript Yarn
npm-shrinkwrap.json JavaScript npm
Pipfile.lock Python pipenv
poetry.lock Python Poetry
conda-lock.yml Python conda
Gemfile.lock Ruby Bundler
composer.lock PHP Composer
packages.lock.json .NET NuGet
project.assets.json .NET .NET Core
pom.xml Java Maven
Cargo.lock Rust Cargo
mix.lock Elixir Mix
pubspec.lock Dart/Flutter pub
go.sum Go Go modules
stack.yaml.lock Haskell Stack
vcpkg.json C++ vcpkg
conan.lock C++ Conan
ivy.xml Scala sbt/Ivy
project.clj Clojure Leiningen
Podfile.lock Swift/Objective-C CocoaPods
Cartfile.resolved Swift/Objective-C Carthage
flake.lock Nix Nix

Tip

You can also filter more files, using config.ignore_files.

extensions

Expects files and provide a list of all unique file extensions.

Argument Usage Type Description
- Input files The list of changed files with their path
- Output [String] List of all unique file extensions

For example, check that only one file type was changed:

{{ files | extensions | length == 1 }}
+

extractJitFindings

Available in GitHub only

This filter is currently availalbe only in GitHub

Get an object with a summary of the findings found by Jit scan. This filter is relevant only for repos that use Jit to scan PRs

The pr context includes all the reviews in the pull request, including the reviews written by the Jit bot, along with all the comments (conversations) to the review.

This filter reads and parses the reviews with Jit's findings, making them available for use inside the .cm file automations.

The output is an object of the following format:

{
+  "vulnerabilities": [{
+    "security_control": 'string',
+    "type": 'string',
+    "description": 'string',
+    "severity": 'string',
+    "summary": 'string'
+  }],
+  "metrics": {
+    "HIGH": number,
+    "MEDIUM": number,
+    "LOW": number,
+    "INFO": number
+  }
+}
+

Argument Usage Type Description
- Input pr The pr context variable
- Output Object The object contains the summary of Jit's scan

Example of the filter output

{
+  "vulnerabilities": [
+    {
+      "security_control": "Static Code Analysis Js",
+      "type": "Codsec.Javascriptnosql-Injection.Nosql-Injection",
+      "description": "Putting request data into a mongo query can leadto a NoSQL Injection. Be sure to properly sanitize thedata if you absolutely must pass request data into a query.",
+      "severity": "HIGH",
+      "summary": "Jit Bot commands and options (e.g., ignore issue)"
+    },
+    {
+      "security_control": "Secret Detection",
+      "type": "Private-Key",
+      "description": "Private Key",
+      "severity": "HIGH",
+      "summary": "Jit Bot commands and options (e.g., ignore issue)"
+    }
+  ],
+  "metrics": {
+    "HIGH": 2,
+    "MEDIUM": 0,
+    "LOW": 0,
+    "INFO": 0
+  }
+}
+

Assign the output to a variable

jit: {{ pr | extractJitFindings }}
+

Add a label if Jit detected secrets in the PR

automations:
+    add_bugs_label:
+      if:
+        - {{ jit.metrics.HIGH > 0 }}
+      run:
+        - action: add-label@v1
+          args:
+            label: "Vulnerable code!""
+

extractSonarFindings

Available in GitHub only

This filter is currently availalbe only in GitHub

Get an object with a summary of the findings found by the SonarCloud scan. This filter is relevant only for repos that use SonarCloud to scan PRs

The pr context includes all the comments added to the pull request, including the comment written by the SonarCloud bot that holds a summary of its scan.

This filter reads and parses the comment with SonarCloud's scan summary and makes them available to use inside the .cm file automations.

The output is an object of the following format:

{
+  "bugs": {
+      "count": number,
+      "rating": 'string' //('A'-'E')
+    },
+  "code_smells": {
+      "count": number,
+      "rating": 'string' //('A'-'E')
+    },
+  "vulnerabilities": {
+      "count": number,
+      "rating": 'string' //('A'-'E')
+    },
+  "security_hotspots": {
+      "count": number,
+      "rating": 'string' //('A'-'E')
+    },
+  "duplications": number,
+  "coverage": number
+}
+

Argument Usage Type Description
- Input pr The pr context variable
- Output Object The object contains the summary of SonCloud's scan

Example of the filter output

{
+  "bugs": {
+      "count": 1,
+      "rating": 'B'
+    },
+  "code_smells": {
+      "count": 2,
+      "rating": 'B'
+    },
+  "vulnerabilities": {
+      "count": 2,
+      "rating": 'E'
+    },
+  "security_hotspots": {
+      "count": 0,
+      "rating": 'A'
+    },
+  "duplications": 3,
+  "coverage": 70
+}
+

Assign the output to a variable

sonar: {{ pr | extractSonarFindings }}
+

Add a label with the number of bugs if the bugs rating is other than 'A', and use mapToEnum to set its color

automations:
+# Add Bugs label
+  show_bugs_count:
+    if:
+      - {{ sonar.bugs.count > 0}}
+    run:
+      - action: add-label@v1
+        args:
+          label: '🐞 x {{ sonar.bugs.count }} Bugs'
+          color: {{ sonar.bugs.rating | mapToEnum(enum = colors) }}
+
+colors:
+  A: '05AA02'
+  B: 'B6D146'
+  C: 'EABE05'
+  D: 'DF8339'
+  E: 'D4343F'
+

explainRankByGitBlame

This filter helps to explain the results of rankByGitBlame, the output is in Markdown format that can be used in a PR comment.

The output lists the Git provider users, e.g., GitHub users, which are mapped from the Git users included in the git-blame output. Git users that could not be automatically mapped are marked with *. To map these users, you can add user_mapping see instructions here.

Argument Usage Type Description
- Input repo The repo context variable
lt Input Integer Filter the user list, keeping those below the specified threshold
gt Input Integer Filter the user list, keeping those above the specified threshold
- Output String Explaining rankByGitBlame results in markdown format

Note

Each contributor's result is rounded down to the nearest integer, so the total may add up to less than 100%.

For example:

automations:
+  the_right_reviewer:
+    if:
+      - true
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: {{ repo | rankByGitBlame(gt=50) }}
+      - action: add-comment@v1
+        args:
+          comment: |
+            {{ repo | explainRankByGitBlame(gt=50) }}
+

Note the comment starts with | and a new-line as explainRankByGitBlame generates a multiline comment.

isFirstCommit

Return true if it's the author first commit in the repo.

Argument Usage Type Description
- Input repo.contributors List of contributors in the repo
- Input String The contributor name
- Output Bool true if its the first commit of the selected contributor
if:
+  - {{ repo.contributors | isFirstCommit(branch.author) }}
+run:
+  - action: add-comment@v1
+    args:
+      comment: "Welcome {{branch.author}}!"
+

isFormattingChange

Return true if all file diffs are validated as formatting changes. This filter function works for JavaScript, TypeScript, Python, JSON, YAML and HTML.

gitStream determines formatting changes by minifying the source code for the incoming changes and the existing code and comparing them. If they are identical, this filter function returns true. If any unsupported languages are contained in the PR, gitStream will return false.

Argument Usage Type Description
- Input source.diff.files List of file diffs
- Output Bool true if the all code changes are non functional
{{ source.diff.files | isFormattingChange }}
+

mapToEnum

Get the enum value matches to the input key

Argument Usage Type Description
- Input String The key name
enum Input Enum Object The enum object to which the input string should be matched
- Output Object The value of the input key in the input enum object

For example, set a label color according to names in the enum:

automations:
+  label_color:
+    if:
+       - true
+    run:
+      - action: add-label@v1
+        args:
+          label: 'Blue label'
+          color: {{ "blue" | mapToEnum(enum = colors) }}
+
+colors:
+  red: 'FF0000'
+  green: '00FF00'
+  blue: '0000FF'
+  yellow: 'FFFF00'
+

matchDiffLines

Checks diff for matching lines.

Argument Usage Type Description
- Input [Object] The list of objects
regex Input String Regex term to match with the input items, use \\ for \
ignoreWhiteSpaces Input Bool false by default, match a named attribute in the input object
caseSensitive Input Bool true by default, ignore case when matching terms
- Output [Bool] true for every matching object

For example, to check if all the changes are of adding prints and ignore white spaces:

{{ source.diff.files | matchDiffLines(regex=r/^\+.*console\.log/, ignoreWhiteSpaces=true) | every }}
+

rankByGitActivity

Get list of contributors based on git-commit activity.

The repo context includes all the changed files, for each file it includes each contributor number of lines changed every week over the last 52 weeks, based on git-commit.

These functions compare each contributor changes per week and yield an average percentage of contribution for any given file. For example, in a certain week a file had 500 line changed, 200 by a first user, while 3 other users changed 100 lines each. So the score for the first user in that week will be 40 (200/500 in %). The function then average the score for each user for the selected time period.

Then you can use the thresholds to get the right reviewer.

Argument Usage Type Description
- Input repo The repo context variable
weeks Input Integer The number of last weeks to include
lt Input Integer Filter the user list, keeping those below the specified threshold
gt Input Integer Filter the user list, keeping those above the specified threshold
- Output [String] The list of users based on their code score comparison

Check if the branch author is a rookie

active_coders: {{ repo | rankByGitActivity(gt=50, weeks=12) }}
+

rankByGitBlame

Get list of contributors based on git-blame results

The repo context includes all the changed files, for each file it includes the contributors' percentage of lines in the file, based on git-blame.

This function sums all these percentages per user and yield an average percentage of contribution. Then you can use the thresholds to get the right reviewer.

The output lists the Git provider users, e.g., GitHub users, which are mapped from the Git users included in the git-blame output. When gitStream cannot map the Git user to a Git provider user it will be dropped from the output list, hence the list may contain less than 100% of the lines.

Argument Usage Type Description
- Input repo The repo context variable
lt Input Integer Filter the user list, keeping those below the specified threshold
gt Input Integer Filter the user list, keeping those above the specified threshold
- Output [String] The list of users based on their code score comparison, sorted by rank - first has highest score

Example of the filter output, note the output are GitHub users in the example:

[
+  "PopeyeUser",
+  "olive_user",
+  "BRUTUS_USER"
+]
+

Get the most significant contributors for the PR files:

contributors: {{ repo | rankByGitBlame(gt=30) }}
+

Check if the branch author is a rookie

is_rookie: {{ repo | rankByGitBlame(lt=15) | match(term=branch.author) | some }}
+
\ No newline at end of file diff --git a/gitStream-playground/index.html b/gitStream-playground/index.html new file mode 100644 index 00000000..6d32e565 --- /dev/null +++ b/gitStream-playground/index.html @@ -0,0 +1 @@ + Playground - gitStream Documentation

Playground

Welcome to gitStream Playground! This platform allows you to thoroughly test gitStream automations before deploying them into the .cm rule file on any GitHub pull request of your choice.

Playground

Getting Started

Accessing gitStream Playground

To access gitStream Playground, visit https://app.gitstream.cm/playground. To be able to test automations of private repository PRs, log in with your GitHub account credentials.

Interface Overview

The gitStream Playground interface consists of the following sections: gitStream Playground

  1. Login \ User icon: supports the following actions
    • Login
    • Logout
    • View user
    • Change organization
  2. Pull Request Link: An input textbox for a link to the pull request
  3. cm editor: Code input box where you can write automations to be executed by the playground. estimated_time_to_review and safe_changes are provided by default.
  4. Output section, with the following tabs:
    • Output - shows syntax errors when the .cm automation syntax is wrong. After running gitStream - it shows the expected result of the automation on the chosen Pull Request.
    • Context Variables - Shows the values of all Context variables of the chosen Pull Request.

Testing Automations

Selecting a Pull Request

On GitHub, navigate to any pull request, copy its link, and paste it onto the "Pull request link" box. If the PR is part of a private repo, you must also log in to the playground with a GitHub user accessible to this repository.

Running gitStream

  1. Add the desired automations to the editor. Make sure there are no syntax errors
  2. Click "Run gitStream."
  3. The rule engine loads the PR and runs the automations defined in the .cm editor.

Viewing Results

The automation results will be shown in the "Output" tab at the bottom of the interface. Context Variables will be shown in the "Context Variables" tab.

Feedback and Support

For additional assistance or to provide feedback, please open an issue on our GitHub issues page

\ No newline at end of file diff --git a/github-installation/index.html b/github-installation/index.html new file mode 100644 index 00000000..8a49803f --- /dev/null +++ b/github-installation/index.html @@ -0,0 +1,235 @@ + How to Setup gitStream with GitHub - gitStream Documentation

How to Setup gitStream with GitHub

Install gitStream

Before you can complete the gitStream setup process, you need to install the gitStream app to your GitHub organization.

Setup

You can set up gitStream for a single repo or your entire GitHub organization. Select the tab below for the instructions you want.

Single Repo Setup

You must implement two main components for gitStream to function for a single GitHub repo. The first is a configuration file that defines the workflow automations to execute for the repo. The second is a GitHub actions configuration file that triggers gitStream when PRs are created or updated.

Required Configurations

gitStream

Create a .cm/gitstream.cm rules file in your repository's default branch (usually master or main). This file will contain a YAML configuration that determines the workflows that run on the repo, and you can name it anything you want as long as it ends in .cm

Here is an example of a gitStream configuration file you can use to setup some basic workflow automations.

# -*- mode: yaml -*-
+# This example configuration for provides basic automations to get started with gitStream.
+# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/
+manifest:
+  version: 1.0
+
+
+automations:
+  # Add a label that indicates how many minutes it will take to review the PR.
+  estimated_time_to_review:
+    if:
+      - true
+    run:
+      - action: add-label@v1
+        args:
+          label: "{{ calc.etr }} min review"
+          color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}
+  # Inform PR authors when they fail to reference Jira tickets in the PR title or description.
+  label_missing_jira_info:
+    if:
+      - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "missing-jira"
+          color: {{ colors.red }}
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR is missing a Jira ticket reference in the title or description.
+            Please add a Jira ticket reference to the title or description of this PR.
+  # Post a comment that lists the best experts for the files that were modified.
+  explain_code_experts:
+    if:
+      - true
+    run:
+      - action: explain-code-experts@v1 
+        args:
+          gt: 10 
+
+
+# +----------------------------------------------------------------------------+
+# | Custom Expressions                                                         |
+# | https://docs.gitstream.cm/how-it-works/#custom-expressions                 |
+# +----------------------------------------------------------------------------+
+
+calc:
+  etr: {{ branch | estimatedReviewTime }}
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }}
+
+colors:
+  red: 'b60205'
+  yellow: 'fbca04'
+  green: '0e8a16'
+

Github Actions

Once your gitStream configuration file is setup, you need a Github Actions configuration file to trigger gitStream automations. Create a .github/workflows/gitstream.yml file in your repository's default branch (usually master or main) and add the following configuration:

# Code generated by gitStream GitHub app - DO NOT EDIT
+
+name: gitStream workflow automation
+run-name: |
+  /:\ gitStream: PR #${{ fromJSON(fromJSON(github.event.inputs.client_payload)).pullRequestNumber }} from ${{ github.event.inputs.full_repository }}
+
+on:
+  workflow_dispatch:
+    inputs:
+      client_payload:
+        description: The Client payload
+        required: true
+      full_repository:
+        description: the repository name include the owner in `owner/repo_name` format
+        required: true
+      head_ref:
+        description: the head sha
+        required: true
+      base_ref:
+        description: the base ref 
+        required: true
+      installation_id:
+        description: the installation id
+        required: false
+      resolver_url:
+        description: the resolver url to pass results to
+        required: true
+      resolver_token:
+        description: Optional resolver token for resolver service
+        required: false
+        default: ''
+
+jobs:
+  gitStream:
+    timeout-minutes: 5
+    runs-on: ubuntu-latest
+    name: gitStream workflow automation
+    steps:
+      - name: Evaluate Rules
+        uses: linear-b/gitstream-github-action@v2
+        id: rules-engine
+        with:
+          full_repository: ${{ github.event.inputs.full_repository }}
+          head_ref: ${{ github.event.inputs.head_ref }}
+          base_ref: ${{ github.event.inputs.base_ref }}
+          client_payload: ${{ github.event.inputs.client_payload }}
+          installation_id: ${{ github.event.inputs.installation_id }}
+          resolver_url: ${{ github.event.inputs.resolver_url }}
+          resolver_token: ${{ github.event.inputs.resolver_token }}
+

Success

When finished, you should have the following file structure in your repo.

.
+├─ .cm/
+│  └─ gitstream.cm
+├─ .github/
+│  └─ workflows/
+│     └─ gitstream.yml
+

GitHub Organization Setup

Organization rules are ideal when you want to enforce consistent rules across every repo in your organization. You can define them by creating a special repository named cm in your GitHub organization where you can add automation files that will apply to all repositories within that organization.

Prerequisite: Create a cm repo and enable gitStream.

Organization-wide automations need to be defined in a repo named "cm" inside your GitHub organization. Before continuing, you must create this repo and enable the gitStream app for it.

Required Configurations

gitStream

Create a gitstream.cm rules file in the root directory of your cm repository's default branch (usually master or main). This file will contain a YAML configuration that determines the workflows that run on your organization's repos. You can name it anything you want as long as it ends in .cm

Configuration files go in the repo's root directory.

Unlike the set up instructions for a single repo, your .cm files should be placed in the repository's root directory.

# -*- mode: yaml -*-
+# This example configuration for provides basic automations to get started with gitStream.
+# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/
+manifest:
+  version: 1.0
+
+
+automations:
+  # Add a label that indicates how many minutes it will take to review the PR.
+  estimated_time_to_review:
+    if:
+      - true
+    run:
+      - action: add-label@v1
+        args:
+          label: "{{ calc.etr }} min review"
+          color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}
+  # Inform PR authors when they fail to reference Jira tickets in the PR title or description.
+  label_missing_jira_info:
+    if:
+      - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "missing-jira"
+          color: {{ colors.red }}
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR is missing a Jira ticket reference in the title or description.
+            Please add a Jira ticket reference to the title or description of this PR.
+  # Post a comment that lists the best experts for the files that were modified.
+  explain_code_experts:
+    if:
+      - true
+    run:
+      - action: explain-code-experts@v1 
+        args:
+          gt: 10 
+
+
+# +----------------------------------------------------------------------------+
+# | Custom Expressions                                                         |
+# | https://docs.gitstream.cm/how-it-works/#custom-expressions                 |
+# +----------------------------------------------------------------------------+
+
+calc:
+  etr: {{ branch | estimatedReviewTime }}
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }}
+
+colors:
+  red: 'b60205'
+  yellow: 'fbca04'
+  green: '0e8a16'
+
GitHub Actions

Once your gitStream configuration file is set up, you will need to create a Github Actions configuration file to trigger gitStream automations. Create a .github/workflows/gitstream.yml file in your cm repository's default branch (usually master or main) and add the following configuration:

# Code generated by gitStream GitHub app - DO NOT EDIT
+
+name: gitStream workflow automation
+run-name: |
+  /:\ gitStream: PR #${{ fromJSON(fromJSON(github.event.inputs.client_payload)).pullRequestNumber }} from ${{ github.event.inputs.full_repository }}
+
+on:
+  workflow_dispatch:
+    inputs:
+      client_payload:
+        description: The Client payload
+        required: true
+      full_repository:
+        description: the repository name include the owner in `owner/repo_name` format
+        required: true
+      head_ref:
+        description: the head sha
+        required: true
+      base_ref:
+        description: the base ref 
+        required: true
+      installation_id:
+        description: the installation id
+        required: false
+      resolver_url:
+        description: the resolver url to pass results to
+        required: true
+      resolver_token:
+        description: Optional resolver token for resolver service
+        required: false
+        default: ''
+
+jobs:
+  gitStream:
+    timeout-minutes: 5
+    runs-on: ubuntu-latest
+    name: gitStream workflow automation
+    steps:
+      - name: Evaluate Rules
+        uses: linear-b/gitstream-github-action@v2
+        id: rules-engine
+        with:
+          full_repository: ${{ github.event.inputs.full_repository }}
+          head_ref: ${{ github.event.inputs.head_ref }}
+          base_ref: ${{ github.event.inputs.base_ref }}
+          client_payload: ${{ github.event.inputs.client_payload }}
+          installation_id: ${{ github.event.inputs.installation_id }}
+          resolver_url: ${{ github.event.inputs.resolver_url }}
+          resolver_token: ${{ github.event.inputs.resolver_token }}
+

Success

Once finished, all PRs to your organization's repositories will be processed by the GitHub Action in this repo, and your cm repo should have a file directory that looks like this.

.
+├─ gitstream.cm
+├─ .github/
+│  └─ workflows/
+│     └─ gitstream.yml
+

gitStream will now do these two things.

When a PR is created or changed, apply or update a label that provides an estimated time to review.
+![Estimated Review Time label](screenshots/etr_label_example.png)
+![Estimated review time](screenshots/slack-estimated-review-time-example-1-min.png)
+
+When a new PR is created, comment with a list of code experts.
+![Suggested reviewers](screenshots/github-codeexperts-expanded.png)
+

Next Step

How gitStream Works

Read our guide: [How gitStream Works](/how-it-works/) to get an overview of the gitStream syntax and automation lifecycle.
+

Additional Resources

Required GitHub Permissions

Permissions Reason
Write access to dedicated gitStream app files Used to set up the gitStream workflow files
Write access to code To allow gitStream to approve PRs once all conditions are met
Read access to administration, issues, and metadata To get the user team membership, and branch protection settings
Read and write access to actions, checks, pull requests, and workflows Trigger workflows, create and update pull requests and their checks, and modify workflow files
User email Used to identify users

Configure gitStream to Block Merges

You can configure Github to require gitStream checks to pass before PRs can be merged using branch protection rules.

Run a gitStream check before continuing

You need to run a check using your gitStream configuration at least once before it can be set as a required check. Make sure to open at least 1 PR before doing this setting.

Here are the steps to configure gitStream in your repo's branch protection rules.

  1. Go to repo settings
  2. On the left panel select Code and automation > Branches
  3. Set Branch protection rules for your desired branch
  4. Enable Require status checks to pass before merging
  5. Search for status checks in the last week for this repository
  6. Select gitStream.cm as required check

Branch protection rules

Required checks

Configuring gitStream with Self-Hosted Runners

Follow these steps to ensure gitStream runs on self-hosted GitHub Actions runners:

  1. Configure Self-Hosted Runners

  2. Prerequisites for Self-Hosted Runners

    • Git: Installation instructions can be found here.
    • Python 3.x
      • black 24.4.2
  3. Update GitHub Actions Configuration

    • Modify the gitStream GitHub Actions workflow file (.github/workflows/gitstream.yml) to specify self-hosted runners:
    jobs:
    +  gitStream:
    +    runs-on: self-hosted
    +    # ... other configuration ...
    +
  4. Save and Commit

    • Save changes to the workflow file and commit them to your repository.
  5. Test with a Sample PR

    • Create a sample pull request to verify gitStream's behavior with self-hosted runners.

Uninstalling gitStream

Configure in your GitHub organization, and choose Uninstall "gitStream.cm"

\ No newline at end of file diff --git a/github-org-level/index.html b/github-org-level/index.html new file mode 100644 index 00000000..86931172 --- /dev/null +++ b/github-org-level/index.html @@ -0,0 +1,15 @@ + + + + + + Redirecting... + + + + + + +Redirecting... + + diff --git a/github-required-check/index.html b/github-required-check/index.html new file mode 100644 index 00000000..86931172 --- /dev/null +++ b/github-required-check/index.html @@ -0,0 +1,15 @@ + + + + + + Redirecting... + + + + + + +Redirecting... + + diff --git a/gitlab-installation/index.html b/gitlab-installation/index.html new file mode 100644 index 00000000..428ca0f9 --- /dev/null +++ b/gitlab-installation/index.html @@ -0,0 +1,157 @@ + How to Setup gitStream with GitLab - gitStream Documentation

How to Setup gitStream with GitLab

Prerequisites

  1. GitLab cloud
  2. GitLab runner v15 or higher
  3. Login, or create a free account on the LinearB app, and follow the steps to connect gitStream Using a GitLab Integration.

GitLab Installation Overview

  1. Designate a gitStream user account.
  2. Create a CM configuration file.
  3. Create a GitLab pipeline.
  4. Install the gitStream service.

Designate a gitStream User Account

gitStream automation rules are executed on behalf of the user account configured when you install the gitStream service. This account must have the maintainer or owner role to the relevant repos.

We recommend creating a dedicated service account to control access to individual repos easily. You can also use your professional or personal GitLab account for this, which would result in all automations being executed under that account, which might also affect LinearB's metrics.

Use this account when you integrate gitStream

Make sure to use this account when authorizing GitLab in LinearB.

Create a cm repo and a CM Configuration File

Group rules are ideal when you want to enforce consistent rules across every repo in your GitLab group. You can define them by creating a special repository named cm in the parent group for the git repositories on which you want to run gitStream. Here, you can add automation files that apply to all repositories within that group that are connected to gitStream.

Create a cm project (repository) in your GitLab group, and create a gitstream.cm rules file in the root directory of your cm repository's default branch (usually master or main). This file will contain a YAML configuration that determines the workflows that run on your organization's repos. You can name the CM file anything you want as long as it ends in .cm

Configuration files go in the repo's root directory.

Group-level rules require your .cm files to be placed in the repository's root directory. You can also define specific repo-level rules under the .cm folder in each of the connected repositories

Example Configuration

Here is an example of a gitStream configuration file to set up some basic workflow automations.
+```yaml+jinja
+# -*- mode: yaml -*-
+# This example configuration for provides basic automations to get started with gitStream.
+# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/
+manifest:
+  version: 1.0
+
+
+automations:
+  # Add a label that indicates how many minutes it will take to review the PR.
+  estimated_time_to_review:
+    if:
+      - true
+    run:
+      - action: add-label@v1
+        args:
+          label: "{{ calc.etr }} min review"
+          color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}
+  # Inform PR authors when they fail to reference Jira tickets in the PR title or description.
+  label_missing_jira_info:
+    if:
+      - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "missing-jira"
+          color: {{ colors.red }}
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR is missing a Jira ticket reference in the title or description.
+            Please add a Jira ticket reference to the title or description of this PR.
+  # Post a comment that lists the best experts for the files that were modified.
+  explain_code_experts:
+    if:
+      - true
+    run:
+      - action: explain-code-experts@v1 
+        args:
+          gt: 10 
+
+
+# +----------------------------------------------------------------------------+
+# | Custom Expressions                                                         |
+# | https://docs.gitstream.cm/how-it-works/#custom-expressions                 |
+# +----------------------------------------------------------------------------+
+
+calc:
+  etr: {{ branch | estimatedReviewTime }}
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }}
+
+colors:
+  red: 'b60205'
+  yellow: 'fbca04'
+  green: '0e8a16'
+```
+

Create a GitLab Pipeline

Once your gitStream configuration file is set up, you need a GitLab CI configuration file to trigger gitStream automations. Create a cm project (repository) in your GitLab group if you haven't already. It should be created in the same group or a parent group of the target repositories. Create a .gitlab-ci.yml file in your new cm repository's default branch (usually master or main) and add the following configuration:

Gitlab-Hosted Runners

Use the following .gitlab-ci.yml

# Code generated by gitStream - DO NOT EDIT
+gitstream-job:
+  stage: gitstream-main
+  image: gitstream/rules-engine:latest
+  only:
+    variables:
+      - $GITSTREAM_MAIN_JOB
+  except:
+    variables:
+      - $GITSTREAM_BLOCK_MERGE
+  script:
+    - apk update && apk add git
+    - mkdir /code
+    - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${repoUrl} /code/repo
+    - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${cmUrl} /code/cm
+    - cd /code && cd repo && git fetch --all && git checkout $base_ref && git pull && ls && git checkout $head_ref && git pull && ls
+    - |
+      HEAD_REF=$head_ref BASE_REF=$base_ref CLIENT_PAYLOAD="$client_payload" RULES_RESOLVER_URL=$resolver_url \
+      RULES_RESOLVER_TOKEN=$resolver_token  DEBUG_MODE=true npm run start
+

Self-Managed Runners

First, register the runner with a tag, and use the named tag in the .gitlab-ci.yml file

Shell executors

Use the tag created above in the workflow file cm/.gitlab-ci.yml instead REGISTERED-TAG

# Code generated by gitStream - DO NOT EDIT
+stages:
+  - gitstream-main
+image: docker:latest
+services:
+  - docker:dind
+before_script:
+  - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
+
+gitstream-job:
+  stage: gitstream-main
+  tags:
+    - REGISTERED-TAG
+  only:
+    variables:
+      - $GITSTREAM_MAIN_JOB
+  except:
+    variables:
+      - $GITSTREAM_BLOCK_MERGE
+  script:
+    - apk update && apk add git && apk add docker
+    - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${repoUrl} gitstream/repo
+    - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${cmUrl} gitstream/cm
+    - cd gitstream && cd repo && git fetch --all && git checkout $base_ref && git pull && ls && git checkout $head_ref && git pull && ls
+    - docker pull gitstream/rules-engine:latest
+    - |
+      docker run -v $CI_PROJECT_DIR/gitstream:/code \
+      -e HEAD_REF=$head_ref \
+      -e BASE_REF=$base_ref \
+      -e CLIENT_PAYLOAD="$client_payload" \
+      -e RULES_RESOLVER_URL=$resolver_url \
+      -e RULES_RESOLVER_TOKEN=$resolver_token \
+      -e DEBUG_MODE=true  gitstream/rules-engine:latest
+

Self-Managed Runners

First, register the runner with a tag, and use the named tag in the .gitlab-ci.yml file

Kubernetes executors

  1. Ensure your runner configuration (config.toml for example) has the followig:
    [runners.kubernetes]
    +privileged = true
    +
  2. Use the tag created above in the workflow file cm/.gitlab-ci.yml instead REGISTERED-TAG
    # Code generated by gitStream - DO NOT EDIT
    +variables:
    +  DOCKER_DRIVER: overlay2
    +  DOCKER_HOST: tcp://docker:2375
    +  DOCKER_TLS_CERTDIR: ""
    +stages:
    +  - gitstream-main
    +
    +image: docker:latest
    +services:
    +  - name: docker:dind
    +    command: ["--mtu=1450", "--tls=false"]
    +before_script:
    +  - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    +
    +gitstream-job:
    +  stage: gitstream-main
    +  tags:
    +    - REGISTERED-TAG
    +  only:
    +    variables:
    +      - $GITSTREAM_MAIN_JOB
    +  except:
    +    variables:
    +      - $GITSTREAM_BLOCK_MERGE
    +  script:
    +    - apk update && apk add git && apk add docker
    +    - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${repoUrl} gitstream/repo
    +    - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${cmUrl} gitstream/cm
    +    - cd gitstream && cd repo && git fetch --all && git checkout $base_ref && git pull && ls && git checkout $head_ref && git pull && ls
    +    - docker pull gitstream/rules-engine:latest
    +    - |
    +      docker run -v $CI_PROJECT_DIR/gitstream:/code \
    +      -e HEAD_REF=$head_ref \
    +      -e BASE_REF=$base_ref \
    +      -e CLIENT_PAYLOAD="$client_payload" \
    +      -e RULES_RESOLVER_URL=$resolver_url \
    +      -e RULES_RESOLVER_TOKEN=$resolver_token \
    +      -e DEBUG_MODE=true  gitstream/rules-engine:latest
    +

Configuring the image location

By default, gitStream pulls the image from DockerHub each time it is invoked. You can configure gitStream to pull the docker image from your own registry, to allow faster build times and reduced bandwidth usage - especially for teams with high CI/CD throughput, by downloading the image and storing it in your own registry (ECR or K8S registry, for example) and changing the cm/.gitlab-ci.yml accordingly:

script:
+- ...
+- docker pull YOUR-REGISTRY-URL/gitstream/rules-engine:latest
+
The docker image can be pulled to your private repository from DockerHub.

Next Step

If you successfully complete these instructions, gitStream will now do these two things.

When a PR is created or changed, apply or update a label that provides an estimated time to review. Estimated Review Time label

When a suggest-reviewers label is applied to a PR, gitStream will comment with a list of code experts. Suggested reviewers

How gitStream Works

Read our guide, How gitStream Works, for a deeper understanding of gitStream's capabilities and how to leverage them fully and to get an overview of the gitStream syntax and automation lifecycle.

Additional Resources

Required GitLab Permissions

The required permissions are:

Permissions Reason
Read/Write API To get notified on MR changes and allow gitStream to approve MRs once all conditions are met
Read repository To read and check rules over the code changes on monitored repositories
Read user profile Used to identify users
\ No newline at end of file diff --git a/how-it-works/index.html b/how-it-works/index.html new file mode 100644 index 00000000..a41b0a28 --- /dev/null +++ b/how-it-works/index.html @@ -0,0 +1,58 @@ + How gitStream Works - gitStream Documentation

How gitStream Works

You can configure gitStream via one or more Continuous Merge (CM) files inside your git repository or GitHub/GitLab organization. These files end with a .cm extension, and they outline automations that will run for your repo's pull requests.

Syntax Overview

CM files contain a combination of YAML and Jinja2 to build rules that follow an "if this, then that" approach to triggering and executing automations. This, combined with templating and gitStream-specific functions gives you a highly-flexible framework for building custom CM automations.

All CM files must have a section that starts with automations: that contains one or more custom automations that will trigger for the repo. By default, gitStream is triggered every time someone opens a new PR or pushes a commit to an existing PR. Once activated, gitStream searches for applicable CM files and executes the automations that are listed inside them.

Explicit Triggers

You can configure gitStream to trigger for other PR interactions, including comments, labels, and merge status. Read more about the gitStream execution model.

Here is an example of the basic components that are required in every CM file.

Required CM Components

Please note, this is not a valid CM automation, it is only for illustrative purposes.

    # -*- mode: yaml -*-
+    manifest:
+      version: 1.0
+    automations:
+      my_automation:
+        if:
+          - # Add a condition here
+        run:
+          - # Add an automation here
+

Info

When editing CM files, make sure you preserve the indentation in the examples because, like YAML, gitStream uses Python-style indentation to indicate nesting.

Automation Actions

Automation actions define the desired automations triggered when specific conditions are met. Each automation must contain an if condition and a run section. Conditions are evaluated when a PR is created or modified. Multiple conditions can be listed, but all must be true to trigger the actions.

Any number of actions can be included in a single automation, and these actions are invoked one-by-one in no particular order. PRs marked as Draft are ignored by default, and this behavior can be modified using explicit triggers (GitHub only).

Basic Automation Example

This example defines an automation named welcome_newcomer that post a comment to welcome anyone who submits their first PR to the repo.

automations:
+  welcome_newcomer:
+    if: 
+      - {{ repo.contributors | isFirstCommit(branch.author) }}
+    run: 
+      - action: add-comment@v1
+        args:
+          comment: Welcome {{branch.author}}!
+

Context Variables and Filter Functions

Context variables are pre-defined objects that gitStream provides as the input data you will need to build your automations. These variables enable you to access information about things like the file names and paths, the person who submitted the PR, or what code was changed.

Filter functions are functions you can call and apply to variables. They are called with a pipe operator | and can take arguments inside parentheses ( ). The logic expressions are based on Jinja2 syntax, supported by the Nunjucks library.

Context Variable and Filter Function Example

The following statement passes the context variable files to the filter function match which uses an optional list of sensitive filepaths that would need to be defined later in the CM file, and returns true if any of the files match the list as indicated by the some filter function.

{{ files | match(list=sensitive) | some }}
+

You can also apply Nunjucks logic operators to filters

Logic Operators Example

This example inverts the previous example using the keyword not.

{{ not (files | match(list=sensitive) | some )}}
+

Custom Expressions

Jinja templating makes it easy to write custom expressions that can be invoked elsewhere in your CM files. This makes it easy to reuse data, define custom criteria, and keep your configuration files cleaner so they're easier to manage.

Custom Expressions Example

This example contains two custom expressions; is: contains a context variable and some filter functions that are invoked in the sensitive_review automation via is.sensitive, and sensitive directories contains a list of directory paths that will be matched in the filter function.

automations:
+  sensitive_review:
+    if:
+      - is.sensitive
+    run:
+      - action: set-required-approvals@v1
+        args:
+          approvals: 2
+
+is:
+  sensitive: {{ files | match(list=sensitive_directories) | some }}
+
+sensitive_directories:
+  - src/app/auth/
+  - src/app/routing/
+  - src/app/resources/
+

Built-in Functions

gitStream is built on top of Jinja2 and provides all default filters from that library. gitStream also includes extra filters on top of Jinja2 that are specific to git repo workflow automations.

Warning

Don't use these terms when naming automations, plugins, custom expressions, or any other component of gitStream because this will lead to naming conflicts

gitStream filters:

allDocs allImages allTests automations codeExperts config difference estimatedReviewTime explainCodeExperts explainRankByGitBlame extractJitFindings extractSonarFindings extensions every filter includes isFirstCommit isFormattingChange intersection manifest map mapToEnum match matchDiffLines nope rankByGitActivity rankByGitBlame reject some

Nunjucks filters:

abs asyncAll asyncEach batch block call capitalize center default dictsort dump e escape extends filter first float for forceescape groupby if import include indent int join last length list lower macro nl2br raw reject rejectattr replace reverse round safe select selectattr set slice sort string striptags sum title trim truncate upper urlencode urlize verbatim wordcount

Ignore Files

You can provide gitStream with a list of specific files to ignore for all automations listed in the same CM file. To do so, add a configuration: section to the CM file that you want to apply the exclusion list to. In the configuration section, add a list of files as an argument to the ignore_files: key.

How to Ignore Files

To ignore a list of files, add a config.ignore_files to you CM file like this:

config:
+  ignore_files:
+    - 'yarn.lock'
+    - 'package-lock.json'
+    - 'openapi.json'
+    - 'ui/src/**/*Model.d.ts'
+

Configuration Priority and Overrides

You can provide any number of CM files and automations for gitStream to process and you can freely combine organization-level automations with automations inside individual repos. There are two important things you need to keep in mind when doing this.

First, when a repository defines the same automation as an organization-level rule, the repository automation will take precedence and override the organization automation. The CM file name and the automation name must both match for this to take effect because gitStream identifies all automations based on a combination of both. For example, if you have a gitstream.cm file that contains an automation named my_automation, gitStream will identify that as gitstream/my_automation.

Second, no priority is given to individual automations. Instead, gitStream collects all applicable automations for a given PR and processes them all at once.

Plugins

gitStream supports the use of JavaScript plugins to create new filter functions. This enables you to write code that further extends gitStream capabilities and connect gitStream to external API services. Read the guide on writing gitStream

Next Step

Write your first automation.

The best way to familiarize yourself with CM syntax is to build automations, and we've covered enough info for you to start!

If you're ready to start writing automations, check out our guide: Write Your First Automation.

Additional Resources

gitStream UI

Once you have gitStream installed and have run some automations, you can view details about them at app.linearb.io/automations. To view gitStream automation data, you will need to login with your LinearB user account.

gitStream UI

Functional Overview

Once gitStream is installed and configured, there are several services that will interact with your repository whenever a PR is created or changed:

  • The git service provider API (e.g. GitHub, Gitlab)
  • The gitStream service that was installed from the git service provider marketplace.
  • A gitStream CI/CD script that is configured for the git service provider (e.g. GitHub Actions, GitLab CI/CD).
  • A gitStream agent the CI/CD script triggers to execute your automation.

Whenever a new PR is opened or an existing PR is changed (see also Execution Model), the following process occurs:

  1. The git service provider API notifies the gitStream service that an applicable change has occured to the PR which triggers a call to execute the gitStream CI/CD script.
  2. The gitStream CI/CD script executes the GitHub Action linear-b/gitstream-github-action@v2 on the repository, which looks for two things:
    • Valid CM files that match the filepath .cm/*.cm
    • Any CM files that are contained in the root directory of the organization's cm repo (if applicable).
  3. The gitStream CI/CD script passes all CM metadata to the gitStream agent which parses a list of all applicable CM rules.
  4. The GitStream agent provides the list of applicable automations to the gitStream service.
  5. The gitStream service iterates through the automations and updates the PR via the git service provider API.

Here is a diagram that illustrates how things work behind the scenes:

sequenceDiagram
+  autonumber
+  Git Provider API->>gitStream app: PR Notification
+  activate gitStream app
+  gitStream app->>gitStream CI/CD script: Execute CI/CD Action
+  activate gitStream CI/CD script
+  gitStream CI/CD script->>gitStream agent: CM Metadata
+  activate gitStream agent
+  gitStream agent->>gitStream app: Applicable Automations 
+  deactivate gitStream agent
+  deactivate gitStream CI/CD script
+  loop Automations
+    loop Actions
+      gitStream app->>Git Provider API: Update PR
+    end
+   end
+  deactivate gitStream app
Upon completion, gitStream will show one of the following three statuses:

  • Success Success - when the applicable automation finished and PR is good to go
  • Neutral Neutral - when there aren't any applicable automations for the PR
  • Failed Failed - when the applicable automation finished without completion

gitStream checks have a 10-minute timeout for fail-safe reasons. If the check exceeds this time limit, the result will be displayed as Neutral - Skipped.

Syntax highlighting

You can add support for .cm in your code editor, see FAQ.

Is something missing?

If you find an issue with these docs or with gitStream itself, please search the gitStream issues page and create an issue if one doesn't already exist for your problem.

\ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 00000000..5885271b --- /dev/null +++ b/index.html @@ -0,0 +1 @@ + gitStream Documentation - gitStream Documentation

/:\ gitStream

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Features

Approve safe changes

Auto-Merge PRs

Not all PRs need extensive review policies that loop in multiple experts. gitStream lets you auto-merge safe changes, small fixes, PRs from trusted teams, and anything else you want to unblock the review process to keep your team focused on their work.

Estimated time to review

Contextual Labels

Reduce the mental burden of code reviews with labels that provide a high degree of context. Indicate an estimated time to review or flag potential issues with Jira information, missing tests, deleted files, and more.

Assign Code Experts

Review Assignment

Identifying the correct people to review a PR can take time, particularly for complex projects and repos requiring deep expertise. Assign code experts to review complex PRs, notify your security team about sensitive changes, and automatically assign reviewers based on the contents of the PR.

Change Deprecated Components

Automated Change Requests

Reduce code review noise by catching issues before anyone invests precious time. Flag deprecated components, missing data objects, off-limits code, and other problems that need to be addressed before assigning code reviewers.

Build Your First Automation in 2 Minutes

  1. Install gitStream for free in GitHub
  2. Configure your repository using the instructions for GitHub. This will guide you through setting up your first automations.

That's it! Now sit back and watch gitStream run automation rules on your next PR.

Tip: Install gitStream for your entire organization

gitStream can be installed for one repo, specific repos, or all repos in your organization. We recommend installing for all because it will ensure all new repos are able to use gitStream. You can change this setting at any time in the future.

  1. Login, or create a free account on the LinearB app.
  2. Connect gitStream to your GitLab repos by following the steps described here.

That's it! Now sit back and watch gitStream run automation rules on your next PR.

Coming soon

Get Involved

Want to report a bug, request a new feature, ask a question, get updates for new features, or propose a new configuration for the automation library? Join us on GitHub.

\ No newline at end of file diff --git a/integrations/asana/index.html b/integrations/asana/index.html new file mode 100644 index 00000000..fe251752 --- /dev/null +++ b/integrations/asana/index.html @@ -0,0 +1,64 @@ + Integrate gitStream with Asana - gitStream Documentation

Integrate gitStream with Asana

Learn how to integrate gitStream with Asana

Label Missing Asana Info

Automatically label PRs that are missing references to Asana resources.

Label Missing Asana

Configuration Description

Conditions (all must be true):

  • The PR is missing an Asana ticket reference in the PR title and a link to an Asana resource in the PR description.

Automation Actions:

  • Apply a red ⚠️ Missing Asana Link label
  • Post a comment that asks the author to add an Asana reference to the PR.

Label Missing Asana

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_missing_asana:
+    if:
+      - {{not (has.asana.ticket_in_title or has.asana.ticket_in_desc)}}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Asana Link"
+          color: {{ colors.red }}
+      - action: add-comment@v1
+        args:
+          comment: Please provide a link to the associated Asana resource.
+
+has:
+  asana:
+    ticket_in_title: {{ pr.title | includes(regex=r/asana-(\d+)/) }}
+    ticket_in_desc: {{ pr.description | includes(regex=r/app\.asana.\com\/(\d+)\/(\d+)\/(\d+)\/(\d+)\/(\d+)/) }}
+
+colors:
+  red: 'b60205'
+

Provide automatic links to Asana cards that are associated with PRs.

Automatically Link to the Related Asana Card

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Asana card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Asana Card.

Automatically Link to the Related Asana Card

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+provider: asana
+
+# Configure this to match your organization. It is used in tracker.asana.baseurl.
+asanaProject: 1234
+
+{% set ticketid = "" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  link_asana:
+    if:
+      - {{ has.ticket_in_title or has.ticket_in_branch }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})
+
+has:
+  ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}
+  ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}
+
+tracker:
+  asana:
+    baseurl: https://app.asana.com/0/[asanaProject]/0/
+    pattern: r/asana-(\d+)/
+
+tickets:
+  - {{branch.name | capture(regex=tracker[provider].pattern)}}
+  - {{pr.title | capture(regex=tracker[provider].pattern)}}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/azure-boards/index.html b/integrations/azure-boards/index.html new file mode 100644 index 00000000..85c6f4b0 --- /dev/null +++ b/integrations/azure-boards/index.html @@ -0,0 +1,66 @@ + Integrate gitStream with Azure Boards - gitStream Documentation

Integrate gitStream with Azure Boards

Learn how to integrate gitStream with Azure Boards.

Label Missing Azure Boards Info

Automatically label PRs that are missing references to Azure Boards resources.

Label Missing Azure Boards

Configuration Description

Conditions (all must be true):

  • The PR is missing one of the following:
    • An Azure Boards ticket reference in the PR title.
    • A link to an Azure Boards resource in the PR description.

Automation Actions:

  • Apply a red ⚠️ Missing Azure Boards Link label
  • Post a comment that asks the author to add an Azure Boards reference to the PR.

Label Missing Azure Boards

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_missing_azure:
+    if:
+      - {{not (has.azure.ticket_in_title or has.azure.ticket_in_desc)}}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Azure Boards Link"
+          color: {{ colors.red }}
+      - action: add-comment@v1
+        args:
+          comment: Please provide a link to the associated resource in Azure Boards.
+
+has:
+  azure:
+    ticket_in_title: {{ pr.title | includes(regex=r/(\w+)-(\w+)-(\d+)/) }}
+    ticket_in_desc: {{ pr.description | includes(regex=r/(dev\.azure\.com|(\w+)\.visualstudio\.com)\/(\w+)\/(\w+)\/_workitems\/edit\/(\d+)/) }}
+
+colors:
+  red: 'b60205'
+

Provide automatic links to Azure Boards resources that are associated with PRs.

Automatically Link to the Related Azure Boards Resource

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Azure Boards resource in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Azure Boards Resource.

Automatically Link to the Related Azure Boards Resource

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+# Configure these to match your organization.
+provider: azure
+# The name of your Azure organization
+orgName: org
+# The name of your Azure project
+azureProject: my_project
+
+{% set ticketid = "" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  link_azure_boards:
+    if:
+      - {{ has.ticket_in_title or has.ticket_in_branch }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})
+
+has:
+  ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}
+  ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}
+
+tracker:
+  azure:
+    baseurl: https://dev.azure.com/[orgName]/[azureProject]/_workitems/
+    pattern: r/(\w+)-(\w+)-(\d+)/
+
+tickets:
+  - {{branch.name | capture(regex=tracker[provider].pattern)}}
+  - {{pr.title | capture(regex=tracker[provider].pattern)}}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/dependabot/index.html b/integrations/dependabot/index.html new file mode 100644 index 00000000..42f1dcd5 --- /dev/null +++ b/integrations/dependabot/index.html @@ -0,0 +1,49 @@ + Integrate gitStream with Dependabot - gitStream Documentation

Integrate gitStream with Dependabot

Approve and Merge Dependabot Changes

Auto-merge Dependabot PRs

Required gitStream Plugins

This example requires you to install the extractDependabotVersionBump and compareSemver plugins.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • The PR author is Dependabot.
  • The branch name includes 'dependabot'
  • The dependency change is a patch or minor update.

Automation Actions:

  • Approve the PR
  • Apply an approved-dependabot label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

manifest:
+  version: 1.0
+
+automations:
+  merge_dependabot_minor:
+    if:
+      - {{ bump == 'minor' }}
+      - {{ branch.name | includes(term="dependabot") }}
+      - {{ branch.author | includes(term="dependabot") }}
+    run:
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Dependabot `minor` version bumps are approved automatically.
+  merge_dependabot_minor_patch:
+    if:
+      - {{ bump == 'patch' }}
+      - {{ branch.name | includes(term="dependabot") }}
+      - {{ branch.author | includes(term="dependabot") }}
+    run:
+      - action: approve@v1
+      - action: merge@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Dependabot `patch` version bumps are approved and merged automatically.
+
+bump: {{ pr.description | extractDependabotVersionBump | compareSemver }}
+

Configuration Description

Conditions (all must be true):

  • The PR author is Dependabot.
  • The branch name includes 'dependabot'

Automation Actions:

  • Approve the PR
  • Apply an approved-dependabot label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_dependabot:
+    if:
+      - {{ branch.name | includes(term="dependabot") }}
+      - {{ branch.author | includes(term="dependabot") }}
+    run:
+      - action: approve@v1
+      - action: add-label@v1
+        args:
+          label: "approved-dependabot"
+      - action: merge@v1
+        args:
+          wait_for_all_checks: true
+          squash_on_merge: true
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/devcycle/index.html b/integrations/devcycle/index.html new file mode 100644 index 00000000..6138a206 --- /dev/null +++ b/integrations/devcycle/index.html @@ -0,0 +1,29 @@ + Integrate gitStream with DevCycle - gitStream Documentation

Integrate gitStream with DevCycle

Label DevCycle Feature Flags

Automatically label code that contians specified feature flags.

Label PRs Based on Feature Flags

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+
+  {% for item in feature_flags %}
+  label_ff_devcycle_{{ item.name }}:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/key = '/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ item.name }}
+          color: {{ colors.yellow }}
+  {% endfor %}
+
+feature_flags:
+   - name: engineering_rollback_plan_activated 
+     regex: r/engineering_rollback_plan_activated/
+   - name: marketing_premium_plan_features_unlocked 
+     regex: r/marketing_premium_plan_features_unlocked/
+   - name: mobile_push_notifications_enabled
+     regex: r/mobile_push_notifications_enabled/
+
+colors:
+  yellow: 'ffb300'   
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/flagr/index.html b/integrations/flagr/index.html new file mode 100644 index 00000000..983aa1a8 --- /dev/null +++ b/integrations/flagr/index.html @@ -0,0 +1,29 @@ + Integrate gitStream with Flagr - gitStream Documentation

Integrate gitStream with Flagr

Label Flagr Feature Flags

Automatically label code that contians specified feature flags.

Label PRs Based on Feature Flags

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+
+  {% for item in feature_flags %}
+  label_ff_flagr_{{ item.name }}:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/evaluation_result.variant_id ==/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ item.name }}
+          color: {{ colors.yellow }}
+  {% endfor %}
+
+feature_flags:
+   - name: engineering_rollback_plan_activated 
+     regex: r/engineering_rollback_plan_activated/
+   - name: marketing_premium_plan_features_unlocked 
+     regex: r/marketing_premium_plan_features_unlocked/
+   - name: mobile_push_notifications_enabled
+     regex: r/mobile_push_notifications_enabled/
+
+colors:
+  yellow: 'ffb300'   
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/flagsmith/index.html b/integrations/flagsmith/index.html new file mode 100644 index 00000000..956094b2 --- /dev/null +++ b/integrations/flagsmith/index.html @@ -0,0 +1,29 @@ + Integrate gitStream with Flagsmith - gitStream Documentation

Integrate gitStream with Flagsmith

Label Flagsmith Feature Flags

Automatically label code that contians specified feature flags.

Label PRs Based on Feature Flags

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+
+  {% for item in feature_flags %}
+  label_ff_flagsmith_{{ item.name }}:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/flagsmith.hasFeature\(/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ item.name }}
+          color: {{ colors.yellow }}
+  {% endfor %}
+
+feature_flags:
+   - name: engineering_rollback_plan_activated 
+     regex: r/engineering_rollback_plan_activated/
+   - name: marketing_premium_plan_features_unlocked 
+     regex: r/marketing_premium_plan_features_unlocked/
+   - name: mobile_push_notifications_enabled
+     regex: r/mobile_push_notifications_enabled/
+
+colors:
+  yellow: 'ffb300'   
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/github-actions/index.html b/integrations/github-actions/index.html new file mode 100644 index 00000000..080438f1 --- /dev/null +++ b/integrations/github-actions/index.html @@ -0,0 +1,179 @@ + Integrate gitStream with GitHub Actions - gitStream Documentation

Integrate gitStream with GitHub Actions

Dispatch GitHub Actions

Automatically trigger GitHub Actions based on PR content like changed resources, source or target branch, slash commands, and more.

Automatically Dispatch GitHub Actions

Configuration Description

Conditions (all must be true):

  • The PR source or target branch matches a specified format.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions by Branch

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+  - commit
+
+automations:
+  {% for item in pipelines %}
+  # Change pr.target to branch.name if you want to trigger on the source branch rather then the target branch.
+  dispatch_github_action_{{ item.name }}:
+    if:
+      - {{ pr.target | includes(term=item.branch_prefix) }}
+    run:
+      - action: run-github-workflow@v1
+        args:
+          workflow: .github/workflows/{{ item.workflow }}
+          check_name: {{ item.name }}
+      - action: add-label@v1
+        args:
+          label: {{ item.label }}
+  {% endfor %}
+
+
+pipelines:
+  - name: mobile_ci
+    label: Mobile CI 
+    branch_prefix: 'mobile-'
+    workflow: mobile.yml
+  - name: backend_ci
+    label: Backend CI 
+    branch_prefix: 'backend-'
+    workflow: 'backend.yml'
+

Configuration Description

Conditions (all must be true):

  • The PR has one or more specified labels applied to it.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions Using Labels

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - label_added
+  - label_removed
+
+automations:
+  {% for item in pipelines %}
+  dispatch_github_action_{{ item.name }}:
+    if:
+      - {{ pr.labels | match(term=item.label) | some }}
+    run:
+      - action: run-github-workflow@v1
+        args:
+          workflow: .github/workflows/{{ item.workflow }}
+          check_name: {{ item.name }}
+  {% endfor %}
+
+pipelines:
+  - name: mobile-ci
+    label: Mobile CI 
+    workflow: mobile.yml
+  - name: backend-ci
+    label: Backend CI 
+    workflow: 'backend.yml'
+

Configuration Description

Conditions (all must be true):

  • The PR modifies one or more specified resources.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions Based on Modified Resources

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+  - commit
+
+automations:
+  {% for item in pipelines %}
+  dispatch_github_action_{{ item.name }}:
+    if:
+      - {{ files | match(list=item.resources) | some }}
+    run:
+      - action: run-github-workflow@v1
+        args:
+          workflow: .github/workflows/{{ item.workflow }}
+          check_name: {{ item.name }}
+      - action: add-label@v1
+        args:
+          label: {{ item.label }}
+  {% endfor %}
+
+
+pipelines:
+  - name: mobile-ci
+    label: Mobile CI 
+    resources:
+      - 'src/android/'
+      - 'src/ios/'
+    workflow: mobile.yml
+  - name: backend-ci
+    label: Backend CI 
+    resources:
+      - 'src/api/'
+      - 'src/services'
+    workflow: 'backend.yml'
+  - name: frontend-ci
+    label: Frontend CI
+    resources:
+      - 'src/app/'
+    workflow: 'frontend.yml'
+

Skip GitHub Actions

Automatically skip GitHub Actions based on branch names, modified resource, slash commands, and more.

Automatically Skip GitHub Actions

Prerequisite Config for Required Statuses

If you want to skip a required status check, you will need to make sure that your branch protection is configured to allow gitStream to bypass status check requirements.

GitHub Branch Protection Config

Configuration Description

Conditions (all must be true):

  • The target branch name includes a specified keyword. Optionally, you can modify this to detect the source branch name.

Automation Actions:

  • Skip the specified CI pipelines.

Automatically Skip GitHub Actions by Branch

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+  - commit
+
+# Optionally, you can change pr.target to branch.name
+# if you want to trigger based on the source branch name rather then the target branch name.
+automations:
+  skip_github_action_branch:
+    if:
+      - {{ pr.target | includes(term='release') }}
+    run:
+      - action: add-github-check@v1
+        args:
+          check_name: staging-ci
+          conclusion: skipped
+      - action: add-comment@v1
+        args:
+          comment: |
+            [gitStream](https://docs.gitstream.cm) automatically skipped staging CI pipelines because this PR targets the release branch.
+

Configuration Description

Conditions (all must be true):

  • Someone applies one or more specified labels to a PR.

Automation Actions:

  • Skip the specified CI pipelines.

Use Labels to Automatically Skip GitHub Actions

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - label_added
+  - label_removed
+
+automations:
+  skip_github_action_label:
+    if:
+      - {{ pr.labels | match(term='experimental') | some }}
+    run:
+      - action: add-github-check@v1
+        args:
+          check_name: production-ci
+          conclusion: skipped
+      - action: add-comment@v1
+        args:
+          comment: |
+            [gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this is labeled for experimental release.
+

Configuration Description

Conditions (all must be true):

  • A PR modifies specific files or directories.

Automation Actions:

  • Skip a specified GitHub Action.

Automatically Skip GitHub Actions Based on Modified Resources

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+  - commit
+
+automations:
+  skip_github_action_resource:
+    if:
+      - {{ files | match(term='docs/') | every }}
+    run:
+      - action: add-github-check@v1
+        args:
+          check_name: release-ci
+          conclusion: skipped
+      - action: add-github-check@v1
+        args:
+          check_name: mobile-ci
+          conclusion: skipped
+      - action: add-comment@v1
+        args:
+          comment: |
+            [gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this PR only contains docs changes.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/github-copilot/index.html b/integrations/github-copilot/index.html new file mode 100644 index 00000000..a504a99c --- /dev/null +++ b/integrations/github-copilot/index.html @@ -0,0 +1,84 @@ + Integrate gitStream with GitHub Copilot - gitStream Documentation

Integrate gitStream with GitHub Copilot

Automatically Label Copilot-Assisted PRs

Automatically apply labels to PRs that are assisted by GitHub Copilot. You can apply labels based on a known list of Copilot users, PR tags, or by prompting the PR author to indicate if they used Copilot.

Prompt PR authors to indicate if they used Copilot for the PR and automatically label the PR if they did. This requires two separate automation files to handle posting the prompt and labeling accordingly.

Label Copilot by Prompt

Configuration Description

Conditions:

  • A PR is created

Automation Actions:

  • Post a comment prompting the author to indicate if Copilot assisted the author with writing the code in the PR.

Ask the PR author about Copilot usage.

-*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+
+automations:
+  comment_copilot_prompt:
+    # Post a comment for all PRs to prompt the PR author to indicate whether they used Copilot to assist coding in this PR
+    if:
+      - true
+    run:
+      - action: add-comment@v1
+        args:
+          comment: |
+            Please mark whether you used Copilot to assist coding in this PR
+
+            - [ ] Copilot Assisted
+            - [ ] Not Copilot Assisted
+

Configuration Description

Conditions:

  • A PR is updated or merged where the author indicates they used Copilot via a prompt.

Automation Actions:

  • Apply a 🤖 Copilot label to the PR

Label PRs where the user indicated Copilot usage

-*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  # You should use this automation in conjunction with comment_copilot_prompt.cm
+  label_copilot_pr:
+    # If the PR author has indicated that they used Copilot to assist coding in this PR, 
+    # apply a label indicating the PR was supported by Copilot
+    if:
+      - {{ pr.comments | filter(attr='commenter', term='gitstream-cm') | filter (attr='content', regex=r/\- \[x\] Copilot Assisted/) | some}}
+    run:
+      - action: add-label@v1
+        args:
+          label: '🤖 Copilot'
+

Automatically apply labels to PRs that are created by known users of generative AI coding tools.

Label by Contributors

Configuration Description

Conditions:

  • The PR author is one of a specified list of contributors

Automation Actions:

  • Apply a 🤖 Copilot label to the PR

Label by Contributors

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_genai:
+    # For all PRs authored by someone who is specified in the genai_contributors list
+    if:
+      - {{ pr.author | match(list=genai_contributors) | some  }}
+    # Apply a label indicating the user has adopted Copilot
+    run:
+      - action: add-label@v1
+        args:
+          label: '🤖 Copilot'
+
+genai_contributors:
+  - username1
+  - username2
+  - etc
+

Look for a specific tag in the PR title, description, comments or commit messages and if found add a label to the PR

Label Copilot by Tag

Configuration Description

Conditions:

  • The #copilot# tag is found in any of the PR title, description, comments or commit messages for commits in the PR

Automation Actions:

  • Apply a 🤖 Copilot label to the PR

Label Copilot by Tag

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - comment_added
+  - commit
+  - pr_created
+
+automations:
+  label_copilot:
+    # Detect PRs that contain the text '#copilot#' in the title, description, comments, or commit messages
+    if:
+      - {{ copilot_tag.pr_title or copilot_tag.pr_desc or copilot_tag.pr_comments or copilot_tag.commit_messages  }}
+    # Apply a label indicating the user has adopted Copilot
+    run:
+      - action: add-label@v1
+        args:
+          label: '🤖 Copilot'
+
+copilot_tag:
+  pr_title: {{ pr.title | includes(regex=r/#copilot#/) }}
+  pr_desc: {{pr.description | includes(regex=r/#copilot#/) }}
+  pr_comments: {{ pr.comments | map(attr='content') | match(regex=r/#copilot#/) | some }}
+  commit_messages: {{ branch.commits.messages | match(regex=r/#copilot#/) | some }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/godoc/index.html b/integrations/godoc/index.html new file mode 100644 index 00000000..37d98373 --- /dev/null +++ b/integrations/godoc/index.html @@ -0,0 +1,77 @@ + Integrate gitStream with Godoc - gitStream Documentation

Integrate gitStream with Godoc

Review Godoc Changes

Approve PRs that only contain changes to Godoc and assign optional reviewers.

Review Godoc

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to Godoc content.

Automation Actions:

  • Assign the org/tech-writers team for optional review.
  • Apply a green 📓 Godoc Only label
  • Approve the PR

Review Godoc

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  #Assign PRs that only affect godocs to the technical writing team and add docs label
+  review_godoc:
+    if:
+      - {{ source.diff.files | match(attr='diff', regex=r/^\/\/.*/) | every }}
+      - {{ files | extensions | match(regex=r/go/) | every }}
+
+    run:
+      - action: add-label@v1
+        args:
+            label: "📓godoc Only"
+            color: {{ colors.green }}
+      - action: add-reviewers@v1
+        args:
+          reviewers: [org/tech-writers]
+      - action: approve@v1
+
+colors:
+  green: '0e8a16'
+

Enforce Godoc Requirements for New Classes

Require Godoc for all new Golang classes.

Enforce Godoc for New Golang Classes

Configuration Description

Conditions (all must be true):

  • The PR creates a new Golang class.
  • The PR lacks Godoc content.

Automation Actions:

  • Request changes and post a comment explaining that Godoc is required
  • Apply a yellow ⚠️ Missing Godoc label.

Enforce Godoc for New Golang Classes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_godoc_new_class: 
+    if:  
+      - {{ is.go and is.new }} 
+      - {{ source.diff.files | match(attr='diff', regex=r/\/*[\s\S]*?\//) | nope }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing godoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            godoc is required for all Golang classes. Please add godoc to all new classes in this PR.
+
+is:
+    go: {{ files | extensions | match(regex=r/go/) | every }}
+    new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}
+
+colors:
+  yellow: 'fbca04'
+

Review Godoc for Large changes

Require more extensive reviews for large Golang changes that lack Godoc updates.

Review Godoc for Large changes

Configuration Description

Conditions (all must be true):

  • The PR changes more than 100 lines of Golang code.

Automation Actions:

  • Post a comment asking the author to review all relevant Godoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow ⚠️ Missing Godoc Label

Review Godoc

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  #Require more extensive reviews for large Golang changes that lack Godoc updates.
+  review_godoc_large:
+    if:
+      - {{ changes.additions > 100}}
+      - {{ source.diff.files | matchDiffLines(regex=r/^\/\/.*/) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Godoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+              This PR makes major changes to Golang classes, but is missing updates to Godoc. Please double check for any necessary Godoc updates.
+      - action: add-reviewers@v1
+        args:
+          reviewers: [fourth-organization/tech-writers]
+
+changes:
+  # Sum all the lines added/edited in the PR
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+
+colors:
+  yellow: 'fbca04'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

\ No newline at end of file diff --git a/integrations/golang/golang-testing-automations/index.html b/integrations/golang/golang-testing-automations/index.html new file mode 100644 index 00000000..5de3b51f --- /dev/null +++ b/integrations/golang/golang-testing-automations/index.html @@ -0,0 +1 @@ + Golang Testing Automations - gitStream Documentation
\ No newline at end of file diff --git a/integrations/html/html-css-automations/index.html b/integrations/html/html-css-automations/index.html new file mode 100644 index 00000000..0207405f --- /dev/null +++ b/integrations/html/html-css-automations/index.html @@ -0,0 +1 @@ + HTML/CSS Automations - gitStream Documentation
\ No newline at end of file diff --git a/integrations/index.html b/integrations/index.html new file mode 100644 index 00000000..5ec28faa --- /dev/null +++ b/integrations/index.html @@ -0,0 +1 @@ + Automation - gitStream Integrations - gitStream Documentation

gitStream Integrations

GitHub / GitLab

Security & Compliance

Project Management

Chat & Communications

Feature Flags

Languages

Documentation

Other

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

\ No newline at end of file diff --git a/integrations/java/java-testing-automations/index.html b/integrations/java/java-testing-automations/index.html new file mode 100644 index 00000000..08361cba --- /dev/null +++ b/integrations/java/java-testing-automations/index.html @@ -0,0 +1 @@ + Java Testing Automations - gitStream Documentation
\ No newline at end of file diff --git a/integrations/javadoc/index.html b/integrations/javadoc/index.html new file mode 100644 index 00000000..dbceb72c --- /dev/null +++ b/integrations/javadoc/index.html @@ -0,0 +1,94 @@ + Integrate gitStream with Javadoc - gitStream Documentation

Integrate gitStream with Javadoc

Javadoc Examples:

Review Javadoc Changes

Review Javadoc Changes

Unblock PRs that only change Javadoc content.

Review Javadoc Changes

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to Javadoc content.

Automation Actions:

  • Assign the org/tech-writersteam for optional review.
  • Apply a green 📓 Javadoc Only label
  • Approve the PR

Review Javadoc Changes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  # Assign PRs that only affect JavaDocs to the technical writing team and add docs label
+  review_javadoc:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | every }}
+      - {{ source.diff.files | matchDiffLines(regex=r/\b(public|protected|private|static|final|synchronized)?\s+\w+\s+\w+\s*\(([^)]*)\)\s*\{/) | nope }}
+    run:
+      - action: add-label@v1
+        args:
+            label: "📓 Javadoc Only"
+            color: {{ colors.green }}
+      - action: add-reviewers@v1
+        args:
+          reviewers: [org/tech-writers]
+      - action: approve@v1
+
+colors:
+  green: '0e8a16'
+

Review Java Input Parameters for Javadoc Changes

Review Java Input Parameters for Javadoc Changes

If a PR modifies the input parameters for a Java method, but not the associated Javadocs, notify reviewers to check for Javadoc updates.

Review Javadoc Input Parameters

Configuration Description

Conditions (all must be true):

  • The PR changes one or more input parameters in Java methods.
    • Note: This may not trigger for methods with annotations, methods that throw exceptions, multi-line method definitions, and other non-standard use cases.
  • The PR lacks changes to ‘@param’ declarations.

Automation Actions:

  • Post a comment warning the user to review the method’s Javadoc to identify necessary updates.

Review Javadoc

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_javadoc_input_parameters: 
+    if:  
+        - {{ source.diff.files | matchDiffLines(regex=r/\*\s@param/) | nope }}
+        - {{ source.diff.files | matchDiffLines(regex=r/\b(public|protected|private|static|final|synchronized)?\s+\w+\s+\w+\s*\(([^)]*)\)\s*\{/) | some }}
+    run:
+      - action: add-comment@v1
+        args: 
+            comment: | 
+              This PR modifies method input parameters, but is missing Javadoc changes. Please check to ensure no Javadoc changes are necessary.
+

Review Javadoc for Large Changes

Review Javadoc for Large Changes

Require more extensive reviews for large Java changes that lack Javadoc updates.

Review JavaDoc for Large Changes

Configuration Description

Conditions (all must be true):

  • The PR changes more than 25% of a Java class.
  • The PR lacks Javadoc changes.

Automation Actions:

  • Post a comment asking the author to review all relevant Javadoc to identify necessary updates.
  • Require a review from the my-organization/tech-writers team.
  • Apply a yellow ⚠️ Missing Javadoc Label

Review Javadoc for Large Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  #Require more extensive reviews for large Java changes that lack Javadoc updates.
+  review_javadoc_large:
+    if:
+      - {{ changes.ratio > 25}}
+      - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Javadoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+              This PR makes major changes to Java classes, but is missing updates to Javadoc. Please double check for any necessary Javadoc updates.
+      - action: add-reviewers@v1
+        args:
+          reviewers: [fourth-organization/tech-writers]
+
+changes:
+  # Sum all the lines added/edited in the PR
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+  # Sum all the line removed in the PR
+  deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}
+  # Calculate the ratio of new code
+  ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}
+
+colors:
+  yellow: 'fbca04'
+

Enforce Javadoc Requirements for New Classes

Enforce Javadoc Requirements for New Classes

Automatically request changes when someone creates a new Java class that lacks Javadoc content.

Enforce Javadoc Requirements for New Classes

Configuration Description

Conditions (all must be true):

  • The PR creates a new Java class.
  • The PR lacks Javadoc content.

Automation Actions:

  • Apply a ⚠️ Missing Javadoc label.
  • Request changes, and post a comment explaining that Javadoc is required

Review Javadoc Requirements for New Classes

manifest:
+  version: 1.0
+
+automations:
+  review_new_class_javadoc:
+    # Triggered for new Java files that lack Javadoc content.
+    if:
+      - {{ is.java and is.new }}
+      - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Javadoc"
+          color: {{ colors.yellow }}
+      - action: request-changes@v1
+        args:
+          comment: | 
+              This PR creates new Java classes, but is missing updates to Javadoc. Please double check for any necessary Javadoc updates.
+
+is:
+    java: {{ files | extensions | match(term='java') | every }}
+    new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}
+
+colors:
+  yellow: 'fbca04'
+

Special thanks to Boemo W Mmopelwa for providing these examples.

\ No newline at end of file diff --git a/integrations/javascript/javascript-testing-automations/index.html b/integrations/javascript/javascript-testing-automations/index.html new file mode 100644 index 00000000..39e5de46 --- /dev/null +++ b/integrations/javascript/javascript-testing-automations/index.html @@ -0,0 +1 @@ + JavaScript Testing Automations - gitStream Documentation
\ No newline at end of file diff --git a/integrations/jira/index.html b/integrations/jira/index.html new file mode 100644 index 00000000..34b68a45 --- /dev/null +++ b/integrations/jira/index.html @@ -0,0 +1,211 @@ + Integrate gitStream with Jira - gitStream Documentation

Integrate gitStream with Jira

gitStream makes it easy to build workflows that link your GitHub repo to your Jira workspace. Automatically update Jira issues, enforce Jira best-practices, and reduce the amount of context switching developers experience by reducing their need to interact with third-party project management tools.

Automation Examples

Label Missing Jira Info

Label PRs that don't reference a Jira ticket in the title or description. This uses regex to detect Jira ticket formats in the title (e.g. ABC-1234), and URLs to Jira tickets in the description.

Label Missing Jira

Configuration Description

Conditions (all must be true):

  • The PR lacks a Jira ticket number in the title, or a link to a Jira ticket in the PR description.

Automation Actions:

  • Apply a missing-jira label.

Label Missing Jira Info

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_missing_jira_info:
+    # Triggered for PRs that don't have either a Jira ticket number in the title,
+    # or a link to a Jira ticket in the PR description.
+    if:
+      - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "missing-jira"
+          color: 'F6443B'
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }}
+

Provide automatic links to Jira issues that are associated with PRs.

Automatically Link to the Related Jira Card

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Jira card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Jira Card.

Automatically Link to the Related Jira Card

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+provider: jira
+
+# Change this to the name of your Jira organization
+orgName: org
+
+{% set ticketid = "" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  link_jira:
+    if:
+      - {{ has.ticket_in_title or has.ticket_in_branch }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})
+
+has:
+  ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}
+  ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}
+
+tracker:
+  jira:
+    baseurl: https://[orgName].atlassian.net/browse/
+    pattern: r/\b[A-Za-z]+-\d+\b/
+
+tickets:
+  - {{branch.name | capture(regex=tracker[provider].pattern)}}
+  - {{pr.title | capture(regex=tracker[provider].pattern)}}
+

Update Jira Fields When PRs are Created

Automatically update Jira tickets with pull request information. You can modify this to send any PR metadata to Jira.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Automatic Jira Updates Automatic Jira Updates

Configuration Description

Conditions (all must be true):

  • A PR is created that contains a Jira ticket reference in the title or branch name.

Automation Actions:

  • Send a webhook to Jira containing metadata to add to the Issue.

Automatic Jira Updates

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+
+{% set ticketid = "\b[A-Za-z]+-\d+\b" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  jira_update_field: 
+    if:
+      - {{ has.jira_ticket_in_title or has.jira_ticket_in_branch }}
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ env.JIRA_UPDATE_PR_FIELD_WEBHOOK }}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{"issues":["{{ticketid}}"],"data":{"pr_url":"https://github.com/{{repo.owner}}/{{repo.name}}/pull/{{pr.number}}"}}'
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_branch: {{ branch.name | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+

Automatically Create Jira Issues for New PRs

Automatically create Jira tickets for new pull/merge requests.

Jira API & Webhook Integration Required.

This automation requires you to connect to the Jira API and incoming webooks.

Required gitStream Plugins

This example requires you to install the hasJiraIssue plugin.

Learn more about gitStream plugins.

Create Jira Issue Create Jira Issue

Configuration Description

Conditions (all must be true):

  • The PR description contains the text - [x] Auto-create Jira Issue
  • No existing Jira issues reference the PRs URL.

Automation Actions:

  • Send an HTTP request to create a new Jira issue.

Automatically Create Jira Issues

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+
+###### ** Configure This Section ** ######
+
+# Configure this for your Jira instance and the email associated with your API key.
+# You can safely use these values because only your API key is sensitive. 
+jiraSpaceName: "my-company" # e.g. my-company.atlassian.net
+email: "my.email@example.com"
+# If you're concerned about exposing this information,
+# we recommend using environment variables for your production environment.
+
+# -----------
+
+# Pass the API token associated with the email above to gitStream via an environment variable.
+jiraAuth: {{ env.JIRA_API_TOKEN }}
+# Learn more about env: https://docs.gitstream.cm/context-variables/#env
+
+# -----------
+
+# Change this to the Jira field you want to match the input string against.
+jiraField: "myField"
+# If you want to search a custom field, you should provide the ID like so:
+# jiraField: "cf[XXXXX]"
+# Replace XXXXX with the ID of the custom field you want to search.
+# More information:
+# Using JQL to search the Jira API: https://support.atlassian.com/jira-service-management-cloud/docs/jql-fields/
+# How to find the ID of a custom field: https://confluence.atlassian.com/jirakb/how-to-find-any-custom-field-s-ids-744522503.html
+
+# -----------
+
+###### ** Automation ** ######
+# You may want to update the text in the comment gitStream posts;
+# otherwise, this section shouldn't need to be changed.
+prUrl: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+has_jira_issue: {{ prUrl  | hasJiraIssue(jiraAuth, jiraField, jiraSpaceName, email) }}
+
+automations:
+  automatic_jira_task: 
+    if:
+      - {{ not has_jira_issue }}
+      - {{ pr.description | includes(regex=r/\- \[x\] Auto-create Jira Task/)}}
+    run:
+      - action: send-http-request@v1
+        args:
+          url: {{ env.JIRA_WEBHOOK }}
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{"data":{"pr_url": "{{ prUrl }}","title":"{{ pr.title }}"}}'
+      - action: add-comment@v1
+        args:
+          comment: "gitStream automatically created a Jira task for this PR"
+

Update Jira Ticket Status When PRs are Created

Automatically update the status of Jira tickets when a PR is opened.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Automatic Jira Status Updates Automatic Jira Status Updates

Configuration Description

Conditions (all must be true):

  • A PR is created that references a Jira ticket in the title or description.

Automation Actions:

  • Make an HTTP request to a Jira webhook that is pre-configured to update the ticket status.

Automatic Jira Status Updates

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+
+{% set ticketid = "\b[A-Za-z]+-\d+\b" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  jira_change_status: 
+    if:
+      - {{ has.jira_ticket_in_title or has.jira_ticket_in_desc }}
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ env.JIRA_CHANGE_STATUS_WEBHOOK }}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{"issues":["{{ticketid}}"],"data":{"pr_url":"https://github.com/{{repo.owner}}/{{repo.name}}/pull/{{pr.number}}"}}'
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_branch: {{ branch.name | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+
+tickets:
+  - {{branch.name | capture(regex=r/\b[A-Za-z]+-\d+\b/)}}
+  - {{pr.title | capture(regex=r/\b[A-Za-z]+-\d+\b/)}}
+

Use Slash Commands to Assign Tickets in Jira

Automatically assign Jira tickets based on code review actions.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Automatically Assign Jira Tickets Automatically Assign Jira Tickets

Configuration Description

Conditions (all must be true):

  • The PR description contains the slash command: /gitstream assign-jira followed by a Jira username.

Automation Actions:

  • Trigger a Jira webhook to update the assignee field with the username provided in the slash command.

Automatically Assign Jira Tickets

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+assigneeRegex: r/(?<=\/gitstream assign-jira ).*(?=<br \/>)/
+
+{% set ticketid = "" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  jira_assign: 
+    if:
+      - {{ pr.description | includes(regex=assigneeRegex) }}
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ env.JIRA_WEBHOOK }}}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{"issues":["{{ticketid}}"],"data":{"assignee":"{{pr.description | capture(regex=assigneeRegex)}}"}}'
+
+has:
+  jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+  jira_ticket_in_branch: {{ branch.name | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
+
+tickets:
+  - {{branch.name | capture(regex=r/\b[A-Za-z]+-\d+\b/)}}
+  - {{pr.title | capture(regex=r/\b[A-Za-z]+-\d+\b/)}}
+

Configure Jira for gitStream Integrations

If you want to build gitStream automations to interact with the Jira API or Jira webhooks, you'll need to complete some setup in Jira, GitHub, and gitStream. This section outlines the setup process depending on the type of automation you want to build.

These guides are for sending HTTP requests to Jira

If the gitStream automations you want to use don't make any HTTP requests to a Jira API or webhook, you can ignore this section.

Use Webhooks to Trigger Jira Automations

Jira automations are the preferred method for gitStream to trigger actions within Jira, so you should use them whenever possible. If webhooks don't provide access to the data you need, or acheive the functionality you want, use the Jira API instead.

First, create a Jira automation that uses an incoming webhook as the trigger and add whatever automation components you want after this trigger. Save the webhook URL in a secure place, you'll need it later.

Here is an example of an automation that uses the webhookData property of the incoming data payload to create a new task. It expects the incoming data payload to contain title and pr_url fields to set the task summary and a pr_url custom field our demo environment already has configured.

Jira Automation Example - Create task from incoming webhook

Learn more about working with incoming webhooks in the Jira docs

Next, in GitHub, create an organization secret to store your Jira webhook URL and pass it to gitStream's env context variable by adding a line to .github/workflows/gitstream.yml inside your repo. Make sure to give this a unique name, such as JIRA_CREATE_ISSUE_WEBHOOK: ${{ secrets.JIRA_CREATE_ISSUE_WEBHOOK }}.

Once finished, you can use the env.JIRA_CREATE_ISSUE_WEBHOOK context variable inside CM files to send HTTP requests to Jira from your GitHub repo. For an example of how to do this, check out the create Jira issue automation.

Connect to the Jira API

The Jira API is useful in situations where you need to retreive data from Jira or need to access capabilities that aren't available via Jira Automations. The Jira API uses an account-based token system that follows a basic auth model; this means you'll need an individual account to connect to Jira's APIs and will pass the account email address and API token in the headers of your API requests.

Here's the process to grant gitStream access to the Jira API:

  1. Create an API token for your Jira account, and give it a unique name. Copy the API token, you'll need it in the next step.
  2. Create a GitHub organization secret to store the token and make the secret available to gitStream's env context variable.
  3. Add env.MY_API_TOKEN to any of your CM automations to access the API token and pass it to plugins and automation actions.

Check out the hasJiraIssue filter plugin for an example of how to use Jira API tokens.

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/jira/jira-webhook-automation.png b/integrations/jira/jira-webhook-automation.png new file mode 100644 index 00000000..b41f469d Binary files /dev/null and b/integrations/jira/jira-webhook-automation.png differ diff --git a/integrations/jit/index.html b/integrations/jit/index.html new file mode 100644 index 00000000..26fc4d95 --- /dev/null +++ b/integrations/jit/index.html @@ -0,0 +1,127 @@ + Integrate gitStream with Jit - gitStream Documentation

Integrate gitStream with Jit

Included with gitStream Core Functionality

This integration is part of gitStream core functionality, and requires no additional configuration.

Jit Examples:

Review Jit Security Alerts

Review Jit Security Alerts

Manage review assignment for high and medium risk Jit security alerts.

Label Jit Alerts

Configuration Description

**Review Jit High Alerts**
+
+* Conditions (all must be true):
+    * Jit reports one or more high vulnerabilities for the PR
+* Automation Actions:
+    * Require a review from the organization’s security team.
+    * Require 2 reviewers.
+    * Post a comment explaining why this action was taken.
+
+**Review Jit Medium Alerts**
+
+* Conditions (all must be true):
+    * Jit reports one or more medium vulnerabilities for the PR
+* Automation Actions:
+    * Require 2 reviewers
+    * Post a comment explaining why this action was taken.
+

Review Jit Security Alerts

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_jit_high_alerts:
+    if:
+      - {{ jit.metrics.HIGH > 0 }}
+    run:
+      - action: require-reviewers@v1
+        args:
+          reviewers: [my-organization/security-team]
+      - action: set-required-approvals@v1
+        args:
+          approvals: 2
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR requires additional review because Jit reported one or more high risk vulnerabilities.
+  review_jit_medium_alerts:
+    if:
+      - {{ jit.metrics.MEDIUM > 0 }}
+    run:
+      - action: set-required-approvals@v1
+        args:
+          approvals: 2
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR requires additional reviewers because Jit reported one or more medium risk vulnerabilities.
+
+
+jit: {{ pr | extractJitFindings }}
+

Review Jit Secret Detection

Review Jit Secret Detection

Close PRs where Jit detects a secret and post a comment explaining steps to remedy the situation.

Label Jit Alerts

Configuration Description

Conditions (all must be true):

  • Jit detects a secret in the PR.

Automation Actions:

  • Close the PR
  • Post a comment explaining why this action was taken and to outline the necessary steps to remedy the situation.

Review Jit Security Control

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_jit_secret:
+    if:
+      - true
+      - {{ jit.vulnerabilities | match(attr='security_control', term='Secret Detection') | some }}
+    run:
+      - action: add-comment@v1
+        args: 
+          comment: |
+            Jit detects secrets in this PR. Please complete the following steps:
+            1. Undo the commit with git reset and remove all secrets from the files you modified.
+            2. Deactivate the secret in any locations its used and replace it with a new key
+            3. Commit your changes and resubmit your PR.
+      - action: close@v1
+
+
+jit: {{ pr | extractJitFindings }}
+

Label Jit Alerts

Label Jit Alerts

Label the number of high, medium, and low risk vulnerabilities Jit reports for PRs.

Label Jit Alerts

Configuration Description

Conditions (all must be true):

  • Jit reports one or more high, medium, or low risk security vulnerabilities for the PR.

Automation Actions:

  • Apply labels to indicate the number of each type of vulnerability

Label Jit Alerts

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in reports %}
+  label_jit_{{ item.name }}:
+    if:
+      - {{ item.count > 0}}
+    run:
+      - action: add-label@v1
+        args:
+          label: 'Jit: {{ item.count }} {{ item.name }} vulnerabilities'
+          color: {{ colors.red if (item.name == 'high') else (colors.orange if (item.name == 'medium' ) else colors.yellow) }}
+  {% endfor %}
+
+jit: {{ pr | extractJitFindings }}
+
+reports:
+  - name: high
+    count: {{ jit.metrics.HIGH }}
+  - name: medium
+    count: {{ jit.metrics.MEDIUM }}
+  - name: low
+    count: {{ jit.metrics.LOW }}
+
+colors:
+  red: 'b60205'
+  orange: 'd93f0b'
+  yellow: 'fbca04'
+

Review Jit Ignore and Accept

Review Jit Ignore and Accept

Notify your Security team when someone ignores a Jit vulnerability report and accepts the risk.

Label Jit Alerts

Configuration Description

Conditions (all must be true):

Automation Actions:

  • Request review from the organization’s security team.
  • Label the PR to indicate someone accepted the risk of a Jit security alert.
  • Post a comment explaining why this action was taken.

Review Jit Ignore and Accept

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_jit_ignore_accept:
+    if:
+      - {{ pr.conversations | reject(attr='commenter', term='jit-ci') | filter(attr='content', term='#jit_ignore_accept') | some }}
+    run:
+
+      - action: add-reviewers@v1
+        args:
+          reviewers: [my-organziation/security]
+      - action: add-label@v1
+        args:
+          label: '❕ Jit: Ignore - Accept Risk'
+      - action: add-comment@v1
+        args:
+          comment: |
+            The security team has been assigned for optional review because this PR ignores a Jit alert and accepts the associated risks.
+
+jit: {{ pr | extractJitFindings }}
+
\ No newline at end of file diff --git a/integrations/jsdoc/index.html b/integrations/jsdoc/index.html new file mode 100644 index 00000000..f4560d3f --- /dev/null +++ b/integrations/jsdoc/index.html @@ -0,0 +1,92 @@ + Integrate gitStream with JSDoc - gitStream Documentation

Integrate gitStream with JSDoc

JSDoc Examples:

Review JSDoc Changes

Review JSDoc Changes

Approve PRs that only contain changes to JSDoc and assign optional reviewers.

Review JSDoc

Configuration Description

Conditions (all must be true):

  • The PR only affects JavaScript and TypeScript files
  • The PR only contains changes to JSDoc content.

Automation Actions:

  • Assign the ORG/tech-writers team.
  • Apply a green 📓 JSDoc Only label
  • Approve the PR

Review JSDoc

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  #Assign PRs that only affect JSDocs to the technical writing team and add docs label
+  review_jsdoc:
+    if:
+      - {{ source.diff.files | match(attr='diff', regex=r/\/*\*[\s\S]*?\//) | every }}
+    run:
+      - action: add-label@v1
+        args:
+            label: "📓JSDoc Only"
+            color: {{ colors.green }}
+      - action: add-reviewers@v1
+        args:
+          reviewers: [fourth-organization/tech-writers]
+      - action: approve@v1
+
+colors:
+  green: '0e8a16'
+

Review JSDoc Input Parameters

Review JSDoc Input Parameters

Warn PR authors when they change JavaScript function or constructor input parameters without updating JSDoc content.

Review JSDoc Input Parameters

Configuration Description

Conditions (all must be true):

  • The PR changes an input parameter in one or more JavaScript methods.
  • The PR lacks changes to ‘@param’ declarations.

Automation Actions:

  • Post a comment warning the user to review the method’s JSDoc to identify necessary updates.

Review JSDoc Input Parameters

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_jsdoc_input: 
+    if:  
+      - {{ source.diff.files | matchDiffLines(regex=r/.*\s@param/) | nope }}
+      - {{ source.diff.files | matchDiffLines(regex=r/\((?:.*\:.*\))/) | some }}
+
+    run:
+      - action: add-comment@v1
+        args: 
+          comment: | 
+              This PR appears to modify method input parameters, but is missing JSDoc changes. Please check to ensure no JSDoc changes are necessary.
+

Review JSDoc for Large Changes

Review JSDoc for Large Changes

Require more extensive reviews for large JavaScript changes that lack JSDoc updates.

Review JSDoc for Large changes

Configuration Description

Conditions (all must be true):

  • The PR changes more than 25% of a JavaScript class.

Automation Actions:

  • Post a comment asking the author to review all relevant JSDoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow ⚠️ Missing JSDoc Label

Review JSDoc

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  #Require more extensive reviews for large Javascript changes that lack JSDoc updates.
+  review_jsdoc_large:
+    if:
+      - {{ changes.ratio > 25}}
+      - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ No JSDoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            This PR makes major changes to JavaScript classes, but is missing updates to JSDoc. Please double check for any necessary JSDoc updates.
+
+      - action: add-reviewers@v1
+        args:
+          reviewers: [fourth-organization/tech-writers]
+
+changes:
+  # Sum all the lines added/edited in the PR
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+  # Sum all the line removed in the PR
+  deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}
+  # Calculate the ratio of new code
+  ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}
+
+colors:
+  yellow: 'fbca04'
+

Enforce JSDoc for New JavaScript Classes

Enforce JSDoc for New JavaScript Classes

Require JSDoc for all new JavaScript classes.

Enforce JSDoc for New JavaScript Classes

Configuration Description

Conditions (all must be true):

  • The PR creates a new JavaScript class.
  • The PR lacks JSDoc content.

Automation Actions:

  • Request changes and post a comment explaining that JSDoc is required
  • Apply a yellow ⚠️ Missing JSDoc label.

Enforce JSDoc for New JavaScript Classes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_jsdoc_new_class: 
+    if:  
+        - {{ is.javascript and is.new }} 
+        - {{ source.diff.files | matchDiffLines(regex=r/\/*\*([\s\S]*?)\//) | nope }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing JSDoc"
+          color: {{ colors.yellow }}
+      - action: request-changes@v1
+        args: 
+          comment: | 
+            JSDoc is required for all JavaScript classes. Please add JSDoc to all new classes in this PR.
+
+is:
+    javascript: {{ files | extensions | match(list=['js', 'ts']) | every }}
+    new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}
+
+colors:
+  yellow: 'fbca04'
+

Special thanks to Boemo W Mmopelwa for help with these examples.

\ No newline at end of file diff --git a/integrations/launch-darkly/index.html b/integrations/launch-darkly/index.html new file mode 100644 index 00000000..050e237a --- /dev/null +++ b/integrations/launch-darkly/index.html @@ -0,0 +1,29 @@ + Integrate gitStream with Launch Darkly - gitStream Documentation

Integrate gitStream with Launch Darkly

Label Launch Darkly Feature Flags

Automatically label code that contians specified feature flags.

Label PRs Based on Feature Flags

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+
+  {% for item in feature_flags %}
+  label_ff_launchdarkly_{{ item.name }}:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/var flagValue = ldclient/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ item.name }}
+          color: {{ colors.yellow }}
+  {% endfor %}
+
+feature_flags:
+   - name: engineering_rollback_plan_activated 
+     regex: r/engineering_rollback_plan_activated/
+   - name: marketing_premium_plan_features_unlocked 
+     regex: r/marketing_premium_plan_features_unlocked/
+   - name: mobile_push_notifications_enabled
+     regex: r/mobile_push_notifications_enabled/
+
+colors:
+  yellow: 'ffb300'   
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/linearb/index.html b/integrations/linearb/index.html new file mode 100644 index 00000000..c64bd919 --- /dev/null +++ b/integrations/linearb/index.html @@ -0,0 +1,141 @@ + Integrate gitStream with LinearB - gitStream Documentation

Integrate gitStream with LinearB

LinearB is a software delivery management platform that makes it easy to benchmark your engineering organization, track engineering metrics and identify opportunities for improvement.

Track the Impact of Generative AI Initiatives

These examples show how to label PRs that are assisted by GitHub Copilot so you can easily track productivity within LinearB. These examples can be adapted for any other generative AI solutions you might use.

Track Copilot Initiatives in LinearB

Automatically apply labels to PRs that are assisted by GitHub Copilot. You can apply labels based on a known list of Copilot users, PR tags, or by prompting the PR author to indicate if they used Copilot.

Prompt PR authors to indicate if they used Copilot for the PR and automatically label the PR if they did. This requires two separate automation files to handle posting the prompt and labeling accordingly.

Label Copilot by Prompt

Configuration Description

Conditions:

  • A PR is created

Automation Actions:

  • Post a comment prompting the author to indicate if Copilot assisted the author with writing the code in the PR.

Ask the PR author about Copilot usage.

-*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - pr_created
+
+automations:
+  comment_copilot_prompt:
+    # Post a comment for all PRs to prompt the PR author to indicate whether they used Copilot to assist coding in this PR
+    if:
+      - true
+    run:
+      - action: add-comment@v1
+        args:
+          comment: |
+            Please mark whether you used Copilot to assist coding in this PR
+
+            - [ ] Copilot Assisted
+            - [ ] Not Copilot Assisted
+

Configuration Description

Conditions:

  • A PR is updated or merged where the author indicates they used Copilot via a prompt.

Automation Actions:

  • Apply a 🤖 Copilot label to the PR

Label PRs where the user indicated Copilot usage

-*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  # You should use this automation in conjunction with comment_copilot_prompt.cm
+  label_copilot_pr:
+    # If the PR author has indicated that they used Copilot to assist coding in this PR, 
+    # apply a label indicating the PR was supported by Copilot
+    if:
+      - {{ pr.comments | filter(attr='commenter', term='gitstream-cm') | filter (attr='content', regex=r/\- \[x\] Copilot Assisted/) | some}}
+    run:
+      - action: add-label@v1
+        args:
+          label: '🤖 Copilot'
+

Automatically apply labels to PRs that are created by known users of generative AI coding tools.

Label by Contributors

Configuration Description

Conditions:

  • The PR author is one of a specified list of contributors

Automation Actions:

  • Apply a 🤖 Copilot label to the PR

Label by Contributors

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_genai:
+    # For all PRs authored by someone who is specified in the genai_contributors list
+    if:
+      - {{ pr.author | match(list=genai_contributors) | some  }}
+    # Apply a label indicating the user has adopted Copilot
+    run:
+      - action: add-label@v1
+        args:
+          label: '🤖 Copilot'
+
+genai_contributors:
+  - username1
+  - username2
+  - etc
+

Look for a specific tag in the PR title, description, comments or commit messages and if found add a label to the PR

Label Copilot by Tag

Configuration Description

Conditions:

  • The #copilot# tag is found in any of the PR title, description, comments or commit messages for commits in the PR

Automation Actions:

  • Apply a 🤖 Copilot label to the PR

Label Copilot by Tag

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+on:
+  - comment_added
+  - commit
+  - pr_created
+
+automations:
+  label_copilot:
+    # Detect PRs that contain the text '#copilot#' in the title, description, comments, or commit messages
+    if:
+      - {{ copilot_tag.pr_title or copilot_tag.pr_desc or copilot_tag.pr_comments or copilot_tag.commit_messages  }}
+    # Apply a label indicating the user has adopted Copilot
+    run:
+      - action: add-label@v1
+        args:
+          label: '🤖 Copilot'
+
+copilot_tag:
+  pr_title: {{ pr.title | includes(regex=r/#copilot#/) }}
+  pr_desc: {{pr.description | includes(regex=r/#copilot#/) }}
+  pr_comments: {{ pr.comments | map(attr='content') | match(regex=r/#copilot#/) | some }}
+  commit_messages: {{ branch.commits.messages | match(regex=r/#copilot#/) | some }}
+

Label Changes to Track in LinearB

These examples show how to label PRs based on the changed code so you can more easily compare metrics across languages, frameworks, changed directories, and more.

Track Copilot Initiatives in LinearB

Automatically label PRs to indicate what resources are being changed.

Label Modified Resources

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Apply labels based on the branch name or modified resources.

Label Modified Resources

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in labels %}
+  label_resource_{{ item.name }}:
+      if:
+        -{{ branch.name | includes(regex=item.branch) or files | match(list=item.resources) }}
+      run:
+        - action: add-label@v1
+          args:
+            label: {{ item.name }}
+  {% endfor %}
+
+labels:
+  - name: Core
+    resources:
+    - src/app
+    branch: r/^core-/
+  - name: mobile
+    resources:
+    - src/android
+    - src/ios
+    branch: r/^mobile-/
+

Automatically detect which programming languages are contained in PRs and automatically label the PRs appropriately.

Label PRs by Language

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Label the PR for each programming language that is included.

Label PRs by Language

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in labels %}
+  label_{{ item.name }}_pr:
+      if:
+        - {{ files | match(regex=item.resources) | some }}
+      run:
+        - action: add-label@v1
+          args:
+            label: '{{ item.name }}'
+  {% endfor %}
+
+labels:
+  - name: Java
+    resources: r/.java$/
+  - name: Rust
+    resources: r/.rs$/
+  - name: HTML
+    resources: r/.html$/
+  - name: JavaScript
+    resources: r/.js$/
+  - name: Python
+    resources: r/.py$/
+  - name: Golang
+    resources: r/.go$/
+  - name: Ruby
+    resources: r/.rb$/
+  - name: CSS
+    resources: r/.css/
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/orca-security/index.html b/integrations/orca-security/index.html new file mode 100644 index 00000000..6d854c2c --- /dev/null +++ b/integrations/orca-security/index.html @@ -0,0 +1,52 @@ + Integrate gitStream with Orca Security - gitStream Documentation

Integrate gitStream with Orca Security

Auto-Label Orca Security Scan Results

Automatically apply labels to PRs that indicate the result of Orca Security scans.

Required gitStream Plugin

This example requires you to install the extractOrcaFindings plugin.

Learn more about gitStream plugins.

Auto-Label Orca Scan ResultsAuto-Label Orca Scan Results

Configuration Description

Conditions (all must be true):

  • Orca Security detects one or more issues with the code in the PR.

Automation Actions:

  • Apply a label that indicates which issue was identified.

Auto-Label Orca Scan Results

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in reports %}
+  label_orca_{{ item.name }}:
+    if:
+      - {{ item.count > 0 }}
+    run:
+      - action: add-label@v1
+        args:
+          label: 'orca:{{ item.name }}'
+  {% endfor %}
+
+orca: {{ pr | extractOrcaFindings }}
+
+reports:
+  - name: introduced-cves
+    count: {{ orca.vulnerabilities.count }}
+  - name: iac-misconfigurations
+    count: {{ orca.infrastructure_as_code.count }}
+  - name: exposed-secrets 
+    count: {{ orca.secrets.count }}
+
+colors:
+  red: 'b60205'
+

Require Security Review for Orca Violations

Automatically require review from your SecOps team for Orca Security violations in pull requests.

Review Orca Security Alerts Review Orca Security Alerts Review Orca Security Alerts Review Orca Security Alerts

Configuration Description

Conditions (all must be true):

  • The PR contains a vulnerability, IAC problem, or secret that is flagged as High or Medium.

Automation Actions:

  • Require review from your organization's security team.
  • Post a comment explaining the requirement.

Review Orca Security Alerts

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+automations:
+  review_orca_alerts:
+    if:
+      - {{ has.vulnerability or has.iac_violation or has.secret }}
+    run:
+      - action: require-reviewers@v1
+        args:
+          reviewers: [my-organization/security-team]
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR requires additional review because it fails to meet Orca Security safe code standards.
+
+orca: {{ pr | extractOrcaFindings }}
+
+has:
+  vulnerability: {{ orca.vulnerabilities.priority == 'High' or orca.vulnerabilities.priority == 'Medium' }}
+  iac_violation: {{ orca.infrastructure_as_code.priority == 'High' or orca.infrastructure_as_code.priority == 'Medium' }}
+  secret: {{ orca.secrets.priority == 'High' or orca.secrets.priority == 'Medium' }}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/python/python-testing-automations/index.html b/integrations/python/python-testing-automations/index.html new file mode 100644 index 00000000..995486ff --- /dev/null +++ b/integrations/python/python-testing-automations/index.html @@ -0,0 +1 @@ + Python Testing Automations - gitStream Documentation
\ No newline at end of file diff --git a/integrations/rdoc/index.html b/integrations/rdoc/index.html new file mode 100644 index 00000000..2d2d6ee8 --- /dev/null +++ b/integrations/rdoc/index.html @@ -0,0 +1,88 @@ + Integrate gitStream with RDoc - gitStream Documentation

Integrate gitStream with RDoc

Integrate gitStream with RDoc: a documentation generation framework for Ruby.

Review RDoc Changes

Approve PRs that only contain changes to RDoc and assign optional reviewers.

Review RDoc

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to RDoc content.

Automation Actions:

  • Assign the org/tech-writers team for optional review.
  • Apply a green 📓 RDoc Only label
  • Approve the PR

Review RDoc

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_rdoc:
+    if:
+      - {{ source.diff.files | match(attr='diff', regex=r/^[\s\t]*#.*/) | every }}
+    run:
+      - action: add-label@v1
+        args:
+            label: "📓RDoc Only"
+            color: {{ colors.green }}
+      - action: add-reviewers@v1
+        args:
+          reviewers: [org/tech-writers]
+      - action: approve@v1
+
+colors:
+  green: '0e8a16'
+

Enforce RDoc Requirements for New Classes

Require RDoc for all new Ruby classes.

Enforce RDoc for New Ruby Classes

Configuration Description

Conditions (all must be true):

  • The PR creates a new Ruby class.
  • The PR lacks RDoc content.

Automation Actions:

  • Request changes and post a comment explaining that RDoc is required
  • Apply a yellow ⚠️ Missing RDoc label.

Enforce RDoc for New Ruby Classes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_rdoc_new_class: 
+    if:  
+      - {{ is.rb and is.new }} 
+      - {{ source.diff.files | match(attr='diff', regex=r/(\#.*\n.*)*def/) | nope }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing RDoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+            RDoc is required for all Ruby classes. Please add documentation for this PR.
+
+is:
+    rb: {{ files | extensions | match(regex=r/rb/) | every }}
+    new: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}
+
+colors:
+  yellow: 'fbca04'
+

Review RDoc for Large changes

Require more extensive reviews for large Ruby changes that lack RDoc updates.

Review RDoc for Large changes

Configuration Description

Conditions (all must be true):

  • The PR changes more than 150 lines of Ruby code.

Automation Actions:

  • Post a comment asking the author to review all relevant RDoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow ⚠️ Missing RDoc Label

Review RDoc

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  #Require more extensive reviews for large Ruby changes that lack RDoc updates.
+  review_rdoc_large:
+    if:
+      - {{ changes.additions > 150}}
+      - {{ source.diff.files | matchDiffLines(regex=r/(\#.*\n.*)*def/) | nope }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing RDoc"
+          color: {{ colors.yellow }}
+      - action: add-comment@v1
+        args: 
+          comment: | 
+              This PR makes major changes to Ruby methods, but is missing updates to RDoc. Please double check for any necessary RDoc updates.
+      - action: add-reviewers@v1
+        args:
+          reviewers: [fourth-organization/tech-writers]
+
+changes:
+  # Sum all the lines added/edited in the PR
+  additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
+
+
+colors:
+  yellow: 'fbca04'
+

Review RDoc For Function Parameter Changes

Warn PR authors when they change Ruby function or constructor input parameters without updating RDoc content.

Review RDoc Input Parameters

Configuration Description

Conditions (all must be true):

  • The PR changes one or more input parameters in Ruby methods.
  • The PR lacks RDoc updates.

Automation Actions:

  • Post a comment warning the user to review the method’s RDoc to identify necessary updates.

Review RDoc Input Parameters

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  review_rdoc_input: 
+    if:  
+      - {{ source.diff.files | match(attr='diff', regex=r/(\#.*\n.*)*def/) | nope }}
+      - {{ source.diff.files | match(attr='diff', regex=r/def.*\(.*\)/ | some }}
+    run:
+    - action: add-comment@v1
+      args: 
+        comment: | 
+            This PR modifies method input parameters, but is missing RDoc changes. Please check to ensure no RDoc changes are necessary.
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

\ No newline at end of file diff --git a/integrations/renovate/index.html b/integrations/renovate/index.html new file mode 100644 index 00000000..3ce1045c --- /dev/null +++ b/integrations/renovate/index.html @@ -0,0 +1,49 @@ + Integrate gitStream with Mend Renovate - gitStream Documentation

Integrate gitStream with Mend Renovate

Auto-Merge Renovate Dependency Updates

Auto-merge Renovate PRs

Required gitStream Plugins

This example requires you to install the extractRenovateVersionBump, compareMultiSemver and compareSemver plugins.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • The PR author is Renovate.
  • The branch name includes 'renovate'
  • The dependency change is a patch or minor update.

Automation Actions:

  • Approve the PR
  • Apply an approved-renovate label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

manifest:
+  version: 1.0
+
+automations:
+  merge_renovate_minor:
+    if:
+      - {{ bump == 'minor' }}
+      - {{ branch.name | includes(term="renovate") }}
+      - {{ branch.author | includes(term="renovate") }}
+    run:
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Renovate `minor` version bumps are approved automatically.
+
+  merge_renovate_minor_patch:
+    if:
+      - {{ bump == 'patch' }}
+      - {{ branch.name | includes(term="renovate") }}
+      - {{ branch.author | includes(term="renovate") }}
+    run:
+      - action: approve@v1
+      - action: merge@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            Renovate `patch` version bumps are approved and merged automatically.
+
+bump: {{ pr.description | extractRenovateVersionBump | compareMultiSemver }}
+

Configuration Description

Conditions (all must be true):

  • The PR author is Renovate.
  • The branch name includes 'renovate'

Automation Actions:

  • Approve the PR
  • Apply an approved-renovate label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_renovate:
+    if:
+      - {{ branch.author | includes(term="renovate") }}
+    run:
+      - action: approve@v1
+      - action: add-label@v1
+        args:
+          label: "approved-renovate"
+      - action: merge@v1
+        args:
+          wait_for_all_checks: true
+          squash_on_merge: true
+

\ No newline at end of file diff --git a/integrations/review-todo-comments/index.html b/integrations/review-todo-comments/index.html new file mode 100644 index 00000000..c3ce7823 --- /dev/null +++ b/integrations/review-todo-comments/index.html @@ -0,0 +1,13 @@ + Automation - Review TODO Comments - gitStream Documentation

Automation - Review TODO Comments

Review TODO Comments

Request changes for a PR that contains a TODO statement.

Review TODO Comments

Configuration Description

Conditions (all must be true):

  • The PR contains a TODO statement

Automation Actions:

  • Request changes and post a comment explaining why.

Review TODO Comments

manifest:
+  version: 1.0
+
+automations:
+  review_todo_comments:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/^[+].*(TODO|todo)/) | some }}
+    run:
+      - action: request-changes@v1
+        args:
+          comment: |
+            This PR contains a TODO statement. Please check to see if they should be removed.
+

Special thanks to Boemo W Mmopelwa for providing these examples.

\ No newline at end of file diff --git a/integrations/ruby/ruby-testing-automations/index.html b/integrations/ruby/ruby-testing-automations/index.html new file mode 100644 index 00000000..faf2d3c1 --- /dev/null +++ b/integrations/ruby/ruby-testing-automations/index.html @@ -0,0 +1 @@ + Ruby Testing Automations - gitStream Documentation
\ No newline at end of file diff --git a/integrations/shortcut/index.html b/integrations/shortcut/index.html new file mode 100644 index 00000000..33e8de28 --- /dev/null +++ b/integrations/shortcut/index.html @@ -0,0 +1,65 @@ + Integrate gitStream with Shortcut - gitStream Documentation

Integrate gitStream with Shortcut

Learn how to integrate gitStream with Shortcut

Label Missing Shortcut Info

Automatically label PRs that are missing references to Shortcut resources.

Label Missing Shortcut

Configuration Description

Conditions (all must be true):

  • The PR is missing one of the following:
    • An Shortcut ticket reference in the PR title.
    • A link to an Shortcut resource in the PR description.

Automation Actions:

  • Apply a red ⚠️ Missing Shortcut Link label
  • Post a comment that asks the author to add an Shortcut reference to the PR.

Label Missing Shortcut

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  label_missing_shortcut:
+    if:
+      - {{not (has.shortcut.ticket_in_title or has.shortcut.ticket_in_desc)}}
+    run:
+      - action: add-label@v1
+        args:
+          label: "⚠️ Missing Shortcut Link"
+          color: {{ colors.red }}
+      - action: add-comment@v1
+        args:
+          comment: Please provide a link to the associated Shortcut resource.
+
+has:
+  shortcut:
+    ticket_in_title: {{ pr.title | includes(regex=r/(\w+)\/sc-(\d+)/) }}
+    ticket_in_desc: {{ pr.description | includes(regex=r/(app\.shortcut\.com)\/(\w+)\/story\/(\d+)\/(\w+)/) }}
+
+colors:
+  red: 'b60205'
+

Provide automatic links to Shortcut tasks that are associated with PRs.

Automatically Link to the Related Shortcut Task

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Shortcut card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Shortcut Task.

Automatically Link to the Related Shortcut Task

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+# Configure these to match your organization.
+provider: jira
+
+# Change this to match the name of your Shortcut organization. This is used in tracker.shortcut.baseurl
+orgName: org
+
+{% set ticketid = "" %}
+{% for ticket in tickets %}
+{% if (ticket | includes(regex=r/.+/)) %}
+{% set ticketid = ticket %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  link_shortcut:
+    if:
+      - {{ has.ticket_in_title or has.ticket_in_branch }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})
+
+has:
+  ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}
+  ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}
+
+tracker:
+  shortcut:
+    baseurl: https://app.shortcut.com/[orgName]/story/
+    pattern: r/(\w+)\/sc-(\d+)/
+
+tickets:
+  - {{branch.name | capture(regex=tracker[provider].pattern)}}
+  - {{pr.title | capture(regex=tracker[provider].pattern)}}
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/slack/index.html b/integrations/slack/index.html new file mode 100644 index 00000000..0c7a4727 --- /dev/null +++ b/integrations/slack/index.html @@ -0,0 +1,61 @@ + Integrate gitStream with Slack - gitStream Documentation

Integrate gitStream with Slack

This page demonstrates uses cases for how to connect gitStream to Slack to post messages via webhooks.

Prerequisite Configurations

To use gitStream with Slack, you first need to do two things:

  1. Create a Slack app with incoming webhooks enabled.
  2. Provide your Slack webhook URL to gitStream as an organization environment variable.

Setup Incoming Webhooks in Slack

Follow this tutorial to configure your Slack instance to receive webhooks from gitStream.You’ll end up with a webhook URL like this:

https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
+

Your webhook URL is secret information!

Slack webhook URLs allow anyone with access to the URL to post to the channel its configured for. Do not publish this URL to public locations.

Configure Environment Variable

gitStream can access GitHub orgnization secrets as environment variables, and you'll need to do this to provide gitStream with access to your Slack webhook URL.

  1. Create an organization secret in GitHub and ensure it isn't being overridden by a repo-level secret of the same name.
  2. Pass the organization secret to gitStream as an environment variable in your gitstream.yml workflow file. We recommend using an easy to understand term like SLACK_WEBHOOK_CHANNEL_NAME.

How to Send Slack Messages From gitStream

Example

To send Slack messages from gitStream, use the send-slack-message automation action, and pass the value you stored your Slack webhook URL to the webhook_url argument.

automations:
+send_slack:
+    if:
+    - true
+    run:
+    - action: send-slack-message@v1
+        args:
+        message: "A message sent from GitStream!"
+        webhook_url: "{{ env.SLACK_WEBHOOK }}"
+

Auto-Recognition For Meeting Team Goals

A good choice to reward developers for submitting great PRs would be to automate a Slack message that gives the developer recognition among their colleagues. To do this, you’ll need to create a Slack webhook that sends to a channel full of reviewers, managers, and anybody else who should see the recognition.

Automatic Slack Recognition

Automatically post positive recognition messages in Slack for well-structured PRs.

Automatic Slack Messages

Configuration Description

Conditions (all must be true):

  • The PR contains updates to tests.
  • The PR has fewer than 5 modified files.
  • The PR branch references a Jira ticket.
  • The PR has fewer than 150 lines of code changed.

Automation Actions:

  • Post a Slack message that automatically recognizes the PR author and provides a link to the PR.

Automatic Slack Messages

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  slack_auto_recognition:
+    if:
+        - {{ files | match(regex=r/(test|spec)/) | some }} # this pr has at least 1 test
+        - {{ files | length <= 5 }} # this pr has 5 or less files
+        - {{ branch.name | includes(regex=r/[A-Z]{2,}-\d+.*/) }} # this branch has the Jira ticket prefix
+        - {{ branch.diff.size <= 150 }} # this branch has 150 lines of code or less changed
+    run:
+        - action: send-slack-message@v1
+          args:
+            webhook_url: "{{ env.SLACK_WEBHOOK }}"
+            message: ":tada: Congrats to {{ pr.author }} for the amazing new PR, '{{ pr.title }}'! Check it out at https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+

Message Specific Teams Based on PR content

You can also use the Slack integration to automatically keep in touch with code owners and others who should be connected to the PR. You could check for certain conditions that require a more personal review from an experienced maintainer, like:

On the other hand, some PRs might not have anything wrong, but still need to be assigned to a certain team based on expertise. In that case, you could set up several Slack automation actions at once, all with different webhooks and conditions. In an organization with different secrets for Slack webhooks to the #security-team channel, the #qa-team channel, and the #docs-team channel.

Send Slack Notifications

Automatically send Slack notifications to specific channels based on the contents of a pull request.

Send Slack Notifications

Configuration Description

Conditions (all must be true):

  • The PR meets one or more of the specified trigger criteria for Slack notifications.

Automation Actions:

  • Post a Slack message based on the contents of the PR.

Send Slack Notifications

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  send_slack_security:
+    # use your custom logic here to determine whether this needs a security review
+    if:
+      - true
+    run:
+      - action: send-slack-message@v1
+        args:
+          webhook_url: "{{ env.SLACK_WEBHOOK_SECURITY }}"
+          message: "A PR requires a security review. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+  send_slack_qa:
+    # use your custom logic here to determine whether this needs a qa review
+    if:
+      - {{ not (files | match(regex=r/(test|spec)/) | some) }}
+    run:
+      - action: send-slack-message@v1
+        args:
+          webhook_url: "{{ env.SLACK_WEBHOOK_QA }}"
+          message: "A PR was submitted without tests. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+  send_slack_docs:
+    # use your custom logic here to determine whether this needs a docs review
+    if:
+      - {{ files | match(regex=r/(docs)/) | some }}
+    run:
+      - action: send-slack-message@v1
+        args:
+          webhook_url: "{{ env.SLACK_WEBHOOK_DOCS }}"
+          message: "A PR has modified the docs. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+

Using this template and custom logic specific to your company, you can build a complete repo management system that gets the right people actively involved by pinging them where they are in Slack.

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/snyk/index.html b/integrations/snyk/index.html new file mode 100644 index 00000000..19235ff7 --- /dev/null +++ b/integrations/snyk/index.html @@ -0,0 +1,19 @@ + Integrate gitStream with Snyk - gitStream Documentation

Integrate gitStream with Snyk

Auto-Merge Snyk Dependency Updates

Approve PRs from Snyk

Approve and Merge Snyk Changes

Configuration Description

Conditions (all must be true):

  • The PR author is Snyk.

Automation Actions:

  • Approve the PR
  • Apply an approved-snyk label to the PR
  • Merge the PR if all status checks pass.

Approve Snyk

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_snyk:
+    if:
+      - {{ branch.author | includes(term="snyk") }}
+    run:
+      - action: approve@v1
+      - action: add-label@v1
+        args:
+          label: "approved-snyk"
+      - action: merge@v1
+        args:
+          wait_for_all_checks: true
+          squash_on_merge: true
+
\ No newline at end of file diff --git a/integrations/soc2/index.html b/integrations/soc2/index.html new file mode 100644 index 00000000..deead42f --- /dev/null +++ b/integrations/soc2/index.html @@ -0,0 +1,40 @@ + Use gitStream for SOC 2 compliance. - gitStream Documentation

Use gitStream for SOC 2 compliance.

gitStream policy-as-code makes it easy to implement workflow automations that help your team remain SOC 2 compliant during the code review process.

Flag Code That's Merged Without Review

Automatically send notifications to your team when code is merged without review.

Flag Code That's Merged Without Review

Slack Message

Configuration Description

Conditions (all must be true):

  • A PR is merged without at least one review.

Automation Actions:

  • Send a Slack notification to alert your team.
  • Apply a red DCF5-merged-without-review label.
  • Post a comment explaining SOC II requirements.

Flag Code That's Merged Without Review

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+on:
+  - merge
+
+# https://docs.gitstream.cm/automation-actions/#send-slack-message
+slack_webhook: {{ env.SLACK_WEBHOOK }}
+
+# Update security_team to match your organization
+security_team: 'my-org/app-sec'
+
+automations:
+  flag_merged_no_review:
+    if:
+      - {{ pr.approvals | length == 0 }}
+    run:
+      - action: add-label@v1
+        args:
+          label: "DCF5-merged-without-review"
+          color: {{ colors.red }}
+
+      - action: send-slack-message@v1
+        args:
+          message: "PR #{{ pr.number }} - {{ pr.title }} - was merged without peer reviews. SOC2 requires code reviews for every code change. _SOC2 ref: CC8.1_"
+          webhook_url: "{{ slack_webhook }}"
+
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR was merged without peer reviews. SOC2 requires code reviews for every code change.
+            _SOC2 ref: CC8.1_
+
+            @{{ security_team }}
+
+
+colors:
+  red: 'F6443B'
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

\ No newline at end of file diff --git a/integrations/sonar/index.html b/integrations/sonar/index.html new file mode 100644 index 00000000..012e0c18 --- /dev/null +++ b/integrations/sonar/index.html @@ -0,0 +1,109 @@ + Integrate gitStream with SonarCloud - gitStream Documentation

Integrate gitStream with SonarCloud

Included with gitStream Core Functionality

This integration is part of gitStream core functionality, and requires no additional configuration.

SonarCloud Examples:

Approve Sonar Clean Code

Approve Sonar Clean Code

Approve PRs that pass SonarCloud's quality gate.

Aprove Sonar Clean Code

Configuration Description

Conditions (all must be true):

  • SonarCloud reports an 'A' rating for vulnerabilities, bugs, security hotspots, and code smells.
  • There is no duplicated code.

Automation Actions:

  • Apply a Sonar: Clean Code label to the PR.
  • Approve the PR.
  • Post a comment that explains why the PR was approved.

Aprove Sonar Clean Code

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+automations:
+  approve_sonar_clean_code:
+    if:
+      - {{ sonar.bugs.rating == 'A' }}
+      - {{ sonar.code_smells.rating == 'A' }}
+      - {{ sonar.vulnerabilities.rating == 'A' }}
+      - {{ sonar.security_hotspots.rating == 'A' }}
+      - {{ sonar.duplications == null or sonar.duplications == 0 }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: '✅ Sonar: Clean Code'
+          color: {{ colors.green }}
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR passes the SonarCloud quality gate check and as been automatically approved.
+
+sonar: {{ pr | extractSonarFindings }}
+
+colors:
+  green: '0e8a16'
+

Label SonarCloud Quality Reports


Label SonarCloud Quality Reports

Label the number of bugs, vulnerabilities, security hotspots, and code smells reported by SonarCloud.

Label SonarCloud Quality Reports

Configuration Description

Conditions (all must be true):

  • There is at least one vulnerability, code smell, security hotspot, or bug reported by SonarCloud. Uses the extractSonarFindings filter function

Automation Actions:

  • Apply color-coded labels to indicate the number of vulnerabilities, code smells, security hotspots, and bugs.

Label SonarCloud Quality Reports

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  {% for item in reports %}
+  label_sonar_{{ item.name }}:
+    if:
+      - {{ item.count > 0}}
+    run:
+      - action: add-label@v1
+        args:
+          label: '{{ item.icon }} sonar:{{ item.name }}-{{ item.rating }}'
+          color: {{ colors.red if (item.rating == 'E' or item.rating == 'D') else (colors.orange if (item.rating == 'C' ) else colors.yellow) }}
+  {% endfor %}
+
+sonar: {{ pr | extractSonarFindings }}
+
+reports:
+  - name: vulnerabilities
+    count: {{ sonar.vulnerabilities.count }}
+    icon: 🔓
+    rating: {{ sonar.vulnerabilities.rating }}
+  - name: code smells
+    count: {{ sonar.code_smells.count }}
+    icon: ☣️
+    rating: {{ sonar.code_smells.rating }}
+  - name: security hotspots
+    count: {{ sonar.security_hotspots.count }}
+    icon: 🛡️
+    rating: {{ sonar.security_hotspots.rating }}
+  - name: bugs
+    count: {{ sonar.bugs.count }}
+    icon: 🪲
+    rating: {{ sonar.bugs.rating }}
+
+colors:
+  red: 'b60205'
+  orange: 'd93f0b'
+  yellow: 'fbca04'
+

Review Sonar Duplications

Review Sonar Duplications

Request changes when Sonar reports an excessive level of duplicated code.

Review Sonar Duplications

Configuration Description

Conditions (all must be true):

  • The PR contains more than 3% duplicated code.

Automation Actions:

  • Apply a label that indicates how much duplicated code Sonar detected.
  • Request changes and post a comment explaining why.

Review Sonar Duplications

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+automations:
+  review_sonar_duplications:
+    if:
+      - {{ sonar.duplications > 3 }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'Sonar: {{ sonar.duplications}}% duplication'
+          color: {{ colors.yellow }}
+      - action: request-changes@v1
+        args:
+          comment: |
+            Sonar reports an excessive level of code duplication. Please consider refactoring your PR to reduce duplications.
+
+sonar: {{ pr | extractSonarFindings }}
+
+colors:
+  yellow: 'fbca04'
+

Review Sonar Security Alerts

Review Sonar Security Alerts

Require additional reviews for Sonar security alerts. gitStream will remove this requirement if the alerts are resolved.

Review Sonar Security Alerts

Configuration Description

Conditions (all must be true):

  • The SonarCloud quality gate check fails to pass for code smells, vulnerabilities, or security hotspots.

Automation Actions:

  • Require a review from the my-organization/security-team team. Customize this to match your organization.
  • Post a comment explaining why this PR requires additional review.

Review Sonar Alerts

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+automations:
+  review_sonar_alerts:
+      if:
+        - {{ sonar.code_smells.rating != 'A' or sonar.vulnerabilities.rating != 'A' or sonar.security_hotspots.rating != 'A'}}
+      run:
+        - action: require-reviewers@v1
+          args:
+            reviewers: [my-organization/security-team]
+        - action: add-comment@v1
+          args:
+            comment: |
+              This PR requires additional review because it fails to meet SonarCloud clean code standards.
+
+sonar: {{ pr | extractSonarFindings }}
+
\ No newline at end of file diff --git a/integrations/swimm/index.html b/integrations/swimm/index.html new file mode 100644 index 00000000..f708cdad --- /dev/null +++ b/integrations/swimm/index.html @@ -0,0 +1,22 @@ + Integrate gitStream with Swimm - gitStream Documentation

Integrate gitStream with Swimm

Approve Swimm Changes

Approve Swimm Changes

Approve changes that only affect Swimm documentation.

Approve Swimm Changes

Configuration Description

Conditions (all must be true):

  • The PR only affects files that end in a .swm extension.

Automation Actions:

  • Add a swimm-docs-only label
  • Approve the PR
  • Post a comment that explains that this is a Swimm docs change only.

Approve Swimm Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  approve_swimm_changes:
+    # Triggered for any changes to Swimm documentation
+    if:
+      - {{ branch.diff.files_metadata | match(attr='file', regex=r/\.swm\//) | every }}
+    # Apply a swimm-docs-only label, approve the PR and explain why in a comment.
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'swimm-docs-only'
+      - action: approve@v1
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR is considered a safe change as it only affects Swimm Docs. 
+            It has been automatically approved.
+

Special thanks to Omerr for providing this example.

\ No newline at end of file diff --git a/integrations/teams/index.html b/integrations/teams/index.html new file mode 100644 index 00000000..c04fa5a8 --- /dev/null +++ b/integrations/teams/index.html @@ -0,0 +1,70 @@ + Integrate gitStream with Microsoft Teams - gitStream Documentation

Integrate gitStream with Microsoft Teams

This page demonstrates uses cases for how to connect gitStream to Microsoft Teams to post messages via webhooks.

Prerequisite Configurations

To use gitStream with MS Teams, you first need to do two things:

  1. Create an incoming webhook in Teams.
  2. Provide your Teams webhook URL to gitStream as an organization environment variable.

Set Up Incoming Webhooks in Teams

Microsoft Teams can accept incoming webhooks to send fully-featured messages to channels and individuals. Here’s the complete tutorial from Microsoft.

Here is an overview of the process:

Step 1: Add the Incoming Webhook connector inside MS Teams.

Untitled

Step 2: Give it a name and an image so your teammates can identify it easily and click create.

Untitled

Once created, copy the webhook URL, you'll need this in the next step.

Your webhook URL is secret information!

Teams webhook URLs allow anyone with access to the URL to post to the channel its configured for. Do not publish this URL to public locations.

Configure gitStream Environment Variable

gitStream can access GitHub orgnization secrets as environment variables, and you'll need to do this to provide gitStream with access to your Slack webhook URL.

  1. Create an organization secret in GitHub and ensure it isn't being overridden by a repo-level secret of the same name.
  2. Pass the organization secret to gitStream as an environment variable in your gitstream.yml workflow file. We recommend using an easy to understand term like MS_TEAMS_WEBHOOK_CHANNEL_NAME.

Untitled

How to Send Microsoft Teams Messages From gitStream

Example

To send Teams messages from gitStream, use the send-http-request automation action and pass the value you stored your webhook URL to the url argument.

automations:
+send_teams_message:
+    if:
+    - true
+    run:
+    - action: send-http-request@v1
+        args:
+        method: "POST"
+                    headers: '{"Content-type": "application/json"}'
+        url: "{{ env.MS_TEAMS_WEBHOOK }}"
+                    body: '{"text": "Hello, world!"}'
+

Auto-Recognition For Meeting Team Goals

A good choice to reward developers for submitting great PRs would be to automate an MS Teams message that gives the developer recognition among their colleagues. To do this, you’ll need to create a MS Teams webhook that sends to a channel full of reviewers, managers, and anybody else who should see the recognition.

Automatic MS Teams Recognition

Automatically post positive recognition messages in MS Teams for well-structured PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains updates to tests.
  • The PR has fewer than 5 modified files.
  • The PR branch references a Jira ticket.
  • The PR has fewer than 150 lines of code changed.

Automation Actions:

  • Post an MS Teams message that automatically recognizes the PR author and provides a link to the PR.

Automatic MS Teams Notifications

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  teams_auto_recognition:
+    if:
+      - {{ files | match(regex=r/(test|spec)/) | some }} # this pr has at least 1 test
+      - {{ files | length <= 5 }} # this pr has 5 or less files
+      - {{ branch.name | includes(regex=r/[A-Z]{2,}-\d+.*/) }} # this branch has the Jira ticket prefix
+      - {{ branch.diff.size <= 150 }} # this branch has 150 lines of code or less changed
+    run:
+      - action: send-http-request@v1
+        args:
+          method: "POST"
+          headers: '{"Content-type": "application/json"}'
+          url: "{{ env.MS_TEAMS_WEBHOOK }}"
+          body: '{"text": "Congrats to {{ pr.author }} for the amazing new PR, {{ pr.title }}! Check it out at https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}'
+

Message Specific Teams Based on PR content

You can also use the Slack integration to automatically keep in touch with code owners and others who should be connected to the PR. You could check for certain conditions that require a more personal review from an experienced maintainer, like:

On the other hand, some PRs might not have anything wrong, but still need to be assigned to a certain team based on expertise. In that case, you could set up several Teams automation actions at once, all with different webhooks and conditions. In an organization with different secrets for Teams webhooks to the #security-team channel, the #qa-team channel, and the #docs-team channel.

MS Teams Channels Notifications

Automatically send Slack notifications to specific channels based on the contents of a pull request.

Configuration Description

Conditions (all must be true):

  • The PR meets one or more of the specified trigger criteria for MS Teams notifications.

Automation Actions:

  • Post an MS Teams message based on the contents of the PR.

Automatically Notify MS Teams Channels

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  send_teams_security:
+    if:
+      # use your custom logic here to determine whether this needs a security review
+      - true
+    run:
+      - action: send-http-request@v1
+        args:
+          method: "POST"
+          headers: '{"Content-type": "application/json"}'
+          url: "{{ env.MS_TEAMS_WEBHOOK_SECURITY }}"
+          body: '{"text": "A PR requires a security review. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}'
+  send_teams_qa:
+    if:
+      # use your custom logic here to determine whether this needs a qa review
+      - {{ not (files | match(regex=r/(test|spec)/) | some) }}
+    run:
+      - action: send-http-request@v1
+        args:
+          method: "POST"
+          headers: '{"Content-type": "application/json"}'
+          url: "{{ env.MS_TEAMS_WEBHOOK_QA }}"
+          body: '{"text": "A PR was submitted without tests. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}'
+  send_teams_docs:
+    if:
+      # use your custom logic here to determine whether this needs a docs review
+      - {{ files | match(regex=r/(docs)/) | some }}
+    run:
+      - action: send-http-request@v1
+        args:
+          method: "POST"
+          headers: '{"Content-type": "application/json"}'
+          url: "{{ env.MS_TEAMS_WEBHOOK_DOCS }}"
+          body: '{"text": "A PR has modified the docs. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"}'
+

Using this template and custom logic specific to your company, you can build a complete repo management system that gets the right people actively involved by pinging them where they are in Teams.

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/terraform/index.html b/integrations/terraform/index.html new file mode 100644 index 00000000..da8d946c --- /dev/null +++ b/integrations/terraform/index.html @@ -0,0 +1,128 @@ + Integrate gitStream with Terraform - gitStream Documentation

Integrate gitStream with Terraform

Terraform Examples:

Review Terraform Changes

title: Automation - Automatically assign infrastructure team for Terraform changes description: Require specific reviewers for Terraform module changes category: [quality, terraform] quickstart: false


Require Reviewers for Terraform changes

Automatically assign org/infrastructure team for reviewing changes when PR contains Terraform file changes.

Review Terraform Changes

Configuration Description

Conditions (all must be true):

  • The PR contains changes to one or more Terraform configuration files.

Automation Actions:

  • Require a review from the org/infrastructure team.

Review Terraform Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_terraform:
+    # Triggered for any changes to Terraform files
+    if:
+      - {{ files | match(regex=r/.*\.tf.*/) | some }}
+    # Assign infrastructure team as reviewer for change in Terraform files
+    run:
+      - action: require-reviewers@v1
+        args:
+          reviewers: [org/infrastructure]
+      - action: add-comment@v1
+        args:
+          comment: |
+            This PR affects Terraform configurations and requires a review from the Infra team.
+

Enforce Requirements for New Terraform Modules

title: Automation - Review Terraform Module Directory description: Enforce directory structure conventions for new Terraform module category: [quality, terraform] quickstart: false


Review New Terraform Modules

Request changes if a PR that creates a new Terraform module which do not conform to the required directory structure.

Review New Module

Configuration Description

Conditions (all must be true):

  • The PR creates a new Terraform module
    • A new sub-directory is created inside the /modules directory.
  • The PR lacks one or more required components from the list in the terraform custom expression.

Automation Actions:

  • Request changes and post a comment explaining the missing parts of the module.
  • Apply Label : ⚠️ Missing Terraform Components

Review New Module

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+{% set misslist = [] %}
+{% for pattern in terraform %}
+{% if (newfilesinpr | match(term=pattern) | nope) %}
+{% set misslist = misslist + [pattern+' '] %}
+{% endif %}
+{% endfor %} 
+
+automations:
+  review_new_terraform_module:
+    if: 
+      - {{misslist | match(regex=r/.*/) | some}}
+      - {{is.mainfile and is.mainfilenotinroot }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: |
+            New terraform modules must contain all required components before merging. Please update your PR with the required components and gitStream will automatically remove this comment once completed.
+
+            Here are the required components, {{misslist}} should be customized appropriately:
+            my_module/
+            ├── main.tf
+            ├── outputs.tf
+            ├── providers.tf
+      - action: add-label@v1
+        args:
+          label: '⚠️ Missing Terraform Components'
+          color: '#FFA500'
+
+resources:
+  module_directory: 'modules'
+terraform:
+  - main.tf
+  - outputs.tf
+  - providers.tf
+is:
+  mainfile: {{newfilesinpr | match(term = "main.tf") | some}}
+  mainfilenotinroot: {{source.diff.files | map(attr='original_file') | match(term = "main.tf") | nope }}
+newfilesinpr:
+  {{ branch.diff.files_metadata | map(attr='new_file')}}
+

Ensure Terraform Source URLs have version numbers

title: Automation - Review Terraform Module Imports description: Enforce Terraform modules use version when importing via URL source category: [quality, terraform] quickstart: false


Review Terraform Source Version

Ensure that all Terraform modules imported via a source URL specify a version.

Review Terraform Source Version

Configuration Description

Conditions (all must be true):

  • The PR contains a Terraform source declaration via URL that lacks a version reference.
  • The source is not included in a whitelist custom expression that defines one or more whitelisted source locations.

Automation Actions:

  • Request review changes on the PR with a comment explaining version number requirement.

Review Terraform Changes

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  review_terraform_source_version:
+    # Check if New Content contains a source URL, the URL is not part of allow list and lacks version reference
+    if: 
+      - {{ source.diff.files | match(attr='new_content', regex=r/source.*?=.*\".*(http|https).*\"/) | some }}
+      - {{ source.diff.files | match(attr='new_content', list=allowlist) | nope }}
+      - {{ source.diff.files | match(attr='new_content', regex=r/source.*?=.*\?ref=v.*/) | nope }}
+    run:
+      - action: request-changes@v1
+        args:
+          comment: |
+            You must reference a specific version when accessing Terraform module sources via URL, e.g. `?ref=v1.0.0`. Please update your Terraform files to follow this practice.
+
+allowlist:
+  - 'https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git'
+  - 'https://github.com/terraform-aws-modules/terraform-aws-vpc.git'
+  - 'https://github.com/terraform-aws-modules/terraform-aws-eks.git'
+

Ensure New Terraform Modules conform to a Naming Pattern

title: Automation - Review Terraform Module Name description: Enforce naming conventions in Terraform module changes category: [quality, terraform] quickstart: false


Review Terraform Module Name

Request changes if a PR creates a new Terraform module that is missing a required prefix or keyword in the name.

Review Terraform Source Version

Configuration Description

Conditions (all must be true):

  • The PR creates a new Terraform module.
  • The module name lacks a required name prefix, or one or more keywords.

Automation Actions:

  • Request review changes on the PR with a comment explaining the structure of module name.

Review Terraform Module Name

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+# Prefix Check Logic
+{% set prefixcheck = [] %}
+{% for pattern in terraform.prefixes %}
+{% if(newfilesinpr | match(term=module_location + pattern) | some) %}
+{% set prefixcheck = prefixcheck + [true]%}
+{% else %}
+{% set prefixcheck = prefixcheck + [false]  %}
+{% endif %}
+{% endfor %}
+
+automations:
+  review_new_terraform_module:
+    if: 
+      - {{is.mainfile and is.mainfilenotinroot}}
+      - {{module_name_checks.prefix or module_name_checks.keyword}}
+    run:
+      - action: request-changes@v1
+        args:
+          comment: |
+            Terraform module names must contain a required prefix and keyword:
+            * Prefixes: {{ terraform.prefixes }}
+            * Keywords: {{ terraform.keywords }}
+
+module_name_checks:
+  prefix: {{prefixcheck | match(term='true') | nope}}
+  keyword: {{newfilesinpr | match(list=terraform.keywords) | nope}}
+
+module_location: infrastructure/modules/
+terraform:
+  prefixes: ['aws', 'gcp', 'azure']
+  keywords: ['db', 'networking', 'security']
+
+is:
+  mainfile: {{newfilesinpr | match(term = "main.tf") | some}}
+  mainfilenotinroot: {{source.diff.files | map(attr='original_file') | match(term = "main.tf") | nope }}
+newfilesinpr:
+  {{ branch.diff.files_metadata | map(attr='new_file')}}
+
\ No newline at end of file diff --git a/integrations/unleash/index.html b/integrations/unleash/index.html new file mode 100644 index 00000000..98972f82 --- /dev/null +++ b/integrations/unleash/index.html @@ -0,0 +1,29 @@ + Integrate gitStream with Unleash - gitStream Documentation

Integrate gitStream with Unleash

Label Unleash Feature Flags

Automatically label code that contians specified feature flags.

Label PRs Based on Feature Flags

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+
+  {% for item in feature_flags %}
+  label_ff_unleash_{{ item.name }}:
+    if:
+      - {{ source.diff.files | matchDiffLines(regex=r/const notificationBadgeEnabled = useFlag/) | some }}
+      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}
+    run:
+      - action: add-label@v1
+        args:
+          label: {{ item.name }}
+          color: {{ colors.yellow }}
+  {% endfor %}
+
+feature_flags:
+   - name: engineering_rollback_plan_activated 
+     regex: r/engineering_rollback_plan_activated/
+   - name: marketing_premium_plan_features_unlocked 
+     regex: r/marketing_premium_plan_features_unlocked/
+   - name: mobile_push_notifications_enabled
+     regex: r/mobile_push_notifications_enabled/
+
+colors:
+  yellow: 'ffb300'   
+

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/integrations/zapier/index.html b/integrations/zapier/index.html new file mode 100644 index 00000000..748e0adc --- /dev/null +++ b/integrations/zapier/index.html @@ -0,0 +1,77 @@ + Integrate gitStream with Zapier - gitStream Documentation

Integrate gitStream with Zapier

Zapier is a workflow automation tool that connects to more than 7,000 apps and APIs and allows you to pass data between them using processes called Zaps. After something triggers the Zap, it’ll sequentially call the different pieces of your workflow.

Prerequisite Configurations

To use gitStream with Zapier, you first need to do two things:

  1. Create a Zap with incoming webhooks enabled.
  2. Provide your Zapier webhook URL to gitStream as an organization environment variable.

Setup Incoming Webhooks in Zapier

Premium Zapier Subscription Required.

As of December 2023, Zapier’s Incoming Webhooks app is only available to premium members.

Get started by signing into Zapier and clicking Create Zap:

Untitled

Then, select the trigger and find the latest version of the Webhooks by Zapier app:

Untitled

Choose Catch Hook (to pass JSON data from gitStream to Zapier), but don’t add any child key (so the root object you send is parsed by Zapier). Then copy the URL it gives you and proceed to the next step

Your webhook URL is secret information!

Zapier webhook URLs allow anyone with access to the URL to use it. Do not publish this URL to public locations.

Configure Environment Variable

gitStream can access GitHub orgnization secrets as environment variables, and you'll need to do this to provide gitStream with access to your Slack webhook URL.

  1. Create an organization secret in GitHub and ensure it isn't being overridden by a repo-level secret of the same name.
  2. Pass the organization secret to gitStream as an environment variable in your gitstream.yml workflow file. We recommend using an easy to understand term like ZAPIER_WEBHOOK.

You should now be ready to send data from gitStream to Zapier.

Export PR Data to Zapier

In your .cm file, you can include an automation that sends data to Zapier. Likely, you won’t be using exactly the workflow that we’re demonstrating here, but that’s alright; you can send any of the context variables in the body of the request for you to make use of in your Zap. It’s best practice to only send as much information as you need, so avoid sending unecessary data.

A Simple Zapier Example

This is an example of how to send data from gitStream to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends a webhook to Zapier that contains the PR number

Export PR Number to Zapier

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+automations:
+  zapier_export_pr_number:
+    if:
+      - true
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ ZAPIER_WEBHOOK }}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{ "pr_number":"{{ pr.number }}" }'
+

Store PR Data in a Table

Zapier can store data it gets from incoming webhooks in its internal database. In Zapier, click on the menu on the left side and select Tables. Then, create a new table called PRs with fields PR number, PR title, and PR URL, with types Number, Text, and Link respectively:

Untitled

Return to the home page and create a new Zap following the instructions above, with twos changes. First, the webhook should only be run when the PR is created. Notice the on condition in the new .cm file below. Also, you’ll notice the example sends additional data points. This could be any data you want; gitStream makes numerous useful resources available via context variables.

Storing PR Data in a Table

Export new PR titles, numbers, and URLs to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends the PR number, title, and URL to Zapier via webhook.

Export PR Number, Title, and URL to Zapier

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+  pr_url: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+
+on:
+    - pr_created
+
+automations:
+  zapier_export_pr_number_title_url:
+    if:
+      - true
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ ZAPIER_WEBHOOK }}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{ "pr_number":"{{ pr.number }}", "pr_title":"{{ pr.title }}", "pr_url":"{{ pr_url }}" }'
+

After the webhook triggers, use the Tables app in the Zap to create a new record in your PR table with the available data.

Untitled

Then, PRs will start showing up in the table as they’re created:

Untitled

Now, you can integrate this PR data into the rest of your workflow! You could expand on this, adding date and status information so that other applications could automatically injest this data.

Create Project Management Tasks From PRs

The next example follows similar conventions as the last, except this on includes the PR description instead of the number:

Create PM Tasks From PR Data

Export new PR titles, description, and URL to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends a webhook to Zapier that contains the PR title, description, and URL.

Create Project Management Tasks Via Zapier

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+pr_url: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+
+on:
+    - pr_created
+
+automations:
+  zapier_export_pr_description_title_url:
+    if:
+      - true
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ ZAPIER_WEBHOOK }}"
+          method: POST
+          headers: '{"Content-type": "application/json"}'
+          body: '{ "pr_description":"{{ pr.description }}", "pr_title":"{{ pr.title }}", "pr_url":"{{ pr_url }}" }'
+

Now, in the Zap,you can pass this data to Trello to create a new task on the QA board. First, add the Trello app, select the Create Card event, and connect your Trello account. Then, you can build the card according to the information from gitStream:

Untitled

This example puts the task in a the 'To Do" column of the QA tasklist to make it easy for QA engineers to take it from there. The title, description and URL are all formatted to fit into Trello.

Untitled

Automatically Schedule Sync Meetings

The next example can help if you're responsible for all the PR reviews that come in. You might want to schedule a synchronous group meeting for the last half hour of every day for all of that day’s PRs to be reviewed. Everyone assigned to review a PR that day is invited. gitStream and Zapier can help build those meetings, invite all the right people automatically, and skip the meeting altogether if it’s not necessary.

Start with this CM example:

Send PR Reviewer Info to Zapier

Automatically update Zapier with a list of PR reviewers.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • gitStream sends the list of reviewers to Zapier via webooks.

Auto-Schedule Sync Meetings via Zapier

# -*- mode: yaml -*-
+
+manifest:
+  version: 1.0
+
+pr_url: "https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}"
+
+automations:
+  zapier_export_pr_reviewers:
+    if:
+      - true
+    run:
+      - action: send-http-request@v1
+        args:
+          url: "{{ env.ZAPIER_WEBHOOK }}"
+          method: "POST"
+          headers: '{"Content-type": "application/json"}'
+          body: '{ "reviewers": "{{ pr.reviewers }}" }'
+

Then in Zapier, set up a Zap like this:

Screenshot 2023-12-19 at 15.21.03.png

In the second piece of the Zap, you can write JavaScript (or Python) to format whatever you get from gitStream. If you return an array of the reviewer usernames, Zapier will run the rest of the steps of the Zap *once per reviewer*, which is what you want. Zapier also has a built-in lookup table you can use, but this example will use a Google Sheet for simplicity.

Untitled

In the Find Event action of the Google Calendar app, search for the daily standup and create one if it doesn’t yet. If you set the new event not to repeat, then the standup will only be created when you have PRs to review. Just make sure the search term and the title of the new event match:

Untitled

Untitled

Lastly, search for the new calendar entry with the Add Attendee/s to Event action, and add the reviewer’s email as an attendee. Remember, this will run *for each reviewer* so you only need to build out this linear path.

Once you’re done, you’ll have your standup automatically added to the schedule whenever it’s needed:

Untitled

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

\ No newline at end of file diff --git a/plugins/index.html b/plugins/index.html new file mode 100644 index 00000000..6361cfed --- /dev/null +++ b/plugins/index.html @@ -0,0 +1,74 @@ + Filter Function Plugins - gitStream Documentation

Filter Function Plugins

gitStream enables you to build JavaScript plugins to extend functionality for more advanced data processing and pulling data from external APIs. Use gitStream plugins to seamlessly create and integrate custom filters and other capabilities within your gitStream automations.

Example: isFlaggedUser

Here is an example of a filter function plugin that evaluates a username input against a list of specified usernames and returns true if the user is in the list.

const flaggedUsers = ["user1", "user2"];
+
+function isFlaggedUser(username) {
+    if (flaggedUsers.includes(username)) {
+        return true;
+    } else {
+        return false;
+    }
+};
+
+module.exports = isFlaggedUser;
+
This creates a new isFlaggedUser filter function that can be invoked inside gitStream CM files. For example, you can use this to enable gitStream automations to trigger only for specific PR authors.

automations:
+  detect_flagged_user:
+    if:
+      - {{ pr.author | isFlaggedUser }}
+    run:
+      - action: add-comment@v1
+        args:
+          comment: {{ pr.author }} is a gitStream user.
+

Installation

gitStream plugins can be installed for an entire git organization or for individual repos.

Repository Plugins Take Precedence

If two filter function plugins have the same name, the repository-level plugin overrides the organization-level plugin.

To use a filter function plugin in all your repositories, place it inside your cm repository in the following location:

plugins/filters/<filterName>/index.js

Success

Once installed, you should have a directory structure that looks like this:

.
+├─ gitstream.cm
+└─ plugins/filters/<filterName>
+   └─ index.js
+

To use a filter function plugin for a single repository, place it inside the repo in the following location:

.cm/plugins/filters/<filterName>/index.js

Success

Once installed, you should have a directory structure that looks like this:

.
+├─ .cm/
+│  ├─ gitstream.cm
+│  └─ plugins/filters/<filterName>
+│     └─ index.js
+

gitStream Community Plugins

We maintain an official list of community-contributed gitStream plugins. Click here to explore plugin examples.

Usage

Once installed, you can call your new plugins inside CM files using the same conventions as the built in filter functions. Filters are called with a pipe operator (|) and can take arguments. The first argument must be declared before the pipe, and all remaining arguments are passed as a set inside parenthesis. For example:

{{ "Hello" | plugin(" world!") }}
+
If the filter does not expect any arguments, you can invoke it by passing an empty string:
{{ "" | myFilter }}
+

Create Filter Function Plugins

gitStream plugins are based on the CommonJS module standard, a widely used pattern for structuring and importing JavaScript modules.

Supported JavaScript Dependencies

gitStream supports the following JavaScript dependencies: axios, github actions core (@actions/core), moment, lodash, octokit rest api (@octokit/rest)

No other dependencies are supported at this time. If you have recommendations for new dependencies, please open a new issue on the gitStream GitHub repo.

Define a New Plugin

Each filter function plugin must have its own unique directory inside the appropriate /filters directory for your repo or organization. To create a new filter function, create an index.js file inside the plugin's top-level directory, all plugins must have an index.js file that serves as the primary entry point

One of the functions contained inside this file must be exported via module.exports, using the following conventions:

Export plugins that use synchronous code:

function myFilter(author) {
+    return "Hello ${author}!";
+};
+
+module.exports = myFilter;
+

When using async JavaScript in your plugin, you need two things:

  • A primary async function that returns a callback() containing any errors as the first argument and the result of the filter as the second.
  • A module.exports statement that includes the properties async: true and filter: <filterName> with <filterName> matching the primary function that's being exported.
const myFilter = async (author, callback) => {
+    const message = { text: "Hello ${author}!" };
+    const error = null;
+    return callback(error, message.text); 
+};
+
+module.exports = {
+    async: true,
+    filter: myFilter
+}
+

Async Error Handling

Errors reported by async plugins are output to the workflow runner logs. E.g. GitHub Actions, GitLab CI, etc.

Here's how to invoke the new filter from this example:

automations:
+  welcome_author:
+    if:
+      - true
+    run:
+      - action: add-comment@v1
+        args:
+          comment: {{ pr.author | myFilter }}
+

Debugging with console.log()

Data passed to console.log() is output in your workflow runner logs, e.g. GitHub Actions, GitLab CI, etc.

15 Minute Time Limit

gitStream actions are terminated after 15 minutes, this is a hard limit that can't be extended.

Accept Arguments

Filter function plugins can accept any number of arguments. The first argument must be passed to the filter function via a | operator; all subsequent arguments are passed as a set inside parenthesis.

Filter function to combine two strings

This example accepts two strings and combines them, separating by a space:

function combineStrings(str1, str2) {
+  return str1 + " " + str2;
+}
+module.exports = combineStrings;
+

In the following invocation, "Hello" is passed as str1 and "world!" is passed as str2

{{ "Hello" | combineStrings("world!") }}

Tips for Debugging Plugins

  1. Context Variable Insight: Utilize the gitStream playground to see how the context variable appears in a real Pull Request (PR). Inspect the PR Context Variables at the bottom of the screen Playground.

  2. Local Execution:

    • Run the plugin locally for testing, for example: Running index.js with Node.js.
      module.exports = (text) => {
      +    return text.replaceAll('banana', '🍌');
      +};
      +
      +const banana = require('./index.js');
      +console.assert(banana("hello banana!") === 'hello 🍌!', `banana("hello banana!") === 'hello 🍌!' but got ${banana("hello banana!")}`);
      +
    • Execute with:
      $ node index.js
      +

By following these steps, you can effectively debug and refine your gitStream plugins.

Next Step

Check out the community plugin library.

Check out the filter function plugin library to explore plugins created by the LinearB community.

Contribute to the Community Plugin Library

LinearB maintains a collection of community-contributed gitStream plugins. Here are the instructions for publishing a plugin as part of this library.

Create a directory for your plugin inside one of the subdirectories in plugins/filters. The name of the directory must match the name of the exported JavaScript function. Then ensure you have all of the required files and JSDoc content outlined below.

Here is an example of a well-designed gitStream plugin.

Required Files:

  • index.js - The entry point for your plugin. This should have a main function that is exported via module.exports that is documented according to the JSDoc requirements outlined below.
  • README.md - Use this template.
  • reference.md - This file must be auto-generated by jsdoc2md, see the instructions below.
  • plugin_name.cm - A gitStream CM example that uses the plugin.
  • LICENSE - The full text of the open source license the code is provided under.

Required JSDoc tags:

  • @module - This must match the name of the exported JavaScript function.
  • @description - A 1-2 line description that wholistically describes the functionality of the plugin.
  • @param - There should be one @param tag for each argument the plugin accepts, with indicated types. Indicate which parameter is the default input parameter with the name "Input."
  • @returns - Provide the type and a short description.
  • @example - Simple examples that show how to invoke the plugin.
  • @license - The name of the lincense contained in the LICENSE file.

Here is an example of properly formatted JSDoc content:

/**
+ * @module isFlaggedUser
+ * @description Returns true if the username that is passed to this function is specified in a predefined list of users. 
+ * This is useful if you want gitStream automations to run only for specified users.
+ * @param {string} Input - The GitHub username to check.
+ * @returns {boolean} Returns true if the user is specified in the flaggedUsers list, otherwise false.
+ * @example {{ pr.author | isFlaggedUser }}
+ * @license MIT
+**/
+

How to Generate Plugin Reference Markdown

You can use jsdoc2md to convert the JSDoc content of your plugin to markdown using templates we've provided. First install jsdoc2md:

npm install -g jsdoc-to-markdown

Then, invoke the following command from inside your plugin directory:

jsdoc2md --partial ../../../docs/snippets/partials/body.hbs --partial ../../../docs/snippets/partials/sig-name.hbs --files index.js > reference.md

This should output a reference.md file that contains properly formatted markdown based on the JSDoc contents of your plugin.

\ No newline at end of file diff --git a/quick-start/index.html b/quick-start/index.html new file mode 100644 index 00000000..2651961f --- /dev/null +++ b/quick-start/index.html @@ -0,0 +1,56 @@ + Write Your First gitStream Automation - gitStream Documentation

Write Your First gitStream Automation

This article provides Continuous Merge (CM) examples to help you start customizing gitStream automations to meet the needs of your team.

Approve Simple Changes

Changes to documentation, testing, and code formatting are often safe enough that there is little to no risk in letting an individual contributor merge those changes without needing to distract other people on their team to meet organization-wide requirements for multiple reviews on PRs. A good first Continuous Merge (CM) automation to implement is one that labels and approves changes to resources that could be considered safe changes.

This example uses the filter functions allDocs, allTests, isFormattingChange and match to detect changes that should be safe to merge with minimal review. It then uses the add-label automation action to apply a safe-changes label and the approve automation action to provide an approval review.

Label and Approve Simple Changes

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  safe_changes:
+    if:
+      - {{ is.docs or is.tests or is.asset or is.formatting }}
+    run: 
+      - action: add-label@v1
+        args:
+          label: 'safe-changes'
+      - action: approve@v1
+is:
+  docs: {{ files | allDocs }}
+  tests: {{ files | allTests }}
+  asset: {{ files | match(regex=r/\.(png|svg|gif|css)$/) | every }}
+  formatting: {{ source.diff.files | isFormattingChange }}
+

Test Your Automation in Dry Run Mode

gitStream includes a dry-run mode that let's you test your automations on your desired repo without pushing significant code, documentation, or other changes to the repo.

Learn more in our guide: How to Test Your Automations.

Find Reviewers for Common Changes

Selecting the right reviewer for your PR is crucial to ensure that your changes are thoroughly reviewed and that any issues are identified and addressed before they are merged into the main codebase.

This example uses the codeExperts filter function to identify the most qualified contributors based on their activity in the repo. It then assigns those individuals as reviewers on the PR with the add-reviewers automation action and posts a comment that lists the code experts via the explain-code-experts automation action.

Identify and Assign Code Experts for Reviews

This example uses the codeExperts filter function to identify the people who have the most expertise in the relevant code, assigns them as reviewers, and provides a comment that explains how those people were selected.

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+
+automations:
+  assign_code_experts:
+    # Triggered when someone applies a suggest-reviewer label to a PR.
+    if: 
+      - {{ pr.labels | match(term='suggest-reviewer') | some }}
+    run:
+      - action: add-reviewers@v1
+        args:
+          reviewers: {{ repo | codeExperts(gt=10) }}
+      - action: explain-code-experts@v1 
+        args:
+          gt: 10 
+

Enforce Review Policies for Critical Changes

Complex and sensitive PRs often require more nuanced and complex review processes that bring in outside teams of experts to review code changes. gitStream makes it easy to set up custom review policies to keep teams align across your organization. This example contains two automations that implement custom review policies for specific parts of a codebase.

First, the security_review automation uses the require-reviewers automation action to add the security team from the git organization as reviewers on PRs that affect the auth directory of the repo. This action accepts a reviewers: argument that contains a list of teams or individual users; you will need to change this value to match your organization and users.

Second, the double_review automation forces any changes to the agent directory to require a review from two people using the set-required-approvals automation action.

Enforce Review Policies

# -*- mode: yaml -*-
+manifest:
+  version: 1.0
+automations:
+  security_review:
+    if:
+      - {{ files | match(regex=r/auth\//) | some }}
+    run:
+      - action: require-reviewers@v1
+        args:
+          reviewers: [my_organization/security]
+      - action: add-reviewers@v1
+        args:
+          reviewers: [my_organization/security]
+  double_review:
+    if:
+      - {{ files | match(regex=r/agent\//) | some }}
+    run:
+      - action: set-required-approvals@v1
+        args:
+          approvals: 2
+

Next Step

Take a Look at the Quickstart Examples

You're ready to browse our CM example library to build more automations for your repo. We have examples that help provide context to PRs with labels, assign reviewers based on custom criteria, manage security requirements, and more.

\ No newline at end of file diff --git a/screenshots/Playground-Overview.png b/screenshots/Playground-Overview.png new file mode 100644 index 00000000..f221911c Binary files /dev/null and b/screenshots/Playground-Overview.png differ diff --git a/screenshots/actions_in_github.png b/screenshots/actions_in_github.png new file mode 100644 index 00000000..9afb297a Binary files /dev/null and b/screenshots/actions_in_github.png differ diff --git a/screenshots/adding_tests_to_repo.png b/screenshots/adding_tests_to_repo.png new file mode 100644 index 00000000..68f88001 Binary files /dev/null and b/screenshots/adding_tests_to_repo.png differ diff --git a/screenshots/app_in_github.png b/screenshots/app_in_github.png new file mode 100644 index 00000000..81281114 Binary files /dev/null and b/screenshots/app_in_github.png differ diff --git a/screenshots/approved-safe-changes.png b/screenshots/approved-safe-changes.png new file mode 100644 index 00000000..3a9aed25 Binary files /dev/null and b/screenshots/approved-safe-changes.png differ diff --git a/screenshots/automation-ui.png b/screenshots/automation-ui.png new file mode 100644 index 00000000..631a8055 Binary files /dev/null and b/screenshots/automation-ui.png differ diff --git a/screenshots/branch_protection_in_github.png b/screenshots/branch_protection_in_github.png new file mode 100644 index 00000000..c9bab9d9 Binary files /dev/null and b/screenshots/branch_protection_in_github.png differ diff --git a/screenshots/change_use_deprectaed_api.png b/screenshots/change_use_deprectaed_api.png new file mode 100644 index 00000000..6fab7ed0 Binary files /dev/null and b/screenshots/change_use_deprectaed_api.png differ diff --git a/screenshots/check_syntax_failure.png b/screenshots/check_syntax_failure.png new file mode 100644 index 00000000..a72ea50e Binary files /dev/null and b/screenshots/check_syntax_failure.png differ diff --git a/screenshots/check_syntax_failure_details.png b/screenshots/check_syntax_failure_details.png new file mode 100644 index 00000000..837fd0ae Binary files /dev/null and b/screenshots/check_syntax_failure_details.png differ diff --git a/screenshots/choose-repo-access-for-new-github-app.png b/screenshots/choose-repo-access-for-new-github-app.png new file mode 100644 index 00000000..eb28f024 Binary files /dev/null and b/screenshots/choose-repo-access-for-new-github-app.png differ diff --git a/screenshots/create-new-github-app-config.png b/screenshots/create-new-github-app-config.png new file mode 100644 index 00000000..e7f113c4 Binary files /dev/null and b/screenshots/create-new-github-app-config.png differ diff --git a/screenshots/create-new-github-app-pkey.png b/screenshots/create-new-github-app-pkey.png new file mode 100644 index 00000000..3c9eb5f8 Binary files /dev/null and b/screenshots/create-new-github-app-pkey.png differ diff --git a/screenshots/create-new-github-app-setup-permissions-1.png b/screenshots/create-new-github-app-setup-permissions-1.png new file mode 100644 index 00000000..98a48c66 Binary files /dev/null and b/screenshots/create-new-github-app-setup-permissions-1.png differ diff --git a/screenshots/create-new-github-app-setup-permissions-2.png b/screenshots/create-new-github-app-setup-permissions-2.png new file mode 100644 index 00000000..1952189e Binary files /dev/null and b/screenshots/create-new-github-app-setup-permissions-2.png differ diff --git a/screenshots/create-new-github-app-setup-permissions-3.png b/screenshots/create-new-github-app-setup-permissions-3.png new file mode 100644 index 00000000..ad0435ed Binary files /dev/null and b/screenshots/create-new-github-app-setup-permissions-3.png differ diff --git a/screenshots/create-new-github-app-setup-permissions-4.png b/screenshots/create-new-github-app-setup-permissions-4.png new file mode 100644 index 00000000..b10c8c70 Binary files /dev/null and b/screenshots/create-new-github-app-setup-permissions-4.png differ diff --git a/screenshots/create-new-github-app-setup-permissions-5.png b/screenshots/create-new-github-app-setup-permissions-5.png new file mode 100644 index 00000000..2e32ae32 Binary files /dev/null and b/screenshots/create-new-github-app-setup-permissions-5.png differ diff --git a/screenshots/create-new-github-app-setup-permissions-6.png b/screenshots/create-new-github-app-setup-permissions-6.png new file mode 100644 index 00000000..d54b9a4e Binary files /dev/null and b/screenshots/create-new-github-app-setup-permissions-6.png differ diff --git a/screenshots/create-new-github-app-setup-permissions-7.png b/screenshots/create-new-github-app-setup-permissions-7.png new file mode 100644 index 00000000..be1491b1 Binary files /dev/null and b/screenshots/create-new-github-app-setup-permissions-7.png differ diff --git a/screenshots/create-new-github-app-setup-post-installation.png b/screenshots/create-new-github-app-setup-post-installation.png new file mode 100644 index 00000000..b97e7110 Binary files /dev/null and b/screenshots/create-new-github-app-setup-post-installation.png differ diff --git a/screenshots/create-new-github-app-setup-register.png b/screenshots/create-new-github-app-setup-register.png new file mode 100644 index 00000000..312b0b10 Binary files /dev/null and b/screenshots/create-new-github-app-setup-register.png differ diff --git a/screenshots/create-new-github-app.png b/screenshots/create-new-github-app.png new file mode 100644 index 00000000..97dfc30e Binary files /dev/null and b/screenshots/create-new-github-app.png differ diff --git a/screenshots/dry-run-mode.png b/screenshots/dry-run-mode.png new file mode 100644 index 00000000..f4e5a65c Binary files /dev/null and b/screenshots/dry-run-mode.png differ diff --git a/screenshots/etr-example-1-min.png b/screenshots/etr-example-1-min.png new file mode 100644 index 00000000..c4a59966 Binary files /dev/null and b/screenshots/etr-example-1-min.png differ diff --git a/screenshots/etr_label_example.png b/screenshots/etr_label_example.png new file mode 100644 index 00000000..84cc6c34 Binary files /dev/null and b/screenshots/etr_label_example.png differ diff --git a/screenshots/first-weeks-example.png b/screenshots/first-weeks-example.png new file mode 100644 index 00000000..03870c59 Binary files /dev/null and b/screenshots/first-weeks-example.png differ diff --git a/screenshots/github-codeexperts-expanded.png b/screenshots/github-codeexperts-expanded.png new file mode 100644 index 00000000..63340909 Binary files /dev/null and b/screenshots/github-codeexperts-expanded.png differ diff --git a/screenshots/github-deleted-files.png b/screenshots/github-deleted-files.png new file mode 100644 index 00000000..5f072269 Binary files /dev/null and b/screenshots/github-deleted-files.png differ diff --git a/screenshots/github-etr-safe-labels-example.png b/screenshots/github-etr-safe-labels-example.png new file mode 100644 index 00000000..8f85267e Binary files /dev/null and b/screenshots/github-etr-safe-labels-example.png differ diff --git a/screenshots/github_pr_actions_log.png b/screenshots/github_pr_actions_log.png new file mode 100644 index 00000000..99d59879 Binary files /dev/null and b/screenshots/github_pr_actions_log.png differ diff --git a/screenshots/github_pr_actions_section.png b/screenshots/github_pr_actions_section.png new file mode 100644 index 00000000..c4ed9a0f Binary files /dev/null and b/screenshots/github_pr_actions_section.png differ diff --git a/screenshots/github_settings_allow_actions.png b/screenshots/github_settings_allow_actions.png new file mode 100644 index 00000000..52380c9e Binary files /dev/null and b/screenshots/github_settings_allow_actions.png differ diff --git a/screenshots/github_settings_allow_specified_actions.png b/screenshots/github_settings_allow_specified_actions.png new file mode 100644 index 00000000..115b43de Binary files /dev/null and b/screenshots/github_settings_allow_specified_actions.png differ diff --git a/screenshots/github_suggest_reviewer.png b/screenshots/github_suggest_reviewer.png new file mode 100644 index 00000000..c7fbc35b Binary files /dev/null and b/screenshots/github_suggest_reviewer.png differ diff --git a/screenshots/gitstream-ui.png b/screenshots/gitstream-ui.png new file mode 100644 index 00000000..00ebbb30 Binary files /dev/null and b/screenshots/gitstream-ui.png differ diff --git a/screenshots/intellij_settings_code_braces.png b/screenshots/intellij_settings_code_braces.png new file mode 100644 index 00000000..6aff3f68 Binary files /dev/null and b/screenshots/intellij_settings_code_braces.png differ diff --git a/screenshots/label-management-starter.png b/screenshots/label-management-starter.png new file mode 100644 index 00000000..7661e7f2 Binary files /dev/null and b/screenshots/label-management-starter.png differ diff --git a/screenshots/merge-enabled-example.png b/screenshots/merge-enabled-example.png new file mode 100644 index 00000000..7a43d82e Binary files /dev/null and b/screenshots/merge-enabled-example.png differ diff --git a/screenshots/merge-queue-check.png b/screenshots/merge-queue-check.png new file mode 100644 index 00000000..4a797e66 Binary files /dev/null and b/screenshots/merge-queue-check.png differ diff --git a/screenshots/missing-labels-example.png b/screenshots/missing-labels-example.png new file mode 100644 index 00000000..8305ab13 Binary files /dev/null and b/screenshots/missing-labels-example.png differ diff --git a/screenshots/normal-mode.png b/screenshots/normal-mode.png new file mode 100644 index 00000000..e2828222 Binary files /dev/null and b/screenshots/normal-mode.png differ diff --git a/screenshots/playground-context-variables.png b/screenshots/playground-context-variables.png new file mode 100644 index 00000000..0e5e1f5c Binary files /dev/null and b/screenshots/playground-context-variables.png differ diff --git a/screenshots/removing-missing-labels-example.png b/screenshots/removing-missing-labels-example.png new file mode 100644 index 00000000..eb3d6b4c Binary files /dev/null and b/screenshots/removing-missing-labels-example.png differ diff --git a/screenshots/repo_in_org_setup.png b/screenshots/repo_in_org_setup.png new file mode 100644 index 00000000..2cba6175 Binary files /dev/null and b/screenshots/repo_in_org_setup.png differ diff --git a/screenshots/required-check-block-merge.png b/screenshots/required-check-block-merge.png new file mode 100644 index 00000000..d3dc53a4 Binary files /dev/null and b/screenshots/required-check-block-merge.png differ diff --git a/screenshots/required_checks_in_github.png b/screenshots/required_checks_in_github.png new file mode 100644 index 00000000..5eaf65c1 Binary files /dev/null and b/screenshots/required_checks_in_github.png differ diff --git a/screenshots/setup-linearb-github-server-step-1.png b/screenshots/setup-linearb-github-server-step-1.png new file mode 100644 index 00000000..9df1c23b Binary files /dev/null and b/screenshots/setup-linearb-github-server-step-1.png differ diff --git a/screenshots/setup-linearb-github-server-step-2.png b/screenshots/setup-linearb-github-server-step-2.png new file mode 100644 index 00000000..9df1c23b Binary files /dev/null and b/screenshots/setup-linearb-github-server-step-2.png differ diff --git a/screenshots/setup-new-github-app.png b/screenshots/setup-new-github-app.png new file mode 100644 index 00000000..d6650db2 Binary files /dev/null and b/screenshots/setup-new-github-app.png differ diff --git a/screenshots/slack-estimated-review-time-example-1-min.png b/screenshots/slack-estimated-review-time-example-1-min.png new file mode 100644 index 00000000..26cf4f3d Binary files /dev/null and b/screenshots/slack-estimated-review-time-example-1-min.png differ diff --git a/screenshots/target_branch_github.png b/screenshots/target_branch_github.png new file mode 100644 index 00000000..ea59496b Binary files /dev/null and b/screenshots/target_branch_github.png differ diff --git a/search/search_index.json b/search/search_index.json new file mode 100644 index 00000000..04f359aa --- /dev/null +++ b/search/search_index.json @@ -0,0 +1 @@ +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"/:\\ gitStream","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

"},{"location":"#features","title":"Features","text":"

Auto-Merge PRs

Not all PRs need extensive review policies that loop in multiple experts. gitStream lets you auto-merge safe changes, small fixes, PRs from trusted teams, and anything else you want to unblock the review process to keep your team focused on their work.

Contextual Labels

Reduce the mental burden of code reviews with labels that provide a high degree of context. Indicate an estimated time to review or flag potential issues with Jira information, missing tests, deleted files, and more.

Review Assignment

Identifying the correct people to review a PR can take time, particularly for complex projects and repos requiring deep expertise. Assign code experts to review complex PRs, notify your security team about sensitive changes, and automatically assign reviewers based on the contents of the PR.

Automated Change Requests

Reduce code review noise by catching issues before anyone invests precious time. Flag deprecated components, missing data objects, off-limits code, and other problems that need to be addressed before assigning code reviewers.

Build Your First Automation in 2 Minutes

GitHub GitLab BitBucket
  1. Install gitStream for free in GitHub
  2. Configure your repository using the instructions for GitHub. This will guide you through setting up your first automations.

That's it! Now sit back and watch gitStream run automation rules on your next PR.

Tip: Install gitStream for your entire organization

gitStream can be installed for one repo, specific repos, or all repos in your organization. We recommend installing for all because it will ensure all new repos are able to use gitStream. You can change this setting at any time in the future.

  1. Login, or create a free account on the LinearB app.
  2. Connect gitStream to your GitLab repos by following the steps described here.

That's it! Now sit back and watch gitStream run automation rules on your next PR.

Coming soon

"},{"location":"#get-involved","title":"Get Involved","text":"

Want to report a bug, request a new feature, ask a question, get updates for new features, or propose a new configuration for the automation library? Join us on GitHub.

"},{"location":"automation-actions/","title":"Automation actions","text":"

Actions are the end results of the automation described in your .cm file.

Legend

The icons indicate the availability status of each action.

  • Supported on GitHub
  • Supported on GitLab
  • Open beta - Feature is under development and currently available for all
"},{"location":"automation-actions/#overview","title":"Overview","text":"

send-http-request is executed immediately after the evaluation of the condition. For all other actions, gitStream executes the actions in the order they are listed per automation. If an action result fails, the following actions will not be executed.

  • add-comment
  • add-github-check
  • add-label
  • add-labels
  • add-reviewers
  • approve
  • close
  • explain-code-experts
  • merge
  • request-changes
  • require-reviewers
  • run-github-workflow
  • send-http-request
  • send-slack-message
  • set-required-approvals
  • update-description
  • update-title

Note

Multiple actions can be listed in a single automation. The actions are invoked one by one.

"},{"location":"automation-actions/#dynamic-actions-arguments","title":"Dynamic actions arguments","text":"

Arguments values a dynamic value is supported using expressions based on Jinja2 syntax, and includes gitStream context variables, for example:

automations:\npr_complexity:\nif:\n- true\nrun:\n- action: add-comment@v1\nargs:\ncomment: \"Estimated {{ branch | estimatedReviewTime }} minutes to review\"\n
"},{"location":"automation-actions/#reference","title":"Reference","text":""},{"location":"automation-actions/#add-comment","title":"add-comment","text":"

This action, once triggered, adds a comment to the PR.

This is a managed action, when a PR updates, the existing comments that were added by gitStream are re-evaluated and those that are not applicable are removed.

Args Usage Type Description comment Required String Sets the comment, markdown is supported example
automations:\nsenior_review:\nif:\n- {{ files | match(term='core/') | some }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: |\nCore service update\n(Updates API)\n
"},{"location":"automation-actions/#add-github-check","title":"add-github-check","text":"

This action, once triggered, adds a completed check with the specified conclusion to the listed checks in the PR.

Args Usage Type Description check_name Required String The check name to be added to the checks list on gitHub conclusion Required String The conclusion of the check. The value is one of the following: action_required, cancelled, timed_out, failure, neutral, skipped, success example
automations:\n# Skip UI checks if the PR doesn't have a UI code changes\nskip_ui_check:\nif:\n- {{ not has.fe_code_changes }}\nrun:\n- action: add-github-check@v1\nargs:\ncheck_name: FE-tests\nconclusion: skipped\nhas:\nfe_code_changes: {{ files | match(regex=r/frontend\\//) | some }}\n
"},{"location":"automation-actions/#add-label","title":"add-label","text":"

This action, once triggered, adds a label to the PR.

This is a managed action, when a PR updates, the existing labels that were added by gitStream are re-evaluated and those that are not applicable are removed.

Args Usage Type Description label Required String The label text any string can work color Optional String The color in hex, for example: 'FEFEFE' (you can also add # prefix #FEFEFE) example
automations:\nsenior_review:\nif:\n- {{ files | match(term='api/') | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: api-change\n
"},{"location":"automation-actions/#add-labels","title":"add-labels","text":"

This action, once triggered, adds a list of labels to the PR.

This is a managed action, when a PR updates existing labels that were added by gitStream are re-evaluated and those that are not applicable are removed.

Args Usage Type Description labels Required [String] The list of text labels"},{"location":"automation-actions/#add-reviewers","title":"add-reviewers","text":"

This action, once triggered, sets a specific reviewer.

Args Usage Type Description reviewers Required [String] Sets required reviewers. Supports user names and teams. Teams notated by adding a prefix with the owner name e.g. owner/team team_reviewers Optional [String] Sets required team reviewers without a prefix team unless_reviewers_set Optional Bool When true, the reviewers are not added if the PR has already assigned reviewers. It is set to false by default fail_on_error Optional Bool When true, trying to assign illegal reviewers shall fail the automation, when false these errors are silently ignored. It is set to true by default wait_for_all_checks Optional Boolean By default false. When true, the action will add reviewers only if all checks (except gitStream) are completed with neutral, skipped, or success conclusion example
automations:\nsenior_review:\nif:\n- {{ files | match(term='src/ui/') }}\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: [popeye, olive, acme/team-a]\n

Enable Team Write Access

If you want to assign teams as PR reviewers, you need to first make sure the team has write access to the repo in via your organization's settings. For more info, refer to the GitHub instructions for managing team review settings.

"},{"location":"automation-actions/#explain-code-experts","title":"explain-code-experts","text":"

This action, shall add a comment with codeExperts suggestion. If the comment already exists, the comment shall be edited.

Args Usage Type Description lt Optional Integer Filter the user list, keeping those below the specified threshold gt Optional Integer Filter the user list, keeping those above the specified threshold verbose Optional Bool When set to false then only shows the suggestion summary and skips the per file details (true by default) example
automations:\ncode_experts:\nif:\n- true\nrun:\n- action: explain-code-experts@v1\nargs:\ngt: 10\n
"},{"location":"automation-actions/#approve","title":"approve","text":"

This action, once triggered, approves the PR for merge.

This is a managed action, when a PR updates existing approval by gitStream is re-evaluated and removed if no longer applicable.

example
automations:\nsmall_change:\nif:\n- {{ source.diff.files | isFormattingChange }}\nrun:\n- action: approve@v1\n
"},{"location":"automation-actions/#close","title":"close","text":"

This action, once triggered, close the PR without merging.

example
automations:\nclose_ui_changes_by_non_ui:\nif:\n- {{ files | match(regex=r/src\\/views/) | some }}\n- {{ pr.author_teams | match(term='ui-team') | nope }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: |\nPlease contact a member of `ui-team` team if you need to make changes to files in `src/views`\n- action: close@v1\n
"},{"location":"automation-actions/#merge","title":"merge","text":"

Once triggered, merge the PR if possible. It can be set to wait for all checks to pass or only required ones.

Args Usage Type Description wait_for_all_checks Optional Boolean By default false, so only Required checks can block merge, when true the action will merge after all checks are completed with neutral, skipped, or success conclusion (except gitStream itself) rebase_on_merge Optional Boolean By default false, when merging use rebase mode squash_on_merge Optional Boolean By default false, when merging use squash mode example
automations:\nsmall_change:\nif:\n- {{ files | allDocs }}\nrun:\n- action: merge@v1\nargs:\nrebase_on_merge: true\n
"},{"location":"automation-actions/#request-changes","title":"request-changes","text":"

This action, once triggered, requests changes on the PR. As long as request change is set, gitStream will block the PR merge.

This is a managed action, when a PR updates an existing change request by gitStream is re-evaluated and removed if no longer applicable.

Args Usage Type Description comment Required [String] The desired request changes comment example
automations:\ncatch_deprecated:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/^[+].*oldFetch/) | some }}\nrun:\n- action: request-changes@v1\nargs:\ncomment: |\nYou have used deprecated API `oldFetch`, use `newFetch` instead.\n

Attention

To allow this action to block merge, The following settings should be set:

Enable branch protection and set gitStream as a required check

Enable the \"All threads must be resolved\" Merge check

"},{"location":"automation-actions/#require-reviewers","title":"require-reviewers","text":"

This action, once triggered, requires a specific reviewer approval. The PR merge is blocked till approved by either of the listed users or teams.

Args Usage Type Description reviewers Required [String] Sets required reviewers. Supports user names and teams. Teams notated by adding a prefix with the owner name e.g. owner/team. Merge is blocked till approved by either of the listed users also_assign Optional Bool true by default, also assign the specified users as reviewers example
automations:\nsenior_review:\nif:\n- {{ files | match(regex=r/src\\/ui\\//) | some }}\nrun:\n- action: require-reviewers@v1\nargs:\nreviewers: [popeye, olive, acme/team-a]\n

Attention

To allow this action to block merge, you should enable branch protection, and gitStream has to be set as required check in GitHub.

"},{"location":"automation-actions/#run-github-workflow","title":"run-github-workflow","text":"

This action, once triggered, will start a workflow dispatch automation with the option to add a check to the list of checks in the PR

Args Usage Type Description workflow Required String The ID or name of the workflow dispatch. owner Optional String By default, the value of repo.owner context variable. The account owner of the repository. Case insensitive. repo Optional String By default, the value of repo.name context variable. The name of the repository without the .git extension. Case insensitive. ref Optional String By default, the value of branch.name context variable. The account owner of the repository. Case insensitive. inputs Optional String By default, an empty list. Key-Value list with the arguments to provide to the workflow check_name Optional String When added, after the workflow is complete, add the check name to the checks list on GitHub stop_ongoing_workflow Optional Boolean By default, false. In case the workflow already runs on the branch, if true: cancel the ongoing workflow before running the newly dispatched workflow. If false: wait for the old workflow to finish before dispatching a new one example
on:\n- commit\nautomations:\nrun_workflow_dispatch:\nif:\n- {{ has.fe_code_changes }}\nrun:\n- action: run-github-workflow@v1\nargs:\nowner: {{ repo.owner }}\nrepo: {{ repo.name}}\nworkflow: .github/workflows/frontend-manual.yml\nref: {{ branch.name }}\ncheck_name: FE-tests\nhas:\nfe_code_changes: {{ files | match(regex=r/frontend\\//) | some }}\n

Attention

  • This action will invoke the run of a workflow dispatch; thus, it might result in significant GitHub action minutes charge.
  • We encourage you to use this action with custom triggers
"},{"location":"automation-actions/#send-http-request","title":"send-http-request","text":"

The action, once triggered, sends an HTTP request to the specified URL

Args Usage Type Description url Required String The request URL method Optional String By default GET, the request method headers Optional [String] Empty by default ([]), Key-Value list of strings, which will be sent as the HTTP headers user Optional String Empty by default, format: 'username:password'. If used - adds a Basic-auth HTTP header, by setting the Authorization header. Using this arg will override any existing Authorization header that was set using headers body Optional String Empty by default, the data to be sent as the request body. Only applicable for request methods PUT, POST, DELETE, and PATCH timeout Optional String Empty by default (no timeout), the number of milliseconds before the request times out. When the time out is reached, the request will be aborted example
automations:\nsend_webhook:\nif:\n- true\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"http://WEBHOOK_URL\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{\"text\": \"Hello, world!\"}'\n
"},{"location":"automation-actions/#send-slack-message","title":"send-slack-message","text":"

The action, once triggered, sends a webhook with a message content to a Slack app. To use this action, create a Slack app with Incoming Webhooks enabled. gitStream uses the webhook URL to send the message.

Args Usage Type Description message Required String The message content webhook_url Optional String The webhook URL. Use the env variable to pass secrets example
automations:\nsend_slack:\nif:\n- true\nrun:\n- action: send-slack-message@v1\nargs:\nmessage: \"Hello world :tada:.\"\nwebhook_url: \"{{ slack_webhook }}\"\nslack_webhook: {{ env.SLACK_WEBHOOK }}\n
"},{"location":"automation-actions/#set-required-approvals","title":"set-required-approvals","text":"

This action, once triggered, blocks PR merge till the desired reviewers approved the PR. The actions fail the check to prevent the PR for merge.

Args Usage Type Description approvals Required Integer Sets the number of required reviewer approvals for merge for that PR example
automations:\ndouble_review:\nif:\n- {{ files | match(regex=r/agent\\//) | some }}\nrun:\n- action: set-required-approvals@v1\nargs:\napprovals: 2\n

Attention

To allow this action to block merge, you should enable branch protection, and gitStream has to be set as required check in GitHub.

"},{"location":"automation-actions/#update-description","title":"update-description","text":"

This action, when triggered, updates the PR description with new content.

This is a managed action. When a PR updates, the existing comments that were added by gitStream are re-evaluated, and those that are not applicable are removed.

Args Usage Type Description description Required String Sets the PR description concat_mode Optional String replace by default, the mode to concatenate the new description with the existing one. Possible values: prepend, append, replace

For example, this automation updates the PR description with the ticket info if present in the PR title.

example
automations:\nadd_jira_to_desc:\nif:\n- {{ has.jira_ticket_in_title and (not has.jira_ticket_in_desc) }}\nrun:\n- action: update-description@v1\nargs:\nconcat_mode: prepend\ndescription: |\n{{ jira_ticket_from_title }}\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\\/browse\\/\\w{1,}-\\d{3,4}/) }}\njira_ticket_from_title: {{ pr.title | capture(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\n
"},{"location":"automation-actions/#update-title","title":"update-title","text":"

This action, when triggered, updates the PR title with new content.

This is a managed action. When a PR updates, the existing comments that were added by gitStream are re-evaluated, and those that are not applicable are removed.

Args Usage Type Description title Required String Sets the PR title concat_mode Optional String replace by default, the mode to concatenate the new description with the existing one. Possible values: prepend, append, replace

For example, this automation updates the PR title with the ticket info if present in the PR title.

example
automations:\nadd_jira_to_title:\nif:\n- {{ has.jira_ticket_in_desc and (not has.jira_ticket_in_title) }}\nrun:\n- action: update-title@v1\nargs:\nconcat_mode: prepend\ntitle: |\n{{ jira_ticket_from_desc }} -\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\\/browse\\/\\w{1,}-\\d{3,4}/) }}\njira_ticket_from_desc: {{ pr.description | capture(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\n
"},{"location":"changelog/","title":"/:\\ gitStream Changelog","text":"

All notable changes to this project will be documented in this file.

"},{"location":"changelog/#2024506","title":"2024.5.06","text":"
  • Simplified GitLab workflow file: Using the image directly instead of docker Dind
"},{"location":"changelog/#2024506_1","title":"2024.5.06","text":"
  • Reorganized trigger configuration: Moved the top-level on keyword under a new triggers keyword to consolidate all trigger settings.
  • Enhanced repository and branch triggering:
    • Moved config.include_repository and config.ignore_repository to triggers.include.repository and triggers.exclude.repository, aligning repository-specific triggers with the new consolidated trigger configuration.
    • Introduced triggers.include.branch and triggers.exclude.branch to specify branch-specific conditions for triggering automations.
"},{"location":"changelog/#2024416","title":"2024.4.16","text":"
  • Added a cache option for the docker image
"},{"location":"changelog/#2024328","title":"2024.3.28","text":"
  • Supporting regular expressions in ~~config.ignore_repositories~~ triggers.include.repository and triggers.exclude.repository
"},{"location":"changelog/#2024314","title":"2024.3.14","text":"
  • Added the following explicit triggers:
    • pr_ready_for_review
    • pr_closed
    • pr_reopened
"},{"location":"changelog/#202437","title":"2024.3.7","text":"
  • Triggering on comment edits
  • Added support for request-changes action in GitLab
"},{"location":"changelog/#20231122","title":"2023.11.22","text":"
  • gitStream Playground official release
"},{"location":"cm-file/","title":"gitStream Configuration Overview","text":"

Continuous Merge automation files have a .cm extension. In a repository, gitStream loads and parse the .cm directory, which can have multiple automation files, each of which is evaluated independently.

You can edit the .cm files and add your own checks and rules. Check out the Automation examples.

"},{"location":"cm-file/#automation-rules","title":"Automation rules","text":"

There are two types of automation rules: repository level rules and organization level rules.

Repository level rules are set by creating a special .cm directory in the repository root. Automation rules are specified in files in this directory, which can have any name but must end with .cm.

Organization level rules are defined by creating a special repository named cm in the organization or group. In this repository, you can add CM automation files, which will apply to all the repositories that gitStream app is connected.

When organization level rules are defines, repository level automation shall take precedence and override organization automation when having the same identifier.

An automation identifier is a composition of the CM file name and the automation name. For example when safe_changes is defined in gitstream.cm then the automation identifier shall be gitstream/safe_changes

Tip

You can select (include or exclude) certain repositories per automation file using the triggers.include.repository and triggers.exclude.repository

"},{"location":"cm-file/#repository-automation-rules","title":"Repository automation rules","text":"

Repository automation rules are set by creating a special .cm directory in your repository root. Automation rules are specified in files in this directory, these files can have any name but must end with .cm. By default, you start with a single automation file .cm/gitstream.cm.

Every file is parsed independently, and the parsing results are combined and executed.

Specifically:

  1. Automation rules are allowed to have same name in different .cm files
  2. The config section is defined per .cm file (except config.admin)
  3. Any accessory expression defined in each file scope, therefore cannot be reused in another file (but it can be duplicated)

When configured correctly, your repository directory structure should look like that (for GitHub):

Repsository automation rules
.\n\u251c\u2500 .cm/\n\u2502  \u2514\u2500 *.cm\n\u251c\u2500 .github/\n\u2502  \u2514\u2500 workflows/\n\u2502     \u2514\u2500 gitstream.yml\n

Note

The .cm/gitstream.cm is special, as it allows repository-level configuration such as config.admin.

"},{"location":"cm-file/#organization-automation-rules","title":"Organization automation rules","text":"

Organization automation rules are defined by creating a special repository cm in your organization or group. In this repository, you can add CM automation files, which will apply to all the repositories that gitStream app is connected.

When configured correctly, the cm repository directory structure should look like that (for GitHub):

Repsository automation rules
.\n\u251c\u2500 *.cm\n\u251c\u2500 .github/\n\u2502  \u2514\u2500 workflows/\n\u2502     \u2514\u2500 gitstream.yml\n

For each PR the following automation rules are applied:

  1. Repository level rules
  2. Organization-level rules, unless with the same identifier as a repository-level automation

When organization level rules are defined, then the CI/CD will be executed on the cm repository on behalf of the PR repository.

"},{"location":"cm-file/#setting-up-global-automation-rules","title":"Setting up Global Automation rules","text":"

By utilizing the following techniques, you can effectively combine and manage global and repository rules to customize the behavior of your automations to fit the specific requirements of your repositories:

  1. Global rules are defined in the configuration management cm repository and are applied to all repositories that are connected to gitStream.
  2. To exclude or run only on specific repositories from a global rule, you can use triggers.include.repository and triggers.exclude.repository in the cm file and add a list of the unwanted or wanted repositories respectfully.
  3. To override a global rule for specific automation in a repository, you can duplicate the rule (both the file and automation name) and place it in the desired repository. The locally defined rule will then take precedence over the global rule for that specific repository.
"},{"location":"cm-file/#the-cm-automation-file","title":"The .cm automation file","text":""},{"location":"cm-file/#schema","title":"Schema","text":"

The following sections are used in .cm file to describe the desired automations:

  • manifest
  • config
  • automations
"},{"location":"cm-file/#manifest","title":"manifest","text":"

The first section in a gitstream.cm file is the manifest.

manifest:\nversion: 1.0\n

The only field required is version.

Key Required Type Description manifest Y Map The manifest section root manifest.version Y String Specify the .cm spec version: 0.1, 1.0

The manifest version field is used to parse the .cm file, in the future if breaking changes are introduced to the parser then older automation will be still supported.

"},{"location":"cm-file/#config","title":"config","text":"

The config section in the .cm file is optional and specifies settings that affect gitStream's operation within a given context.

Key Type Default Scope Description config Map - per .cm file Root configuration section, applies to the automations defined in the current file. config.admin.users [String] [] gitstream.cm List of admin users, identified by Git provider usernames. config.ignore_files [String] [] per .cm file Files to exclude from consideration. config.user_mapping [String: String] [] per .cm file Map Git user details to provider account names."},{"location":"cm-file/#configadminusers","title":"config.admin.users","text":"

When specified in gitstream.cm the config.admin.users allows adding admin rights, when a PR changes the *.cm files only, if the user is listed in config.admin.users the PR will be then approved by gitStream. For example, setting popeye as admin:

example
config:\nadmin:\nusers: ['popeye']\n

This configuration is valid only when used in .cm/gitstream.cm, when defined in other .cm files this configuration is ignored.

When you add a user to config.admin.users in your organization's cm repository, they are granted administrative privileges to CM changes across every repository in the organization. gitStream evaluates CM rules in the individual repository and your organization's cm repository to determine admin users.

"},{"location":"cm-file/#configignore_files","title":"config.ignore_files","text":"

The config.ignore_files supports glob pattern matching that contains a list of files to ignore.

Common usage, since some files such as lock files are intentionally not a required part of a review, they would not want to them to be counted in the estimated review time. In such cases, you can add config.ignore_files to the relevant CM file, for example:

example
config:\nignore_files:\n- 'yarn.lock'\n- 'package-lock.json'\n- 'openapi.json'\n- 'ui/src/**/*Model.d.ts'\n
"},{"location":"cm-file/#configuser_mapping","title":"config.user_mapping","text":"

Accepts list of key value strings.

For example, when using rankByGitBlame or explainRankByGitBlame Git users are mapped to their matching Git provider accounts based on the Git details. The automatic mapping can sometimes result with the wrong account or fail to find a proper mapping, in these cases you can configure the config.user_mapping. This allows you to map confusing Git user into their specific accounts and dump some irrelevant accounts:

example
config:\nuser_mapping:\n- 'Popeye Man <popeye@invalid.com>': 'popeye-the-salyor-man' # (1)\n- 'Popeye Man <popeye2@invalid.com>': 'popeye-the-salyor-man' # (2)\n- 'olive <olive@invalid.com>': null # (3)\n
  1. Map Git user signature to the correct Git provider user name (e.g. GitHub)
  2. Map Git user signature to the correct Git provider user name (e.g. GitHub)
  3. Mapping to null removes this Git user from the suggested results

When using rankByGitBlame to assign reviewers automatically with add-reviewers@v1 then mapping users to null is a way to prevent the automatic mapping in certain cases, like in your example contributors that are not longer part of the team.

On the other hand, when using explainRankByGitBlame with add-comment@v1 it still shows these users details in the PR comment suggestion as this info might be valuable by itself.

- action: add-reviewers@v1\nargs: # (1)\nreviewers: {{ repo | rankByGitBlame(gt=25) }}\n- action: add-comment@v1\nargs: # (2)\ncomment: |\n{{ repo | explainRankByGitBlame(gt=25) }}\n
  1. rankByGitBlame will drop null users
  2. explainRankByGitBlame will NOT drop null users
"},{"location":"cm-file/#triggers","title":"triggers","text":"

The triggers is section specifies when automations are executed, supporting include and exclude lists for branch and repository patterns at the file level. The on keyword can also be used within individual automations to define specific events that trigger those automations.

triggers:\non:\n- pr_created\n- commit\nexclude:\nbranch:\n- hotfix\n

Read more here: triggers.

"},{"location":"cm-file/#automations","title":"automations","text":"

The automations section defines the automations and their conditions.

automations:\nmark_small_pr:\nif:\n- {{ checks.size.is.xsmall }}\nrun:\n- action: add-label@v1\nargs:\nlabel: xsmall\n

Each automation includes its name, and few fields: if and run.

Key Required Type Description automations Y Map The automations section root automations.NAME Y Map User defined name of the automation, can be any string automations.NAME.if Y Map List of conditions with AND relationship automations.NAME.run Y Map Actions to run if all conditions are met, invoked one by one

The if field includes the list of conditions. The conditions are checked when a pull request is opened or changed, if all the conditions pass, the automation is executed.

The run field includes the automation to execute. It includes the following fields:

Key Required Type Description action Y String The action pointer engine N String The action engine, default is gitstream args N List The action inputs list

For gitstream engine, the action is specified by: name@version

gitStream supported actions, see actions.

"},{"location":"cm-file/#reusing-checks","title":"Reusing checks","text":"

You can define an accessory section, e.g. checks, that defines common conditions, and reuse.

size:\nis:\nsmall: {{ branch.diff.size < 20 }}\nmedium: {{ branch.diff.size >= 20 and branch.diff.size < 100 }}\nlarge: {{ branch.diff.size >= 100 }}\nautomations:\napprove_small:\nif:\n- {{ size.is.small }}\nrun:\n- action: approve@v1\nmark_small_medium:\nif:\n# Check that the PR is either small or medium size\n- {{ size.is.small or size.is.medium }}\n# AND its less than 5 minutes review (estimated)\n- {{ branch | estimatedReviewTime <= 5 }}\nrun:\n- action: add-label@v1\nargs:\nlabel: 'good-size'\n
"},{"location":"cm-syntax/","title":"Cm syntax","text":"

Deprecated. See: /how-it-works

"},{"location":"context-variables/","title":"Context variables","text":"

Context variable are the inputs for the automation conditions or checks.

Legend

The icons indicate the availability status of each action.

  • Supported on GitHub
  • Supported on GitLab
  • Under development and not available yet.
  • Open beta - Under development and currently available for all
"},{"location":"context-variables/#overview","title":"Overview","text":""},{"location":"context-variables/#context","title":"Context","text":"

gitStream includes a collection of variables called contexts.

  • branch
  • env
  • files
  • pr
  • repo
  • source
"},{"location":"context-variables/#structures","title":"Structures","text":"

The following structures are used in the context objects:

  • GitBlame
  • Check
  • Contributor
  • FileDiff
  • FileMetadata
  • Comment
  • conversations
Example of a context object

Partial example of a context object for a PR that changed few lines in a README.md file:

{\n\"branch\": {\n\"name\": \"new-feature-branch\",\n\"base\": \"main\",\n\"diff\": {\n\"size\": 50,\n\"files_metadata\": [\n{\n\"original_file\": \"README.md\",\n\"new_file\": \"README.md\",\n\"deletions\": 0,\n\"additions\": 2\n}\n]\n},\n\"num_of_commits\": 1\n},\n\"source\": {\n\"diff\": {\n\"files\": [\n{\n\"original_file\": \"README.md\",\n\"new_file\": \"README.md\",\n\"diff\": \"@@ -10,3 +10,5 @@ This project \\n+\\n+## Intro\",\n\"original_content\": \"This project \\n\",\n\"new_content\": \"This project \\n\\n## Intro\"\n}\n]\n}\n},\n\"repo\": {\n\"contributors\": {\n\"popeye\": \"46\",\n\"olive\": \"6\"\n},\n\"owner\": \"acme\"\n},\n\"files\": [\n\"README.md\"\n]\n}\n
"},{"location":"context-variables/#reference","title":"Reference","text":""},{"location":"context-variables/#branch","title":"branch","text":"

The branch context contains info regarding the branch changes compared to the base branch.

Note

compared to the source context does not include actual source code.

Values Type Description branch Map Includes the info related to the current branch branch.author String The branch author (the user that did first commit in the branch). The formatted like author in git-log, e.g. Popeye <popeye@acme.com> branch.author_name String The branch author name branch.author_email String The branch author email branch.base String The main branch, main branch.commits.messages [String] A list with all the commit messages in this branch branch.diff.size Integer The sum of line changed: additions, edits and deletions branch.diff.files_metadata FileMetadata List of changed files including their relative path branch.name String The current branch, feature-123-branch branch.num_of_commits Integer The number of commits in the branch

The branch context doesn't include any source code, but only related metadata.

Example for using branch.name and branch.author to automatically approve and merge version bumps.

automations:\ndependabot:\nif:\n- {{ branch.name | includes(term=\"dependabot\") }}\n- {{ branch.author | includes(term=\"dependabot\") }}\nrun:\n- action: approve@v1\n- action: add-label@v1\nargs:\nlabel: \"approved-dependabot\"\n- action: merge@v1\nargs:\nwait_for_all_checks: true\nsquash_on_merge: true\n

Tip

The files context doesn't include deleted file, to identify both modified and deleted files use the branch.diff.files_metadata, for example:

{{ branch.diff.files_metadata | match(attr='file', regex=r/\\.md$/) | every }}\n

"},{"location":"context-variables/#env","title":"env","text":"

The env context allows the user to pass data from the repo that is unavailable in the other context variables. Thus, the structure of the variable is not fixed and depends on user configuration.

To configure the env variable, add the env field to gitstream's workflow job configurations on .github/workflows/gitstream.yml. For more information, visit GitHub's guide for Using secrets in GitHub Actions

examle: add secrets to the env variable
...\njobs:\ngitStream:\ntimeout-minutes: 5\nruns-on: ubuntu-latest\nname: gitStream workflow automation\nenv:\nSLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}\n...\n

To use the context variable, access to the env variable's fields as configured in gitstream.yml

example: use slack webhook secret
automations:\nsend_slack:\nif:\n- true\nrun:\n- action: send-slack-message@v1\nargs:\nmessage: \"Hello world :tada:.\"\nwebhook_url: \"{{ slack_webhook }}\"\nslack_webhook: {{ env.SLACK_WEBHOOK }}\n
"},{"location":"context-variables/#files","title":"files","text":"

The files context includes the list of changed files in the branch compared to the main branch.

Values Type Description files [String] List of all changed files with their full path

For example, a typical files context can look like this:

[\n\"README.md\",\n\"package.json\",\n\"src/app.js\",\n\"src/index.js\",\n\"docs/examples.md\"\n]\n

Example for checking if certain changes are made:

automations:\nui_review:\nif:\n- {{ files | match(list=ui_templates_files) | some }}\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: [GitHubUser1, GitHubUser2]\nui_templates_files:\n- resources/app/ui_template.yml\n- resources/app/role_template.yml\n- resources/app/account_template.yml\n
"},{"location":"context-variables/#pr","title":"pr","text":"

The pr context includes metadata related to the pull request.

Values Type Description pr Map Includes the info related to the PR pr.approvals [String] A list of the of reviewers that approved the PR pr.author String The PR author name pr.author_teams String The teams which the PR author is member of pr.author_is_org_member Bool true if the PR author is a member of the organization where gitStream is installed pr.checks [Check] List of checks, names and status pr.comments [Comment] List of PR comments objects pr.conflicted_files_count Integer The number files in the PR with conflicts pr.conversations [Conversation] List of PR conversation objects, usually when reviewer have comments about the source code pr.created_at String The date and time the PR was created pr.draft Bool true when the PR is marked as Draft/WIP pr.description String The PR description text pr.labels [String] The labels that are attached to the PR pr.number Integer The PR or MR Id number pr.provider String The Git cloud provider name, e.g. GitHub, GitLab etc. pr.reviewers [String] The list of reviewers set for this PR pr.source String The branch from which the PR originates pr.status String The PR status: open, closed and merged pr.target String The branch the PR is intended merged into pr.title String The PR title pr.requested_changes [String] List of users that requested changes pr.reviews [Review] List of PR reviews, relevant in GitHub pr.unresolved_threads Integer The number of open review comments in the PR pr.updated_at String The date and time the PR was last updated

Example for checking the PR title includes a Jira ticket:

automations:\ncheck_jira_ticket:\nif:\n- {{ not has.jira_ticket }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"missing-ticket\"\ncolor: 'F6443B'\nhas:\njira_ticket: {{ pr.title | includes(regex=r/^\\[?\\w{3,4}-\\d{1,6}\\]?(\\s|-|_).{20,}$/) }}\n
"},{"location":"context-variables/#repo","title":"repo","text":"

The repo context includes metadata related to the repo.

Values Type Description repo Map Includes the info related to the current repo repo.age Integer Number of days since first commit (of any user) repo.author_age Integer number of days since first commit to this repo repo.blame GitBlame The percentage each user's lines in a file, the list includes all changed files in the branch. The list is sorted by the ratio field repo.contributors Contributor List of contributors in the repo repo.git_activity GitActivity Per file and user, the number of lines changed every week for the last 52 weeks repo.name String Repository name repo.owner String Repository owner account name repo.visibility String The visibility of the source branch repo. Value is one of: private, internal, or public"},{"location":"context-variables/#source","title":"source","text":"

The source context includes a list of FileDiff objects that can be used to get insights based on code changes. The changes compared to the latest main branch.

Values Type Description source.diff.files FileDiff List of changed files with their code changes

The source context include all code changes, it is not safe to share it with unknown services.

"},{"location":"context-variables/#check-structure","title":"Check structure","text":"
{\n\"name\": String, # The check name\n\"status\": String, # The check status: `queued`, `in_progress`, `completed`\n\"conclusion\": String, # The check conclusion: `action_required`, `cancelled`, `failure` `neutral`, `success`, `skipped`, `stale`, `timed_out`\n}\n
"},{"location":"context-variables/#comment-structure","title":"Comment structure","text":"
{\n\"commenter\": String, # The user that add the comment\n\"content\": String, # The comment body\n\"created_at\": String, # The time on which the comment was created\n\"updated_at\": String, # The time on which the comment was last updated\n}\n
"},{"location":"context-variables/#conversation-structure","title":"Conversation structure","text":"
{\n\"commenter\": String, # The user that add the comment\n\"content\": String, # The comment body\n\"created_at\": String, # The time on which the comment was created\n\"updated_at\": String, # The time on which the comment was updated\n\"start_line\": Integer, # The first line marked for this comment\n\"end_line\": Integer, # The last line marked for this comment\n\"is_resolved\": Boolean # `true` when marked as resolved\n}\n
"},{"location":"context-variables/#contributor-structure","title":"Contributor structure","text":"

The repo.contributors mapping includes a list of Contributor, where the user name is used as dynamic key:

{\nUSER_NAME: Integer # Number of commits\n}\n
"},{"location":"context-variables/#filediff-structure","title":"FileDiff structure","text":"

The source.diff.files mapping includes a list of FileDiff:

{\n\"diff\": String, #  The content in diff format `+` for additions, `-` for deletions\n\"new_content\": String, # The new content in this branch\n\"new_file\": String, # The name of the file after the changes, including its path\n\"original_content\": String, #  The content as is in the `main` branch\n\"original_file\": String, #  The name of the file before the changes, including its path\n}\n
"},{"location":"context-variables/#filemetadata-structure","title":"FileMetadata structure","text":"

The branch.diff.files_metadata mapping includes a list of FileMetadata:

{\n\"additions\": Integer, # The number of lines edited or added to the file\n\"deletions\": Integer, # The number of lines removed from the file\n\"file\": String, # The name of the file before the changes, including its path\n}\n

For example, sum additions in javascript code files:

{{ branch.diff.files_metadata | filter(attr='new_file', regex=r/\\.js$|\\.ts$/) | map(attr='additions') | sum }}\n
"},{"location":"context-variables/#gitactivity-structure","title":"GitActivity structure","text":"

This structure include per changed file, for every user, the number of lines changed every week for the last 52 weeks.

{\nFILE_NAME: # The file name and path\n{\n# The git user identifier (String)\nGIT_USER: {\n\"week_INDEX\": Integer # Number of lines changed that week\n# ... for the last 52 weeks\n}\n}\n}\n

For example:

{\n\"src/utils/service.js\": {\n\"popeye <popeye@acme.com>\": {\n\"week_1\": 20,\n\"week_2\": 15,\n\"week_10\": 250\n},\n\"olive <olive@acme.com>\": {\n\"week_1\": 3,\n\"week_3\": 50,\n\"week_52\": 250\n}\n},\n\"README.md\": {\n\"popeye <popeye@acme.com>\": {\n\"week_2\": 15,\n\"week_3\": 10\n}\n}\n}\n
"},{"location":"context-variables/#gitblame-structure","title":"GitBlame structure","text":"

For each file, a list of user's blame ratio.

{\nFILE_NAME: # The file name and path\n{\n# The git user identifier (String)\nGIT_USER: Integer, # Precentage 0-100, ratio of user's lines / total lines in file\n}\n}\n

For example:

{\n\"src/utils/service.js\": {\n\"popeye <popeye@acme.com>\": 78,\n\"olive <olive@acme.com>\": 22,\n},\n\"README.md\": {\n\"popeye <popeye@acme.com>\": 13,\n\"olive <olive@acme.com>\": 22,\n\"brutus <brutus@acme.com>\": 65,\n}\n}\n
"},{"location":"context-variables/#review-structure","title":"Review structure","text":"
{\n\"commenter\": String, # The user that add the comment\n\"content\": String, # The comment body\n\"created_at\": String, # The time on which the comment was created\n\"state\": String, # Either `approved`, `changes_requested`, `commented`, `pending`, `submitted`\n\"conversations\": [Conversation], # Conversations that are relvant to this Review feedback\n}\n
"},{"location":"custom-github-app/","title":"How to Set Up Custom GitHub App and Connect to gitStream Services","text":"

Note

This guide is for installations on self-hosted GitHub Server. If you are using the gitStream cloud service, please refer to this guide.

"},{"location":"custom-github-app/#custom-github-app-for-self-hosted-github-server","title":"Custom GitHub App for Self-Hosted GitHub Server","text":"

A GitHub application serves as the link between gitStream and GitHub. It facilitates user authentication via OAuth2 and allows users to select repositories accessible by gitStream.

Prerequisites

GitHub Server v3.10 or higher

In this section, we'll guide you through creating a GitHub app for your self-hosted gitStream installation. By the end, you should have noted down the following values:

  • App ID
  • Private Key

Note

Throughout this document, when we refer to a GitHub account, it refers to your own GitHub Server installation.

"},{"location":"custom-github-app/#1-connect-github-server-to-linearb","title":"1. Connect GitHub Server to LinearB","text":"

First login, or create a free account on the LinearB app.

In LinearB, go to Settings -> Git -> click the Connect gitStream button next to your GitHub Server integration. You\u2019ll need to use the Webhook URL and Webhook secret later when setting up the GitHub App.

Keep this window open and complete the next steps in GitHub. Once you have the App ID and Private Key (.pem file), you can complete the connection in LinearB.

"},{"location":"custom-github-app/#2-create-a-new-github-app","title":"2. Create a New GitHub App","text":"

Any GitHub account can own the app, but we recommend creating it under the organization account of the team who will maintain the gitStream installation.

  • Log in to GitHub and go to your organization account page (e.g., https://github.com/<organization account name>)
  • Click on Settings -> Developer Settings -> GitHub Apps -> New GitHub App as shown below
  • Or go directly to https://github.com/organizations/<organization account name>/settings/apps/new

"},{"location":"custom-github-app/#3-set-up-urls-and-general-information","title":"3. Set Up URLs and General Information","text":"

Fill in the app information as shown in the screenshot below. For URLs, replace gitstream.<your-domain>.com with the actual endpoint at which you'll be hosting the gitStream application.

Warning

  1. Do not forget trailing slashes for the URLs
  2. Do not forget to disable the \"Expire user authorization tokens\" checkbox
  3. The GitHub App name must contain gitstream in lower case

Tip

Use the following texts:

  1. GitHub App name: gitstream app
  2. Homepage URL: https://gitstream.cm

Tip

Use the following texts:

  1. Webhook URL from LinearB setup page
  2. Webhook secret from LinearB setup page

"},{"location":"custom-github-app/#4-set-up-permissions","title":"4. Set Up Permissions","text":"

We need the following permissions to enable all gitStream functionality:

  • Write access to dedicated gitStream app files: Used to set up the gitStream workflow files
  • Write access to code: To allow gitStream to approve PRs once all conditions are met
  • Read access to administration, issues, and metadata: To get user team membership and branch protection settings
  • Read and write access to actions, checks, pull requests, and workflows: Trigger workflows, create and update pull requests and their checks, and modify workflow files
  • User email: Used to identify users |

You need to enable these under the permissions section as shown below:

Tip

Add the following Path (content paths to single files the app can access):

  1. .cm/gitstream.cm
  2. github/workflows/gitstream.yml

"},{"location":"custom-github-app/#5-webhook-events-and-scope","title":"5. Webhook Events and Scope","text":"
  • Subscribe to events so gitStream is notified when a PR is created, changed, or commented on, etc

Tip

\"Where can this GitHub App be installed?\" choose \"Any account\" so other orgs in your company can use gitStream as well. For on-prem installations that work with github.com, only repositories under your company's org account can be accessed via gitStream.

"},{"location":"custom-github-app/#6-generate-a-private-key","title":"6. Generate a Private Key","text":"

Once the app is created, scroll down and click Generate private key. This will create and download a .pem file for you.

Tip

Please keep this file safe, we'll need to put it back in LinearB setup.

"},{"location":"custom-github-app/#7-upload-a-logo","title":"7. Upload a Logo","text":"

Download the logo file and upload the logo to your app.

  • Black logo
  • White logo
"},{"location":"custom-github-app/#8-get-app-configuration","title":"8. Get App Configuration","text":"

On your newly created app page, you can find the App ID.

Tip

Please keep the App ID, we'll need to put it back in LinearB setup.

"},{"location":"custom-github-app/#9-finish-setup-in-linearb","title":"9. Finish Setup in LinearB","text":"

To complete the integration, fill in the App ID and Private Key in the LinearB setup screen.

Tip

Use the App ID, and Private key (.pem file) to complete the LinearB setup.

"},{"location":"custom-github-app/#10-connect-github-app-to-your-repositories","title":"10. Connect GitHub App to Your Repositories","text":"

Go to your organization settings in GitHub and in Third-party Access choose the GitHub Apps. You may need to choose the account to install the gitStream app on. Choose your org you used to create the GitHub app in the previous sections.

Choose the repositories you want to connect.

Tip

It's recommended to select All repositories, as it covers also future repositories.

"},{"location":"custom-github-app/#11-finish-setting-up-gitstream","title":"11. Finish Setting Up gitStream","text":"

Follow the instructions to configure your repository using the GitHub Instructions

"},{"location":"dry-run-mode/","title":"How to Test Your Automation","text":"

By default, gitStream runs all applicable automations for every new PR and change to existing PR. If you want to test and experiment with new rules, gitStream supports a dry-run mode that will avoid making changes to your PRs. When you commit changes to any CM files found inside your repo's .cm/ directory, gitStream will switch to dry-run mode.

In dry-run mode, gitStream won't execute any automation rules on the PR. Instead, gitStream will parse all applicable automation rules and post a comment to the PR discussion that describes the actions that will be taken for normal PRs. A new comment will be added after every new commit.

Note

When in dry-run mode, incoming changes to the CM files are ignored. In other words, new automations and configurations won't take effect until you merge the PR.

Once you are satisfied with the results, you can merge your CM changes into the main branch to enable the new configurations.

"},{"location":"examples/","title":"gitStream Quickstart","text":"

This page contains common gitStream configurations that are a great place to begin adopting a continuous merge mindset with gitStream. If you haven't already, you'll need to install gitStream to your GitHub or GitLab organization before you can use these automations

Build your first gitStream automation in as little as two minutes.

These example are complete gitStream configuration files that you can download directly via the buttons below the examples and upload to the .cm directory of your repo. Alternatively, you can copy and paste the individual automations, but make sure you include all required declarations and any related custom expressions from the configuration to ensure everything works properly.

"},{"location":"examples/#improve-pr-context-with-label-automation","title":"Improve PR Context with Label Automation","text":"

This CM automation contains a collection of workflows to automatically apply labels that to provide deeper context to code reviewers to help them more quickly triage and address incoming requests for reviews. Ideally, you should implement these automations across your entire git organization to maximize developer usage.

The following example includes workflow automations to do the following:

  • Apply color-coded labels that estimate how long it takes to review the PR.
  • Flag PRs that lack required references to Jira tickets. Check out the gitStream integrations page for more examples of third-party project management tools gitStream integrates with.
  • Label PRs that have unresolved change requests, or delete code.

Label Management with gitStream

# -*- mode: yaml -*-\n# +----------------------------------------------------------------------------+\n# | /:\\ gitStream: Workflow automation for the code review process.            |\n# +----------------------------------------------------------------------------+\n# | This file contains one or more /:\\ gitStream automations:                  |\n# | https:// docs.gitstream.cm                                                 |\n# |                                                                            |\n# | gitStream uses YAML syntax with nunjucks templating via Jinja 2.           |\n# |                                                                            |\n# | Automations follow an \"if this, then that\" execution format.               |\n# | More info here: https://docs.gitstream.cm/how-it-works/                    |\n# |                                                                            |\n# +----------------------------------------------------------------------------+\n# /:\\ gitStream Reference Docs: \n#    Context Variables: https://docs.gitstream.cm/context-variables/\n#    Filter Functions: https://docs.gitstream.cm/filter-functions/\n#    Automation Actions: https://docs.gitstream.cm/automation-actions/\nmanifest:\nversion: 1.0\n# +----------------------------------------------------------------------------+\n# | Automations\n# +----------------------------------------------------------------------------+\nautomations:\n# Apply color coded labels to PRs based on the estimated time to review.\n# https://docs.gitstream.cm/automations/provide-estimated-time-to-review/\nestimated_time_to_review:\nif:\n- true\nrun:\n- action: add-label@v1\nargs:\nlabel: \"{{ calc.etr }} min review\"\ncolor: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}\n# Flag PRs that are missing a Jira ticket reference in the title or description.\n# https://docs.gitstream.cm/integrations/jira/\nlabel_missing_jira_info:\nif:\n- {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"missing-jira\"\ncolor: {{ colors.red }}\n# Flag PRs that have unresolved comment threads.\n# https://docs.gitstream.cm/automations/standard/label-management/label-unresolved-threads/\nlabel_unresolved_threads:  if:\n- {{ pr.status == 'open' }}  - {{ pr.unresolved_threads }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \ud83d\udea8 {{ pr.unresolved_threads }} Unresolved Thread(s)\ncolor: {{ colors.yellow }}  # Flag PRs that delete files to highlight potential refactors that need extra scrutiny.\n# https://docs.gitstream.cm/automations/label-deleted-files/\nflag_deleted_files:\nif:\n- {{ has.deleted_files }}\nrun: - action: add-label@v1\nargs:\nlabel: \ud83d\uddd1\ufe0f Deleted files\ncolor: {{ colors.orange }}\n# +----------------------------------------------------------------------------+\n# | Custom Expressions                                                         |\n# | https://docs.gitstream.cm/how-it-works/#custom-expressions                 |\n# +----------------------------------------------------------------------------+\n# https://docs.gitstream.cm/filter-functions/#estimatedreviewtime\ncalc:\netr: {{ branch | estimatedReviewTime }}\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\\/browse\\/\\w{1,}-\\d{3,4}/) }}\ndeleted_files: {{ source.diff.files | map(attr='new_file') | match(term='/dev/null') | some }}\n# These are all of the colors in GitHub's default label color palette.\ncolors:\nred: 'b60205'\norange: 'd93f0b'\nyellow: 'fbca04'\ngreen: '0e8a16'\nblue: '1d76db'\npurple: '5319e7'\n
Download this example as a CM file.

"},{"location":"examples/#automatically-route-pr-reviews","title":"Automatically Route PR Reviews","text":"

If you're ready to begin automatically routing PRs for review, the best solution is to classify PRs according to the amount of risk they create. This next example classifies PRs into one of three categories based on the changes they contain and automatically establishes review criteria.

The following example includes workflow automations to do the following:

  • Recommend the most knowledgeable code experts to review the PR.
  • Automatically approve low-risk PRs to docs, testing, or code formatting.
  • Define criteria for when PRs need one or more reviews.
  • Label PRs that are available to be cherry picked to merge into the next release.

Review Routing with gitStream

# -*- mode: yaml -*-\n# +----------------------------------------------------------------------------+\n# | WARNING: This file controls repo automations, use caution when modifying   |\n# +----------------------------------------------------------------------------+\n# | This file contains one or more /:\\ gitStream automations:                  |\n# | https:// docs.gitstream.cm                                                 |\n# |                                                                            |\n# | gitStream uses YAML syntax with nunjucks templating via Jinja 2.           |\n# |                                                                            |\n# | Automations follow an \"if this, then that\" execution format.               |\n# | More info here: https://docs.gitstream.cm/how-it-works/                    |\n# |                                                                            |\n# +----------------------------------------------------------------------------+\n# /:\\ gitStream Reference Docs: \n#    Context Variables: https://docs.gitstream.cm/context-variables/\n#    Filter Functions: https://docs.gitstream.cm/filter-functions/\n#    Automation Actions: https://docs.gitstream.cm/automation-actions/\nmanifest:\nversion: 1.0\n# +----------------------------------------------------------------------------+\n# | Customize This Section                                                     |\n# +----------------------------------------------------------------------------+\n# Change review_team to match your organization or repo's primary review team. \n# The format is Git Organization Name / Team Name\nreview_team: 'my-org/team-name'\n# List of files that should trigger a sensitive file change review.\nsensitive:\n- App.tsx\n- AppRoot.tsx\n# Files to exclude from gitStream automations.\nconfig:\nignore_files:\n- 'yarn.lock'\n- 'ios/*.lock'\n- 'android/*.lock'\n# Set long_review_threshold to the number of minutes that should trigger extra review requirements.\nlong_review_threshold: 5\n# +----------------------------------------------------------------------------+\n# | Automations\n# +----------------------------------------------------------------------------+\nautomations:\n# Post a comment that recommends reviewers based on their knowledge of the files in the PR.\n# https://docs.gitstream.cm/automations/standard/explain-code-experts/\nexplain_code_experts:\n# Alternatively, if you only want to trigger when the slash command `/gitstream suggest-reviewers` is included in a comment,\n# change '- true' to '- {{ (pr.comments | match(attr='content', term='/gitstream suggest-reviewers') | some) }}'\nif:\n- true\nrun:\n- action: explain-code-experts@v1 args:\ngt: 10\n# Automatically approve changes that only affect formatting, documentation, tests, or images\n# https://docs.gitstream.cm/automations/approve-safe-changes/\napprove_safe_changes:\nif:\n- {{ is.safe_change }}\n# Apply a safe change label, approve the PR and explain why in a comment.\nrun: - action: add-label@v1\nargs:\nlabel: 'Safe Change'\ncolor: {{ colors.green }}\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR is considered a safe change and has been automatically approved.\n# Set criteria for PRs that only need one reviewer.\n# This helps reduce the review burden for low-risk PRs.\nrequire_one_review:\nif:\n- {{ not has.sensitive_files }}\n- {{ is.quick_review }}\n- {{ approvals.zero }}\nrun:\n- action: add-label@v1\nargs: label: \u23f3 Waiting for 1 reviewer\ncolor: {{ colors.yellow }}\n- action: add-reviewers@v1\nargs:\nreviewers: [{{ review_team }}]\nunless_reviewers_set: true\n- action: set-required-approvals@v1\nargs:\napprovals: 1\n# Set criteria for PRs that need extra reviewers.\n# This helps bring in extra scrutiny for large PRs or PRs that touch sensitive parts of the code.\nrequire_two_reviews:\nif:\n- {{ is.long_review or has.sensitive_files }}\n- {{ approvals.ltTwo }}\nrun:\n- action: add-label@v1\nargs: label: {{ '\u23f3 Waiting for 2 reviewers' if (approvals.zero) else '\u23f3 Waiting for 1 reviewer' }}\ncolor: {{ colors.yellow }}\n- action: add-reviewers@v1\nargs:\nreviewers: [{{ review_team }}]\nunless_reviewers_set: true\n- action: set-required-approvals@v1\nargs:\napprovals: 2\n# Flag low-risk PRs that are ready to merge.\nflag_quick_review_merge:\nif:\n- {{ not has.sensitive_files }}\n- {{ is.quick_review }}\n- {{ not has.do_not_merge_label }}\n- {{ approvals.gtZero }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \u270c\ufe0f Ready to merge\ncolor: {{ colors.green }}\n# Flag higher risk PRs that are ready to merge.\nflag_large_review_merge:\nif:\n- {{ is.long_review or has.sensitive_files }}\n- {{ approvals.gtOne }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \u270c\ufe0f Ready to merge\ncolor: {{ colors.green }}\n# +----------------------------------------------------------------------------+\n# | Custom Expressions                                                         |\n# | https://docs.gitstream.cm/how-it-works/#custom-expressions                 |\n# +----------------------------------------------------------------------------+\n# https://docs.gitstream.cm/filter-functions/#estimatedreviewtime\ncalc:\netr: {{ branch | estimatedReviewTime }}\nhas:\nsensitive_files: {{ files | match(list=sensitive) | some }}\ndo_not_merge_label: {{ pr.labels | match(term='Do not merge') | some }}\nis:\nsafe_change: {{ (source.diff.files | isFormattingChange) or (files | allDocs) or (files | allTests) or (files | allImages) }}\nquick_review: {{ files | length <= 7 and calc.etr <= long_review_threshold }}\nlong_review: {{ files | length > 7 or calc.etr > long_review_threshold }}\napprovals:\nzero: {{ pr.approvals | length == 0 }}\ngtZero: {{ pr.approvals | length > 0 }}\ngtOne: {{ pr.approvals | length > 1 }}\nltTwo: {{ pr.approvals | length < 2 }}\n# These are all of the colors in GitHub's default label color palette.\ncolors:\nred: 'b60205'\norange: 'd93f0b'\nyellow: 'fbca04'\ngreen: '0e8a16'\nblue: '1d76db'\npurple: '5319e7'\n
Download this example as a CM file.

"},{"location":"examples/#next-step","title":"Next Step","text":"

For a more detailed list of automations, check out the gitStream integrations page or automation library.

"},{"location":"execution-model/","title":"Execution Model","text":"

gitStream is triggered on new pull requests (PRs) for repositories that have gitStream installed. Upon triggering, gitStream collects context variables and evaluates the automation rules to determine which ones are relevant.

"},{"location":"execution-model/#organization-level-rules-and-repository-rules","title":"Organization-level rules and repository rules","text":"

When a central cm repository is set with the CI/CD runner, the events for PRs from all installed repositories shall be evaluated in the cm repository pipeline, considering the organization-level and PR repository rules.

"},{"location":"execution-model/#triggering-mechanism","title":"Triggering Mechanism","text":"

gitStream automations are triggered by events related to pull requests (PRs). You can specify triggers to fine-tune which events should initiate automations.

"},{"location":"execution-model/#implicit-triggers","title":"Implicit triggers","text":"

By default, gitStream evaluates any new commit pushed to the PR, triggering automation evaluation.

Additionally, if any of the automation rules reference the following pr context variables: pr.comments, pr.title, pr.description, or pr.labels, gitStream shall trigger and will initiate automation rules evaluation where there are changes to the PR comments, title, description, or labels respectfully.

This allows for greater flexibility in the automation process, ensuring that the relevant automation rules are evaluated and triggered when necessary. The execution model ensures the automation process is streamlined, efficient, and effective.

"},{"location":"execution-model/#explicit-triggers","title":"Explicit triggers","text":"

gitstream supports an explicit triggering mechanism. When using explicit triggers, the automations will run only according to the defined triggers, which means the Implicit triggers will not work. Automations triggered by explicit triggers will also be invoked on draft PRs

Triggers can be defined globally at the file level or specifically for each automation. Triggers are applied only to the file(s) where they are declared.

"},{"location":"execution-model/#triggers-section","title":"triggers section","text":"

Use explicit triggers to enhance the control and customization of automations in gitStream, when you need to define precisely when and how automations should be triggered based on various events and actions within pull requests.

The triggers is section specifies when automations are executed, supporting include and exclude lists for branch and repository patterns at the file level.

The on keyword can also be used within individual automations to define specific events that trigger those automations. Add the on keyword under the triggers key in the file and/or to a specific automation to define explicit triggers.

Key Type Description triggers.on [String] Specifies the explicit triggers that initiate the automations. triggers.include.branch [String or regex] Branches that match will trigger the automation. triggers.exclude.branch [String or regex] Branches that match will not trigger the automation. triggers.include.repository [String or regex] Repositories that match will trigger the automation. triggers.exclude.repository [String or regex] Repositories that match will not trigger the automation.

The table below lists supported explicit triggers, categorized into those enabled by default and those that require manual activation.

Triggering event Explicit Trigger Default (implicit triggers) Creating a PR pr_created on Commit commit on Adding label label_added when pr.label in .cm Removing label label_removed when pr.label in .cm Merging the PR merge off Adding new comment comment_added when pr.comment in .cm Editing an existing comment - when pr.comment in .cm Title change - when pr.title in .cm Description change - when pr.description in .cm Transition from draft to ready for review pr_ready_for_review off transition from any state to closed pr_closed off transition from closed to open pr_reopened off

Explicit triggers are set independently per each automation block and can be configured at the file level, specific to each automation separately or in combination. If triggers are listed at the file level and specific automation, the automation will be triggered according to both triggers. If an automation block does not have explicit triggers configured, it will be triggered according to the default (implicit) triggers.

Usage example:

triggers:\non:\n- pr_created\n- commit\nexclude:\nbranch:\n- hotfix\nautomations:\nskip_github_action_label:\non:\n- label_added\nif:\n- {{ pr.labels | match(term='experimental') | some }}\nrun:\n- action: add-github-check@v1\nargs:\ncheck_name: production-ci\nconclusion: skipped\n

Note on Matching:

  • When using a String as the matching type, the values in triggers.include.* and triggers.exclude.* require exact matches. This means that the names of branches or repositories must exactly match the specified string to either trigger or prevent triggering the automation.
  • For more precise control, use a regular expression (regex) format: r/REGEX_PATTERN/.

Default Behavior:

  • Implicit triggers are the default behavior if the automation doesn't have explicit triggers configured.
  • The automation runs for all branches and repositories if neither include nor exclude is specified.

Exclude/Include prioritization

  • Exclude overrides the include option. Thus, a repo will be excluded when a it matches both the include and exclude lists.

    In the following example, the automations in the file will be triggered for all repositories that contain the string feature, except for the repository my_feature

    triggers:\ninclude:\nrepository:\n- r/feature/\nexclude:\nrepository:\n- my_feature\n

"},{"location":"execution-model/#examples","title":"Examples","text":"
  • Assign code expert reviewer when the PR is created and after each commit. Ignore branches with the string \"hotfix\" in them

    triggers:\non:\n- pr_created\n- commit\nexclude:\nbranch:\n- hotfix\nautomations:\nassign_code_experts:\nif:\n- true\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: {{ repo | codeExperts(gt=10) }}\n

  • Explain code experts only if the label \u201csuggest-reviewer\u201d exists. The automation will be triggered after each commit and after each label addition. If the label \u201csuggest-reviewer\u201d exists, it will trigger the explain-code-experts automation

    triggers:\non:\n- commit\nautomations:\nexplain_code_experts:\non:\n- label_added\nif:\n- {{ pr.labels | match(term='suggest-reviewer') | some }}\nrun:\n- action: explain-code-experts@v1\nargs:\ngt: 10\n

  • Trigger only specific automations branch pattern A, and trigger other automation for all other branches except those that fit the pattern REGEX_PATTERN

    # Automation in this file will trigger only for branch pattern REGEX_PATTERN\ntriggers:\ninclude:\nbranch:\n- r/REGEX_PATTERN/\n
    # Automations in this file will trigger for all branches except pattern REGEX_PATTERN\ntriggers:\nexclude:\nbranch:\n- r/REGEX_PATTERN/\n

"},{"location":"faq/","title":"FAQ","text":""},{"location":"faq/#what-permissions-are-needed","title":"What permissions are needed?","text":"

In your repo permissions, make sure GitHub actions are permitted:

Go to Repo's settings > Actions > General > Actions permissions

Choose which repositories are permitted to use GitHub Actions.

[x] Allow all actions and reusable workflows

"},{"location":"faq/#does-gitstream-services-have-access-to-my-code","title":"Does gitStream services have access to my code?","text":"

Like any other CI/CD automation, the source code is being scanned in the repo and is not shared with any external services. Only metadata that relates and affects the workflow is shared to allow rule based automation on the repo.

"},{"location":"faq/#why-does-gitstream-require-permission-to-write-code","title":"Why does gitStream require permission to write code?","text":"

In order to support automations that either Approve or Merge PRs, GitHub API requires code write scope.

"},{"location":"faq/#what-repos-are-supported","title":"What repos are supported?","text":"

Any repo in GitHub is supported. More Git providers are planned soon.

"},{"location":"faq/#can-i-use-gitstream-with-merge-queues","title":"Can I use gitStream with Merge Queues?","text":"

Yes. When a merge queue is used, and gitStream is set as a required check, gitStream automation will be invoked with the merge event. The automation will set gitStream to a Completed status and Skipped conclusion to allow the PR merge.

"},{"location":"faq/#custom-filter-functions","title":"Custom filter functions","text":"

Coming soon.

"},{"location":"faq/#is-there-cm-syntax-highlighting","title":"Is there .cm syntax highlighting?","text":"

The .cm file use YAML with JINJA2, in order for your favorite editor to choose automatically the right syntax, you can use modelines.

Add the following line to the top of the .cm file (the default has it already):

# -*- mode: yaml -*-\n

Get a plug-in that enable modelines, popular ones are:

  • VS Code: Modelines
  • Sublime Text: CM syntax for ST4 or Emacs-like Sublime Modeline
  • Vim Modeline magic
"},{"location":"faq/#i-have-an-issue-i-cant-seem-to-solve-what-should-i-do","title":"I have an issue I can't seem to solve, what should I do?","text":"

Go to our issues page and check if there are any similar issues already reported. If not, create a new issue with all the details so we can take a look.

Found a bug? Create a new item in the project's issues

"},{"location":"filter-function-plugins/","title":"Filter Function Plugin Library","text":"

JavaScript plugins that enable custom filter functions for gitStream. To learn how to use these examples, read our guide on how to use gitStream plugins.

"},{"location":"filter-function-plugins/#comparemultisemver","title":"compareMultiSemver","text":"

Processes a list of pairs of semantic version numbers and determines the most significant change among them.

Returns: string - It returns a string of either: 'major' if any pair has a major version increment. 'minor' if no pair has a major version increment but has a minor version increment. 'patch' if no pair has major or minor version increments but has a patch version increment. 'downgrade' if no pairs have a higher version. 'equal' if all pairs are equal. 'error' if the comparison is abnormal or cannot be determined.

License: MIT

Param Type Default Description listOfPairs Array.<Array> An array of version pairs, where each pair is an array of two semantic version strings.

Example

{{ [[\"1.2.3\", \"0.2.1\"], [\"1.3.1\", \"1.2.3\"]] | compareMultiSemver  == \"major\" }}\n

Plugin Code: compareMultiSemver

/**\n * @module compareMultiSemver\n * @description Processes a list of pairs of semantic version numbers and determines the most significant change among them.\n * Each pair consists of two versions to be compared.\n * @param {string[][]} listOfPairs - An array of version pairs, where each pair is an array of two semantic version strings.\n * @returns {string} It returns a string of either:\n * 'major' if any pair has a major version increment.\n * 'minor' if no pair has a major version increment but has a minor version increment.\n * 'patch' if no pair has major or minor version increments but has a patch version increment.\n * 'downgrade' if no pairs have a higher version.\n * 'equal' if all pairs are equal.\n * 'error' if the comparison is abnormal or cannot be determined.\n * @example {{ [[\"1.2.3\", \"1.2.1\"], [\"1.3.1\", \"1.2.3\"]] | compareMultiSemver  == \"minor\" }}\n * @license MIT\n */\nconst compareSemver = require('../compareSemver/index.js');\nmodule.exports = (listOfPairs) => {\nconst priority = {\n'major': 3,\n'minor': 2,\n'patch': 1,\n'downgrade': 0,\n'equal': -1,\n'error': -2\n};\nlet mostSignificantChange = 'equal';\nlistOfPairs.forEach(pair => {\nconst result = compareSemver(pair);\nif (priority[result] > priority[mostSignificantChange]) {\nmostSignificantChange = result;\n}\n});\nreturn mostSignificantChange;\n}\nconst compareMultiSemver = require('./index.js');\nconsole.assert(compareMultiSemver([[\"1.2.3\", \"1.2.1\"], [\"1.3.1\", \"1.2.3\"]]) === 'minor', `compareSemver([[\"1.2.3\", \"1.2.1\"], [\"1.3.1\", \"1.2.3\"]]) == 'minor'`);\nconsole.assert(compareMultiSemver([[\"1.2.3\", \"0.2.1\"], [\"1.3.1\", \"1.2.3\"]]) === 'major', `compareMultiSemver([[\"1.2.3\", \"0.2.1\"], [\"1.3.1\", \"1.2.3\"]]) === 'major'`);\nconsole.assert(compareMultiSemver([[\"2.2.3\", \"0.2.1\"], [\"1.3.1\", \"1.2.3\"]]) === 'major', `compareMultiSemver([[\"2.2.3\", \"0.2.1\"], [\"1.3.1\", \"1.2.3\"]]) === 'major'`);\nconsole.assert(compareMultiSemver([[\"1.2.3\", \"1.2.1\"], [\"1.2.4\", \"1.2.3\"]]) === 'patch', `compareMultiSemver([[\"1.2.3\", \"1.2.1\"], [\"1.2.4\", \"1.2.3\"]]) === 'patch'`);\n

gitStream CM Example: compareMultiSemver

manifest:\nversion: 1.0\nautomations:\nbump_minor:\nif:\n- {{ bump == 'minor' }}\nrun:\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nbot `minor` version bumps are approved automatically.\nbump_patch:\nif:\n- {{ bump == 'patch' }}\nrun:\n- action: approve@v1\n- action: merge@v1\n- action: add-comment@v1\nargs:\ncomment: |\nbot `patch` version bumps are approved and merged automatically.\nbump: {{ [[\"1.2.3\", \"1.2.1\"], [\"1.3.1\", \"1.2.3\"]] | compareMultiSemver }}\n

Download Source Code

"},{"location":"filter-function-plugins/#comparesemver","title":"compareSemver","text":"

Compares two software version numbers (e.g., \"1.2.1\" or \"1.2b\") and determines the type of version change. The first version to be compared, and the second are passed as argument 1 and 2 or as array of 2 items. When V1 > V2 the it means and upgrade.

Returns: string - It returns a string of either: 'major' if the major version is incremented. 'minor' if the minor version is incremented. 'patch' if the patch version is incremented. 'downgrade' if the second version is lower than the first. 'equal' if both versions are equal. 'error' if the comparison is abnormal or cannot be determined. License: MIT

Param Type Default Description versions Array.<string> V1 and V2 in Semver format [lexicographical] boolean false compares each part of the version strings lexicographically instead of naturally; this allows suffixes such as \"b\" or \"dev\" but will cause \"1.10\" to be considered smaller than \"1.2\". [zeroExtend] boolean true changes the result if one version string has less parts than the other. In this case the shorter string will be padded with \"zero\" parts instead of being considered smaller.

Example

{{ [\"1.2.1\", \"1.2.3\"] | compareSemver  == \"patch\" }}\n

Plugin Code: compareSemver

/**\n * @module compareSemver\n * @description Compares two software version numbers (e.g., \"1.2.1\" or \"1.2b\") and determines the type of version change.\n * The first version to be compared, and the second are passed as argument 1 and 2 or as array of 2 items.\n * When V1 > V2 the it means and upgrade.\n * @param {string[]} versions - V1 and V2 in Semver format\n * @returns {string} It returns a string of either:\n * 'major' if the major version is incremented.\n * 'minor' if the minor version is incremented.\n * 'patch' if the patch version is incremented.\n * 'downgrade' if the second version is lower than the first.\n * 'equal' if both versions are equal.\n * 'error' if the comparison is abnormal or cannot be determined.\n * @example {{ [\"1.2.3\", \"1.2.1\"] | compareSemver  == \"patch\" }}\n * @license MIT\n**/\nmodule.exports = (v1, v2) => {\nconst lexicographical = false;\nconst zeroExtend = true;\n// support array as input\nif (Array.isArray(v1) && v2 === undefined) {\n[v1, v2] = v1; // Destructure the first two elements of the array into v1 and v2\n}\nlet v1parts = (v1 || \"0\").split('.');\nlet v2parts = (v2 || \"0\").split('.');\nconst isValidPart = x => lexicographical ? /^\\d+[A-Za-z\u03b1\u00df]*$/.test(x) : /^\\d+[A-Za-z\u03b1\u00df]?$/.test(x);\nif (!v1parts.every(isValidPart) || !v2parts.every(isValidPart)) {\nreturn 'error';\n}\nif (zeroExtend) {\nconst maxLength = Math.max(v1parts.length, v2parts.length);\nv1parts = [...v1parts, ...Array(maxLength - v1parts.length).fill(\"0\")];\nv2parts = [...v2parts, ...Array(maxLength - v2parts.length).fill(\"0\")];\n}\nconst convertPart = x => {\nconst match = /[A-Za-z\u03b1\u00df]/.exec(x);\nreturn Number(match ? x.replace(match[0], \".\" + x.charCodeAt(match.index)) : x);\n};\nif (!lexicographical) {\nv1parts = v1parts.map(convertPart);\nv2parts = v2parts.map(convertPart);\n}\nfor (let i = 0; i < v1parts.length; i++) {\nif (v1parts[i] !== v2parts[i]) {\nif (v1parts[i] < v2parts[i]) {\nreturn 'downgrade';\n}\nswitch (i) {\ncase 0: return 'major';\ncase 1: return 'minor';\ncase 2: return 'patch';\ndefault: return 'error';\n}\n}\n}\nreturn 'equal';\n}\nconst compareSemver = require('./index.js');\nconsole.assert(compareSemver([\"1.2.3\", \"1.2.1\"]) === 'patch', `compareSemver([\"1.2.3\", \"1.2.1\"]) == 'patch'`);\nconsole.assert(compareSemver([\"1.2.0\", \"1.2.1\"]) === 'downgrade', `compareSemver([\"1.2.0\", \"1.2.1\"]) === downgrade'`);\nconsole.assert(compareSemver([\"1.3.0\", \"1.2.1\"]) === 'minor', `compareSemver([\"1.3.0\", \"1.2.1\"]) == 'minor'`);\nconsole.assert(compareSemver([\"2.0.0\", \"1.2.1\"]) === 'major', `compareSemver([\"2.0.0\", \"1.2.1\"]) == 'major'`);\nconsole.assert(compareSemver([\"1.2.1\", \"1.2.1\"]) === 'equal', `compareSemver([\"1.2.1\", \"1.2.1\"]) == 'equal'`);\nconsole.assert(compareSemver([\"1.2b\", \"1.2.1\"]) === 'minor', `compareSemver([\"1.2b\", \"1.2.1\"]) == 'error'`);\nconsole.assert(compareSemver([\"1.2.0\", \"1.2\"]) === 'equal', `compareSemver([\"1.2.0\", \"1.2\"]) == 'equal'`);\nconsole.assert(compareSemver([\"1.2.1.0\", \"1.2.1\"]) === 'equal', `compareSemver([\"1.2.1.0\", \"1.2.1\"]) == 'equal'`);\nconsole.assert(compareSemver([\"1.2.1.0a\", \"1.2.1\"]) === 'error', `compareSemver([\"1.2.1.0a\", \"1.2.1\"]) === downgrade'`);\n

gitStream CM Example: compareSemver

manifest:\nversion: 1.0\nautomations:\nbump_minor:\nif:\n- {{ bump == 'minor' }}\nrun:\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nbot `minor` version bumps are approved automatically.\nbump_patch:\nif:\n- {{ bump == 'patch' }}\nrun:\n- action: approve@v1\n- action: merge@v1\n- action: add-comment@v1\nargs:\ncomment: |\nbot `patch` version bumps are approved and merged automatically.\nbump: {{ [\"1.2.3\", \"1.2.1\"] | compareSemver }}\n

Download Source Code

"},{"location":"filter-function-plugins/#extractdependabotversionbump","title":"extractDependabotVersionBump","text":"

Extract version bump information from Dependabot PRs description

Returns: Array.<string> - V1 (to) and V2 (from) License: MIT

Param Type Description description string the PR description

Example

{{ pr.description | extractDependabotVersionBump | compareSemver }}\n

Plugin Code: extractDependabotVersionBump

/**\n * @module extractDependabotVersionBump\n * @description Extract version bump information from Dependabot PRs description\n * @param {string} description - the PR description\n * @returns {string[]} V1 (to) and V2 (from)\n * @example {{ pr.description | extractDependabotVersionBump | compareSemver }}\n * @license MIT\n**/\nmodule.exports = (desc) => {\nif (desc && desc !== '\"\"' && desc !== \"''\" ) {    const matches = /Bumps.*from ([\\d\\.]+[A-Za-z\u03b1\u00df]*) to ([\\d\\.]+[A-Za-z\u03b1\u00df]*)/.exec(desc);\nif (matches && matches.length == 3) {\nvar [_, from, to] = matches;\n// remove trailing dot on to\nif (to[to.length - 1] === \".\") {\nto = to.slice(0, -1);\n}\nreturn [to, from];\n}\n}\nreturn null;\n}\n

gitStream CM Example: extractDependabotVersionBump

manifest:\nversion: 1.0\nautomations:\nbump_minor:\nif:\n- {{ bump == 'minor' }}\n- {{ branch.name | includes(term=\"dependabot\") }}\n- {{ branch.author | includes(term=\"dependabot\") }}\nrun:\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nDependabot `minor` version bumps are approved automatically.\nbump_patch:\nif:\n- {{ bump == 'patch' }}\n- {{ branch.name | includes(term=\"dependabot\") }}\n- {{ branch.author | includes(term=\"dependabot\") }}\nrun:\n- action: approve@v1\n- action: merge@v1\n- action: add-comment@v1\nargs:\ncomment: |\nDependabot `patch` version bumps are approved and merged automatically.\nbump: {{ pr.description | extractDependabotVersionBump | compareSemver }}\n

Download Source Code

"},{"location":"filter-function-plugins/#extractrenovateversionbump","title":"extractRenovateVersionBump","text":"

Extract version bump information from Renovate PRs description

Returns: Array.<string> - V1 (to) and V2 (from) License: MIT

Param Type Description description string the PR description

Example

{{ pr.description | extractRenovateVersionBump | compareMultiSemver }}\n

Plugin Code: extractRenovateVersionBump

/**\n * @module extractRenovateVersionBump\n * @description Extract version bump information from Renovate PRs description\n * @param {string} description - the PR description\n * @returns {string[]} V1 (to) and V2 (from)\n * @example {{ pr.description | extractRenovateVersionBump | compareMultiSemver }}\n * @license MIT\n**/\nmodule.exports = (desc) => {\nconst results = [];\nif (desc && desc !== '\"\"' && desc !== \"''\") {\nconst regex =\n/\\[[\\\\]*`([\\d\\.]+[A-Za-z\u03b1\u00df]*)[\\\\]*` -> [\\\\]*`([\\d\\.]+[A-Za-z\u03b1\u00df]*)[\\\\]*`\\]/g;\nlet matches = null;\ndo {\nmatches = regex.exec(desc);\nif (matches?.length === 3) {\nlet [_, from, to] = matches;\n// remove trailing dot on to\nif (to.at(-1) === \".\") {\nto = to.slice(0, -1);\n}\nresults.push([to, from]);\n}\n} while (matches !== null);\n}\nreturn results;\n}\n

gitStream CM Example: extractRenovateVersionBump

manifest:\nversion: 1.0\nautomations:\nbump_minor:\nif:\n- {{ bump == 'minor' }}\n- {{ branch.name | includes(term=\"renovate\") }}\n- {{ branch.author | includes(term=\"renovate\") }}\nrun:\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nRenovate `minor` version bumps are approved automatically.\nbump_patch:\nif:\n- {{ bump == 'patch' }}\n- {{ branch.name | includes(term=\"renovate\") }}\n- {{ branch.author | includes(term=\"renovate\") }}\nrun:\n- action: approve@v1\n- action: merge@v1\n- action: add-comment@v1\nargs:\ncomment: |\nRenovate `patch` version bumps are approved and merged automatically.\nbump: {{ pr.description | extractRenovateVersionBump | compareMultiSemver }}\n

Download Source Code

"},{"location":"filter-function-plugins/#extractsnykversionbump","title":"extractSnykVersionBump","text":"

Extract version bump information from Snyk PRs description

Returns: Array.<string> - V1 (to) and V2 (from) License: MIT

Param Type Description description string the PR description

Example

{{ pr.description | extractSnykVersionBump | compareSemver }}\n

Plugin Code: extractSnykVersionBump

/**\n * @module extractSnykVersionBump\n * @description Extract version bump information from Snyk PRs description\n * @param {string} description - the PR description\n * @returns {string[]} V1 (to) and V2 (from)\n * @example {{ pr.description | extractSnykVersionBump | compareSemver }}\n * @license MIT\n**/\nmodule.exports = (desc) => {\nif (desc && desc !== '\"\"' && desc !== \"''\" ) {    const matches = /Upgrade.*from ([\\d\\.]+[A-Za-z\u03b1\u00df]*) to ([\\d\\.]+[A-Za-z\u03b1\u00df]*)/.exec(desc);\nif (matches && matches.length == 3) {\nvar [_, from, to] = matches;\n// remove trailing dot on to\nif (to[to.length - 1] === \".\") {\nto = to.slice(0, -1);\n}\nreturn [to, from];\n}\n}\nreturn null;\n}\n

gitStream CM Example: extractSnykVersionBump

manifest:\nversion: 1.0\nautomations:\nbump_minor:\nif:\n- {{ bump == 'minor' }}\n- {{ branch.name | includes(term=\"snyk-update\"\") }}\n      - {{ branch.author | includes(term=\"snyk-update\"\") }}\nrun:\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nSnyk `minor` version bumps are approved automatically.\nbump_patch:\nif:\n- {{ bump == 'patch' }}\n- {{ branch.name | includes(term=\"snyk-update\"\") }}\n      - {{ branch.author | includes(term=\"snyk-update\"\") }}\nrun:\n- action: approve@v1\n- action: merge@v1\n- action: add-comment@v1\nargs:\ncomment: |\nSnyk `patch` version bumps are approved and merged automatically.\nbump: {{ pr.description | extractSnykVersionBump | compareSemver }}\n

Download Source Code

"},{"location":"filter-function-plugins/#extractorcafindings","title":"extractOrcaFindings","text":"

Extract security issues information from Orca PR reviews

Returns: Object - Findings Findings.infrastructure_as_code: { count: null, priority: '' }, Findings.vulnerabilities: { count: null, priority: '' }, Findings.secrets: { count: null, priority: '' }, License: MIT

Param Type Description PR Object the gitStream's PR context variable

Example

{{ pr | extractOrcaFindings }}\n

Usage example, that adds lables based on Orca Secuirty findings.

Plugin Code: extractOrcaFindings

/**\n * @module extractOrcaFindings\n * @description Extract security issues information from Orca PR reviews\n * @param {Object} pr - the gitStream's PR context variable\n * @returns {Object} Findings\n * Findings.infrastructure_as_code: { count: null, priority: '' },\n * Findings.vulnerabilities: { count: null, priority: '' },\n * Findings.secrets: { count: null, priority: '' },\n * @example {{ pr | extractOrcaFindings }}\n * @license MIT\n**/\nfunction getOrcaPropertyRating(lines, lineIdentifierRegex, findingsCellIndex) {\nconst matches = lines.filter(x => x.match(lineIdentifierRegex));\nconst [firstMatch] = matches;\nconst cells = firstMatch.split('|');\nconst [_, high, medium, low, info] = /\"High\"> ([\\d]+).*\"Medium\"> ([\\d]+).*\"Low\"> ([\\d]+).*\"Info\"> ([\\d]+)/\n.exec(cells[findingsCellIndex])\n.map(x => parseInt(x));\nreturn {high, medium, low, info};\n}\nmodule.exports = (pr) => {\nlet orcaObject = {\ninfrastructure_as_code: { count: null, priority: '' },\nvulnerabilities: { count: null, priority: '' },\nsecrets: { count: null, priority: '' },\n};\n// Orca comments are added as PR review\nconst orcaComment = pr.reviews.filter(x => x.commenter.includes('orca-security'));\nif (orcaComment.length) {\nconst orcaCommentArray = orcaComment[orcaComment.length - 1].content.split('\\n');\nvar priority = getOrcaPropertyRating(orcaCommentArray, /Infrastructure as Code/, 3);\norcaObject.infrastructure_as_code = {\ncount: priority.high + priority.medium + priority.low + priority.info,\npriority,\n};\nvar priority = getOrcaPropertyRating(orcaCommentArray, /Vulnerabilities/, 3);\norcaObject.vulnerabilities = {\ncount: priority.high + priority.medium + priority.low + priority.info,\npriority,\n};\nvar priority = getOrcaPropertyRating(orcaCommentArray, /Secrets/, 3);\norcaObject.secrets = {\ncount: priority.high + priority.medium + priority.low + priority.info,\npriority,\n};\n}\nreturn JSON.stringify(orcaObject);\n}\n

gitStream CM Example: extractOrcaFindings

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in reports %}\nlabel_orca_{{ item.name }}:\nif:\n- {{ item.count > 0 }}\nrun:\n- action: add-label@v1\nargs:\nlabel: 'orca:{{ item.name }}'\n{% endfor %}\norca: {{ pr | extractOrcaFindings }}\nreports:\n- name: introduced-cves\ncount: {{ orca.vulnerabilities.count }}\n- name: iac-misconfigurations\ncount: {{ orca.infrastructure_as_code.count }}\n- name: exposed-secrets count: {{ orca.secrets.count }}\ncolors:\nred: 'b60205'\n

Download Source Code

"},{"location":"filter-function-plugins/#getcodeowners","title":"getCodeowners","text":"

Resolves the PR's code owners based on the repository's CODEOWNERS file

Returns: Array.<string> - user names License: MIT

Param Type Description files Array.<string> the gitStream's files context variable pr Object the gitStream's pr context variable token string access token with repo:read scope, used to read the CODEOWNERS file

Example

{{ files | getCodeowners(pr, env.CODEOWNERS_TOKEN) }}\n

When used, create a secret TOKEN, and add it to the workflow file, in GitHub:

jobs:\n  gitStream:\n    ...\n    env:\n      CODEOWNERS: ${{ secrets.GITSTREAM_CODEOWNERS }}\n    steps:\n      - name: Evaluate Rules\n        uses: linear-b/gitstream-github-action@v2\n
Plugin Code: getCodeowners

/**\n * @module getCodeowners\n * @description Resolves the PR's code owners based on the repository's CODEOWNERS file\n * @param {string[]} files - the gitStream's files context variable\n * @param {Object} pr - the gitStream's pr context variable\n * @param {string} token - access token with repo:read scope, used to read the CODEOWNERS file\n * @returns {string[]} user names\n * @example {{ files | getCodeowners(pr, env.CODEOWNERS_TOKEN) }}\n * @license MIT\n**/\nconst { Octokit } = require(\"@octokit/rest\");\nconst ignore = require('./ignore/index.js');\nasync function loadCodeownersFile(owner, repo, auth) {\nconst octokit = new Octokit({\nrequest: { fetch },\nauth,\n});\nconst res = await octokit.repos.getContent({\nowner,\nrepo,\npath: 'CODEOWNERS'\n});\nreturn Buffer.from(res.data.content, 'base64').toString()\n}\nfunction codeownersMapping(data) {\nreturn data\n.toString()\n.split('\\n')\n.filter(x => x && !x.startsWith('#'))\n.map(x => x.split(\"#\")[0])\n.map(x => {\nconst line = x.trim();\nconst [path, ...owners] = line.split(/\\s+/);\nreturn {path, owners};\n});\n}\nfunction resolveCodeowner(mapping, file) {\nconst match = mapping\n.slice()\n.reverse()\n.find(x =>\nignore()\n.add(x.path)\n.ignores(file)\n);\nif (!match) return false;\nreturn match.owners;\n}\nmodule.exports = {\nasync: true,\nfilter: async (files, pr, token, callback) => {\nconst fileData = await loadCodeownersFile(pr.author, pr.repo, token);\nconst mapping = codeownersMapping(fileData);\nconst resolved = files\n.map(f => resolveCodeowner(mapping, f))\n.flat()\n.filter(i => typeof i === 'string')\n.map(u => u.replace(/^@/, \"\"));\nconst unique = [...new Set(resolved)];\nreturn callback(null, unique); },\n}\n

gitStream CM Example: getCodeowners

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nsenior_review:\nif:\n- true\nrun:\n- action: explain-code-experts@v1\nargs:\ngt: 10\n- action: add-reviewers@v1\nargs:\nreviewers: {{ experts | intersection(list=owners) }}\nexperts: {{ repo | codeExperts(gt=10) }}\nowners: {{ files | codeowners(pr, env.CODEOWNERS) }}\n

Download Source Code

"},{"location":"filter-function-plugins/#hasjiraissue","title":"hasJiraIssue","text":"

Check to see if the input string matches a specified field for one or more Jira issues.

Returns: boolean - Returns true if the input string matches a Jira task title. License: MIT

Param Type Description input string The string to search for a Jira task title. password string Your Jira API token key string The Jira key to search for matches against the input string. jiraSpaceName string The name of the Jira space to search for tasks. email string The email address associated with the Jira API token.

Example

{{ \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\" | hasJiraIssue(password, key, jiraSpaceName, email) }}\n

Prerequisite Configuration

You will need to complete the following steps to use this plugin:

  1. Create an API token for your Jira account.
  2. Make the token available to gitStream via an environment variable.
Plugin Code: hasJiraIssue

/**\n * @module hasJiraIssue\n * @description Check to see if the input string matches a specified field for one or more Jira issues.\n * @param {string} input - The string to search for a Jira task title.\n * @param {string} password - Your Jira API token\n * @param {string} key - The Jira key to search for matches against the input string.\n * @param {string} jiraSpaceName - The name of the Jira space to search for tasks.\n * @param {string} email - The email address associated with the Jira API token.\n * @returns {boolean} Returns true if the input string matches a Jira task title. \n * @example {{ \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\" | hasJiraIssue(password, key, jiraSpaceName, email) }}\n * @license MIT\n */\nmodule.exports = {\nasync: true,\nfilter: async (inputString, password, key, jiraSpaceName, email, callback) => {\nconst jql = `\"${key}\" = \"${inputString}\"`;\nconst resp = await fetch(`https://${jiraSpaceName}.atlassian.net/rest/api/2/search`, {\nmethod: 'POST',\nheaders: {\n'Content-Type': 'application/json',\n'Authorization': 'Basic ' + btoa(`${email}:${password}`)\n},\nbody: JSON.stringify({\n'jql': jql,\n'maxResults': 1,\n\"fieldsByKeys\": true,\n'fields': [ 'assignee' ]\n})\n});\nconst results = await resp.json();\nreturn callback(null,  !!results.issues?.length);\n}\n}\n

gitStream CM Example: hasJiraIssue

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n###### ** Configure This Section ** ######\n# Configure this for your Jira instance and the email associated with your API key.\n# You can safely use these values because only your API key is sensitive. \njiraSpaceName: \"my-company\" # e.g. my-company.atlassian.net\nemail: \"my.email@example.com\"\n# If you're concerned about exposing this information,\n# we recommend using environment variables for your production environment.\n# -----------\n# Pass the API token associated with the email above to gitStream via an environment variable.\njiraAuth: {{ env.JIRA_API_TOKEN }}\n# Learn more about env: https://docs.gitstream.cm/context-variables/#env\n# -----------\n# Change this to the Jira field you want to match the input string against.\njiraField: \"myField\"\n# If you want to search a custom field, you should provide the ID like so:\n# jiraField: \"cf[XXXXX]\"\n# Replace XXXXX with the ID of the custom field you want to search.\n# More information:\n# Using JQL to search the Jira API: https://support.atlassian.com/jira-service-management-cloud/docs/jql-fields/\n# How to find the ID of a custom field: https://confluence.atlassian.com/jirakb/how-to-find-any-custom-field-s-ids-744522503.html\n# -----------\nprUrl: \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\nhas_jira_issue: {{ prUrl  | hasJiraIssue(jiraAuth, jiraField, jiraSpaceName, email) }}\nautomations:\nhas_jira_issue: if:\n- {{ not has_jira_issue }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: \"This PR is missing a related issue in Jira. Please create a Jira task.\"\n

Download Source Code

"},{"location":"filter-function-plugins/#isflaggeduser","title":"isFlaggedUser","text":"

Returns true if the username that is passed to this function is specified in a predefined list of users. This is useful if you want gitStream automations to run only for specified users.

Returns: boolean - Returns true if the user is specified in the flaggedUsers list, otherwise false. License: MIT

Param Type Description Input string The GitHub username to check.

Example

{{ pr.author | isFlaggedUser }}\n

Plugin Code: isFlaggedUser

// Add users who you want to add to the flag list.\nconst flaggedUsers = [\"user1\", \"user2\"];\n/**\n * @module isFlaggedUser\n * @description Returns true if the username that is passed to this function is specified in a predefined list of users. \n * This is useful if you want gitStream automations to run only for specified users.\n * @param {string} Input - The GitHub username to check.\n * @returns {boolean} Returns true if the user is specified in the flaggedUsers list, otherwise false.\n * @example {{ pr.author | isFlaggedUser }}\n * @license MIT\n */\nfunction isFlaggedUser(username) {\nif (flaggedUsers.includes(username)) {\nreturn true;\n} else {\nreturn false;\n}\n};\nfunction containsString(arr, str) {\nreturn arr.includes(str);\n};\nmodule.exports = isFlaggedUser;\n

gitStream CM Example: isFlaggedUser

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\ndetect_flagged_user:\nif:\n- {{ pr.author | isFlaggedUser }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: {{ pr.author }} is a gitStream user.\n

Download Source Code

"},{"location":"filter-functions/","title":"Filter functions","text":"

Filters can change the look and format of the source data, or even generate new data derived from the input values. What's important is that the original data is replaced by the result of transformations, and that's what ends up in rendered templates.

Note

Items marked with are under development and are not available yet.

"},{"location":"filter-functions/#overview","title":"Overview","text":"

The following functions are supported in addition to the built-in functions provided by Nunjucks.

"},{"location":"filter-functions/#low-level-functions","title":"Low level functions","text":"Function Input Args Output captureFind and return the first occurrence of a regex in the input string String regex [Objects] differenceGiven two lists, keep only items that are in the 1st list but not in the 2nd. [Objects] list [Objects] everyChecks whether all element in the list are true [Bool] - Bool filterReduce list of items into a list of same items that match the specified term [String][Object] regex, term, list, attr [String][Object] includesCheck if substring match String regex, term, list Bool intersectionGiven two lists, keep only items that are in both lists. [Objects] list [Objects] mapMaps each object in a list into their specified attribute value [Object] attr [Object] matchMaps list of items into a list of booleans that match the specified term [String][Object] regex, term, list attr [Bool] nopeChecks whether all element in the list are false [Bool] - Bool rejectInverse of filter, the result list contains non-matching items [String][Object] regex, term, list, attr [String][Object] someChecks whether at least one element in the list is true [Bool] - Bool"},{"location":"filter-functions/#high-level-functions","title":"High level functions","text":"Function Input Args Output allDocsChecks the list includes only documents files - Bool allImagesChecks the list includes only images files - Bool allTestsChecks the list includes only tests files - Bool codeExpertsGet list of contributors based on expert reviewer model results repo gt, lt [String] estimatedReviewTimeEstimated review time in minutes branch - Integer extensionsLists all the unique file extensions [String] - [String] extractJitFindings Get an object with a summary of the findings found by the Jit scan pr - Object extractSonarFindings Get an object with a summary of the findings found by the SonarCloud scan pr - Object explainRankByGitBlameShort markdown text explaining rankByGitBlame results repo gt, lt [String] isFirstCommitChecks if its the author first commit in the repo repo.contributors String Bool isFormattingChangeChecks that only formatting changed [FileDiff ] - Bool mapToEnumreturn the enum value matches to the input key String Enum object Object matchDiffLinesMatch every line in diff [FileDiff ] regex, ignoreWhiteSpaces [Bool] rankByGitActivityGet list of contributors based on git-commit activity repo gt, lt [String] rankByGitBlameGet list of contributors based on git-blame results repo gt, lt [String]"},{"location":"filter-functions/#named-arguments","title":"Named arguments","text":"

Some functions support named arguments, many of these repeat in different functions.

term - a single string, used as a substring to match with the matched item.

list - a list of strings, trying to match any of the listed substrings with the matched item.

regex - a single string, used as a regular expression with the matched item. A regular expression can be created just like JavaScript, but needs to be prefixed with r, for example, r/^foo.*/g, for more info see Nunjucks.

attr - a key in the element to use when doing the requested operation.

For example, the following expressions provide an identical result:

- {{ 'something' | includes(regex=r/^some.*/) }}\n- {{ 'something' | includes(term='some') }}\n- {{ 'something' | includes(list=['some']) }}\n
"},{"location":"filter-functions/#reference","title":"Reference","text":""},{"location":"filter-functions/#capture","title":"capture","text":"

Extract the first match of the regex in the input string. If no match is found, the function returns an empty string.

Argument Usage Type Description - Input String The string to find the match in regex Input String Search term to match with the input string - Output Bool The first substring that match the provided regex

For example, the following line will extract the substring \"hello wo\" from the input

{{ \"hello world\" | capture(regex=r/he.+o/) }}\n
"},{"location":"filter-functions/#difference","title":"difference","text":"

Given two lists, keep only items that are in the 1st list but not in the 2nd.

Argument Usage Type Description - Input [Objects] List of objects to inspect. list Input [Objects] List of objects to exclude. - Output [Objects] Returns a list of objects containing items that exist in one input, but not in the other."},{"location":"filter-functions/#every","title":"every","text":"

Checks whether all element in the list are\u00a0true. In case the list of elements is empty, it will return false.

Argument Usage Type Description - Input [Bool] List of booleans - Output Bool Returns true when all list items are true

For example, check that all changes are in either 'src' or 'dest' directories:

{{ files | match(list=['src', 'dest']) | every }}\n
"},{"location":"filter-functions/#filter","title":"filter","text":"

Creates a shallow copy of a portion of a given list, filtered down to just the elements that match the given term. You can use either a single term, regex, or a list of terms to match with.

Argument Usage Type Description - Input [String][Object] The list of strings to match, or list of objects if attr is used termregexlist Input (either) StringString[String] Search term to match with the input items attr Input (optional) String match a named attribute in the input object - Output [String][Object] The list with only the matching items

Examples: Check if all changes to JavaScript files are in the tests directory:

{{ files | filter(regex=r/\\.js$/) | match(regex=r/tests\\//) | every }}\n

Check if all changes to JavaScript files are formatting:

{{ source.diff.files | filter(attr='new_file', regex=r/\\.js$/) | isFormattingChange }}\n

Check if the PR has new Python files:

{{ branch.diff.files_metadata | filter(attr='original_file', regex=r/^$/) | filter(attr='new_file', regex=r/\\.py$/) | some }}\n

"},{"location":"filter-functions/#includes","title":"includes","text":"

Determines whether a string includes a certain substring. You can use either a single term, regex, or a list of terms to match with.

Argument Usage Type Description - Input String The string you want to check for matching substrings termregexlist Input (either) StringString[String] Substring term to match - Output Bool true if search terms matches

Check string matches either of the terms:

{{ 'something' | includes(list=['any', 'thing']) }}\n
"},{"location":"filter-functions/#intersection","title":"intersection","text":"

Given two lists, keep only items that are in both lists.

Argument Usage Type Description - Input [Objects] List of objects to inspect. list Input [Objects] List of objects to check for intersection. - Output [Objects] Returns a list of objects containing items that intersect between the two lists."},{"location":"filter-functions/#map","title":"map","text":"

Creates a new list populated with the values of the selected attribute of every element in the input list.

Argument Usage Type Description - Input [Object] The list of objects to map, see context for valid inputs attr Input String Object attribute to select - Output [Object] List of the selected object attributes

For example, the source.diff.files context holds a list of FileDiff , each has new_file attribute. You can create a list of all the new file names by mapping to the new_file attribute and then check if there are changes to any handler.js file:

{{ source.diff.files | map(attr='new_file') | match(term='handler.js') | some }}\n
"},{"location":"filter-functions/#match","title":"match","text":"

Return true for each element in the list that match the search term.

Argument Usage Type Description - Input [String][Object] The list of strings or if attr used the list of objects termregexlist Input (either) StringString[String] Search term to match attr Input String match a named attribute in the input object - Output [Bool] true for every matching item

For example, to check if all code changes are in the tests directory:

{{ files | match(regex=r/tests\\//) | every }}\n

For example, to check if there are code changes with specific function call:

{{ source.diff.files | match(attr='diff', term='myFunction') | some }}\n
"},{"location":"filter-functions/#nope","title":"nope","text":"

The inverse of every, checks whether all elements in the list are\u00a0false. In case the list of elements is empty, it will return true.

Argument Usage Type Description - Input [Bool] List of booleans - Output Bool Returns true when all list items are false

For example, check that no changes in either 'src' or 'dest' directories:

{{ files | match(list=['src', 'dest']) | nope }}\n
"},{"location":"filter-functions/#reject","title":"reject","text":"

Creates a shallow copy of a portion of a given list, filtered down to just the elements that do not match the given term. You can use either a single term, regex, or a list of terms to match with.

Argument Usage Type Description - Input [String][Object] The list of strings to match, or list of objects if attr is used termregexlist Input (either) StringString[String] Search term to match with the input items attr Input (optional) String match a named attribute in the input object - Output [String][Object] The list with only the non-matching items

For example, check if all changes, but JavaScript files are in tests directory:

{{ files | reject(regex=r/\\.js$/) | match(regex=r/tests\\//') | every }}\n

For example, check if all changes except for config.json files are formatting:

{{ source.diff.files | reject(attr='new_file', regex=r/config\\.json$/) | isFormattingChange }}\n
"},{"location":"filter-functions/#some","title":"some","text":"

Checks whether any element in the list is\u00a0true. In case the list of elements is empty it will return false.

Argument Usage Type Description - Input [Bool] List of booleans - Output Bool Returns true when any of the items is true
{{ files | match(list=['src', 'dest']) | some }}\n
"},{"location":"filter-functions/#alldocs","title":"allDocs","text":"

Return true if the input list includes only documents based on file extensions.

Doc files extensions are: md, mkdown, txt, rst, adoc, except for requirements.txt.

Argument Usage Type Description - Input files The list of changed files with their path - Output Bool true if all file extensions are of docs
{{ files | allDocs }}\n

In case you want to exclude more files, like all txt under the requirements directory, add another check:

{{ (files | allDocs) and (files | match(regex=r/requirements\\/.*\\.txt$/) | nope ) }}\n
"},{"location":"filter-functions/#allimages","title":"allImages","text":"

Return true if the input list includes only images based on file extensions.

Image file extensions are: svg, png, gif.

Argument Usage Type Description - Input files The list of changed files with their path - Output Bool true if all file extensions are of images
{{ files | allImages }}\n
"},{"location":"filter-functions/#alltests","title":"allTests","text":"

Return true if the input list includes only tests based on the file's path and name.

To identify as test the file must include the word test or spec in its name or path, it is checked using this regex: [^a-zA-Z0-9](spec|test|tests)[^a-zA-Z0-9].

Argument Usage Type Description - Input files The list of changed files with their path - Output Bool true if all file tests are based on name and path
{{ files | allTests }}\n
"},{"location":"filter-functions/#codeexperts","title":"codeExperts","text":"

When requesting a review for a pull request, it's important to select a reviewer who has a deep understanding of the relevant code area, the domain problem, and the framework being used. This ensures that the reviewer can provide specific and informed feedback, rather than general comments that may not take into account the context in which the issue was solved.

The filter provides the list of most qualified contributors based on git-blame and git-commit results to determine who has been most active in the relevant code area, and then combines this information into a score between 0 and 100. The commit activity is scored higher for recent commits, which ensures that those who are actively contributing to the codebase are given higher priority as potential reviewers. The result will be limited to 2 users and shall not include the PR author.

The output lists the Git provider users, e.g., GitHub users, which are mapped from the Git users included in the git-blame output. When gitStream cannot map the Git user to a Git provider user it will be dropped from the output list, hence the list may contain less than 100% of the lines.

Note

The codeExperts filter function calls gitStream app API with the repo context to calculate the estimated review time value.

Argument Usage Type Description - Input repo The repo context variable lt Input Integer Filter the user list, keeping those below the specified threshold gt Input Integer Filter the user list, keeping those above the specified threshold - Output [String] Up to 2 users, sorted by best match first (it won't include the PR author)

For example:

automations:\ncode_experts:\nif:\n- true\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: {{ repo | codeExperts(gt=10) }}\n
"},{"location":"filter-functions/#estimatedreviewtime","title":"estimatedReviewTime","text":"

Returns the estimated review time in minutes based on statistical model. The model uses the amount of additions and deletions statistics for each file type with additional information about the commits and base branch.

Note

The estimatedReviewTime filter function calls gitStream app API with the branch context to calculate the estimated review time value.

The following files are excluded when calculating this value:

Argument Usage Type Description - Input branch Branch meta data - Output Integer the estimated time for review in minutes
{{ branch | estimatedReviewTime }}\n

The following files are automatically excluded from the estimated review time calculation.

File type Filter type Values Data Extension ini csv xls xlsx xlr doc docx txt pps ppt pptx dot dotx log tar rtf dat ipynb po profile object obj dxf twb bcsymbolmap tfstate pdf rbi pem crt svg png jpeg jpg ttf Data Regex .*dist/.*\\.js$ .*public/assets/.*\\.js$ Pipeline Regex .*ci\\.yml$ Lock File Name Programming Language Package Manager package-lock.json JavaScript npm yarn.lock JavaScript Yarn npm-shrinkwrap.json JavaScript npm Pipfile.lock Python pipenv poetry.lock Python Poetry conda-lock.yml Python conda Gemfile.lock Ruby Bundler composer.lock PHP Composer packages.lock.json .NET NuGet project.assets.json .NET .NET Core pom.xml Java Maven Cargo.lock Rust Cargo mix.lock Elixir Mix pubspec.lock Dart/Flutter pub go.sum Go Go modules stack.yaml.lock Haskell Stack vcpkg.json C++ vcpkg conan.lock C++ Conan ivy.xml Scala sbt/Ivy project.clj Clojure Leiningen Podfile.lock Swift/Objective-C CocoaPods Cartfile.resolved Swift/Objective-C Carthage flake.lock Nix Nix

Tip

You can also filter more files, using config.ignore_files.

"},{"location":"filter-functions/#extensions","title":"extensions","text":"

Expects files and provide a list of all unique file extensions.

Argument Usage Type Description - Input files The list of changed files with their path - Output [String] List of all unique file extensions

For example, check that only one file type was changed:

{{ files | extensions | length == 1 }}\n
"},{"location":"filter-functions/#extractjitfindings","title":"extractJitFindings","text":"

Available in GitHub only

This filter is currently availalbe only in GitHub

Get an object with a summary of the findings found by Jit scan. This filter is relevant only for repos that use Jit to scan PRs

The pr context includes all the reviews in the pull request, including the reviews written by the Jit bot, along with all the comments (conversations) to the review.

This filter reads and parses the reviews with Jit's findings, making them available for use inside the .cm file automations.

The output is an object of the following format:

{\n\"vulnerabilities\": [{\n\"security_control\": 'string',\n\"type\": 'string',\n\"description\": 'string',\n\"severity\": 'string',\n\"summary\": 'string'\n}],\n\"metrics\": {\n\"HIGH\": number,\n\"MEDIUM\": number,\n\"LOW\": number,\n\"INFO\": number\n}\n}\n

Argument Usage Type Description - Input pr The pr context variable - Output Object The object contains the summary of Jit's scan

Example of the filter output

{\n\"vulnerabilities\": [\n{\n\"security_control\": \"Static Code Analysis Js\",\n\"type\": \"Codsec.Javascriptnosql-Injection.Nosql-Injection\",\n\"description\": \"Putting request data into a mongo query can leadto a NoSQL Injection. Be sure to properly sanitize thedata if you absolutely must pass request data into a query.\",\n\"severity\": \"HIGH\",\n\"summary\": \"Jit Bot commands and options (e.g., ignore issue)\"\n},\n{\n\"security_control\": \"Secret Detection\",\n\"type\": \"Private-Key\",\n\"description\": \"Private Key\",\n\"severity\": \"HIGH\",\n\"summary\": \"Jit Bot commands and options (e.g., ignore issue)\"\n}\n],\n\"metrics\": {\n\"HIGH\": 2,\n\"MEDIUM\": 0,\n\"LOW\": 0,\n\"INFO\": 0\n}\n}\n

Assign the output to a variable

jit: {{ pr | extractJitFindings }}\n

Add a label if Jit detected secrets in the PR

automations:\nadd_bugs_label:\nif:\n- {{ jit.metrics.HIGH > 0 }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"Vulnerable code!\"\"\n
"},{"location":"filter-functions/#extractsonarfindings","title":"extractSonarFindings","text":"

Available in GitHub only

This filter is currently availalbe only in GitHub

Get an object with a summary of the findings found by the SonarCloud scan. This filter is relevant only for repos that use SonarCloud to scan PRs

The pr context includes all the comments added to the pull request, including the comment written by the SonarCloud bot that holds a summary of its scan.

This filter reads and parses the comment with SonarCloud's scan summary and makes them available to use inside the .cm file automations.

The output is an object of the following format:

{\n\"bugs\": {\n\"count\": number,\n\"rating\": 'string' //('A'-'E')\n},\n\"code_smells\": {\n\"count\": number,\n\"rating\": 'string' //('A'-'E')\n},\n\"vulnerabilities\": {\n\"count\": number,\n\"rating\": 'string' //('A'-'E')\n},\n\"security_hotspots\": {\n\"count\": number,\n\"rating\": 'string' //('A'-'E')\n},\n\"duplications\": number,\n\"coverage\": number\n}\n

Argument Usage Type Description - Input pr The pr context variable - Output Object The object contains the summary of SonCloud's scan

Example of the filter output

{\n\"bugs\": {\n\"count\": 1,\n\"rating\": 'B'\n},\n\"code_smells\": {\n\"count\": 2,\n\"rating\": 'B'\n},\n\"vulnerabilities\": {\n\"count\": 2,\n\"rating\": 'E'\n},\n\"security_hotspots\": {\n\"count\": 0,\n\"rating\": 'A'\n},\n\"duplications\": 3,\n\"coverage\": 70\n}\n

Assign the output to a variable

sonar: {{ pr | extractSonarFindings }}\n

Add a label with the number of bugs if the bugs rating is other than 'A', and use mapToEnum to set its color

automations:\n# Add Bugs label\nshow_bugs_count:\nif:\n- {{ sonar.bugs.count > 0}}\nrun:\n- action: add-label@v1\nargs:\nlabel: '\ud83d\udc1e x {{ sonar.bugs.count }} Bugs'\ncolor: {{ sonar.bugs.rating | mapToEnum(enum = colors) }}\ncolors:\nA: '05AA02'\nB: 'B6D146'\nC: 'EABE05'\nD: 'DF8339'\nE: 'D4343F'\n
"},{"location":"filter-functions/#explainrankbygitblame","title":"explainRankByGitBlame","text":"

This filter helps to explain the results of rankByGitBlame, the output is in Markdown format that can be used in a PR comment.

The output lists the Git provider users, e.g., GitHub users, which are mapped from the Git users included in the git-blame output. Git users that could not be automatically mapped are marked with *. To map these users, you can add user_mapping see instructions here.

Argument Usage Type Description - Input repo The repo context variable lt Input Integer Filter the user list, keeping those below the specified threshold gt Input Integer Filter the user list, keeping those above the specified threshold - Output String Explaining rankByGitBlame results in markdown format

Note

Each contributor's result is rounded down to the nearest integer, so the total may add up to less than 100%.

For example:

automations:\nthe_right_reviewer:\nif:\n- true\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: {{ repo | rankByGitBlame(gt=50) }}\n- action: add-comment@v1\nargs:\ncomment: |\n{{ repo | explainRankByGitBlame(gt=50) }}\n

Note the comment starts with | and a new-line as explainRankByGitBlame generates a multiline comment.

"},{"location":"filter-functions/#isfirstcommit","title":"isFirstCommit","text":"

Return true if it's the author first commit in the repo.

Argument Usage Type Description - Input repo.contributors List of contributors in the repo - Input String The contributor name - Output Bool true if its the first commit of the selected contributor
if:\n- {{ repo.contributors | isFirstCommit(branch.author) }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: \"Welcome {{branch.author}}!\"\n
"},{"location":"filter-functions/#isformattingchange","title":"isFormattingChange","text":"

Return true if all file diffs are validated as formatting changes. This filter function works for JavaScript, TypeScript, Python, JSON, YAML and HTML.

gitStream determines formatting changes by minifying the source code for the incoming changes and the existing code and comparing them. If they are identical, this filter function returns true. If any unsupported languages are contained in the PR, gitStream will return false.

Argument Usage Type Description - Input source.diff.files List of file diffs - Output Bool true if the all code changes are non functional
{{ source.diff.files | isFormattingChange }}\n
"},{"location":"filter-functions/#maptoenum","title":"mapToEnum","text":"

Get the enum value matches to the input key

Argument Usage Type Description - Input String The key name enum Input Enum Object The enum object to which the input string should be matched - Output Object The value of the input key in the input enum object

For example, set a label color according to names in the enum:

automations:\nlabel_color:\nif:\n- true\nrun:\n- action: add-label@v1\nargs:\nlabel: 'Blue label'\ncolor: {{ \"blue\" | mapToEnum(enum = colors) }}\ncolors:\nred: 'FF0000'\ngreen: '00FF00'\nblue: '0000FF'\nyellow: 'FFFF00'\n
"},{"location":"filter-functions/#matchdifflines","title":"matchDiffLines","text":"

Checks diff for matching lines.

Argument Usage Type Description - Input [Object] The list of objects regex Input String Regex term to match with the input items, use \\\\ for \\ ignoreWhiteSpaces Input Bool false by default, match a named attribute in the input object caseSensitive Input Bool true by default, ignore case when matching terms - Output [Bool] true for every matching object

For example, to check if all the changes are of adding prints and ignore white spaces:

{{ source.diff.files | matchDiffLines(regex=r/^\\+.*console\\.log/, ignoreWhiteSpaces=true) | every }}\n
"},{"location":"filter-functions/#rankbygitactivity","title":"rankByGitActivity","text":"

Get list of contributors based on git-commit activity.

The repo context includes all the changed files, for each file it includes each contributor number of lines changed every week over the last 52 weeks, based on git-commit.

These functions compare each contributor changes per week and yield an average percentage of contribution for any given file. For example, in a certain week a file had 500 line changed, 200 by a first user, while 3 other users changed 100 lines each. So the score for the first user in that week will be 40 (200/500 in %). The function then average the score for each user for the selected time period.

Then you can use the thresholds to get the right reviewer.

Argument Usage Type Description - Input repo The repo context variable weeks Input Integer The number of last weeks to include lt Input Integer Filter the user list, keeping those below the specified threshold gt Input Integer Filter the user list, keeping those above the specified threshold - Output [String] The list of users based on their code score comparison

Check if the branch author is a rookie

active_coders: {{ repo | rankByGitActivity(gt=50, weeks=12) }}\n
"},{"location":"filter-functions/#rankbygitblame","title":"rankByGitBlame","text":"

Get list of contributors based on git-blame results

The repo context includes all the changed files, for each file it includes the contributors' percentage of lines in the file, based on git-blame.

This function sums all these percentages per user and yield an average percentage of contribution. Then you can use the thresholds to get the right reviewer.

The output lists the Git provider users, e.g., GitHub users, which are mapped from the Git users included in the git-blame output. When gitStream cannot map the Git user to a Git provider user it will be dropped from the output list, hence the list may contain less than 100% of the lines.

Argument Usage Type Description - Input repo The repo context variable lt Input Integer Filter the user list, keeping those below the specified threshold gt Input Integer Filter the user list, keeping those above the specified threshold - Output [String] The list of users based on their code score comparison, sorted by rank - first has highest score

Example of the filter output, note the output are GitHub users in the example:

[\n\"PopeyeUser\",\n\"olive_user\",\n\"BRUTUS_USER\"\n]\n

Get the most significant contributors for the PR files:

contributors: {{ repo | rankByGitBlame(gt=30) }}\n

Check if the branch author is a rookie

is_rookie: {{ repo | rankByGitBlame(lt=15) | match(term=branch.author) | some }}\n
"},{"location":"gitStream-playground/","title":"Playground","text":"

Welcome to gitStream Playground! This platform allows you to thoroughly test gitStream automations before deploying them into the .cm rule file on any GitHub pull request of your choice.

Playground

"},{"location":"gitStream-playground/#getting-started","title":"Getting Started","text":""},{"location":"gitStream-playground/#accessing-gitstream-playground","title":"Accessing gitStream Playground","text":"

To access gitStream Playground, visit https://app.gitstream.cm/playground. To be able to test automations of private repository PRs, log in with your GitHub account credentials.

"},{"location":"gitStream-playground/#interface-overview","title":"Interface Overview","text":"

The gitStream Playground interface consists of the following sections:

  1. Login \\ User icon: supports the following actions
    • Login
    • Logout
    • View user
    • Change organization
  2. Pull Request Link: An input textbox for a link to the pull request
  3. cm editor: Code input box where you can write automations to be executed by the playground. estimated_time_to_review and safe_changes are provided by default.
  4. Output section, with the following tabs:
    • Output - shows syntax errors when the .cm automation syntax is wrong. After running gitStream - it shows the expected result of the automation on the chosen Pull Request.
    • Context Variables - Shows the values of all Context variables of the chosen Pull Request.
"},{"location":"gitStream-playground/#testing-automations","title":"Testing Automations","text":""},{"location":"gitStream-playground/#selecting-a-pull-request","title":"Selecting a Pull Request","text":"

On GitHub, navigate to any pull request, copy its link, and paste it onto the \"Pull request link\" box. If the PR is part of a private repo, you must also log in to the playground with a GitHub user accessible to this repository.

"},{"location":"gitStream-playground/#running-gitstream","title":"Running gitStream","text":"
  1. Add the desired automations to the editor. Make sure there are no syntax errors
  2. Click \"Run gitStream.\"
  3. The rule engine loads the PR and runs the automations defined in the .cm editor.
"},{"location":"gitStream-playground/#viewing-results","title":"Viewing Results","text":"

The automation results will be shown in the \"Output\" tab at the bottom of the interface. Context Variables will be shown in the \"Context Variables\" tab.

"},{"location":"gitStream-playground/#feedback-and-support","title":"Feedback and Support","text":"

For additional assistance or to provide feedback, please open an issue on our GitHub issues page

"},{"location":"github-installation/","title":"How to Setup gitStream with GitHub","text":"

Install gitStream

Before you can complete the gitStream setup process, you need to install the gitStream app to your GitHub organization.

"},{"location":"github-installation/#setup","title":"Setup","text":"

You can set up gitStream for a single repo or your entire GitHub organization. Select the tab below for the instructions you want.

Single RepoGitHub Organization

Single Repo Setup

You must implement two main components for gitStream to function for a single GitHub repo. The first is a configuration file that defines the workflow automations to execute for the repo. The second is a GitHub actions configuration file that triggers gitStream when PRs are created or updated.

Required Configurations

gitStream

Create a .cm/gitstream.cm rules file in your repository's default branch (usually master or main). This file will contain a YAML configuration that determines the workflows that run on the repo, and you can name it anything you want as long as it ends in .cm

Here is an example of a gitStream configuration file you can use to setup some basic workflow automations.

# -*- mode: yaml -*-\n# This example configuration for provides basic automations to get started with gitStream.\n# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/\nmanifest:\nversion: 1.0\nautomations:\n# Add a label that indicates how many minutes it will take to review the PR.\nestimated_time_to_review:\nif:\n- true\nrun:\n- action: add-label@v1\nargs:\nlabel: \"{{ calc.etr }} min review\"\ncolor: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}\n# Inform PR authors when they fail to reference Jira tickets in the PR title or description.\nlabel_missing_jira_info:\nif:\n- {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"missing-jira\"\ncolor: {{ colors.red }}\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR is missing a Jira ticket reference in the title or description.\nPlease add a Jira ticket reference to the title or description of this PR.\n# Post a comment that lists the best experts for the files that were modified.\nexplain_code_experts:\nif:\n- true\nrun:\n- action: explain-code-experts@v1 args:\ngt: 10 # +----------------------------------------------------------------------------+\n# | Custom Expressions                                                         |\n# | https://docs.gitstream.cm/how-it-works/#custom-expressions                 |\n# +----------------------------------------------------------------------------+\ncalc:\netr: {{ branch | estimatedReviewTime }}\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\\/browse\\/\\w{1,}-\\d{3,4}/) }}\ncolors:\nred: 'b60205'\nyellow: 'fbca04'\ngreen: '0e8a16'\n

Github Actions

Once your gitStream configuration file is setup, you need a Github Actions configuration file to trigger gitStream automations. Create a .github/workflows/gitstream.yml file in your repository's default branch (usually master or main) and add the following configuration:

# Code generated by gitStream GitHub app - DO NOT EDIT\nname: gitStream workflow automation\nrun-name: |\n/:\\ gitStream: PR #${{ fromJSON(fromJSON(github.event.inputs.client_payload)).pullRequestNumber }} from ${{ github.event.inputs.full_repository }}\non:\nworkflow_dispatch:\ninputs:\nclient_payload:\ndescription: The Client payload\nrequired: true\nfull_repository:\ndescription: the repository name include the owner in `owner/repo_name` format\nrequired: true\nhead_ref:\ndescription: the head sha\nrequired: true\nbase_ref:\ndescription: the base ref required: true\ninstallation_id:\ndescription: the installation id\nrequired: false\nresolver_url:\ndescription: the resolver url to pass results to\nrequired: true\nresolver_token:\ndescription: Optional resolver token for resolver service\nrequired: false\ndefault: ''\njobs:\ngitStream:\ntimeout-minutes: 5\nruns-on: ubuntu-latest\nname: gitStream workflow automation\nsteps:\n- name: Evaluate Rules\nuses: linear-b/gitstream-github-action@v2\nid: rules-engine\nwith:\nfull_repository: ${{ github.event.inputs.full_repository }}\nhead_ref: ${{ github.event.inputs.head_ref }}\nbase_ref: ${{ github.event.inputs.base_ref }}\nclient_payload: ${{ github.event.inputs.client_payload }}\ninstallation_id: ${{ github.event.inputs.installation_id }}\nresolver_url: ${{ github.event.inputs.resolver_url }}\nresolver_token: ${{ github.event.inputs.resolver_token }}\n

Success

When finished, you should have the following file structure in your repo.

.\n\u251c\u2500 .cm/\n\u2502  \u2514\u2500 gitstream.cm\n\u251c\u2500 .github/\n\u2502  \u2514\u2500 workflows/\n\u2502     \u2514\u2500 gitstream.yml\n

GitHub Organization Setup

Organization rules are ideal when you want to enforce consistent rules across every repo in your organization. You can define them by creating a special repository named cm in your GitHub organization where you can add automation files that will apply to all repositories within that organization.

Prerequisite: Create a cm repo and enable gitStream.

Organization-wide automations need to be defined in a repo named \"cm\" inside your GitHub organization. Before continuing, you must create this repo and enable the gitStream app for it.

Required Configurations

gitStream

Create a gitstream.cm rules file in the root directory of your cm repository's default branch (usually master or main). This file will contain a YAML configuration that determines the workflows that run on your organization's repos. You can name it anything you want as long as it ends in .cm

Configuration files go in the repo's root directory.

Unlike the set up instructions for a single repo, your .cm files should be placed in the repository's root directory.

# -*- mode: yaml -*-\n# This example configuration for provides basic automations to get started with gitStream.\n# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/\nmanifest:\nversion: 1.0\nautomations:\n# Add a label that indicates how many minutes it will take to review the PR.\nestimated_time_to_review:\nif:\n- true\nrun:\n- action: add-label@v1\nargs:\nlabel: \"{{ calc.etr }} min review\"\ncolor: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}\n# Inform PR authors when they fail to reference Jira tickets in the PR title or description.\nlabel_missing_jira_info:\nif:\n- {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"missing-jira\"\ncolor: {{ colors.red }}\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR is missing a Jira ticket reference in the title or description.\nPlease add a Jira ticket reference to the title or description of this PR.\n# Post a comment that lists the best experts for the files that were modified.\nexplain_code_experts:\nif:\n- true\nrun:\n- action: explain-code-experts@v1 args:\ngt: 10 # +----------------------------------------------------------------------------+\n# | Custom Expressions                                                         |\n# | https://docs.gitstream.cm/how-it-works/#custom-expressions                 |\n# +----------------------------------------------------------------------------+\ncalc:\netr: {{ branch | estimatedReviewTime }}\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\\/browse\\/\\w{1,}-\\d{3,4}/) }}\ncolors:\nred: 'b60205'\nyellow: 'fbca04'\ngreen: '0e8a16'\n
GitHub Actions

Once your gitStream configuration file is set up, you will need to create a Github Actions configuration file to trigger gitStream automations. Create a .github/workflows/gitstream.yml file in your cm repository's default branch (usually master or main) and add the following configuration:

# Code generated by gitStream GitHub app - DO NOT EDIT\nname: gitStream workflow automation\nrun-name: |\n/:\\ gitStream: PR #${{ fromJSON(fromJSON(github.event.inputs.client_payload)).pullRequestNumber }} from ${{ github.event.inputs.full_repository }}\non:\nworkflow_dispatch:\ninputs:\nclient_payload:\ndescription: The Client payload\nrequired: true\nfull_repository:\ndescription: the repository name include the owner in `owner/repo_name` format\nrequired: true\nhead_ref:\ndescription: the head sha\nrequired: true\nbase_ref:\ndescription: the base ref required: true\ninstallation_id:\ndescription: the installation id\nrequired: false\nresolver_url:\ndescription: the resolver url to pass results to\nrequired: true\nresolver_token:\ndescription: Optional resolver token for resolver service\nrequired: false\ndefault: ''\njobs:\ngitStream:\ntimeout-minutes: 5\nruns-on: ubuntu-latest\nname: gitStream workflow automation\nsteps:\n- name: Evaluate Rules\nuses: linear-b/gitstream-github-action@v2\nid: rules-engine\nwith:\nfull_repository: ${{ github.event.inputs.full_repository }}\nhead_ref: ${{ github.event.inputs.head_ref }}\nbase_ref: ${{ github.event.inputs.base_ref }}\nclient_payload: ${{ github.event.inputs.client_payload }}\ninstallation_id: ${{ github.event.inputs.installation_id }}\nresolver_url: ${{ github.event.inputs.resolver_url }}\nresolver_token: ${{ github.event.inputs.resolver_token }}\n

Success

Once finished, all PRs to your organization's repositories will be processed by the GitHub Action in this repo, and your cm repo should have a file directory that looks like this.

.\n\u251c\u2500 gitstream.cm\n\u251c\u2500 .github/\n\u2502  \u2514\u2500 workflows/\n\u2502     \u2514\u2500 gitstream.yml\n

gitStream will now do these two things.

When a PR is created or changed, apply or update a label that provides an estimated time to review.\n![Estimated Review Time label](screenshots/etr_label_example.png)\n![Estimated review time](screenshots/slack-estimated-review-time-example-1-min.png)\n\nWhen a new PR is created, comment with a list of code experts.\n![Suggested reviewers](screenshots/github-codeexperts-expanded.png)\n
"},{"location":"github-installation/#next-step","title":"Next Step","text":"

How gitStream Works

Read our guide: [How gitStream Works](/how-it-works/) to get an overview of the gitStream syntax and automation lifecycle.\n
"},{"location":"github-installation/#additional-resources","title":"Additional Resources","text":""},{"location":"github-installation/#required-github-permissions","title":"Required GitHub Permissions","text":"Permissions Reason Write access to dedicated gitStream app files Used to set up the gitStream workflow files Write access to code To allow gitStream to approve PRs once all conditions are met Read access to administration, issues, and metadata To get the user team membership, and branch protection settings Read and write access to actions, checks, pull requests, and workflows Trigger workflows, create and update pull requests and their checks, and modify workflow files User email Used to identify users"},{"location":"github-installation/#configure-gitstream-to-block-merges","title":"Configure gitStream to Block Merges","text":"

You can configure Github to require gitStream checks to pass before PRs can be merged using branch protection rules.

Run a gitStream check before continuing

You need to run a check using your gitStream configuration at least once before it can be set as a required check. Make sure to open at least 1 PR before doing this setting.

Here are the steps to configure gitStream in your repo's branch protection rules.

  1. Go to repo settings
  2. On the left panel select Code and automation > Branches
  3. Set Branch protection rules for your desired branch
  4. Enable Require status checks to pass before merging
  5. Search for status checks in the last week for this repository
  6. Select gitStream.cm as required check

"},{"location":"github-installation/#configuring-gitstream-with-self-hosted-runners","title":"Configuring gitStream with Self-Hosted Runners","text":"

Follow these steps to ensure gitStream runs on self-hosted GitHub Actions runners:

  1. Configure Self-Hosted Runners

    • Set up self-hosted runners for your GitHub organization or repository. Refer to GitHub documentation on self-hosted runners and using them in a workflow for detailed instructions.
  2. Prerequisites for Self-Hosted Runners

    • Git: Installation instructions can be found here.
    • Python 3.x
      • black 24.4.2
  3. Update GitHub Actions Configuration

    • Modify the gitStream GitHub Actions workflow file (.github/workflows/gitstream.yml) to specify self-hosted runners:
    jobs:\ngitStream:\nruns-on: self-hosted\n# ... other configuration ...\n
  4. Save and Commit

    • Save changes to the workflow file and commit them to your repository.
  5. Test with a Sample PR

    • Create a sample pull request to verify gitStream's behavior with self-hosted runners.
"},{"location":"github-installation/#uninstalling-gitstream","title":"Uninstalling gitStream","text":"

Configure in your GitHub organization, and choose Uninstall \"gitStream.cm\"

"},{"location":"github-org-level/","title":"Github org level","text":"

Deprecated

"},{"location":"github-required-check/","title":"Github required check","text":"

Deprecated

"},{"location":"gitlab-installation/","title":"How to Setup gitStream with GitLab","text":"

Prerequisites

  1. GitLab cloud
  2. GitLab runner v15 or higher
  3. Login, or create a free account on the LinearB app, and follow the steps to connect gitStream Using a GitLab Integration.

GitLab Installation Overview

  1. Designate a gitStream user account.
  2. Create a CM configuration file.
  3. Create a GitLab pipeline.
  4. Install the gitStream service.
"},{"location":"gitlab-installation/#designate-a-gitstream-user-account","title":"Designate a gitStream User Account","text":"

gitStream automation rules are executed on behalf of the user account configured when you install the gitStream service. This account must have the maintainer or owner role to the relevant repos.

We recommend creating a dedicated service account to control access to individual repos easily. You can also use your professional or personal GitLab account for this, which would result in all automations being executed under that account, which might also affect LinearB's metrics.

Use this account when you integrate gitStream

Make sure to use this account when authorizing GitLab in LinearB.

"},{"location":"gitlab-installation/#create-a-cm-repo-and-a-cm-configuration-file","title":"Create a cm repo and a CM Configuration File","text":"

Group rules are ideal when you want to enforce consistent rules across every repo in your GitLab group. You can define them by creating a special repository named cm in the parent group for the git repositories on which you want to run gitStream. Here, you can add automation files that apply to all repositories within that group that are connected to gitStream.

Create a cm project (repository) in your GitLab group, and create a gitstream.cm rules file in the root directory of your cm repository's default branch (usually master or main). This file will contain a YAML configuration that determines the workflows that run on your organization's repos. You can name the CM file anything you want as long as it ends in .cm

Configuration files go in the repo's root directory.

Group-level rules require your .cm files to be placed in the repository's root directory. You can also define specific repo-level rules under the .cm folder in each of the connected repositories

Example Configuration

Here is an example of a gitStream configuration file to set up some basic workflow automations.\n```yaml+jinja\n# -*- mode: yaml -*-\n# This example configuration for provides basic automations to get started with gitStream.\n# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/\nmanifest:\n  version: 1.0\n\n\nautomations:\n  # Add a label that indicates how many minutes it will take to review the PR.\n  estimated_time_to_review:\n    if:\n      - true\n    run:\n      - action: add-label@v1\n        args:\n          label: \"{{ calc.etr }} min review\"\n          color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}\n  # Inform PR authors when they fail to reference Jira tickets in the PR title or description.\n  label_missing_jira_info:\n    if:\n      - {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}\n    run:\n      - action: add-label@v1\n        args:\n          label: \"missing-jira\"\n          color: {{ colors.red }}\n      - action: add-comment@v1\n        args:\n          comment: |\n            This PR is missing a Jira ticket reference in the title or description.\n            Please add a Jira ticket reference to the title or description of this PR.\n  # Post a comment that lists the best experts for the files that were modified.\n  explain_code_experts:\n    if:\n      - true\n    run:\n      - action: explain-code-experts@v1 \n        args:\n          gt: 10 \n\n\n# +----------------------------------------------------------------------------+\n# | Custom Expressions                                                         |\n# | https://docs.gitstream.cm/how-it-works/#custom-expressions                 |\n# +----------------------------------------------------------------------------+\n\ncalc:\n  etr: {{ branch | estimatedReviewTime }}\n\nhas:\n  jira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\n  jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\\/browse\\/\\w{1,}-\\d{3,4}/) }}\n\ncolors:\n  red: 'b60205'\n  yellow: 'fbca04'\n  green: '0e8a16'\n```\n
"},{"location":"gitlab-installation/#create-a-gitlab-pipeline","title":"Create a GitLab Pipeline","text":"

Once your gitStream configuration file is set up, you need a GitLab CI configuration file to trigger gitStream automations. Create a cm project (repository) in your GitLab group if you haven't already. It should be created in the same group or a parent group of the target repositories. Create a .gitlab-ci.yml file in your new cm repository's default branch (usually master or main) and add the following configuration:

GitLab-Hosted runnersSelf-Managed Runners - ShellSelf-Managed Runners - Kubernetes

Gitlab-Hosted Runners

Use the following .gitlab-ci.yml

# Code generated by gitStream - DO NOT EDIT\ngitstream-job:\nstage: gitstream-main\nimage: gitstream/rules-engine:latest\nonly:\nvariables:\n- $GITSTREAM_MAIN_JOB\nexcept:\nvariables:\n- $GITSTREAM_BLOCK_MERGE\nscript:\n- apk update && apk add git\n- mkdir /code\n- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${repoUrl} /code/repo\n- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${cmUrl} /code/cm\n- cd /code && cd repo && git fetch --all && git checkout $base_ref && git pull && ls && git checkout $head_ref && git pull && ls\n- |\nHEAD_REF=$head_ref BASE_REF=$base_ref CLIENT_PAYLOAD=\"$client_payload\" RULES_RESOLVER_URL=$resolver_url \\\nRULES_RESOLVER_TOKEN=$resolver_token  DEBUG_MODE=true npm run start\n

Self-Managed Runners

First, register the runner with a tag, and use the named tag in the .gitlab-ci.yml file

Self-Managed Runners

First, register the runner with a tag, and use the named tag in the .gitlab-ci.yml file

Configuring the image location

By default, gitStream pulls the image from DockerHub each time it is invoked. You can configure gitStream to pull the docker image from your own registry, to allow faster build times and reduced bandwidth usage - especially for teams with high CI/CD throughput, by downloading the image and storing it in your own registry (ECR or K8S registry, for example) and changing the cm/.gitlab-ci.yml accordingly:

script:\n- ...\n- docker pull YOUR-REGISTRY-URL/gitstream/rules-engine:latest\n
The docker image can be pulled to your private repository from DockerHub.

"},{"location":"gitlab-installation/#shell-executors","title":"Shell executors","text":"

Use the tag created above in the workflow file cm/.gitlab-ci.yml instead REGISTERED-TAG

# Code generated by gitStream - DO NOT EDIT\nstages:\n- gitstream-main\nimage: docker:latest\nservices:\n- docker:dind\nbefore_script:\n- docker login -u \"$CI_REGISTRY_USER\" -p \"$CI_REGISTRY_PASSWORD\" $CI_REGISTRY\ngitstream-job:\nstage: gitstream-main\ntags:\n- REGISTERED-TAG\nonly:\nvariables:\n- $GITSTREAM_MAIN_JOB\nexcept:\nvariables:\n- $GITSTREAM_BLOCK_MERGE\nscript:\n- apk update && apk add git && apk add docker\n- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${repoUrl} gitstream/repo\n- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${cmUrl} gitstream/cm\n- cd gitstream && cd repo && git fetch --all && git checkout $base_ref && git pull && ls && git checkout $head_ref && git pull && ls\n- docker pull gitstream/rules-engine:latest\n- |\ndocker run -v $CI_PROJECT_DIR/gitstream:/code \\\n-e HEAD_REF=$head_ref \\\n-e BASE_REF=$base_ref \\\n-e CLIENT_PAYLOAD=\"$client_payload\" \\\n-e RULES_RESOLVER_URL=$resolver_url \\\n-e RULES_RESOLVER_TOKEN=$resolver_token \\\n-e DEBUG_MODE=true  gitstream/rules-engine:latest\n

"},{"location":"gitlab-installation/#kubernetes-executors","title":"Kubernetes executors","text":"
  1. Ensure your runner configuration (config.toml for example) has the followig:
    [runners.kubernetes]\nprivileged = true\n
  2. Use the tag created above in the workflow file cm/.gitlab-ci.yml instead REGISTERED-TAG
    # Code generated by gitStream - DO NOT EDIT\nvariables:\nDOCKER_DRIVER: overlay2\nDOCKER_HOST: tcp://docker:2375\nDOCKER_TLS_CERTDIR: \"\"\nstages:\n- gitstream-main\nimage: docker:latest\nservices:\n- name: docker:dind\ncommand: [\"--mtu=1450\", \"--tls=false\"]\nbefore_script:\n- docker login -u \"$CI_REGISTRY_USER\" -p \"$CI_REGISTRY_PASSWORD\" $CI_REGISTRY\ngitstream-job:\nstage: gitstream-main\ntags:\n- REGISTERED-TAG\nonly:\nvariables:\n- $GITSTREAM_MAIN_JOB\nexcept:\nvariables:\n- $GITSTREAM_BLOCK_MERGE\nscript:\n- apk update && apk add git && apk add docker\n- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${repoUrl} gitstream/repo\n- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}${cmUrl} gitstream/cm\n- cd gitstream && cd repo && git fetch --all && git checkout $base_ref && git pull && ls && git checkout $head_ref && git pull && ls\n- docker pull gitstream/rules-engine:latest\n- |\ndocker run -v $CI_PROJECT_DIR/gitstream:/code \\\n-e HEAD_REF=$head_ref \\\n-e BASE_REF=$base_ref \\\n-e CLIENT_PAYLOAD=\"$client_payload\" \\\n-e RULES_RESOLVER_URL=$resolver_url \\\n-e RULES_RESOLVER_TOKEN=$resolver_token \\\n-e DEBUG_MODE=true  gitstream/rules-engine:latest\n
"},{"location":"gitlab-installation/#next-step","title":"Next Step","text":"

If you successfully complete these instructions, gitStream will now do these two things.

When a PR is created or changed, apply or update a label that provides an estimated time to review.

When a suggest-reviewers label is applied to a PR, gitStream will comment with a list of code experts.

How gitStream Works

Read our guide, How gitStream Works, for a deeper understanding of gitStream's capabilities and how to leverage them fully and to get an overview of the gitStream syntax and automation lifecycle.

"},{"location":"gitlab-installation/#additional-resources","title":"Additional Resources","text":""},{"location":"gitlab-installation/#required-gitlab-permissions","title":"Required GitLab Permissions","text":"

The required permissions are:

Permissions Reason Read/Write API To get notified on MR changes and allow gitStream to approve MRs once all conditions are met Read repository To read and check rules over the code changes on monitored repositories Read user profile Used to identify users"},{"location":"how-it-works/","title":"How gitStream Works","text":"

You can configure gitStream via one or more Continuous Merge (CM) files inside your git repository or GitHub/GitLab organization. These files end with a .cm extension, and they outline automations that will run for your repo's pull requests.

"},{"location":"how-it-works/#syntax-overview","title":"Syntax Overview","text":"

CM files contain a combination of YAML and Jinja2 to build rules that follow an \"if this, then that\" approach to triggering and executing automations. This, combined with templating and gitStream-specific functions gives you a highly-flexible framework for building custom CM automations.

All CM files must have a section that starts with automations: that contains one or more custom automations that will trigger for the repo. By default, gitStream is triggered every time someone opens a new PR or pushes a commit to an existing PR. Once activated, gitStream searches for applicable CM files and executes the automations that are listed inside them.

Explicit Triggers

You can configure gitStream to trigger for other PR interactions, including comments, labels, and merge status. Read more about the gitStream execution model.

Here is an example of the basic components that are required in every CM file.

Required CM Components

Please note, this is not a valid CM automation, it is only for illustrative purposes.

    # -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nmy_automation:\nif:\n- # Add a condition here\nrun:\n- # Add an automation here\n

Info

When editing CM files, make sure you preserve the indentation in the examples because, like YAML, gitStream uses Python-style indentation to indicate nesting.

"},{"location":"how-it-works/#automation-actions","title":"Automation Actions","text":"

Automation actions define the desired automations triggered when specific conditions are met. Each automation must contain an if condition and a run section. Conditions are evaluated when a PR is created or modified. Multiple conditions can be listed, but all must be true to trigger the actions.

Any number of actions can be included in a single automation, and these actions are invoked one-by-one in no particular order. PRs marked as Draft are ignored by default, and this behavior can be modified using explicit triggers (GitHub only).

Basic Automation Example

This example defines an automation named welcome_newcomer that post a comment to welcome anyone who submits their first PR to the repo.

automations:\nwelcome_newcomer:\nif: - {{ repo.contributors | isFirstCommit(branch.author) }}\nrun: - action: add-comment@v1\nargs:\ncomment: Welcome {{branch.author}}!\n

"},{"location":"how-it-works/#context-variables-and-filter-functions","title":"Context Variables and Filter Functions","text":"

Context variables are pre-defined objects that gitStream provides as the input data you will need to build your automations. These variables enable you to access information about things like the file names and paths, the person who submitted the PR, or what code was changed.

Filter functions are functions you can call and apply to variables. They are called with a pipe operator | and can take arguments inside parentheses ( ). The logic expressions are based on Jinja2 syntax, supported by the Nunjucks library.

Context Variable and Filter Function Example

The following statement passes the context variable files to the filter function match which uses an optional list of sensitive filepaths that would need to be defined later in the CM file, and returns true if any of the files match the list as indicated by the some filter function.

{{ files | match(list=sensitive) | some }}\n

You can also apply Nunjucks logic operators to filters

Logic Operators Example

This example inverts the previous example using the keyword not.

{{ not (files | match(list=sensitive) | some )}}\n

"},{"location":"how-it-works/#custom-expressions","title":"Custom Expressions","text":"

Jinja templating makes it easy to write custom expressions that can be invoked elsewhere in your CM files. This makes it easy to reuse data, define custom criteria, and keep your configuration files cleaner so they're easier to manage.

Custom Expressions Example

This example contains two custom expressions; is: contains a context variable and some filter functions that are invoked in the sensitive_review automation via is.sensitive, and sensitive directories contains a list of directory paths that will be matched in the filter function.

automations:\nsensitive_review:\nif:\n- is.sensitive\nrun:\n- action: set-required-approvals@v1\nargs:\napprovals: 2\nis:\nsensitive: {{ files | match(list=sensitive_directories) | some }}\nsensitive_directories:\n- src/app/auth/\n- src/app/routing/\n- src/app/resources/\n

"},{"location":"how-it-works/#built-in-functions","title":"Built-in Functions","text":"

gitStream is built on top of Jinja2 and provides all default filters from that library. gitStream also includes extra filters on top of Jinja2 that are specific to git repo workflow automations.

Warning

Don't use these terms when naming automations, plugins, custom expressions, or any other component of gitStream because this will lead to naming conflicts

gitStream filters:

allDocs allImages allTests automations codeExperts config difference estimatedReviewTime explainCodeExperts explainRankByGitBlame extractJitFindings extractSonarFindings extensions every filter includes isFirstCommit isFormattingChange intersection manifest map mapToEnum match matchDiffLines nope rankByGitActivity rankByGitBlame reject some

Nunjucks filters:

abs asyncAll asyncEach batch block call capitalize center default dictsort dump e escape extends filter first float for forceescape groupby if import include indent int join last length list lower macro nl2br raw reject rejectattr replace reverse round safe select selectattr set slice sort string striptags sum title trim truncate upper urlencode urlize verbatim wordcount

"},{"location":"how-it-works/#ignore-files","title":"Ignore Files","text":"

You can provide gitStream with a list of specific files to ignore for all automations listed in the same CM file. To do so, add a configuration: section to the CM file that you want to apply the exclusion list to. In the configuration section, add a list of files as an argument to the ignore_files: key.

How to Ignore Files

To ignore a list of files, add a config.ignore_files to you CM file like this:

config:\nignore_files:\n- 'yarn.lock'\n- 'package-lock.json'\n- 'openapi.json'\n- 'ui/src/**/*Model.d.ts'\n

"},{"location":"how-it-works/#configuration-priority-and-overrides","title":"Configuration Priority and Overrides","text":"

You can provide any number of CM files and automations for gitStream to process and you can freely combine organization-level automations with automations inside individual repos. There are two important things you need to keep in mind when doing this.

First, when a repository defines the same automation as an organization-level rule, the repository automation will take precedence and override the organization automation. The CM file name and the automation name must both match for this to take effect because gitStream identifies all automations based on a combination of both. For example, if you have a gitstream.cm file that contains an automation named my_automation, gitStream will identify that as gitstream/my_automation.

Second, no priority is given to individual automations. Instead, gitStream collects all applicable automations for a given PR and processes them all at once.

"},{"location":"how-it-works/#plugins","title":"Plugins","text":"

gitStream supports the use of JavaScript plugins to create new filter functions. This enables you to write code that further extends gitStream capabilities and connect gitStream to external API services. Read the guide on writing gitStream

"},{"location":"how-it-works/#next-step","title":"Next Step","text":"

Write your first automation.

The best way to familiarize yourself with CM syntax is to build automations, and we've covered enough info for you to start!

If you're ready to start writing automations, check out our guide: Write Your First Automation.

"},{"location":"how-it-works/#additional-resources","title":"Additional Resources","text":""},{"location":"how-it-works/#gitstream-ui","title":"gitStream UI","text":"

Once you have gitStream installed and have run some automations, you can view details about them at app.linearb.io/automations. To view gitStream automation data, you will need to login with your LinearB user account.

"},{"location":"how-it-works/#functional-overview","title":"Functional Overview","text":"

Once gitStream is installed and configured, there are several services that will interact with your repository whenever a PR is created or changed:

  • The git service provider API (e.g. GitHub, Gitlab)
  • The gitStream service that was installed from the git service provider marketplace.
  • A gitStream CI/CD script that is configured for the git service provider (e.g. GitHub Actions, GitLab CI/CD).
  • A gitStream agent the CI/CD script triggers to execute your automation.

Whenever a new PR is opened or an existing PR is changed (see also Execution Model), the following process occurs:

  1. The git service provider API notifies the gitStream service that an applicable change has occured to the PR which triggers a call to execute the gitStream CI/CD script.
  2. The gitStream CI/CD script executes the GitHub Action linear-b/gitstream-github-action@v2 on the repository, which looks for two things:
    • Valid CM files that match the filepath .cm/*.cm
    • Any CM files that are contained in the root directory of the organization's cm repo (if applicable).
  3. The gitStream CI/CD script passes all CM metadata to the gitStream agent which parses a list of all applicable CM rules.
  4. The GitStream agent provides the list of applicable automations to the gitStream service.
  5. The gitStream service iterates through the automations and updates the PR via the git service provider API.

Here is a diagram that illustrates how things work behind the scenes:

sequenceDiagram\n  autonumber\n  Git Provider API->>gitStream app: PR Notification\n  activate gitStream app\n  gitStream app->>gitStream CI/CD script: Execute CI/CD Action\n  activate gitStream CI/CD script\n  gitStream CI/CD script->>gitStream agent: CM Metadata\n  activate gitStream agent\n  gitStream agent->>gitStream app: Applicable Automations \n  deactivate gitStream agent\n  deactivate gitStream CI/CD script\n  loop Automations\n    loop Actions\n      gitStream app->>Git Provider API: Update PR\n    end\n   end\n  deactivate gitStream app
Upon completion, gitStream will show one of the following three statuses:

  • Success - when the applicable automation finished and PR is good to go
  • Neutral - when there aren't any applicable automations for the PR
  • Failed - when the applicable automation finished without completion

gitStream checks have a 10-minute timeout for fail-safe reasons. If the check exceeds this time limit, the result will be displayed as Neutral - Skipped.

"},{"location":"how-it-works/#syntax-highlighting","title":"Syntax highlighting","text":"

You can add support for .cm in your code editor, see FAQ.

"},{"location":"how-it-works/#is-something-missing","title":"Is something missing?","text":"

If you find an issue with these docs or with gitStream itself, please search the gitStream issues page and create an issue if one doesn't already exist for your problem.

"},{"location":"plugins/","title":"Filter Function Plugins","text":"

gitStream enables you to build JavaScript plugins to extend functionality for more advanced data processing and pulling data from external APIs. Use gitStream plugins to seamlessly create and integrate custom filters and other capabilities within your gitStream automations.

Example: isFlaggedUser

Here is an example of a filter function plugin that evaluates a username input against a list of specified usernames and returns true if the user is in the list.

const flaggedUsers = [\"user1\", \"user2\"];\nfunction isFlaggedUser(username) {\nif (flaggedUsers.includes(username)) {\nreturn true;\n} else {\nreturn false;\n}\n};\nmodule.exports = isFlaggedUser;\n
This creates a new isFlaggedUser filter function that can be invoked inside gitStream CM files. For example, you can use this to enable gitStream automations to trigger only for specific PR authors.

automations:\ndetect_flagged_user:\nif:\n- {{ pr.author | isFlaggedUser }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: {{ pr.author }} is a gitStream user.\n
"},{"location":"plugins/#installation","title":"Installation","text":"

gitStream plugins can be installed for an entire git organization or for individual repos.

Repository Plugins Take Precedence

If two filter function plugins have the same name, the repository-level plugin overrides the organization-level plugin.

Org-LevelRepo-Level

To use a filter function plugin in all your repositories, place it inside your cm repository in the following location:

plugins/filters/<filterName>/index.js

Success

Once installed, you should have a directory structure that looks like this:

.\n\u251c\u2500 gitstream.cm\n\u2514\u2500 plugins/filters/<filterName>\n   \u2514\u2500 index.js\n

To use a filter function plugin for a single repository, place it inside the repo in the following location:

.cm/plugins/filters/<filterName>/index.js

Success

Once installed, you should have a directory structure that looks like this:

.\n\u251c\u2500 .cm/\n\u2502  \u251c\u2500 gitstream.cm\n\u2502  \u2514\u2500 plugins/filters/<filterName>\n\u2502     \u2514\u2500 index.js\n

gitStream Community Plugins

We maintain an official list of community-contributed gitStream plugins. Click here to explore plugin examples.

"},{"location":"plugins/#usage","title":"Usage","text":"

Once installed, you can call your new plugins inside CM files using the same conventions as the built in filter functions. Filters are called with a pipe operator (|) and can take arguments. The first argument must be declared before the pipe, and all remaining arguments are passed as a set inside parenthesis. For example:

{{ \"Hello\" | plugin(\" world!\") }}\n
If the filter does not expect any arguments, you can invoke it by passing an empty string:
{{ \"\" | myFilter }}\n

"},{"location":"plugins/#create-filter-function-plugins","title":"Create Filter Function Plugins","text":"

gitStream plugins are based on the CommonJS module standard, a widely used pattern for structuring and importing JavaScript modules.

Supported JavaScript Dependencies

gitStream supports the following JavaScript dependencies: axios, github actions core (@actions/core), moment, lodash, octokit rest api (@octokit/rest)

No other dependencies are supported at this time. If you have recommendations for new dependencies, please open a new issue on the gitStream GitHub repo.

"},{"location":"plugins/#define-a-new-plugin","title":"Define a New Plugin","text":"

Each filter function plugin must have its own unique directory inside the appropriate /filters directory for your repo or organization. To create a new filter function, create an index.js file inside the plugin's top-level directory, all plugins must have an index.js file that serves as the primary entry point

One of the functions contained inside this file must be exported via module.exports, using the following conventions:

SynchronousAsynchronous

Export plugins that use synchronous code:

function myFilter(author) {\nreturn \"Hello ${author}!\";\n};\nmodule.exports = myFilter;\n

When using async JavaScript in your plugin, you need two things:

  • A primary async function that returns a callback() containing any errors as the first argument and the result of the filter as the second.
  • A module.exports statement that includes the properties async: true and filter: <filterName> with <filterName> matching the primary function that's being exported.
const myFilter = async (author, callback) => {\nconst message = { text: \"Hello ${author}!\" };\nconst error = null;\nreturn callback(error, message.text); };\nmodule.exports = {\nasync: true,\nfilter: myFilter\n}\n

Async Error Handling

Errors reported by async plugins are output to the workflow runner logs. E.g. GitHub Actions, GitLab CI, etc.

Here's how to invoke the new filter from this example:

automations:\nwelcome_author:\nif:\n- true\nrun:\n- action: add-comment@v1\nargs:\ncomment: {{ pr.author | myFilter }}\n

Debugging with console.log()

Data passed to console.log() is output in your workflow runner logs, e.g. GitHub Actions, GitLab CI, etc.

15 Minute Time Limit

gitStream actions are terminated after 15 minutes, this is a hard limit that can't be extended.

"},{"location":"plugins/#accept-arguments","title":"Accept Arguments","text":"

Filter function plugins can accept any number of arguments. The first argument must be passed to the filter function via a | operator; all subsequent arguments are passed as a set inside parenthesis.

Filter function to combine two strings

This example accepts two strings and combines them, separating by a space:

function combineStrings(str1, str2) {\nreturn str1 + \" \" + str2;\n}\nmodule.exports = combineStrings;\n

In the following invocation, \"Hello\" is passed as str1 and \"world!\" is passed as str2

{{ \"Hello\" | combineStrings(\"world!\") }}

"},{"location":"plugins/#tips-for-debugging-plugins","title":"Tips for Debugging Plugins","text":"
  1. Context Variable Insight: Utilize the gitStream playground to see how the context variable appears in a real Pull Request (PR). Inspect the PR Context Variables at the bottom of the screen .

  2. Local Execution:

    • Run the plugin locally for testing, for example: Running index.js with Node.js.
      module.exports = (text) => {\nreturn text.replaceAll('banana', '\ud83c\udf4c');\n};\nconst banana = require('./index.js');\nconsole.assert(banana(\"hello banana!\") === 'hello \ud83c\udf4c!', `banana(\"hello banana!\") === 'hello \ud83c\udf4c!' but got ${banana(\"hello banana!\")}`);\n
    • Execute with:
      $ node index.js\n

By following these steps, you can effectively debug and refine your gitStream plugins.

"},{"location":"plugins/#next-step","title":"Next Step","text":"

Check out the community plugin library.

Check out the filter function plugin library to explore plugins created by the LinearB community.

"},{"location":"plugins/#contribute-to-the-community-plugin-library","title":"Contribute to the Community Plugin Library","text":"

LinearB maintains a collection of community-contributed gitStream plugins. Here are the instructions for publishing a plugin as part of this library.

Create a directory for your plugin inside one of the subdirectories in plugins/filters. The name of the directory must match the name of the exported JavaScript function. Then ensure you have all of the required files and JSDoc content outlined below.

Here is an example of a well-designed gitStream plugin.

Required Files:

  • index.js - The entry point for your plugin. This should have a main function that is exported via module.exports that is documented according to the JSDoc requirements outlined below.
  • README.md - Use this template.
  • reference.md - This file must be auto-generated by jsdoc2md, see the instructions below.
  • plugin_name.cm - A gitStream CM example that uses the plugin.
  • LICENSE - The full text of the open source license the code is provided under.

Required JSDoc tags:

  • @module - This must match the name of the exported JavaScript function.
  • @description - A 1-2 line description that wholistically describes the functionality of the plugin.
  • @param - There should be one @param tag for each argument the plugin accepts, with indicated types. Indicate which parameter is the default input parameter with the name \"Input.\"
  • @returns - Provide the type and a short description.
  • @example - Simple examples that show how to invoke the plugin.
  • @license - The name of the lincense contained in the LICENSE file.

Here is an example of properly formatted JSDoc content:

/**\n * @module isFlaggedUser\n * @description Returns true if the username that is passed to this function is specified in a predefined list of users. \n * This is useful if you want gitStream automations to run only for specified users.\n * @param {string} Input - The GitHub username to check.\n * @returns {boolean} Returns true if the user is specified in the flaggedUsers list, otherwise false.\n * @example {{ pr.author | isFlaggedUser }}\n * @license MIT\n**/\n

How to Generate Plugin Reference Markdown

You can use jsdoc2md to convert the JSDoc content of your plugin to markdown using templates we've provided. First install jsdoc2md:

npm install -g jsdoc-to-markdown

Then, invoke the following command from inside your plugin directory:

jsdoc2md --partial ../../../docs/snippets/partials/body.hbs --partial ../../../docs/snippets/partials/sig-name.hbs --files index.js > reference.md

This should output a reference.md file that contains properly formatted markdown based on the JSDoc contents of your plugin.

"},{"location":"quick-start/","title":"Write Your First gitStream Automation","text":"

This article provides Continuous Merge (CM) examples to help you start customizing gitStream automations to meet the needs of your team.

"},{"location":"quick-start/#approve-simple-changes","title":"Approve Simple Changes","text":"

Changes to documentation, testing, and code formatting are often safe enough that there is little to no risk in letting an individual contributor merge those changes without needing to distract other people on their team to meet organization-wide requirements for multiple reviews on PRs. A good first Continuous Merge (CM) automation to implement is one that labels and approves changes to resources that could be considered safe changes.

This example uses the filter functions allDocs, allTests, isFormattingChange and match to detect changes that should be safe to merge with minimal review. It then uses the add-label automation action to apply a safe-changes label and the approve automation action to provide an approval review.

Label and Approve Simple Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nsafe_changes:\nif:\n- {{ is.docs or is.tests or is.asset or is.formatting }}\nrun: - action: add-label@v1\nargs:\nlabel: 'safe-changes'\n- action: approve@v1\nis:\ndocs: {{ files | allDocs }}\ntests: {{ files | allTests }}\nasset: {{ files | match(regex=r/\\.(png|svg|gif|css)$/) | every }}\nformatting: {{ source.diff.files | isFormattingChange }}\n

Test Your Automation in Dry Run Mode

gitStream includes a dry-run mode that let's you test your automations on your desired repo without pushing significant code, documentation, or other changes to the repo.

Learn more in our guide: How to Test Your Automations.

"},{"location":"quick-start/#find-reviewers-for-common-changes","title":"Find Reviewers for Common Changes","text":"

Selecting the right reviewer for your PR is crucial to ensure that your changes are thoroughly reviewed and that any issues are identified and addressed before they are merged into the main codebase.

This example uses the codeExperts filter function to identify the most qualified contributors based on their activity in the repo. It then assigns those individuals as reviewers on the PR with the add-reviewers automation action and posts a comment that lists the code experts via the explain-code-experts automation action.

Identify and Assign Code Experts for Reviews

This example uses the codeExperts filter function to identify the people who have the most expertise in the relevant code, assigns them as reviewers, and provides a comment that explains how those people were selected.

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nassign_code_experts:\n# Triggered when someone applies a suggest-reviewer label to a PR.\nif: - {{ pr.labels | match(term='suggest-reviewer') | some }}\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: {{ repo | codeExperts(gt=10) }}\n- action: explain-code-experts@v1 args:\ngt: 10 
"},{"location":"quick-start/#enforce-review-policies-for-critical-changes","title":"Enforce Review Policies for Critical Changes","text":"

Complex and sensitive PRs often require more nuanced and complex review processes that bring in outside teams of experts to review code changes. gitStream makes it easy to set up custom review policies to keep teams align across your organization. This example contains two automations that implement custom review policies for specific parts of a codebase.

First, the security_review automation uses the require-reviewers automation action to add the security team from the git organization as reviewers on PRs that affect the auth directory of the repo. This action accepts a reviewers: argument that contains a list of teams or individual users; you will need to change this value to match your organization and users.

Second, the double_review automation forces any changes to the agent directory to require a review from two people using the set-required-approvals automation action.

Enforce Review Policies

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nsecurity_review:\nif:\n- {{ files | match(regex=r/auth\\//) | some }}\nrun:\n- action: require-reviewers@v1\nargs:\nreviewers: [my_organization/security]\n- action: add-reviewers@v1\nargs:\nreviewers: [my_organization/security]\ndouble_review:\nif:\n- {{ files | match(regex=r/agent\\//) | some }}\nrun:\n- action: set-required-approvals@v1\nargs:\napprovals: 2\n
"},{"location":"quick-start/#next-step","title":"Next Step","text":"

Take a Look at the Quickstart Examples

You're ready to browse our CM example library to build more automations for your repo. We have examples that help provide context to PRs with labels, assign reviewers based on custom criteria, manage security requirements, and more.

"},{"location":"troubleshooting/","title":"Troubleshooting","text":""},{"location":"troubleshooting/#i-cant-see-any-action-running","title":"I can't see any action running","text":""},{"location":"troubleshooting/#did-you-install-gitstream-in-your-repo","title":"Did you install gitStream in your repo?","text":"

Check that you see gitStream app on repository's Settings > GitHub apps:

In case you don't see it, visit the marketplace and install it for free: https://github.com/marketplace/gitstream-by-linearb

"},{"location":"troubleshooting/#did-you-set-the-workflow-files-correctly","title":"Did you set the workflow files correctly?","text":"

Check you have placed these two files in your repository with these exact names:

  1. gitstream.cm in the cm repo, (for org level installs), or .cm/gitstream.cm on all other repositories
  2. .github/workflows/gitstream.yml

These files must be committed to the repository default branch (usually master or main). Notice that the action will not run until these files are found on the default branch.

Check that you see \"gitStream workflow automation\" in the Action section in your repository:

Next, if you see failed action, check out the details:

Some organization limit which actions can run, in that case in the repository settings you should enable it:

Also, add

linear-b/gitstream-github-action@v2,*/*/.github/workflows/gitstream.yml*\n
to the Allow specified actions and reusable workflows list, if it is shown.

"},{"location":"troubleshooting/#using-org-level-did-you-enable-gitstream-for-your-cm-repo","title":"Using org level? Did you enable gitStream for your cm repo","text":"

Make sure you have added the cm repo to the repos gitStream should run on

"},{"location":"troubleshooting/#is-the-pr-in-draft-mode","title":"Is the PR in Draft mode?","text":"

gitStream automations won't trigger for PRs that are in Draft mode.

"},{"location":"troubleshooting/#i-see-gitstream-workflow-file-not-found-error","title":"I see 'gitStream workflow file not found' error","text":"

This error indicates that gitStream is unable to locate the file .github/workflows/gitstream.yml. The tool first searches for this file in the cm repository and then in the PR's repository. If the CI file is not found, this error message is displayed. To resolve this issue, ensure that your setup is correct and that the specified file exists in your repository.

"},{"location":"troubleshooting/#i-have-rules-that-should-have-blocked-merge-but-the-pr-can-be-merged-still","title":"I have rules that should have blocked merge, but the PR can be merged still","text":"

For example, when using the set-required-approvals action, gitStream can ensure the PR got enough approvals before it can be merged. gitStream does that by running as a check and marking the check conclusion as failed. In order for the PR to be blocked, gitStream should be set as a required check in the repo: instructions here.

"},{"location":"troubleshooting/#i-cant-set-gitstream-as-required-check","title":"I can't set gitStream as required check","text":"

In order for gitStream to be listed as a required check, it needs to be triggered at least once in that repo. First create a new PR so gitStream is triggered.

Check it under repository's Settings > Branches:

"},{"location":"troubleshooting/#i-dont-want-gitstream-to-run-on-prs-that-was-generated-by-a-bot","title":"I don't want gitStream to run on PRs that was generated by a bot","text":"

When using repository level rules, you can edit the .github/workflows/gitstream.yml and uncomment the if line, you can edit and replace the bot name with the bot name you want to ignore (dependabot[bot] in the example below).

Note

This will not work for org level rules

.github/workflows/gitstream.yml
jobs:\ngitStream:\ntimeout-minutes: 5\n# uncomment this condition, if you don't want any automation on dependabot PRs\nif: github.actor != 'dependabot[bot]'\nruns-on: ubuntu-latest\nname: gitStream workflow automation\nsteps:\n- name: Evaluate Rules\nuses: linear-b/gitstream-github-action@v2\n
"},{"location":"troubleshooting/#gitstream-fails-and-i-dont-understand-why","title":"gitStream fails and I don't understand why","text":"

gitStream check run can fail from different reasons, and these are shown in the check result.

"},{"location":"troubleshooting/#missing-workflow-file","title":"Missing workflow file","text":"

When it says gitStream.cm Skipped \u2014 gitStream workflow file not found, it means that the GitHub action was not found, check again that you have this file in your repository root: .github/workflows/gitstream.yml, see instructions on GitHub installation.

"},{"location":"troubleshooting/#syntax-error-in-the-cm-files","title":"Syntax error in the cm files","text":"

Clicking the Details button will show more information and context.

You can add this automation to see details on context variable.

"},{"location":"troubleshooting/#how-can-i-debug-expressions-and-see-their-content","title":"How can I debug expressions and see their content?","text":"

You can dump any context value to the PR comment. For example, to see the list of changed files, use:

automations:\nshow_changed_files:\nif:\n- true\nrun:\n- action: add-comment@v1\nargs:\ncomment: |\nFILES DUMP {{ files | dump | safe }}\nJS FILES DUMP {{ files | filter(regex=r/\\.js$/) | dump | safe }}\n

Download and add to your repo .cm directory

"},{"location":"troubleshooting/#gitstream-fails-with-syntax-error-after-adding-new-rules","title":"gitStream fails with syntax error after adding new rules","text":"

IntelliJ IDEA has automatic code styling for YAML that can break the .cm syntax, check the following Settings/Preferences | Editor | Code Style | YAML --> Spaces | Code braces and make sure it is unchecked.

VS Code YAML plugin by Red Hat extension [vscode-yaml](https://github.com/redhat-developer/vscode-yaml) has automatic code styling for YAML that can break the .cm syntax, make sure you disable bracketSpacing

{\n\"yaml.format.bracketSpacing\": false,\n}\n

"},{"location":"troubleshooting/#not-here","title":"Not here?","text":"

Create a new issue in the project's issues

"},{"location":"automations/automation-library/","title":"gitStream Automation Library","text":"

This library of gitStream examples is meant to serve as a starting point for your automation. We encourage you to customize them for your project and organization.

How to use these examples.

These examples are all complete gitStream configuration files that you can download directly via the buttons below the examples and upload to the .cm directory of your repo. Alternatively, you can copy and paste the individual automations, but make sure you include all required declarations and any related custom expressions from the configurations to ensure they work properly.

"},{"location":"automations/automation-library/#most-popular-automations","title":"Most Popular Automations","text":"
  • Approve safe changes - Approve documentation, formatting changes, and tests.
  • Provide estimated time to review - Label all PRs with an estimated number of minutes it would take someone to review.
  • Explain Code Experts - Post a comment that recommends reviewers based on their expertise.
  • Review sensitive files - Define a custom list of files and directories that trigger additional reviews.
  • Additional review for large PRs - Require additional reviewers for complex PRs.
"},{"location":"automations/automation-library/#improve-pr-efficiency","title":"Improve PR Efficiency","text":""},{"location":"automations/automation-library/#auto-approve-merges","title":"Auto-Approve Merges","text":"
  • Approve tests - Label and approve PRs that only include tests.
  • Approve Tiny Changes - Approve single-line changes to a single file.
  • Approve team by directory - Approve PRs from specific teams to specified directories and files.
"},{"location":"automations/automation-library/#add-pr-context-with-labels-and-comments","title":"Add PR Context With Labels and Comments","text":"
  • Label PRs without tests - Apply a missing-tests label to any PRs that lack updates to tests.
  • Label percent new code - Post a comment that indicates what percentage of the PR contains new code.
  • Label deleted files - Label PRs that delete files.
  • Label missing project tracker - Flag PRs that are missing a reference to an associated project tracking resource.
  • Automatic project tracking links - Automatically post PR comments that link to the associated project tracking resource (Jira, Shortcut, Azure Boards, and more).
  • Summarize PR contents by language - Post a comment that breaks down code changes by the programming languages contained in the PR.
"},{"location":"automations/automation-library/#improve-pr-quality","title":"Improve PR Quality","text":""},{"location":"automations/automation-library/#merge-routing","title":"Merge Routing","text":"
  • Assign code experts - Identify the best experts for a PR and assign them to review.
  • Assign reviewers by directory - Automatically assign code reviewers based on directory structure.
  • Assign reviewers for knowledge share - Automatically assign code reviewers based on contributions between specified thresholds.
  • Change missing Lambda field - Request changes if a PR creates a new Lambda function that lacks a required field.
  • Close wrong team by directory - Close PRs to a specified directory if the PR author is not on an approved team.
"},{"location":"automations/automation-library/#quality-checks","title":"Quality Checks","text":"
  • Enforce Semantic PR Titles - Enforce PR naming conventions.
  • Enforce Changelog Updates - Require changelog updates for PRs that meet specific criteria.
  • Request screenshot - Request a screenshot in the PR description if none exist.
  • Welcome newcomer - Post a welcome message when someone makes their first PR to a repo, and provide context to help them know what's next.
  • Remove TODO comments - Detect TODO comments in PRs and ask the author to remove or fix them.
"},{"location":"automations/automation-library/#security-and-policy-compliance","title":"Security and Policy Compliance","text":"

These examples help you follow your team's security best practices.

  • Change deprecated components - Request changes when a PR includes one or more deprecated components.
  • Enforce copyright headers - Enforce the use of copyright headers when publishing open source code.
"},{"location":"automations/automation-library/#third-party-integrations","title":"Third-party Integrations","text":"

LinearB

"},{"location":"automations/automation-library/#github-gitlab","title":"GitHub / GitLab","text":"

:: GitHub Actions

:: GitHub Copilot

PR Labels

Branch Management

PR Reviews

"},{"location":"automations/automation-library/#security-compliance","title":"Security & Compliance","text":"

Orca

SonarCloud

Dependabot

Jit

Renovate

Snyk

SOC 2

"},{"location":"automations/automation-library/#project-management","title":"Project Management","text":"

Jira

Asana

Shortcut

Azure Boards

"},{"location":"automations/automation-library/#chat-communications","title":"Chat & Communications","text":"

Slack

Microsoft Teams

"},{"location":"automations/automation-library/#feature-flags","title":"Feature Flags","text":"

DevCycle

Launch Darkly

Flagsmith

Unleash

Flagr

"},{"location":"automations/automation-library/#languages","title":"Languages","text":"

JavaScript

Go

Python

Java

Ruby

HTML/CSS

Rust

"},{"location":"automations/automation-library/#documentation","title":"Documentation","text":"

Swimm

Javadoc

JSDoc

RDoc

Godoc

"},{"location":"automations/automation-library/#other","title":"Other","text":"

Terraform

Zapier

"},{"location":"automations/automation-library/#utilities","title":"Utilities","text":"

These examples provide useful components to use in other automations. These aren't intended to be used on their own; instead they act as a reference point for improving other automations.

  • Colors custom expression - A custom expression that implements all of GitHub's default label colors in a custom expression.
  • CM File Header - A header to copy/paste to the top of your CM files to help yourself, and others, understand the purpose of the file.
"},{"location":"automations/automation-library/#contribute-your-idea","title":"Contribute Your Idea","text":"

Have a great idea for an automation that should be included in this library?

Submit your configuration on GitHub. We'll recognize your contribution publicly (if you want) and might even send you some special swag for your contribution.

"},{"location":"automations/additional-review-for-large-pr/","title":"Additional Review for Large PRs","text":"

Require 2 reviewers for PRs that have more than 10 changed files in the src directory and the estimated time to review is 30 or more minutes.

Configuration Description

Conditions (all must be true):

  • There are 10 or more changed files
  • The estimated time to review is 30 minutes or more.
  • One or more of the changed files is inside the src directory.

Automation Actions:

  • Require a minumim of 2 reviews.
  • Post a comment that explains this is considered a large change that requires 2 reviews.

Additional Review for Large PRs

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nadditional_review_for_large_pr:\nif:\n- {{ branch | estimatedReviewTime >= 30 }}\n- {{ files | length >= 10 }}\n- {{ files | match(regex=r/src\\//) | some }}\nrun:\n- action: set-required-approvals@v1\nargs:\napprovals: 2\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR is a large change and requires 2 reviews.\n
Download this example as a CM file.

"},{"location":"automations/additional-review-for-large-pr/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Assign or suggest reviewers based on level of code expertise for the code changed in a PR.
  • Assign reviewers based on modified directories and files
  • Assign reviewers to share knowledge based on pre-determined criteria

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/approve-safe-changes/","title":"Approve Safe Changes","text":"

Automatically approve PRs that change docs, tests, and other safe assets.

Configuration Description

Conditions (all must be true):

  • The PR only contains documentation, tests, or formatting changes.

Automation Actions:

  • Add a safe-change label
  • Approve the PR
  • Post a comment that explains that this is a safe change

Approve Safe Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nsafe_changes:\n# Triggered for any changes that only affect formatting, documentation, tests, or images\nif:\n- {{ is.formatting or is.docs or is.tests or is.image }}\n# Apply a safe change label, approve the PR and explain why in a comment.\nrun: - action: add-label@v1\nargs:\nlabel: 'safe-change'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR is considered a safe change and has been automatically approved.\n# These custom expressions are used in the safe_changes automation\nis:\nformatting: {{ source.diff.files | isFormattingChange }}\ndocs: {{ files | allDocs }}\ntests: {{ files | allTests }}\nimage: {{ files | allImages }}\n
Download this example as a CM file.

"},{"location":"automations/approve-safe-changes/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Approve low-risk PRs from trusted teams.
  • Approve Python or JavaScript formatting changes.
  • Approve Tiny Changes
  • Approve JSDoc or Javadoc changes.
  • Approve and Merge Dependabot PRs

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/approve-swimm/","title":"Index","text":"

This file has moved: /docs/automations/integrations/swimm/approve-swimm

"},{"location":"automations/approve-team-by-directory/","title":"Approve Trusted Team","text":"

Automatically approve low-risk PRs from trusted teams.

Configuration Description

Conditions (all must be true):

  • All changed files are inside the docs directory
  • The PR author is on the tech-writers team.

Automation Actions:

  • Approve the PR
  • Post a comment that explains the approval.

Approve Expert Team

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_team_by_directory:\n# Triggered for PRs that only include changes to files inside the docs directory,\n# and that are authored by someone on the tech-writers team.\nif:\n- {{ files | match(regex=r/docs\\//) | every }}\n- {{ pr.author_teams | match(term='tech-writers') }}\nrun: - action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nDocs changes from the tech-writers team are automatically approved.\n
Download this example as a CM file.

"},{"location":"automations/approve-team-by-directory/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Automatically approve changes to docs, tests, and other safe assets.
  • Approve Python or JavaScript formatting changes.
  • Approve Tiny Changes
  • Approve JSDoc or Javadoc changes.
  • Approve and Merge Dependabot PRs

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/approve-tests/","title":"Approve test changes","text":"

Label and approve PRs that only include tests, and post an explanation comment.

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to tests

Automation Actions:

  • Add a tests-only label
  • Approve the PR
  • Post a comment that explains why the PR was approved.

Approve Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_tests:\nif:\n# Triggered for PRs that only include changes to tests\n- {{ files | allTests }}\nrun: - action: add-label@v1\nargs:\nlabel: 'tests-only'\n- action: add-comment@v1\nargs:\ncomment: |\nThis merge has been automatically approved because it only contains changes to tests.\n- action: approve@v1\n
Download this example as a CM file.

"},{"location":"automations/approve-tests/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Automatically approve changes to docs, tests, and other safe assets.
  • Approve low-risk PRs from trusted teams.
  • Approve Python or JavaScript formatting changes.
  • Approve Tiny Changes
  • Approve JSDoc or Javadoc changes.
  • Approve and Merge Dependabot PRs

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/approve-tiny-changes/","title":"Approve Tiny Changes","text":"

Approve single-line changes to a single file.

Configuration Description

Conditions (all must be true):

  • If the PR contains a one-line change to a single file.

Automation Actions:

  • Apply a single-line label.
  • Approve the PR.
  • Post a comment explaining why the PR was approved.

name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_tiny_change:\n# Triggered for PRs that contain one file and one line.\nif:\n- {{ is.one_file and is.one_line }}\nrun:\n- action: add-label@v1\nargs:\nlabel: 'single-line'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it is only a single line\nchanges:\n# Sum all the lines added in the PR\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\n# Sum all the line removed in the PR\ndeletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}\nis:\none_file: {{ files | length == 1 }}\none_line: {{ changes.additions - changes.deletions <= 1 }}\n
Download this example as a CM file.

"},{"location":"automations/approve-tiny-changes/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Automatically approve changes to docs, tests, and other safe assets.
  • Approve low-risk PRs from trusted teams.
  • Approve Python or JavaScript formatting changes.
  • Approve JSDoc or Javadoc changes.
  • Approve and Merge Dependabot PRs

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/assign-reviewers-by-directory/","title":"Assign Reviewers by Directory","text":"

Automatically assign code reviewers based on directory structure. Optionally, you can substitue require-reviewers for add-reviewers to make review from the specified teams and individuals mandatory.

Configuration Description

Conditions (all must be true):

  • The PR contains changes to JavaScript files inside the src/ui directory.

Automation Actions:

  • Add a user named my-teamate and a team named my-organization/ui-team as reviewers. These should be customized to match your organization.
  • Post a comment explaining why these reviewers were assigned.

Assign Reviewers by Directory

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_ui:\n# Triggered for PRs that contain any changes to JavaScript files inside the `src/ui` directory.\nif:\n- {{ files | match(regex=r/src\\/ui\\/.*/) | some}}\n# Add a specified user and team as reviewers.\n# Customize the reviewers to match your organization\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: [my-teamate, my-organization/security]\n- action: add-comment@v1\nargs:\ncomment: |\nThe Security team has automatically been added for review because this PR contains changes to components inside `/src/ui`\n
Download this example as a CM file."},{"location":"automations/assign-reviewers-by-directory/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Assign additional reviewers for large PRs
  • Assign or suggest reviewers based on level of code expertise for the code changed in a PR.
  • Assign reviewers to share knowledge based on pre-determined criteria

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/assign-team-members-as-reviewers/","title":"Assign team members as reviewers","text":"

Assign PR reviewer based on the owner team membership.

You can also omit the | first filter to assign all teams the owner is member of.

name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nadd_first_team_reviewer:\nif:\n- true\nrun:\n- action: add-reviewers@v1\nargs:\nteam_reviewers: {{ pr.author_teams | first }}\n
Download this example as a CM file.

"},{"location":"automations/assign-team-members-as-reviewers/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Assign additional reviewers for large PRs
  • Assign or suggest reviewers based on level of code expertise for the code changed in a PR.
  • Assign reviewers based on modified directories and files
  • Assign reviewers to share knowledge based on pre-determined criteria

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/change-deprecated-components/","title":"Change Deprecated Components","text":"

Request changes when a PR includes one or more deprecated components.

Configuration Description

Conditions (all must be true):

  • A PR contains one or more references to functions, methods, or classes that have been designated as deprecated.

Automation Actions:

  • Add a deprecated-component label to the PR
  • Request changes to the PR and post a comment that explains what deprecated component was included and what the alternative is.

Change Deprecated Components

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# Request changes when a PR includes deprecated components.\n# This requires the `item` custom expression found at the bottom of this file.\n{% for item in deprecated %}\n# Automation names must be unique, so this adds an iterator index to each instance\nreview_deprecated_component_{{ item.old }}:\n# Triggered when any of the modified files use a deprecated component\nif:\n- {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}\n# Apply a deprecated-component label, request changes, and post a comment with an explanation.\nrun:\n- action: add-label@v1\nargs:\nlabel: 'deprecated-component'\ncolor: '#FF0000'\n- action: request-changes@v1\nargs:\ncomment: |\n`{{ item.old }}` component is deprecated, use `{{ item.new }}` instead\n{% endfor %}\n# These are the deprecated files that are evaluated in catch_deprecated_components\ndeprecated:\n- regex: r/oldAPI/\nold: oldAPI\nnew: newAPI\n- regex: r/anotherOldAPI/\nold: anotherOldAPI\nnew: anotherNewAPI\n
Download this example as a CM file."},{"location":"automations/change-deprecated-components/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Require changelog updates for PRs to specific branches
  • Restrict portions of your code base to authorized teams only.
  • Require changes when PRs include !important tags in CSS files

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/change-missing-lambda-field/","title":"Change Missing Lambda Field","text":"

If a PR creates a new Lambda function, but lacks a description field, gitStream will request changes and post a comment that explains why.

Configuration Description

Conditions (all must be true):

  • The PR contains an update to a Lambda function.
  • The affected files are missing a description field.

Automation Actions:

  • Add a lambda-missing-field label to the PR.
  • Request changes and post a comment that explains why.

Change Missing Lambda Field

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# Request changes when required Lambda information is missing from the PR.\ncatch_missing_lambda_info:\n# Triggered for new Lambda functions that are missing a description field.\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/LambdaFunction/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=r/description:/) | nope }}\n# Apply the lambda-missing-field label and request changes to the PR.\nrun:\n- action: add-label@v1\nargs:\nlabel: 'lambda-missing-field'\ncolor: '#FF0000'\n- action: request-changes@v1\nargs:\ncomment: |\nNew `LambdaFunction` must have `description:` field.\n
Download this example as a CM file."},{"location":"automations/change-missing-lambda-field/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Require changelog updates for PRs to specific branches
  • Flag the use of deprecated APIs, functions, or other components.
  • Restrict portions of your code base to authorized teams only.
  • Require changes when PRs include !important tags in CSS files

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/close-wrong-team-by-directory/","title":"Close Wrong Team by Directory","text":"

Close PRs to a specified directory if the PR author is not on an approved team.

Configuration Description

Conditions (all must be true):

  • The PR changes one or more files inside /src/views. Customize this value for your project.
  • The PR author is not a member of the ui team. Customize this value for your organization.

Automation Actions:

  • Close the PR.
  • Post a comment that explains why the PR was closed.

Close Wrong Team by Directory

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# Close PRs to restricted sections of the codebase if the PR author isn't on the correct team. \nclose_wrong_team_by_directory:\n# Triggered when someone who isn't on the `ui` team submits a PR to change files inside /src/views\nif:\n- {{ files | match(regex=r/src\\/views/) | some }}\n- {{ pr.author_teams | match(term='ui') | nope }}\n# Close the PR and post a comment explaining the next step.\nrun:\n- action: add-comment@v1\nargs: comment: Please contact a member of the `ui` team if you need to make changes to files in `src/views`\n- action: close@v1\n
Download this example as a CM file."},{"location":"automations/close-wrong-team-by-directory/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Require changelog updates for PRs to specific branches
  • Flag the use of deprecated APIs, functions, or other components.
  • Require changes when PRs include !important tags in CSS files

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/asana/label-missing-asana/","title":"Label Missing Asana","text":"

Automatically label PRs that are missing references to Asana resources.

Configuration Description

Conditions (all must be true):

  • The PR is missing an Asana ticket reference in the PR title and a link to an Asana resource in the PR description.

Automation Actions:

  • Apply a red \u26a0\ufe0f Missing Asana Link label
  • Post a comment that asks the author to add an Asana reference to the PR.

Label Missing Asana

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_missing_asana:\nif:\n- {{not (has.asana.ticket_in_title or has.asana.ticket_in_desc)}}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Asana Link\"\ncolor: {{ colors.red }}\n- action: add-comment@v1\nargs:\ncomment: Please provide a link to the associated Asana resource.\nhas:\nasana:\nticket_in_title: {{ pr.title | includes(regex=r/asana-(\\d+)/) }}\nticket_in_desc: {{ pr.description | includes(regex=r/app\\.asana.\\com\\/(\\d+)\\/(\\d+)\\/(\\d+)\\/(\\d+)\\/(\\d+)/) }}\ncolors:\nred: 'b60205'\n
Download this example as a CM file."},{"location":"automations/integrations/asana/label-missing-asana/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/asana/link-asana/","title":"Automatically Link PRs to Related Asana Cards","text":"

Provide automatic links to Asana cards that are associated with PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Asana card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Asana Card.

Automatically Link to the Related Asana Card

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nprovider: asana\n# Configure this to match your organization. It is used in tracker.asana.baseurl.\nasanaProject: 1234\n{% set ticketid = \"\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\nlink_asana:\nif:\n- {{ has.ticket_in_title or has.ticket_in_branch }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})\nhas:\nticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}\nticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}\ntracker:\nasana:\nbaseurl: https://app.asana.com/0/[asanaProject]/0/\npattern: r/asana-(\\d+)/\ntickets:\n- {{branch.name | capture(regex=tracker[provider].pattern)}}\n- {{pr.title | capture(regex=tracker[provider].pattern)}}\n
Download this example as a CM file."},{"location":"automations/integrations/asana/link-asana/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/azure-boards/label-missing-azure-boards/","title":"Label Missing Azure Boards Info","text":"

Automatically label PRs that are missing references to Azure Boards resources.

Configuration Description

Conditions (all must be true):

  • The PR is missing one of the following:
    • An Azure Boards ticket reference in the PR title.
    • A link to an Azure Boards resource in the PR description.

Automation Actions:

  • Apply a red \u26a0\ufe0f Missing Azure Boards Link label
  • Post a comment that asks the author to add an Azure Boards reference to the PR.

Label Missing Azure Boards

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_missing_azure:\nif:\n- {{not (has.azure.ticket_in_title or has.azure.ticket_in_desc)}}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Azure Boards Link\"\ncolor: {{ colors.red }}\n- action: add-comment@v1\nargs:\ncomment: Please provide a link to the associated resource in Azure Boards.\nhas:\nazure:\nticket_in_title: {{ pr.title | includes(regex=r/(\\w+)-(\\w+)-(\\d+)/) }}\nticket_in_desc: {{ pr.description | includes(regex=r/(dev\\.azure\\.com|(\\w+)\\.visualstudio\\.com)\\/(\\w+)\\/(\\w+)\\/_workitems\\/edit\\/(\\d+)/) }}\ncolors:\nred: 'b60205'\n
Download this example as a CM file."},{"location":"automations/integrations/azure-boards/label-missing-azure-boards/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/azure-boards/link-azure-boards/","title":"Automatically Link PRs to Related Azure Boards Resources","text":"

Provide automatic links to Azure Boards resources that are associated with PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Azure Boards resource in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Azure Boards Resource.

Automatically Link to the Related Azure Boards Resource

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n# Configure these to match your organization.\nprovider: azure\n# The name of your Azure organization\norgName: org\n# The name of your Azure project\nazureProject: my_project\n{% set ticketid = \"\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\nlink_azure_boards:\nif:\n- {{ has.ticket_in_title or has.ticket_in_branch }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})\nhas:\nticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}\nticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}\ntracker:\nazure:\nbaseurl: https://dev.azure.com/[orgName]/[azureProject]/_workitems/\npattern: r/(\\w+)-(\\w+)-(\\d+)/\ntickets:\n- {{branch.name | capture(regex=tracker[provider].pattern)}}\n- {{pr.title | capture(regex=tracker[provider].pattern)}}\n
Download this example as a CM file."},{"location":"automations/integrations/azure-boards/link-azure-boards/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/copilot/flag-copilot-pr/","title":"Automatically Label GitHub Copilot PRs","text":"

Automatically apply labels to PRs that are assisted by GitHub Copilot. You can apply labels based on a known list of Copilot users, PR tags, or by prompting the PR author to indicate if they used Copilot.

Label by PromptLabel by Known UsersLabel by Tag

Prompt PR authors to indicate if they used Copilot for the PR and automatically label the PR if they did. This requires two separate automation files to handle posting the prompt and labeling accordingly.

Configuration Description

Conditions:

  • A PR is created

Automation Actions:

  • Post a comment prompting the author to indicate if Copilot assisted the author with writing the code in the PR.

Ask the PR author about Copilot usage.

-*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\nautomations:\ncomment_copilot_prompt:\n# Post a comment for all PRs to prompt the PR author to indicate whether they used Copilot to assist coding in this PR\nif:\n- true\nrun:\n- action: add-comment@v1\nargs:\ncomment: |\nPlease mark whether you used Copilot to assist coding in this PR\n- [ ] Copilot Assisted\n- [ ] Not Copilot Assisted\n
Download this example as a CM file.

Configuration Description

Conditions:

  • A PR is updated or merged where the author indicates they used Copilot via a prompt.

Automation Actions:

  • Apply a \ud83e\udd16 Copilot label to the PR

Label PRs where the user indicated Copilot usage

-*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# You should use this automation in conjunction with comment_copilot_prompt.cm\nlabel_copilot_pr:\n# If the PR author has indicated that they used Copilot to assist coding in this PR, \n# apply a label indicating the PR was supported by Copilot\nif:\n- {{ pr.comments | filter(attr='commenter', term='gitstream-cm') | filter (attr='content', regex=r/\\- \\[x\\] Copilot Assisted/) | some}}\nrun:\n- action: add-label@v1\nargs:\nlabel: '\ud83e\udd16 Copilot'\n
Download this example as a CM file.

Automatically apply labels to PRs that are created by known users of generative AI coding tools.

Configuration Description

Conditions:

  • The PR author is one of a specified list of contributors

Automation Actions:

  • Apply a \ud83e\udd16 Copilot label to the PR

Label by Contributors

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_genai:\n# For all PRs authored by someone who is specified in the genai_contributors list\nif:\n- {{ pr.author | match(list=genai_contributors) | some  }}\n# Apply a label indicating the user has adopted Copilot\nrun:\n- action: add-label@v1\nargs:\nlabel: '\ud83e\udd16 Copilot'\ngenai_contributors:\n- username1\n- username2\n- etc\n
Download this example as a CM file.

Look for a specific tag in the PR title, description, comments or commit messages and if found add a label to the PR

Configuration Description

Conditions:

  • The #copilot# tag is found in any of the PR title, description, comments or commit messages for commits in the PR

Automation Actions:

  • Apply a \ud83e\udd16 Copilot label to the PR

Label Copilot by Tag

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- comment_added\n- commit\n- pr_created\nautomations:\nlabel_copilot:\n# Detect PRs that contain the text '#copilot#' in the title, description, comments, or commit messages\nif:\n- {{ copilot_tag.pr_title or copilot_tag.pr_desc or copilot_tag.pr_comments or copilot_tag.commit_messages  }}\n# Apply a label indicating the user has adopted Copilot\nrun:\n- action: add-label@v1\nargs:\nlabel: '\ud83e\udd16 Copilot'\ncopilot_tag:\npr_title: {{ pr.title | includes(regex=r/#copilot#/) }}\npr_desc: {{pr.description | includes(regex=r/#copilot#/) }}\npr_comments: {{ pr.comments | map(attr='content') | match(regex=r/#copilot#/) | some }}\ncommit_messages: {{ branch.commits.messages | match(regex=r/#copilot#/) | some }}\n
Download this example as a CM file.

"},{"location":"automations/integrations/dependabot/approve-dependabot/","title":"Approve and Merge Dependabot Changes","text":"

Auto-merge Dependabot PRs

By Release TypeAll Updates

Required gitStream Plugins

This example requires you to install the extractDependabotVersionBump and compareSemver plugins.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • The PR author is Dependabot.
  • The branch name includes 'dependabot'
  • The dependency change is a patch or minor update.

Automation Actions:

  • Approve the PR
  • Apply an approved-dependabot label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

manifest:\nversion: 1.0\nautomations:\nmerge_dependabot_minor:\nif:\n- {{ bump == 'minor' }}\n- {{ branch.name | includes(term=\"dependabot\") }}\n- {{ branch.author | includes(term=\"dependabot\") }}\nrun:\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nDependabot `minor` version bumps are approved automatically.\nmerge_dependabot_minor_patch:\nif:\n- {{ bump == 'patch' }}\n- {{ branch.name | includes(term=\"dependabot\") }}\n- {{ branch.author | includes(term=\"dependabot\") }}\nrun:\n- action: approve@v1\n- action: merge@v1\n- action: add-comment@v1\nargs:\ncomment: |\nDependabot `patch` version bumps are approved and merged automatically.\nbump: {{ pr.description | extractDependabotVersionBump | compareSemver }}\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • The PR author is Dependabot.
  • The branch name includes 'dependabot'

Automation Actions:

  • Approve the PR
  • Apply an approved-dependabot label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_dependabot:\nif:\n- {{ branch.name | includes(term=\"dependabot\") }}\n- {{ branch.author | includes(term=\"dependabot\") }}\nrun:\n- action: approve@v1\n- action: add-label@v1\nargs:\nlabel: \"approved-dependabot\"\n- action: merge@v1\nargs:\nwait_for_all_checks: true\nsquash_on_merge: true\n
Download this example as a CM file.

"},{"location":"automations/integrations/devcycle/label-ff-devcycle/","title":"Label DevCycle Feature Flags","text":"

Automatically label code that contians specified feature flags.

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in feature_flags %}\nlabel_ff_devcycle_{{ item.name }}:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/key = '/) | some }}\n      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}\n    run:\n      - action: add-label@v1\n        args:\n          label: {{ item.name }}\n          color: {{ colors.yellow }}\n  {% endfor %}\nfeature_flags:\n   - name: engineering_rollback_plan_activated \n     regex: r/engineering_rollback_plan_activated/\n   - name: marketing_premium_plan_features_unlocked \n     regex: r/marketing_premium_plan_features_unlocked/\n   - name: mobile_push_notifications_enabled\n     regex: r/mobile_push_notifications_enabled/\ncolors:\n  yellow: 'ffb300'   \n
Download this example as a CM file."},{"location":"automations/integrations/flagr/label-ff-flagr/","title":"Label Flagr Feature Flags","text":"

Automatically label code that contians specified feature flags.

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in feature_flags %}\nlabel_ff_flagr_{{ item.name }}:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/evaluation_result.variant_id ==/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ item.name }}\ncolor: {{ colors.yellow }}\n{% endfor %}\nfeature_flags:\n- name: engineering_rollback_plan_activated regex: r/engineering_rollback_plan_activated/\n- name: marketing_premium_plan_features_unlocked regex: r/marketing_premium_plan_features_unlocked/\n- name: mobile_push_notifications_enabled\nregex: r/mobile_push_notifications_enabled/\ncolors:\nyellow: 'ffb300'   
Download this example as a CM file."},{"location":"automations/integrations/flagsmith/label-ff-flagsmith/","title":"Label Flagsmith Feature Flags","text":"

Automatically label code that contians specified feature flags.

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in feature_flags %}\nlabel_ff_flagsmith_{{ item.name }}:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/flagsmith.hasFeature\\(/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ item.name }}\ncolor: {{ colors.yellow }}\n{% endfor %}\nfeature_flags:\n- name: engineering_rollback_plan_activated regex: r/engineering_rollback_plan_activated/\n- name: marketing_premium_plan_features_unlocked regex: r/marketing_premium_plan_features_unlocked/\n- name: mobile_push_notifications_enabled\nregex: r/mobile_push_notifications_enabled/\ncolors:\nyellow: 'ffb300'   
Download this example as a CM file."},{"location":"automations/integrations/github-actions/dispatch-github-action/","title":"Dispatch GitHub Actions","text":"

Automatically trigger GitHub Actions based on PR content like changed resources, source or target branch, slash commands, and more.

By BranchUsing LabelsBy Modified Resources

Configuration Description

Conditions (all must be true):

  • The PR source or target branch matches a specified format.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions by Branch

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n- commit\nautomations:\n{% for item in pipelines %}\n# Change pr.target to branch.name if you want to trigger on the source branch rather then the target branch.\ndispatch_github_action_{{ item.name }}:\nif:\n- {{ pr.target | includes(term=item.branch_prefix) }}\nrun:\n- action: run-github-workflow@v1\nargs:\nworkflow: .github/workflows/{{ item.workflow }}\ncheck_name: {{ item.name }}\n- action: add-label@v1\nargs:\nlabel: {{ item.label }}\n{% endfor %}\npipelines:\n- name: mobile_ci\nlabel: Mobile CI branch_prefix: 'mobile-'\nworkflow: mobile.yml\n- name: backend_ci\nlabel: Backend CI branch_prefix: 'backend-'\nworkflow: 'backend.yml'\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • The PR has one or more specified labels applied to it.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions Using Labels

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- label_added\n- label_removed\nautomations:\n{% for item in pipelines %}\ndispatch_github_action_{{ item.name }}:\nif:\n- {{ pr.labels | match(term=item.label) | some }}\nrun:\n- action: run-github-workflow@v1\nargs:\nworkflow: .github/workflows/{{ item.workflow }}\ncheck_name: {{ item.name }}\n{% endfor %}\npipelines:\n- name: mobile-ci\nlabel: Mobile CI workflow: mobile.yml\n- name: backend-ci\nlabel: Backend CI workflow: 'backend.yml'\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • The PR modifies one or more specified resources.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions Based on Modified Resources

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n- commit\nautomations:\n{% for item in pipelines %}\ndispatch_github_action_{{ item.name }}:\nif:\n- {{ files | match(list=item.resources) | some }}\nrun:\n- action: run-github-workflow@v1\nargs:\nworkflow: .github/workflows/{{ item.workflow }}\ncheck_name: {{ item.name }}\n- action: add-label@v1\nargs:\nlabel: {{ item.label }}\n{% endfor %}\npipelines:\n- name: mobile-ci\nlabel: Mobile CI resources:\n- 'src/android/'\n- 'src/ios/'\nworkflow: mobile.yml\n- name: backend-ci\nlabel: Backend CI resources:\n- 'src/api/'\n- 'src/services'\nworkflow: 'backend.yml'\n- name: frontend-ci\nlabel: Frontend CI\nresources:\n- 'src/app/'\nworkflow: 'frontend.yml'\n
Download this example as a CM file.

"},{"location":"automations/integrations/github-actions/dispatch-github-action/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Automatically approve changes to docs, tests, and other safe assets.
  • Approve low-risk PRs from trusted teams.
  • Approve Python or JavaScript formatting changes.
  • Approve Tiny Changes
  • Approve JSDoc or Javadoc changes.
  • Approve and Merge Dependabot PRs

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/github-actions/skip-github-action/","title":"Skip Required GitHub Actions","text":"

Automatically skip GitHub Actions based on branch names, modified resource, slash commands, and more.

Prerequisite Config for Required Statuses

If you want to skip a required status check, you will need to make sure that your branch protection is configured to allow gitStream to bypass status check requirements.

By BranchUsing LabelsBy Modified Resource

Configuration Description

Conditions (all must be true):

  • The target branch name includes a specified keyword. Optionally, you can modify this to detect the source branch name.

Automation Actions:

  • Skip the specified CI pipelines.

Automatically Skip GitHub Actions by Branch

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n- commit\n# Optionally, you can change pr.target to branch.name\n# if you want to trigger based on the source branch name rather then the target branch name.\nautomations:\nskip_github_action_branch:\nif:\n- {{ pr.target | includes(term='release') }}\nrun:\n- action: add-github-check@v1\nargs:\ncheck_name: staging-ci\nconclusion: skipped\n- action: add-comment@v1\nargs:\ncomment: |\n[gitStream](https://docs.gitstream.cm) automatically skipped staging CI pipelines because this PR targets the release branch.\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • Someone applies one or more specified labels to a PR.

Automation Actions:

  • Skip the specified CI pipelines.

Use Labels to Automatically Skip GitHub Actions

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- label_added\n- label_removed\nautomations:\nskip_github_action_label:\nif:\n- {{ pr.labels | match(term='experimental') | some }}\nrun:\n- action: add-github-check@v1\nargs:\ncheck_name: production-ci\nconclusion: skipped\n- action: add-comment@v1\nargs:\ncomment: |\n[gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this is labeled for experimental release.\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • A PR modifies specific files or directories.

Automation Actions:

  • Skip a specified GitHub Action.

Automatically Skip GitHub Actions Based on Modified Resources

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n- commit\nautomations:\nskip_github_action_resource:\nif:\n- {{ files | match(term='docs/') | every }}\nrun:\n- action: add-github-check@v1\nargs:\ncheck_name: release-ci\nconclusion: skipped\n- action: add-github-check@v1\nargs:\ncheck_name: mobile-ci\nconclusion: skipped\n- action: add-comment@v1\nargs:\ncomment: |\n[gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this PR only contains docs changes.\n
Download this example as a CM file.

"},{"location":"automations/integrations/github-actions/skip-github-action/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Automatically approve changes to docs, tests, and other safe assets.
  • Approve low-risk PRs from trusted teams.
  • Approve Python or JavaScript formatting changes.
  • Approve Tiny Changes
  • Approve JSDoc or Javadoc changes.
  • Approve and Merge Dependabot PRs

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/godoc/review-godoc/","title":"Review Godoc Changes","text":"

Approve PRs that only contain changes to Godoc and assign optional reviewers.

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to Godoc content.

Automation Actions:

  • Assign the org/tech-writers team for optional review.
  • Apply a green \ud83d\udcd3 Godoc Only label
  • Approve the PR

Review Godoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Assign PRs that only affect godocs to the technical writing team and add docs label\nreview_godoc:\nif:\n- {{ source.diff.files | match(attr='diff', regex=r/^\\/\\/.*/) | every }}\n- {{ files | extensions | match(regex=r/go/) | every }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\ud83d\udcd3godoc Only\"\ncolor: {{ colors.green }}\n- action: add-reviewers@v1\nargs:\nreviewers: [org/tech-writers]\n- action: approve@v1\ncolors:\ngreen: '0e8a16'\n
Download this example as a CM file."},{"location":"automations/integrations/godoc/review-godoc-large/","title":"Review Godoc for Large Changes","text":"

Require more extensive reviews for large Golang changes that lack Godoc updates.

Configuration Description

Conditions (all must be true):

  • The PR changes more than 100 lines of Golang code.

Automation Actions:

  • Post a comment asking the author to review all relevant Godoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow \u26a0\ufe0f Missing Godoc Label

Review Godoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Require more extensive reviews for large Golang changes that lack Godoc updates.\nreview_godoc_large:\nif:\n- {{ changes.additions > 100}}\n- {{ source.diff.files | matchDiffLines(regex=r/^\\/\\/.*/) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Godoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | This PR makes major changes to Golang classes, but is missing updates to Godoc. Please double check for any necessary Godoc updates.\n- action: add-reviewers@v1\nargs:\nreviewers: [fourth-organization/tech-writers]\nchanges:\n# Sum all the lines added/edited in the PR\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/integrations/godoc/review-godoc-new-class/","title":"Require Godoc for New Golang Classes","text":"

Require Godoc for all new Golang classes.

Configuration Description

Conditions (all must be true):

  • The PR creates a new Golang class.
  • The PR lacks Godoc content.

Automation Actions:

  • Request changes and post a comment explaining that Godoc is required
  • Apply a yellow \u26a0\ufe0f Missing Godoc label.

Enforce Godoc for New Golang Classes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_godoc_new_class: if:  - {{ is.go and is.new }} - {{ source.diff.files | match(attr='diff', regex=r/\\/*[\\s\\S]*?\\//) | nope }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing godoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | godoc is required for all Golang classes. Please add godoc to all new classes in this PR.\nis:\ngo: {{ files | extensions | match(regex=r/go/) | every }}\nnew: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/integrations/javadoc/review-javadoc/","title":"Review Javadoc Changes","text":"

Unblock PRs that only change Javadoc content.

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to Javadoc content.

Automation Actions:

  • Assign the org/tech-writersteam for optional review.
  • Apply a green \ud83d\udcd3 Javadoc Only label
  • Approve the PR

Review Javadoc Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# Assign PRs that only affect JavaDocs to the technical writing team and add docs label\nreview_javadoc:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/\\/*\\*([\\s\\S]*?)\\//) | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/\\b(public|protected|private|static|final|synchronized)?\\s+\\w+\\s+\\w+\\s*\\(([^)]*)\\)\\s*\\{/) | nope }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\ud83d\udcd3 Javadoc Only\"\ncolor: {{ colors.green }}\n- action: add-reviewers@v1\nargs:\nreviewers: [org/tech-writers]\n- action: approve@v1\ncolors:\ngreen: '0e8a16'\n
Download this example as a CM file."},{"location":"automations/integrations/javadoc/review-javadoc-input-parameters/","title":"Review Java Input Parameters for Javadoc Changes","text":"

If a PR modifies the input parameters for a Java method, but not the associated Javadocs, notify reviewers to check for Javadoc updates.

Configuration Description

Conditions (all must be true):

  • The PR changes one or more input parameters in Java methods.
    • Note: This may not trigger for methods with annotations, methods that throw exceptions, multi-line method definitions, and other non-standard use cases.
  • The PR lacks changes to \u2018@param\u2019 declarations.

Automation Actions:

  • Post a comment warning the user to review the method\u2019s Javadoc to identify necessary updates.

Review Javadoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_javadoc_input_parameters: if:  - {{ source.diff.files | matchDiffLines(regex=r/\\*\\s@param/) | nope }}\n- {{ source.diff.files | matchDiffLines(regex=r/\\b(public|protected|private|static|final|synchronized)?\\s+\\w+\\s+\\w+\\s*\\(([^)]*)\\)\\s*\\{/) | some }}\nrun:\n- action: add-comment@v1\nargs: comment: | This PR modifies method input parameters, but is missing Javadoc changes. Please check to ensure no Javadoc changes are necessary.\n
Download this example as a CM file."},{"location":"automations/integrations/javadoc/review-javadoc-large-change/","title":"Review Javadoc for Large Changes","text":"

Require more extensive reviews for large Java changes that lack Javadoc updates.

Configuration Description

Conditions (all must be true):

  • The PR changes more than 25% of a Java class.
  • The PR lacks Javadoc changes.

Automation Actions:

  • Post a comment asking the author to review all relevant Javadoc to identify necessary updates.
  • Require a review from the my-organization/tech-writers team.
  • Apply a yellow \u26a0\ufe0f Missing Javadoc Label

Review Javadoc for Large Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Require more extensive reviews for large Java changes that lack Javadoc updates.\nreview_javadoc_large:\nif:\n- {{ changes.ratio > 25}}\n- {{ source.diff.files | matchDiffLines(regex=r/\\/*\\*([\\s\\S]*?)\\//) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Javadoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | This PR makes major changes to Java classes, but is missing updates to Javadoc. Please double check for any necessary Javadoc updates.\n- action: add-reviewers@v1\nargs:\nreviewers: [fourth-organization/tech-writers]\nchanges:\n# Sum all the lines added/edited in the PR\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\n# Sum all the line removed in the PR\ndeletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}\n# Calculate the ratio of new code\nratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/integrations/javadoc/review-new-class-javadoc/","title":"Enforce Javadoc Requirements for New Classes","text":"

Automatically request changes when someone creates a new Java class that lacks Javadoc content.

Configuration Description

Conditions (all must be true):

  • The PR creates a new Java class.
  • The PR lacks Javadoc content.

Automation Actions:

  • Apply a \u26a0\ufe0f Missing Javadoc label.
  • Request changes, and post a comment explaining that Javadoc is required

Review Javadoc Requirements for New Classes

manifest:\nversion: 1.0\nautomations:\nreview_new_class_javadoc:\n# Triggered for new Java files that lack Javadoc content.\nif:\n- {{ is.java and is.new }}\n- {{ source.diff.files | matchDiffLines(regex=r/\\/*\\*([\\s\\S]*?)\\//) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Javadoc\"\ncolor: {{ colors.yellow }}\n- action: request-changes@v1\nargs:\ncomment: | This PR creates new Java classes, but is missing updates to Javadoc. Please double check for any necessary Javadoc updates.\nis:\njava: {{ files | extensions | match(term='java') | every }}\nnew: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/integrations/jira/configure/","title":"Configure Jira for gitStream Integrations","text":"

If you want to build gitStream automations to interact with the Jira API or Jira webhooks, you'll need to complete some setup in Jira, GitHub, and gitStream. This section outlines the setup process depending on the type of automation you want to build.

These guides are for sending HTTP requests to Jira

If the gitStream automations you want to use don't make any HTTP requests to a Jira API or webhook, you can ignore this section.

"},{"location":"automations/integrations/jira/configure/#use-webhooks-to-trigger-jira-automations","title":"Use Webhooks to Trigger Jira Automations","text":"

Jira automations are the preferred method for gitStream to trigger actions within Jira, so you should use them whenever possible. If webhooks don't provide access to the data you need, or acheive the functionality you want, use the Jira API instead.

First, create a Jira automation that uses an incoming webhook as the trigger and add whatever automation components you want after this trigger. Save the webhook URL in a secure place, you'll need it later.

Here is an example of an automation that uses the webhookData property of the incoming data payload to create a new task. It expects the incoming data payload to contain title and pr_url fields to set the task summary and a pr_url custom field our demo environment already has configured.

Learn more about working with incoming webhooks in the Jira docs

Next, in GitHub, create an organization secret to store your Jira webhook URL and pass it to gitStream's env context variable by adding a line to .github/workflows/gitstream.yml inside your repo. Make sure to give this a unique name, such as JIRA_CREATE_ISSUE_WEBHOOK: ${{ secrets.JIRA_CREATE_ISSUE_WEBHOOK }}.

Once finished, you can use the env.JIRA_CREATE_ISSUE_WEBHOOK context variable inside CM files to send HTTP requests to Jira from your GitHub repo. For an example of how to do this, check out the create Jira issue automation.

"},{"location":"automations/integrations/jira/configure/#connect-to-the-jira-api","title":"Connect to the Jira API","text":"

The Jira API is useful in situations where you need to retreive data from Jira or need to access capabilities that aren't available via Jira Automations. The Jira API uses an account-based token system that follows a basic auth model; this means you'll need an individual account to connect to Jira's APIs and will pass the account email address and API token in the headers of your API requests.

Here's the process to grant gitStream access to the Jira API:

  1. Create an API token for your Jira account, and give it a unique name. Copy the API token, you'll need it in the next step.
  2. Create a GitHub organization secret to store the token and make the secret available to gitStream's env context variable.
  3. Add env.MY_API_TOKEN to any of your CM automations to access the API token and pass it to plugins and automation actions.

Check out the hasJiraIssue filter plugin for an example of how to use Jira API tokens.

"},{"location":"automations/integrations/jira/create-jira-issue/","title":"Automatically Create Jira Issues from PRs","text":"

Automatically create Jira tickets for new pull/merge requests.

Jira API & Webhook Integration Required.

This automation requires you to connect to the Jira API and incoming webooks.

Required gitStream Plugins

This example requires you to install the hasJiraIssue plugin.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • The PR description contains the text - [x] Auto-create Jira Issue
  • No existing Jira issues reference the PRs URL.

Automation Actions:

  • Send an HTTP request to create a new Jira issue.

Automatically Create Jira Issues

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n###### ** Configure This Section ** ######\n# Configure this for your Jira instance and the email associated with your API key.\n# You can safely use these values because only your API key is sensitive. \njiraSpaceName: \"my-company\" # e.g. my-company.atlassian.net\nemail: \"my.email@example.com\"\n# If you're concerned about exposing this information,\n# we recommend using environment variables for your production environment.\n# -----------\n# Pass the API token associated with the email above to gitStream via an environment variable.\njiraAuth: {{ env.JIRA_API_TOKEN }}\n# Learn more about env: https://docs.gitstream.cm/context-variables/#env\n# -----------\n# Change this to the Jira field you want to match the input string against.\njiraField: \"myField\"\n# If you want to search a custom field, you should provide the ID like so:\n# jiraField: \"cf[XXXXX]\"\n# Replace XXXXX with the ID of the custom field you want to search.\n# More information:\n# Using JQL to search the Jira API: https://support.atlassian.com/jira-service-management-cloud/docs/jql-fields/\n# How to find the ID of a custom field: https://confluence.atlassian.com/jirakb/how-to-find-any-custom-field-s-ids-744522503.html\n# -----------\n###### ** Automation ** ######\n# You may want to update the text in the comment gitStream posts;\n# otherwise, this section shouldn't need to be changed.\nprUrl: \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\nhas_jira_issue: {{ prUrl  | hasJiraIssue(jiraAuth, jiraField, jiraSpaceName, email) }}\nautomations:\nautomatic_jira_task: if:\n- {{ not has_jira_issue }}\n- {{ pr.description | includes(regex=r/\\- \\[x\\] Auto-create Jira Task/)}}\nrun:\n- action: send-http-request@v1\nargs:\nurl: {{ env.JIRA_WEBHOOK }}\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{\"data\":{\"pr_url\": \"{{ prUrl }}\",\"title\":\"{{ pr.title }}\"}}'\n- action: add-comment@v1\nargs:\ncomment: \"gitStream automatically created a Jira task for this PR\"\n
Download this example as a CM file."},{"location":"automations/integrations/jira/create-jira-issue/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/jira/create-jira-ticket/","title":"Automatically Create Jira Tickets","text":"

Automatically create Jira tickets for new PRs.

Required gitStream Plugins

This example requires you to install the hasJiraTicket plugin.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • A Jira ticket does not yet exist with the same title as the PR.

Automation Actions:

  • Send an HTTP request to create a new Jira ticket.

Plugin:

  • hasJiraTicket

Create Jira Ticket

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nhas_jira_ticket: {{ pr.title | hasJiraTicket(env.JIRA_API_TOKEN) }}\nautomations:\nadd_jira: if:\n- {{ not has_jira_ticket }}\nrun:\n- action: send-http-request@v1\nargs:\nurl: env.JIRA_WEBHOOK_URL\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{\"data\":{\"pr_url\": \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"}}'\n
Download this example as a CM file."},{"location":"automations/integrations/jira/create-jira-ticket/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/jira/jira-assign/","title":"Automatically Assign Jira Tickets","text":"

Automatically assign Jira tickets based on code review actions.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Configuration Description

Conditions (all must be true):

  • The PR description contains the slash command: /gitstream assign-jira followed by a Jira username.

Automation Actions:

  • Trigger a Jira webhook to update the assignee field with the username provided in the slash command.

Automatically Assign Jira Tickets

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nassigneeRegex: r/(?<=\\/gitstream assign-jira ).*(?=<br \\/>)/\n{% set ticketid = \"\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\njira_assign: if:\n- {{ pr.description | includes(regex=assigneeRegex) }}\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ env.JIRA_WEBHOOK }}}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{\"issues\":[\"{{ticketid}}\"],\"data\":{\"assignee\":\"{{pr.description | capture(regex=assigneeRegex)}}\"}}'\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_branch: {{ branch.name | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\ntickets:\n- {{branch.name | capture(regex=r/\\b[A-Za-z]+-\\d+\\b/)}}\n- {{pr.title | capture(regex=r/\\b[A-Za-z]+-\\d+\\b/)}}\n
Download this example as a CM file."},{"location":"automations/integrations/jira/jira-assign/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/jira/jira-change-status/","title":"Automatic Jira Status Updates","text":"

Automatically update the status of Jira tickets when a PR is opened.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Configuration Description

Conditions (all must be true):

  • A PR is created that references a Jira ticket in the title or description.

Automation Actions:

  • Make an HTTP request to a Jira webhook that is pre-configured to update the ticket status.

Automatic Jira Status Updates

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n{% set ticketid = \"\\b[A-Za-z]+-\\d+\\b\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\njira_change_status: if:\n- {{ has.jira_ticket_in_title or has.jira_ticket_in_desc }}\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ env.JIRA_CHANGE_STATUS_WEBHOOK }}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{\"issues\":[\"{{ticketid}}\"],\"data\":{\"pr_url\":\"https://github.com/{{repo.owner}}/{{repo.name}}/pull/{{pr.number}}\"}}'\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_branch: {{ branch.name | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\ntickets:\n- {{branch.name | capture(regex=r/\\b[A-Za-z]+-\\d+\\b/)}}\n- {{pr.title | capture(regex=r/\\b[A-Za-z]+-\\d+\\b/)}}\n
Download this example as a CM file."},{"location":"automations/integrations/jira/jira-change-status/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/jira/jira-update-field/","title":"Automatic Jira Updates","text":"

Automatically update Jira tickets with pull request information. You can modify this to send any PR metadata to Jira.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Configuration Description

Conditions (all must be true):

  • A PR is created that contains a Jira ticket reference in the title or branch name.

Automation Actions:

  • Send a webhook to Jira containing metadata to add to the Issue.

Automatic Jira Updates

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n{% set ticketid = \"\\b[A-Za-z]+-\\d+\\b\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\njira_update_field: if:\n- {{ has.jira_ticket_in_title or has.jira_ticket_in_branch }}\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ env.JIRA_UPDATE_PR_FIELD_WEBHOOK }}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{\"issues\":[\"{{ticketid}}\"],\"data\":{\"pr_url\":\"https://github.com/{{repo.owner}}/{{repo.name}}/pull/{{pr.number}}\"}}'\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_branch: {{ branch.name | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\n
Download this example as a CM file."},{"location":"automations/integrations/jira/jira-update-field/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/jira/label-missing-jira-info/","title":"Label Missing Jira Info","text":"

Label PRs that don't reference a Jira ticket in the title or description. This uses regex to detect Jira ticket formats in the title (e.g. ABC-1234), and URLs to Jira tickets in the description.

Configuration Description

Conditions (all must be true):

  • The PR lacks a Jira ticket number in the title, or a link to a Jira ticket in the PR description.

Automation Actions:

  • Apply a missing-jira label.

Label Missing Jira Info

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_missing_jira_info:\n# Triggered for PRs that don't have either a Jira ticket number in the title,\n# or a link to a Jira ticket in the PR description.\nif:\n- {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"missing-jira\"\ncolor: 'F6443B'\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\\/browse\\/\\w{1,}-\\d{3,4}/) }}\n
Download this example as a CM file."},{"location":"automations/integrations/jira/link-jira/","title":"Automatically Link PRs to Related Jira Issues","text":"

Provide automatic links to Jira issues that are associated with PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Jira card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Jira Card.

Automatically Link to the Related Jira Card

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nprovider: jira\n# Change this to the name of your Jira organization\norgName: org\n{% set ticketid = \"\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\nlink_jira:\nif:\n- {{ has.ticket_in_title or has.ticket_in_branch }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})\nhas:\nticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}\nticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}\ntracker:\njira:\nbaseurl: https://[orgName].atlassian.net/browse/\npattern: r/\\b[A-Za-z]+-\\d+\\b/\ntickets:\n- {{branch.name | capture(regex=tracker[provider].pattern)}}\n- {{pr.title | capture(regex=tracker[provider].pattern)}}\n
Download this example as a CM file."},{"location":"automations/integrations/jira/link-jira/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/jit/label-jit-alerts/","title":"Label Jit Alerts","text":"

Label the number of high, medium, and low risk vulnerabilities Jit reports for PRs.

Configuration Description

Conditions (all must be true):

  • Jit reports one or more high, medium, or low risk security vulnerabilities for the PR.

Automation Actions:

  • Apply labels to indicate the number of each type of vulnerability

Label Jit Alerts

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in reports %}\nlabel_jit_{{ item.name }}:\nif:\n- {{ item.count > 0}}\nrun:\n- action: add-label@v1\nargs:\nlabel: 'Jit: {{ item.count }} {{ item.name }} vulnerabilities'\ncolor: {{ colors.red if (item.name == 'high') else (colors.orange if (item.name == 'medium' ) else colors.yellow) }}\n{% endfor %}\njit: {{ pr | extractJitFindings }}\nreports:\n- name: high\ncount: {{ jit.metrics.HIGH }}\n- name: medium\ncount: {{ jit.metrics.MEDIUM }}\n- name: low\ncount: {{ jit.metrics.LOW }}\ncolors:\nred: 'b60205'\norange: 'd93f0b'\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/integrations/jit/review-jit-alerts/","title":"Review Jit Security Alerts","text":"

Manage review assignment for high and medium risk Jit security alerts.

Configuration Description

**Review Jit High Alerts**\n\n* Conditions (all must be true):\n    * Jit reports one or more high vulnerabilities for the PR\n* Automation Actions:\n    * Require a review from the organization\u2019s security team.\n    * Require 2 reviewers.\n    * Post a comment explaining why this action was taken.\n\n**Review Jit Medium Alerts**\n\n* Conditions (all must be true):\n    * Jit reports one or more medium vulnerabilities for the PR\n* Automation Actions:\n    * Require 2 reviewers\n    * Post a comment explaining why this action was taken.\n

Review Jit Security Alerts

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_jit_high_alerts:\nif:\n- {{ jit.metrics.HIGH > 0 }}\nrun:\n- action: require-reviewers@v1\nargs:\nreviewers: [my-organization/security-team]\n- action: set-required-approvals@v1\nargs:\napprovals: 2\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR requires additional review because Jit reported one or more high risk vulnerabilities.\nreview_jit_medium_alerts:\nif:\n- {{ jit.metrics.MEDIUM > 0 }}\nrun:\n- action: set-required-approvals@v1\nargs:\napprovals: 2\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR requires additional reviewers because Jit reported one or more medium risk vulnerabilities.\njit: {{ pr | extractJitFindings }}\n
Download this example as a CM file."},{"location":"automations/integrations/jit/review-jit-ignore-accept/","title":"Review Jit Ignore and Accept","text":"

Notify your Security team when someone ignores a Jit vulnerability report and accepts the risk.

Configuration Description

Conditions (all must be true):

  • Someone ignores and accepts a Jit finding

Automation Actions:

  • Request review from the organization\u2019s security team.
  • Label the PR to indicate someone accepted the risk of a Jit security alert.
  • Post a comment explaining why this action was taken.

Review Jit Ignore and Accept

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_jit_ignore_accept:\nif:\n- {{ pr.conversations | reject(attr='commenter', term='jit-ci') | filter(attr='content', term='#jit_ignore_accept') | some }}\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: [my-organziation/security]\n- action: add-label@v1\nargs:\nlabel: '\u2755 Jit: Ignore - Accept Risk'\n- action: add-comment@v1\nargs:\ncomment: |\nThe security team has been assigned for optional review because this PR ignores a Jit alert and accepts the associated risks.\njit: {{ pr | extractJitFindings }}\n
Download this example as a CM file."},{"location":"automations/integrations/jit/review-jit-secret/","title":"Review Jit Secret Detection","text":"

Close PRs where Jit detects a secret and post a comment explaining steps to remedy the situation.

Configuration Description

Conditions (all must be true):

  • Jit detects a secret in the PR.

Automation Actions:

  • Close the PR
  • Post a comment explaining why this action was taken and to outline the necessary steps to remedy the situation.

Review Jit Security Control

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_jit_secret:\nif:\n- true\n- {{ jit.vulnerabilities | match(attr='security_control', term='Secret Detection') | some }}\nrun:\n- action: add-comment@v1\nargs: comment: |\nJit detects secrets in this PR. Please complete the following steps:\n1. Undo the commit with git reset and remove all secrets from the files you modified.\n2. Deactivate the secret in any locations its used and replace it with a new key\n3. Commit your changes and resubmit your PR.\n- action: close@v1\njit: {{ pr | extractJitFindings }}\n
Download this example as a CM file."},{"location":"automations/integrations/jsdoc/review-jsdoc/","title":"Review JSDoc Changes","text":"

Approve PRs that only contain changes to JSDoc and assign optional reviewers.

Configuration Description

Conditions (all must be true):

  • The PR only affects JavaScript and TypeScript files
  • The PR only contains changes to JSDoc content.

Automation Actions:

  • Assign the ORG/tech-writers team.
  • Apply a green \ud83d\udcd3 JSDoc Only label
  • Approve the PR

Review JSDoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Assign PRs that only affect JSDocs to the technical writing team and add docs label\nreview_jsdoc:\nif:\n- {{ source.diff.files | match(attr='diff', regex=r/\\/*\\*[\\s\\S]*?\\//) | every }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\ud83d\udcd3JSDoc Only\"\ncolor: {{ colors.green }}\n- action: add-reviewers@v1\nargs:\nreviewers: [fourth-organization/tech-writers]\n- action: approve@v1\ncolors:\ngreen: '0e8a16'\n
Download this example as a CM file."},{"location":"automations/integrations/jsdoc/review-jsdoc-input/","title":"Review JSDoc Input Parameters","text":"

Warn PR authors when they change JavaScript function or constructor input parameters without updating JSDoc content.

Configuration Description

Conditions (all must be true):

  • The PR changes an input parameter in one or more JavaScript methods.
  • The PR lacks changes to \u2018@param\u2019 declarations.

Automation Actions:

  • Post a comment warning the user to review the method\u2019s JSDoc to identify necessary updates.

Review JSDoc Input Parameters

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_jsdoc_input: if:  - {{ source.diff.files | matchDiffLines(regex=r/.*\\s@param/) | nope }}\n- {{ source.diff.files | matchDiffLines(regex=r/\\((?:.*\\:.*\\))/) | some }}\nrun:\n- action: add-comment@v1\nargs: comment: | This PR appears to modify method input parameters, but is missing JSDoc changes. Please check to ensure no JSDoc changes are necessary.\n
Download this example as a CM file."},{"location":"automations/integrations/jsdoc/review-jsdoc-large/","title":"Review JSDoc for Large Changes","text":"

Require more extensive reviews for large JavaScript changes that lack JSDoc updates.

Configuration Description

Conditions (all must be true):

  • The PR changes more than 25% of a JavaScript class.

Automation Actions:

  • Post a comment asking the author to review all relevant JSDoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow \u26a0\ufe0f Missing JSDoc Label

Review JSDoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Require more extensive reviews for large Javascript changes that lack JSDoc updates.\nreview_jsdoc_large:\nif:\n- {{ changes.ratio > 25}}\n- {{ source.diff.files | matchDiffLines(regex=r/\\/*\\*([\\s\\S]*?)\\//) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f No JSDoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | This PR makes major changes to JavaScript classes, but is missing updates to JSDoc. Please double check for any necessary JSDoc updates.\n- action: add-reviewers@v1\nargs:\nreviewers: [fourth-organization/tech-writers]\nchanges:\n# Sum all the lines added/edited in the PR\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\n# Sum all the line removed in the PR\ndeletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}\n# Calculate the ratio of new code\nratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/integrations/jsdoc/review-jsdoc-new-class/","title":"Enforce JSDoc for New JavaScript Classes","text":"

Require JSDoc for all new JavaScript classes.

Configuration Description

Conditions (all must be true):

  • The PR creates a new JavaScript class.
  • The PR lacks JSDoc content.

Automation Actions:

  • Request changes and post a comment explaining that JSDoc is required
  • Apply a yellow \u26a0\ufe0f Missing JSDoc label.

Enforce JSDoc for New JavaScript Classes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_jsdoc_new_class: if:  - {{ is.javascript and is.new }} - {{ source.diff.files | matchDiffLines(regex=r/\\/*\\*([\\s\\S]*?)\\//) | nope }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing JSDoc\"\ncolor: {{ colors.yellow }}\n- action: request-changes@v1\nargs: comment: | JSDoc is required for all JavaScript classes. Please add JSDoc to all new classes in this PR.\nis:\njavascript: {{ files | extensions | match(list=['js', 'ts']) | every }}\nnew: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/integrations/launch-darkly/label-ff-launch-darkly/","title":"Label LaunchDarkly Feature Flags","text":"

Automatically label code that contians specified feature flags.

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in feature_flags %}\nlabel_ff_launchdarkly_{{ item.name }}:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/var flagValue = ldclient/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ item.name }}\ncolor: {{ colors.yellow }}\n{% endfor %}\nfeature_flags:\n- name: engineering_rollback_plan_activated regex: r/engineering_rollback_plan_activated/\n- name: marketing_premium_plan_features_unlocked regex: r/marketing_premium_plan_features_unlocked/\n- name: mobile_push_notifications_enabled\nregex: r/mobile_push_notifications_enabled/\ncolors:\nyellow: 'ffb300'   
Download this example as a CM file."},{"location":"automations/integrations/orca/label-orca-scan-results/","title":"Auto-Label Orca Scan Results","text":"

Automatically apply labels to PRs that indicate the result of Orca Security scans.

Required gitStream Plugin

This example requires you to install the extractOrcaFindings plugin.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • Orca Security detects one or more issues with the code in the PR.

Automation Actions:

  • Apply a label that indicates which issue was identified.

Auto-Label Orca Scan Results

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in reports %}\nlabel_orca_{{ item.name }}:\nif:\n- {{ item.count > 0 }}\nrun:\n- action: add-label@v1\nargs:\nlabel: 'orca:{{ item.name }}'\n{% endfor %}\norca: {{ pr | extractOrcaFindings }}\nreports:\n- name: introduced-cves\ncount: {{ orca.vulnerabilities.count }}\n- name: iac-misconfigurations\ncount: {{ orca.infrastructure_as_code.count }}\n- name: exposed-secrets count: {{ orca.secrets.count }}\ncolors:\nred: 'b60205'\n
Download this example as a CM file."},{"location":"automations/integrations/orca/label-orca-scan-results/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/orca/review-orca-alerts/","title":"Require Security Review for Orca Alerts","text":"

Automatically require review from your SecOps team for Orca Security violations in pull requests.

Configuration Description

Conditions (all must be true):

  • The PR contains a vulnerability, IAC problem, or secret that is flagged as High or Medium.

Automation Actions:

  • Require review from your organization's security team.
  • Post a comment explaining the requirement.

Review Orca Security Alerts

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_orca_alerts:\nif:\n- {{ has.vulnerability or has.iac_violation or has.secret }}\nrun:\n- action: require-reviewers@v1\nargs:\nreviewers: [my-organization/security-team]\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR requires additional review because it fails to meet Orca Security safe code standards.\norca: {{ pr | extractOrcaFindings }}\nhas:\nvulnerability: {{ orca.vulnerabilities.priority == 'High' or orca.vulnerabilities.priority == 'Medium' }}\niac_violation: {{ orca.infrastructure_as_code.priority == 'High' or orca.infrastructure_as_code.priority == 'Medium' }}\nsecret: {{ orca.secrets.priority == 'High' or orca.secrets.priority == 'Medium' }}\n
Download this example as a CM file."},{"location":"automations/integrations/orca/review-orca-alerts/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/rdoc/review-rdoc/","title":"Automatically Approve RDoc Changes","text":"

Approve PRs that only contain changes to RDoc and assign optional reviewers.

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to RDoc content.

Automation Actions:

  • Assign the org/tech-writers team for optional review.
  • Apply a green \ud83d\udcd3 RDoc Only label
  • Approve the PR

Review RDoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_rdoc:\nif:\n- {{ source.diff.files | match(attr='diff', regex=r/^[\\s\\t]*#.*/) | every }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\ud83d\udcd3RDoc Only\"\ncolor: {{ colors.green }}\n- action: add-reviewers@v1\nargs:\nreviewers: [org/tech-writers]\n- action: approve@v1\ncolors:\ngreen: '0e8a16'\n
Download this example as a CM file."},{"location":"automations/integrations/rdoc/review-rdoc-input/","title":"Review RDoc Input Parameters","text":"

Warn PR authors when they change Ruby function or constructor input parameters without updating RDoc content.

Configuration Description

Conditions (all must be true):

  • The PR changes one or more input parameters in Ruby methods.
  • The PR lacks RDoc updates.

Automation Actions:

  • Post a comment warning the user to review the method\u2019s RDoc to identify necessary updates.

Review RDoc Input Parameters

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_rdoc_input: if:  - {{ source.diff.files | match(attr='diff', regex=r/(\\#.*\\n.*)*def/) | nope }}\n- {{ source.diff.files | match(attr='diff', regex=r/def.*\\(.*\\)/ | some }}\nrun:\n- action: add-comment@v1\nargs: comment: | This PR modifies method input parameters, but is missing RDoc changes. Please check to ensure no RDoc changes are necessary.\n
Download this example as a CM file."},{"location":"automations/integrations/rdoc/review-rdoc-large/","title":"Review RDoc for Large Changes","text":"

Require more extensive reviews for large Ruby changes that lack RDoc updates.

Configuration Description

Conditions (all must be true):

  • The PR changes more than 150 lines of Ruby code.

Automation Actions:

  • Post a comment asking the author to review all relevant RDoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow \u26a0\ufe0f Missing RDoc Label

Review RDoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Require more extensive reviews for large Ruby changes that lack RDoc updates.\nreview_rdoc_large:\nif:\n- {{ changes.additions > 150}}\n- {{ source.diff.files | matchDiffLines(regex=r/(\\#.*\\n.*)*def/) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing RDoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | This PR makes major changes to Ruby methods, but is missing updates to RDoc. Please double check for any necessary RDoc updates.\n- action: add-reviewers@v1\nargs:\nreviewers: [fourth-organization/tech-writers]\nchanges:\n# Sum all the lines added/edited in the PR\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/integrations/rdoc/review-rdoc-new-class/","title":"Enforce RDoc for New Ruby Classes","text":"

Require RDoc for all new Ruby classes.

Configuration Description

Conditions (all must be true):

  • The PR creates a new Ruby class.
  • The PR lacks RDoc content.

Automation Actions:

  • Request changes and post a comment explaining that RDoc is required
  • Apply a yellow \u26a0\ufe0f Missing RDoc label.

Enforce RDoc for New Ruby Classes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_rdoc_new_class: if:  - {{ is.rb and is.new }} - {{ source.diff.files | match(attr='diff', regex=r/(\\#.*\\n.*)*def/) | nope }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing RDoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | RDoc is required for all Ruby classes. Please add documentation for this PR.\nis:\nrb: {{ files | extensions | match(regex=r/rb/) | every }}\nnew: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/integrations/renovate/approve-renovate/","title":"Approve and Merge Renovate Changes","text":"

Auto-merge Renovate PRs

By Release TypeAll Updates

Required gitStream Plugins

This example requires you to install the extractRenovateVersionBump, compareMultiSemver and compareSemver plugins.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • The PR author is Renovate.
  • The branch name includes 'renovate'
  • The dependency change is a patch or minor update.

Automation Actions:

  • Approve the PR
  • Apply an approved-renovate label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

manifest:\nversion: 1.0\nautomations:\nmerge_renovate_minor:\nif:\n- {{ bump == 'minor' }}\n- {{ branch.name | includes(term=\"renovate\") }}\n- {{ branch.author | includes(term=\"renovate\") }}\nrun:\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nRenovate `minor` version bumps are approved automatically.\nmerge_renovate_minor_patch:\nif:\n- {{ bump == 'patch' }}\n- {{ branch.name | includes(term=\"renovate\") }}\n- {{ branch.author | includes(term=\"renovate\") }}\nrun:\n- action: approve@v1\n- action: merge@v1\n- action: add-comment@v1\nargs:\ncomment: |\nRenovate `patch` version bumps are approved and merged automatically.\nbump: {{ pr.description | extractRenovateVersionBump | compareMultiSemver }}\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • The PR author is Renovate.
  • The branch name includes 'renovate'

Automation Actions:

  • Approve the PR
  • Apply an approved-renovate label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_renovate:\nif:\n- {{ branch.author | includes(term=\"renovate\") }}\nrun:\n- action: approve@v1\n- action: add-label@v1\nargs:\nlabel: \"approved-renovate\"\n- action: merge@v1\nargs:\nwait_for_all_checks: true\nsquash_on_merge: true\n
Download this example as a CM file.

"},{"location":"automations/integrations/shortcut/label-missing-shortcut/","title":"Label Missing Shortcut","text":"

Automatically label PRs that are missing references to Shortcut resources.

Configuration Description

Conditions (all must be true):

  • The PR is missing one of the following:
    • An Shortcut ticket reference in the PR title.
    • A link to an Shortcut resource in the PR description.

Automation Actions:

  • Apply a red \u26a0\ufe0f Missing Shortcut Link label
  • Post a comment that asks the author to add an Shortcut reference to the PR.

Label Missing Shortcut

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_missing_shortcut:\nif:\n- {{not (has.shortcut.ticket_in_title or has.shortcut.ticket_in_desc)}}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Shortcut Link\"\ncolor: {{ colors.red }}\n- action: add-comment@v1\nargs:\ncomment: Please provide a link to the associated Shortcut resource.\nhas:\nshortcut:\nticket_in_title: {{ pr.title | includes(regex=r/(\\w+)\\/sc-(\\d+)/) }}\nticket_in_desc: {{ pr.description | includes(regex=r/(app\\.shortcut\\.com)\\/(\\w+)\\/story\\/(\\d+)\\/(\\w+)/) }}\ncolors:\nred: 'b60205'\n
Download this example as a CM file."},{"location":"automations/integrations/shortcut/label-missing-shortcut/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/shortcut/link-shortcut/","title":"Automatically Link PRs to Related Shortcut Tasks","text":"

Provide automatic links to Shortcut tasks that are associated with PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Shortcut card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Shortcut Task.

Automatically Link to the Related Shortcut Task

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n# Configure these to match your organization.\nprovider: jira\n# Change this to match the name of your Shortcut organization. This is used in tracker.shortcut.baseurl\norgName: org\n{% set ticketid = \"\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\nlink_shortcut:\nif:\n- {{ has.ticket_in_title or has.ticket_in_branch }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})\nhas:\nticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}\nticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}\ntracker:\nshortcut:\nbaseurl: https://app.shortcut.com/[orgName]/story/\npattern: r/(\\w+)\\/sc-(\\d+)/\ntickets:\n- {{branch.name | capture(regex=tracker[provider].pattern)}}\n- {{pr.title | capture(regex=tracker[provider].pattern)}}\n
Download this example as a CM file."},{"location":"automations/integrations/shortcut/link-shortcut/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/slack/slack-auto-recognition/","title":"Automatic Slack Messages","text":"

Automatically post positive recognition messages in Slack for well-structured PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains updates to tests.
  • The PR has fewer than 5 modified files.
  • The PR branch references a Jira ticket.
  • The PR has fewer than 150 lines of code changed.

Automation Actions:

  • Post a Slack message that automatically recognizes the PR author and provides a link to the PR.

Automatic Slack Messages

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nslack_auto_recognition:\nif:\n- {{ files | match(regex=r/(test|spec)/) | some }} # this pr has at least 1 test\n- {{ files | length <= 5 }} # this pr has 5 or less files\n- {{ branch.name | includes(regex=r/[A-Z]{2,}-\\d+.*/) }} # this branch has the Jira ticket prefix\n- {{ branch.diff.size <= 150 }} # this branch has 150 lines of code or less changed\nrun:\n- action: send-slack-message@v1\nargs:\nwebhook_url: \"{{ env.SLACK_WEBHOOK }}\"\nmessage: \":tada: Congrats to {{ pr.author }} for the amazing new PR, '{{ pr.title }}'! Check it out at https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\n
Download this example as a CM file."},{"location":"automations/integrations/slack/slack-auto-recognition/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/slack/slack-send-notification/","title":"Send Slack Notifications","text":"

Automatically send Slack notifications to specific channels based on the contents of a pull request.

Configuration Description

Conditions (all must be true):

  • The PR meets one or more of the specified trigger criteria for Slack notifications.

Automation Actions:

  • Post a Slack message based on the contents of the PR.

Send Slack Notifications

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nsend_slack_security:\n# use your custom logic here to determine whether this needs a security review\nif:\n- true\nrun:\n- action: send-slack-message@v1\nargs:\nwebhook_url: \"{{ env.SLACK_WEBHOOK_SECURITY }}\"\nmessage: \"A PR requires a security review. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\nsend_slack_qa:\n# use your custom logic here to determine whether this needs a qa review\nif:\n- {{ not (files | match(regex=r/(test|spec)/) | some) }}\nrun:\n- action: send-slack-message@v1\nargs:\nwebhook_url: \"{{ env.SLACK_WEBHOOK_QA }}\"\nmessage: \"A PR was submitted without tests. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\nsend_slack_docs:\n# use your custom logic here to determine whether this needs a docs review\nif:\n- {{ files | match(regex=r/(docs)/) | some }}\nrun:\n- action: send-slack-message@v1\nargs:\nwebhook_url: \"{{ env.SLACK_WEBHOOK_DOCS }}\"\nmessage: \"A PR has modified the docs. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\n
Download this example as a CM file."},{"location":"automations/integrations/slack/slack-send-notification/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/snyk/approve-snyk/","title":"Approve and Merge Snyk Changes","text":"

Approve PRs from Snyk

Configuration Description

Conditions (all must be true):

  • The PR author is Snyk.

Automation Actions:

  • Approve the PR
  • Apply an approved-snyk label to the PR
  • Merge the PR if all status checks pass.

Approve Snyk

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_snyk:\nif:\n- {{ branch.author | includes(term=\"snyk\") }}\nrun:\n- action: approve@v1\n- action: add-label@v1\nargs:\nlabel: \"approved-snyk\"\n- action: merge@v1\nargs:\nwait_for_all_checks: true\nsquash_on_merge: true\n
Download this example as a CM file."},{"location":"automations/integrations/sonar/approve-sonar-clean-code/","title":"Approve Sonar Clean Code","text":"

Approve PRs that pass SonarCloud's quality gate.

Configuration Description

Conditions (all must be true):

  • SonarCloud reports an 'A' rating for vulnerabilities, bugs, security hotspots, and code smells.
  • There is no duplicated code.

Automation Actions:

  • Apply a Sonar: Clean Code label to the PR.
  • Approve the PR.
  • Post a comment that explains why the PR was approved.

Aprove Sonar Clean Code

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_sonar_clean_code:\nif:\n- {{ sonar.bugs.rating == 'A' }}\n- {{ sonar.code_smells.rating == 'A' }}\n- {{ sonar.vulnerabilities.rating == 'A' }}\n- {{ sonar.security_hotspots.rating == 'A' }}\n- {{ sonar.duplications == null or sonar.duplications == 0 }}\nrun: - action: add-label@v1\nargs:\nlabel: '\u2705 Sonar: Clean Code'\ncolor: {{ colors.green }}\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR passes the SonarCloud quality gate check and as been automatically approved.\nsonar: {{ pr | extractSonarFindings }}\ncolors:\ngreen: '0e8a16'\n
Download this example as a CM file."},{"location":"automations/integrations/sonar/label-sonar/","title":"Label SonarCloud Quality Reports","text":"

Label the number of bugs, vulnerabilities, security hotspots, and code smells reported by SonarCloud.

Configuration Description

Conditions (all must be true):

  • There is at least one vulnerability, code smell, security hotspot, or bug reported by SonarCloud. Uses the extractSonarFindings filter function

Automation Actions:

  • Apply color-coded labels to indicate the number of vulnerabilities, code smells, security hotspots, and bugs.

Label SonarCloud Quality Reports

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in reports %}\nlabel_sonar_{{ item.name }}:\nif:\n- {{ item.count > 0}}\nrun:\n- action: add-label@v1\nargs:\nlabel: '{{ item.icon }} sonar:{{ item.name }}-{{ item.rating }}'\ncolor: {{ colors.red if (item.rating == 'E' or item.rating == 'D') else (colors.orange if (item.rating == 'C' ) else colors.yellow) }}\n{% endfor %}\nsonar: {{ pr | extractSonarFindings }}\nreports:\n- name: vulnerabilities\ncount: {{ sonar.vulnerabilities.count }}\nicon: \ud83d\udd13\nrating: {{ sonar.vulnerabilities.rating }}\n- name: code smells\ncount: {{ sonar.code_smells.count }}\nicon: \u2623\ufe0f\nrating: {{ sonar.code_smells.rating }}\n- name: security hotspots\ncount: {{ sonar.security_hotspots.count }}\nicon: \ud83d\udee1\ufe0f\nrating: {{ sonar.security_hotspots.rating }}\n- name: bugs\ncount: {{ sonar.bugs.count }}\nicon: \ud83e\udeb2\nrating: {{ sonar.bugs.rating }}\ncolors:\nred: 'b60205'\norange: 'd93f0b'\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/integrations/sonar/review-sonar-alerts/","title":"Review Sonar Security Alerts","text":"

Require additional reviews for Sonar security alerts. gitStream will remove this requirement if the alerts are resolved.

Configuration Description

Conditions (all must be true):

  • The SonarCloud quality gate check fails to pass for code smells, vulnerabilities, or security hotspots.

Automation Actions:

  • Require a review from the my-organization/security-team team. Customize this to match your organization.
  • Post a comment explaining why this PR requires additional review.

Review Sonar Alerts

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_sonar_alerts:\nif:\n- {{ sonar.code_smells.rating != 'A' or sonar.vulnerabilities.rating != 'A' or sonar.security_hotspots.rating != 'A'}}\nrun:\n- action: require-reviewers@v1\nargs:\nreviewers: [my-organization/security-team]\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR requires additional review because it fails to meet SonarCloud clean code standards.\nsonar: {{ pr | extractSonarFindings }}\n
Download this example as a CM file."},{"location":"automations/integrations/sonar/review-sonar-duplications/","title":"Review Sonar Duplications","text":"

Request changes when Sonar reports an excessive level of duplicated code.

Configuration Description

Conditions (all must be true):

  • The PR contains more than 3% duplicated code.

Automation Actions:

  • Apply a label that indicates how much duplicated code Sonar detected.
  • Request changes and post a comment explaining why.

Review Sonar Duplications

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_sonar_duplications:\nif:\n- {{ sonar.duplications > 3 }}\nrun: - action: add-label@v1\nargs:\nlabel: 'Sonar: {{ sonar.duplications}}% duplication'\ncolor: {{ colors.yellow }}\n- action: request-changes@v1\nargs:\ncomment: |\nSonar reports an excessive level of code duplication. Please consider refactoring your PR to reduce duplications.\nsonar: {{ pr | extractSonarFindings }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/integrations/swimm/approve-swimm/","title":"Approve Swimm Changes","text":"

Approve changes that only affect Swimm documentation.

Configuration Description

Conditions (all must be true):

  • The PR only affects files that end in a .swm extension.

Automation Actions:

  • Add a swimm-docs-only label
  • Approve the PR
  • Post a comment that explains that this is a Swimm docs change only.

Approve Swimm Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_swimm_changes:\n# Triggered for any changes to Swimm documentation\nif:\n- {{ branch.diff.files_metadata | match(attr='file', regex=r/\\.swm\\//) | every }}\n# Apply a swimm-docs-only label, approve the PR and explain why in a comment.\nrun: - action: add-label@v1\nargs:\nlabel: 'swimm-docs-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR is considered a safe change as it only affects Swimm Docs. \nIt has been automatically approved.\n
Download this example as a CM file.

Special thanks to Omerr for providing this example.

"},{"location":"automations/integrations/teams/teams-auto-recognition/","title":"Automatic MS Teams Notifications","text":"

Automatically post positive recognition messages in MS Teams for well-structured PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains updates to tests.
  • The PR has fewer than 5 modified files.
  • The PR branch references a Jira ticket.
  • The PR has fewer than 150 lines of code changed.

Automation Actions:

  • Post an MS Teams message that automatically recognizes the PR author and provides a link to the PR.

Automatic MS Teams Notifications

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nteams_auto_recognition:\nif:\n- {{ files | match(regex=r/(test|spec)/) | some }} # this pr has at least 1 test\n- {{ files | length <= 5 }} # this pr has 5 or less files\n- {{ branch.name | includes(regex=r/[A-Z]{2,}-\\d+.*/) }} # this branch has the Jira ticket prefix\n- {{ branch.diff.size <= 150 }} # this branch has 150 lines of code or less changed\nrun:\n- action: send-http-request@v1\nargs:\nmethod: \"POST\"\nheaders: '{\"Content-type\": \"application/json\"}'\nurl: \"{{ env.MS_TEAMS_WEBHOOK }}\"\nbody: '{\"text\": \"Congrats to {{ pr.author }} for the amazing new PR, {{ pr.title }}! Check it out at https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"}'\n
Download this example as a CM file."},{"location":"automations/integrations/teams/teams-auto-recognition/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/teams/teams-send-notification/","title":"Automatically Notify MS Teams Channels","text":"

Automatically send Slack notifications to specific channels based on the contents of a pull request.

Configuration Description

Conditions (all must be true):

  • The PR meets one or more of the specified trigger criteria for MS Teams notifications.

Automation Actions:

  • Post an MS Teams message based on the contents of the PR.

Automatically Notify MS Teams Channels

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nsend_teams_security:\nif:\n# use your custom logic here to determine whether this needs a security review\n- true\nrun:\n- action: send-http-request@v1\nargs:\nmethod: \"POST\"\nheaders: '{\"Content-type\": \"application/json\"}'\nurl: \"{{ env.MS_TEAMS_WEBHOOK_SECURITY }}\"\nbody: '{\"text\": \"A PR requires a security review. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"}'\nsend_teams_qa:\nif:\n# use your custom logic here to determine whether this needs a qa review\n- {{ not (files | match(regex=r/(test|spec)/) | some) }}\nrun:\n- action: send-http-request@v1\nargs:\nmethod: \"POST\"\nheaders: '{\"Content-type\": \"application/json\"}'\nurl: \"{{ env.MS_TEAMS_WEBHOOK_QA }}\"\nbody: '{\"text\": \"A PR was submitted without tests. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"}'\nsend_teams_docs:\nif:\n# use your custom logic here to determine whether this needs a docs review\n- {{ files | match(regex=r/(docs)/) | some }}\nrun:\n- action: send-http-request@v1\nargs:\nmethod: \"POST\"\nheaders: '{\"Content-type\": \"application/json\"}'\nurl: \"{{ env.MS_TEAMS_WEBHOOK_DOCS }}\"\nbody: '{\"text\": \"A PR has modified the docs. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"}'\n
Download this example as a CM file."},{"location":"automations/integrations/teams/teams-send-notification/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/terraform/review-new-module/","title":"Review New Terraform Modules","text":"

Request changes if a PR that creates a new Terraform module which do not conform to the required directory structure.

Configuration Description

Conditions (all must be true):

  • The PR creates a new Terraform module
    • A new sub-directory is created inside the /modules directory.
  • The PR lacks one or more required components from the list in the terraform custom expression.

Automation Actions:

  • Request changes and post a comment explaining the missing parts of the module.
  • Apply Label : \u26a0\ufe0f Missing Terraform Components

Review New Module

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n{% set misslist = [] %}\n{% for pattern in terraform %}\n{% if (newfilesinpr | match(term=pattern) | nope) %}\n{% set misslist = misslist + [pattern+' '] %}\n{% endif %}\n{% endfor %} automations:\nreview_new_terraform_module:\nif: - {{misslist | match(regex=r/.*/) | some}}\n- {{is.mainfile and is.mainfilenotinroot }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: |\nNew terraform modules must contain all required components before merging. Please update your PR with the required components and gitStream will automatically remove this comment once completed.\nHere are the required components, {{misslist}} should be customized appropriately:\nmy_module/\n\u251c\u2500\u2500 main.tf\n\u251c\u2500\u2500 outputs.tf\n\u251c\u2500\u2500 providers.tf\n- action: add-label@v1\nargs:\nlabel: '\u26a0\ufe0f Missing Terraform Components'\ncolor: '#FFA500'\nresources:\nmodule_directory: 'modules'\nterraform:\n- main.tf\n- outputs.tf\n- providers.tf\nis:\nmainfile: {{newfilesinpr | match(term = \"main.tf\") | some}}\nmainfilenotinroot: {{source.diff.files | map(attr='original_file') | match(term = \"main.tf\") | nope }}\nnewfilesinpr:\n{{ branch.diff.files_metadata | map(attr='new_file')}}\n
Download this example as a CM file."},{"location":"automations/integrations/terraform/review-terraform/","title":"Require Reviewers for Terraform changes","text":"

Automatically assign org/infrastructure team for reviewing changes when PR contains Terraform file changes.

Configuration Description

Conditions (all must be true):

  • The PR contains changes to one or more Terraform configuration files.

Automation Actions:

  • Require a review from the org/infrastructure team.

Review Terraform Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_terraform:\n# Triggered for any changes to Terraform files\nif:\n- {{ files | match(regex=r/.*\\.tf.*/) | some }}\n# Assign infrastructure team as reviewer for change in Terraform files\nrun:\n- action: require-reviewers@v1\nargs:\nreviewers: [org/infrastructure]\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR affects Terraform configurations and requires a review from the Infra team.\n
Download this example as a CM file."},{"location":"automations/integrations/terraform/review-terraform-module-name/","title":"Review Terraform Module Name","text":"

Request changes if a PR creates a new Terraform module that is missing a required prefix or keyword in the name.

Configuration Description

Conditions (all must be true):

  • The PR creates a new Terraform module.
  • The module name lacks a required name prefix, or one or more keywords.

Automation Actions:

  • Request review changes on the PR with a comment explaining the structure of module name.

Review Terraform Module Name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n# Prefix Check Logic\n{% set prefixcheck = [] %}\n{% for pattern in terraform.prefixes %}\n{% if(newfilesinpr | match(term=module_location + pattern) | some) %}\n{% set prefixcheck = prefixcheck + [true]%}\n{% else %}\n{% set prefixcheck = prefixcheck + [false]  %}\n{% endif %}\n{% endfor %}\nautomations:\nreview_new_terraform_module:\nif: - {{is.mainfile and is.mainfilenotinroot}}\n- {{module_name_checks.prefix or module_name_checks.keyword}}\nrun:\n- action: request-changes@v1\nargs:\ncomment: |\nTerraform module names must contain a required prefix and keyword:\n* Prefixes: {{ terraform.prefixes }}\n* Keywords: {{ terraform.keywords }}\nmodule_name_checks:\nprefix: {{prefixcheck | match(term='true') | nope}}\nkeyword: {{newfilesinpr | match(list=terraform.keywords) | nope}}\nmodule_location: infrastructure/modules/\nterraform:\nprefixes: ['aws', 'gcp', 'azure']\nkeywords: ['db', 'networking', 'security']\nis:\nmainfile: {{newfilesinpr | match(term = \"main.tf\") | some}}\nmainfilenotinroot: {{source.diff.files | map(attr='original_file') | match(term = \"main.tf\") | nope }}\nnewfilesinpr:\n{{ branch.diff.files_metadata | map(attr='new_file')}}\n
Download this example as a CM file."},{"location":"automations/integrations/terraform/review-terraform-source-version/","title":"Review Terraform Source Version","text":"

Ensure that all Terraform modules imported via a source URL specify a version.

Configuration Description

Conditions (all must be true):

  • The PR contains a Terraform source declaration via URL that lacks a version reference.
  • The source is not included in a whitelist custom expression that defines one or more whitelisted source locations.

Automation Actions:

  • Request review changes on the PR with a comment explaining version number requirement.

Review Terraform Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_terraform_source_version:\n# Check if New Content contains a source URL, the URL is not part of allow list and lacks version reference\nif: - {{ source.diff.files | match(attr='new_content', regex=r/source.*?=.*\\\".*(http|https).*\\\"/) | some }}\n- {{ source.diff.files | match(attr='new_content', list=allowlist) | nope }}\n- {{ source.diff.files | match(attr='new_content', regex=r/source.*?=.*\\?ref=v.*/) | nope }}\nrun:\n- action: request-changes@v1\nargs:\ncomment: |\nYou must reference a specific version when accessing Terraform module sources via URL, e.g. `?ref=v1.0.0`. Please update your Terraform files to follow this practice.\nallowlist:\n- 'https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git'\n- 'https://github.com/terraform-aws-modules/terraform-aws-vpc.git'\n- 'https://github.com/terraform-aws-modules/terraform-aws-eks.git'\n
Download this example as a CM file."},{"location":"automations/integrations/unleash/label-ff-unleash/","title":"Label Unleash Feature Flags","text":"

Automatically label code that contians specified feature flags.

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in feature_flags %}\nlabel_ff_unleash_{{ item.name }}:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/const notificationBadgeEnabled = useFlag/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ item.name }}\ncolor: {{ colors.yellow }}\n{% endfor %}\nfeature_flags:\n- name: engineering_rollback_plan_activated regex: r/engineering_rollback_plan_activated/\n- name: marketing_premium_plan_features_unlocked regex: r/marketing_premium_plan_features_unlocked/\n- name: mobile_push_notifications_enabled\nregex: r/mobile_push_notifications_enabled/\ncolors:\nyellow: 'ffb300'   
Download this example as a CM file."},{"location":"automations/integrations/zapier/zapier-export-pr-description-title-url/","title":"Create Project Management Tasks Via Zapier","text":"

Export new PR titles, description, and URL to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends a webhook to Zapier that contains the PR title, description, and URL.

Create Project Management Tasks Via Zapier

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\npr_url: \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\non:\n- pr_created\nautomations:\nzapier_export_pr_description_title_url:\nif:\n- true\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ ZAPIER_WEBHOOK }}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{ \"pr_description\":\"{{ pr.description }}\", \"pr_title\":\"{{ pr.title }}\", \"pr_url\":\"{{ pr_url }}\" }'\n
Download this example as a CM file."},{"location":"automations/integrations/zapier/zapier-export-pr-description-title-url/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/zapier/zapier-export-pr-number/","title":"Export PR Data to Zapier","text":"

This is an example of how to send data from gitStream to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends a webhook to Zapier that contains the PR number

Export PR Number to Zapier

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nzapier_export_pr_number:\nif:\n- true\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ ZAPIER_WEBHOOK }}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{ \"pr_number\":\"{{ pr.number }}\" }'\n
Download this example as a CM file."},{"location":"automations/integrations/zapier/zapier-export-pr-number/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/zapier/zapier-export-pr-number-title-url/","title":"Export PR Number, Title, and URL to Zapier","text":"

Export new PR titles, numbers, and URLs to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends the PR number, title, and URL to Zapier via webhook.

Export PR Number, Title, and URL to Zapier

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\npr_url: \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\non:\n- pr_created\nautomations:\nzapier_export_pr_number_title_url:\nif:\n- true\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ ZAPIER_WEBHOOK }}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{ \"pr_number\":\"{{ pr.number }}\", \"pr_title\":\"{{ pr.title }}\", \"pr_url\":\"{{ pr_url }}\" }'\n
Download this example as a CM file."},{"location":"automations/integrations/zapier/zapier-export-pr-number-title-url/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/integrations/zapier/zapier-export-pr-reviewers/","title":"Auto-Schedule Sync Meetings via Zapier","text":"

Automatically update Zapier with a list of PR reviewers.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • gitStream sends the list of reviewers to Zapier via webooks.

Auto-Schedule Sync Meetings via Zapier

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\npr_url: \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\nautomations:\nzapier_export_pr_reviewers:\nif:\n- true\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ env.ZAPIER_WEBHOOK }}\"\nmethod: \"POST\"\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{ \"reviewers\": \"{{ pr.reviewers }}\" }'\n
Download this example as a CM file."},{"location":"automations/integrations/zapier/zapier-export-pr-reviewers/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/label-deleted-files/","title":"Label Deleted Files","text":"

Label PRs that delete files.

Configuration Description

Conditions (all must be true):

  • The PR deletes one or more files.

Automation Actions:

  • Apply a deleted-files label to the PR.

Label Deleted Files

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# Apply a label that indicates when a PR deletes files\n# This uses the `has` custom expression found at the bottom of this file\nlabel_deleted_files:\nif:\n- {{ has.deleted_files }}\nrun: - action: add-label@v1\nargs:\nlabel: 'deleted-files'\ncolor: '#DF9C04'\n# This is used in the `label_deleted_files` automation\nhas:\ndeleted_files: {{ source.diff.files | map(attr='new_file') | match(term='/dev/null') | some }}\n
Download this example as a CM file."},{"location":"automations/label-deleted-files/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/label-missing-jira-info/","title":"Index","text":"

This file has moved: /docs/automations/integrations/jira/label-missing-jira-info

"},{"location":"automations/label-missing-project-tracker/","title":"Flag Missing Project Tracking Info","text":"

Label PRs that lack a reference to a project tracker issue (Jira, Azure Boards, Shortcut and Asana) in the PR title or description.

Configuration Description

Conditions (all must be true):

  • The PR lacks a project tracker ticket number in the title, or a link to a project tracker resource in the PR description.

Automation Actions:

  • Apply Label : \u26a0\ufe0f Missing Project Tracker
  • Post a comment asking the author to reference the associated project tracker resource.

Label Missing Project Tracker

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_missing_project_tracker:\nif:\n- {{not (has[provider].ticket_in_title or has[provider].ticket_in_desc)}}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Project Tracker\"\ncolor: 'F6443B'\n- action: add-comment@v1\nargs:\ncomment: Please provide a link to the associated resource in your team's project tracker.\nhas:\njira:\nticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\nticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\\/browse\\/\\w{1,}-\\d{3,4}/) }}\nasana:\nticket_in_title: {{ pr.title | includes(regex=r/asana-(\\d+)/) }}\nticket_in_desc: {{ pr.description | includes(regex=r/app\\.asana.\\com\\/(\\d+)\\/(\\d+)\\/(\\d+)\\/(\\d+)\\/(\\d+)/) }}\nazure:\nticket_in_title: {{ pr.title | includes(regex=r/(\\w+)-(\\w+)-(\\d+)/) }}\nticket_in_desc: {{ pr.description | includes(regex=r/(dev\\.azure\\.com|(\\w+)\\.visualstudio\\.com)\\/(\\w+)\\/(\\w+)\\/_workitems\\/edit\\/(\\d+)/) }}\nshortcut:\nticket_in_title: {{ pr.title | includes(regex=r/(\\w+)\\/sc-(\\d+)/) }}\nticket_in_desc: {{ pr.description | includes(regex=r/(app\\.shortcut\\.com)\\/(\\w+)\\/story\\/(\\d+)\\/(\\w+)/) }}\nprovider: jira\n
Download this example as a CM file."},{"location":"automations/label-prs-without-tests/","title":"Label PRs Without Tests","text":"

Apply a missing-tests label to any PRs that don't update tests. gitStream will remove this label if the contributor adds a test change to the PR.

Configuration Description

Conditions (all must be true):

  • The PR has no changes to a test.

Automation Actions:

  • Apply a missing-tests label.

Label PRs Without Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_prs_without_tests:\nif:\n- {{ files | match(regex=r/[^a-zA-Z0-9](spec|test|tests)[^a-zA-Z0-9]/) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: 'missing-tests'\ncolor: '#E94637'\n
Download this example as a CM file."},{"location":"automations/label-prs-without-tests/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/languages/golang/","title":"Automation - Integrate gitStream with Golang","text":""},{"location":"automations/languages/golang/#approve-golang-log-output-changes","title":"Approve Golang Log Output Changes","text":"

Approve changes to Golang files that only affect lines of code that invoke the logger object.

Configuration Description

Conditions (all must be true):

  • All files end in .go
  • The changes only affect lines of code that invoke the log object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Golang Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_golang_log_output:\n# Triggered for Golang changes that only affect the console.log() method\nif: - {{ files | extensions | match(term='go') | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^.*log\\.Println/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file."},{"location":"automations/languages/golang/#review-missing-golang-tests","title":"Review Missing Golang Tests","text":"

Automatically request changes for Golang PRs that are missing tests.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Golang files
  • The PR lacks new test files that match the name of the Golang files

Automation Actions:

  • The PR lacks new test files that match the name of the Golang files
  • Apply a red missing-tests label

Review Missing Golang Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^(pkg|internal)\\/(?!.*\\_test\\.go$).*\\.go$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/.*\\_test\\.go$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^(pkg|internal)\\/(?!.*\\_test\\.go$).*\\.go$/) | filter(attr='original_file', regex=r/^$/) | length }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/.*\\_test\\.go$/) | filter(attr='original_file', regex=r/^$/) | length }}\nautomations:\nreview_missing_golang_tests:\nif:\n- {{ newFilesCount != newTestsCount }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Tests\"\ncolor: {{ colors.orange }}    - action: request-changes@v1\nargs:\ncomment: |\nSome of your new Golang files are missing corresponding tests. Please ensure that all new files have a corresponding test file.\n**New Files**: {{ newFilesCount }}\n{{ newFiles }}\n**New Tests**: {{ newTestsCount }}\n{{ newTests }}\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/golang/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"automations/languages/golang/approve-golang-log-output/","title":"Approve Golang Log Output Changes","text":"

Approve changes to Golang files that only affect lines of code that invoke the logger object.

Configuration Description

Conditions (all must be true):

  • All files end in .go
  • The changes only affect lines of code that invoke the log object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Golang Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_golang_log_output:\n# Triggered for Golang changes that only affect the console.log() method\nif: - {{ files | extensions | match(term='go') | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^.*log\\.Println/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file."},{"location":"automations/languages/golang/review-missing-golang-tests/","title":"Review Missing Golang Tests","text":"

Automatically request changes for Golang PRs that are missing tests.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Golang files
  • The PR lacks new test files that match the name of the Golang files

Automation Actions:

  • The PR lacks new test files that match the name of the Golang files
  • Apply a red missing-tests label

Review Missing Golang Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^(pkg|internal)\\/(?!.*\\_test\\.go$).*\\.go$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/.*\\_test\\.go$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^(pkg|internal)\\/(?!.*\\_test\\.go$).*\\.go$/) | filter(attr='original_file', regex=r/^$/) | length }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/.*\\_test\\.go$/) | filter(attr='original_file', regex=r/^$/) | length }}\nautomations:\nreview_missing_golang_tests:\nif:\n- {{ newFilesCount != newTestsCount }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Tests\"\ncolor: {{ colors.orange }}    - action: request-changes@v1\nargs:\ncomment: |\nSome of your new Golang files are missing corresponding tests. Please ensure that all new files have a corresponding test file.\n**New Files**: {{ newFilesCount }}\n{{ newFiles }}\n**New Tests**: {{ newTestsCount }}\n{{ newTests }}\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/html/","title":"Automation - Integrate gitStream with HTML and CSS","text":""},{"location":"automations/languages/html/#request-changes-for-css-important-tags","title":"Request Changes for CSS Important Tags","text":"

Flag the use of !important in CSS files and automatically request changes.

Configuration Description

Conditions (all must be true):

  • The PR contains changes to CSS files.
  • The changes include !important

Automation Actions:

  • Apply an orange label that says \u26a0\ufe0f Includes !important tag
  • Request changes an post a comment asking the PR author to remove the important tage.

Review Important Tags in CSS Files

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_css_important:\nif:\n- {{ files | extensions | match(term='css') | some }}\n- {{ source.diff.files | matchDiffLines(regex=r/!important/) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: '\u26a0\ufe0f Includes !important tag'\ncolor: '{{ colors.orange }}'\n- action: request-changes@v1\nargs:\ncomment: |\nPlease remove the `!important` tag from your CSS.\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/html/#flag-missing-html-tags","title":"Flag Missing HTML Tags","text":"

Request changes for HTML files that lack the canonical and robots tag.

Configuration Description

Conditions (all must be true):

  • The PR contains only new HTML files
  • One or more files are missing a canonical tag
  • One or more files are missing a robots meta tag

Automation Actions:

  • Apply a \u26a0\ufe0f Missing Required Tag label.
  • Post a comment asking the user to add required tags.

Flag Missing HTML Tags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nflag_missing_html_tags:\nif:\n- {{ is.html and is.new }}\n- {{ source.diff.files | matchDiffLines(regex=r/rel=\"canonical\"/) | nope }}\n- {{ source.diff.files | matchDiffLines(regex=r/meta name=\"robots\"/) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Required Tag\"\ncolor: {{ colors.yellow }}\n- action: request-changes@v1\nargs:\ncomment: | Please ensure new HTML files contain canonical and robots meta tags.\nis:\nhtml: {{ files | extensions | match(term='html') | every }}\nnew: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/languages/html/#flag-duplicate-h1","title":"Flag Duplicate H1","text":"

Automatically request changes when PRs contain HTML files that have more than one H1 heading.

Configuration Description

Conditions (all must be true):

  • The PR contains more than one H1 heading in an HTML file.

Automation Actions:

  • Post a comment requesting the author to reduce H1 headings to one per file.

Flag Duplicate H1

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nflag_duplicate_h1:\nif:\n- {{ duplicateH1 > 0 }}\nrun: - action: request-changes@v1\nargs:\ncomment: | This PR contains HTML files with multiple H1 tags. Please ensure that each HTML file has only one H1 tag.\nduplicateH1: {{ source.diff.files | filter(attr='new_content', regex=r/<h1>(.|\\n)*<h1>/) | length }}\n
Download this example as a CM file."},{"location":"automations/languages/html/#enforce-html-title-length-requirements","title":"Enforce HTML Title Length Requirements","text":"

Automatically request changes for <title> tags that don't comply with best practices.

Configuration Description

Conditions (all must be true):

  • The PR adds a <title> tag that is less than 30 or greater than 90 characters.

Automation Actions:

  • Request changes and post a comment asking the author to modify the title.

Enforce HTML Title Length Requirements

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nenforce_html_title_length:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/(<title>([\\w\\W]{1,29})<\\/title>)|(<title>([\\w\\W]{61,})<\\/title>)/) | some }}\nrun: - action: request-changes@v1\nargs:\ncomment: | Please ensure that all HTML titles are between 30 and 60 characters.\n
Download this example as a CM file."},{"location":"automations/languages/html/#enforce-image-alt-attributes","title":"Enforce Image Alt Attributes","text":"

Automatically request changes for PRs HTML files that are missing image alt attributes.

Configuration Description

Conditions (all must be true):

  • The PR adds an image tag to an HTML file.
  • The PR is missing alt attributes for one or more images.

Automation Actions:

  • Add a \u26a0\ufe0f Missing alt label label
  • Request changes and post a comment asking the author to add alt attributes to images.

Enforce Image Alt Attributes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nenforce_image_alt:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/<img src/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=r/<img src.*alt=/) | nope}}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing alt label\"\ncolor: {{ colors.yellow }}\n- action: request-changes@v1\nargs:\ncomment: | Please ensure that all images in HTML files have an alt attribute. For example: <img alt=\"Alt Message\">\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/languages/html/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"automations/languages/html/enforce-html-title-length/","title":"Enforce HTML Title Length Requirements","text":"

Automatically request changes for <title> tags that don't comply with best practices.

Configuration Description

Conditions (all must be true):

  • The PR adds a <title> tag that is less than 30 or greater than 90 characters.

Automation Actions:

  • Request changes and post a comment asking the author to modify the title.

Enforce HTML Title Length Requirements

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nenforce_html_title_length:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/(<title>([\\w\\W]{1,29})<\\/title>)|(<title>([\\w\\W]{61,})<\\/title>)/) | some }}\nrun: - action: request-changes@v1\nargs:\ncomment: | Please ensure that all HTML titles are between 30 and 60 characters.\n
Download this example as a CM file."},{"location":"automations/languages/html/enforce-image-alt/","title":"Enforce Image Alt Attributes","text":"

Automatically request changes for PRs HTML files that are missing image alt attributes.

Configuration Description

Conditions (all must be true):

  • The PR adds an image tag to an HTML file.
  • The PR is missing alt attributes for one or more images.

Automation Actions:

  • Add a \u26a0\ufe0f Missing alt label label
  • Request changes and post a comment asking the author to add alt attributes to images.

Enforce Image Alt Attributes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nenforce_image_alt:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/<img src/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=r/<img src.*alt=/) | nope}}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing alt label\"\ncolor: {{ colors.yellow }}\n- action: request-changes@v1\nargs:\ncomment: | Please ensure that all images in HTML files have an alt attribute. For example: <img alt=\"Alt Message\">\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/languages/html/flag-duplicate-h1/","title":"Flag Duplicate H1","text":"

Automatically request changes when PRs contain HTML files that have more than one H1 heading.

Configuration Description

Conditions (all must be true):

  • The PR contains more than one H1 heading in an HTML file.

Automation Actions:

  • Post a comment requesting the author to reduce H1 headings to one per file.

Flag Duplicate H1

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nflag_duplicate_h1:\nif:\n- {{ duplicateH1 > 0 }}\nrun: - action: request-changes@v1\nargs:\ncomment: | This PR contains HTML files with multiple H1 tags. Please ensure that each HTML file has only one H1 tag.\nduplicateH1: {{ source.diff.files | filter(attr='new_content', regex=r/<h1>(.|\\n)*<h1>/) | length }}\n
Download this example as a CM file."},{"location":"automations/languages/html/flag-missing-html-tags/","title":"Flag Missing HTML Tags","text":"

Request changes for HTML files that lack the canonical and robots tag.

Configuration Description

Conditions (all must be true):

  • The PR contains only new HTML files
  • One or more files are missing a canonical tag
  • One or more files are missing a robots meta tag

Automation Actions:

  • Apply a \u26a0\ufe0f Missing Required Tag label.
  • Post a comment asking the user to add required tags.

Flag Missing HTML Tags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nflag_missing_html_tags:\nif:\n- {{ is.html and is.new }}\n- {{ source.diff.files | matchDiffLines(regex=r/rel=\"canonical\"/) | nope }}\n- {{ source.diff.files | matchDiffLines(regex=r/meta name=\"robots\"/) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Required Tag\"\ncolor: {{ colors.yellow }}\n- action: request-changes@v1\nargs:\ncomment: | Please ensure new HTML files contain canonical and robots meta tags.\nis:\nhtml: {{ files | extensions | match(term='html') | every }}\nnew: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/languages/html/review-css-important/","title":"Review Important Tags in CSS Files","text":"

Flag the use of !important in CSS files and automatically request changes.

Configuration Description

Conditions (all must be true):

  • The PR contains changes to CSS files.
  • The changes include !important

Automation Actions:

  • Apply an orange label that says \u26a0\ufe0f Includes !important tag
  • Request changes an post a comment asking the PR author to remove the important tage.

Review Important Tags in CSS Files

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_css_important:\nif:\n- {{ files | extensions | match(term='css') | some }}\n- {{ source.diff.files | matchDiffLines(regex=r/!important/) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: '\u26a0\ufe0f Includes !important tag'\ncolor: '{{ colors.orange }}'\n- action: request-changes@v1\nargs:\ncomment: |\nPlease remove the `!important` tag from your CSS.\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/java/","title":"Automation - Integrate gitStream with Java","text":""},{"location":"automations/languages/java/#approve-java-log-output-changes","title":"Approve Java Log Output Changes","text":"

Approve changes to Java files that only affect lines of code that invoke the logger object.

Configuration Description

Conditions (all must be true):

  • All files end in .java
  • The changes only affect lines of code that invoke logger object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Java Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_java_log_output:\n# Triggered for Java changes that only affect the logger method\nif: - {{ files | extensions | match(term='java') | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^.*logger\\.(trace|fatal|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file."},{"location":"automations/languages/java/#review-missing-java-tests","title":"Review Missing Java Tests","text":"

Automatically request changes for Java PRs that lack test files.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Java files
  • The PR lacks new test files that match the name of the Java files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Java Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!.*Test\\.java$).*\\.java$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/src\\/.*Test\\.java$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!.*Test\\.java$).*\\.java$/) | filter(attr='original_file', regex=r/^$/) | length }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/src\\/.*Test\\.java$/) | filter(attr='original_file', regex=r/^$/) | length }}\nautomations:\nreview_missing_java_tests:\nif:\n- {{ newFilesCount != newTestsCount }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Tests\"\ncolor: {{ colors.orange }}    - action: request-changes@v1\nargs:\ncomment: |\nSome of your new Java files are missing corresponding tests. Please ensure that all new files have a corresponding test file.\n**New Files**: {{ newFilesCount }}\n{{ newFiles }}\n**New Tests**: {{ newTestsCount }}\n{{ newTests }}\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/java/#review-java-test-names","title":"Review Java Test Names","text":"

Automatically request changes for Java test files that fail to match the required naming convention.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Java test files
  • The Java test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Java test name requirements.

Review Java Test Name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0  newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/test\\/) }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/test\\/) | length }}\nautomations:\nreview_java_test_name:\nif:\n- {{ newTestsCount > 0}}     - {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/test\\/) | match(attr='new_file', regex=r/Test.java$/) | nope }}\nrun: - action: request-changes@v1\nargs:\ncomment: |\nThe test file name does not follow the Java test name conventions. A test file name needs to have the word Test at the end of class name. For example, if you are testing a class called Data then the test file name has to be DataTest.java.\n
Download this example as a CM file."},{"location":"automations/languages/java/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"automations/languages/java/approve-java-log-output/","title":"Approve Java Log Output Changes","text":"

Approve changes to Java files that only affect lines of code that invoke the logger object.

Configuration Description

Conditions (all must be true):

  • All files end in .java
  • The changes only affect lines of code that invoke logger object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Java Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_java_log_output:\n# Triggered for Java changes that only affect the logger method\nif: - {{ files | extensions | match(term='java') | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^.*logger\\.(trace|fatal|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file."},{"location":"automations/languages/java/review-java-test-name/","title":"Review Java Test Name","text":"

Automatically request changes for Java test files that fail to match the required naming convention.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Java test files
  • The Java test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Java test name requirements.

Review Java Test Name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0  newTests: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/test\\/) }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/test\\/) | length }}\nautomations:\nreview_java_test_name:\nif:\n- {{ newTestsCount > 0}}     - {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/test\\/) | match(attr='new_file', regex=r/Test.java$/) | nope }}\nrun: - action: request-changes@v1\nargs:\ncomment: |\nThe test file name does not follow the Java test name conventions. A test file name needs to have the word Test at the end of class name. For example, if you are testing a class called Data then the test file name has to be DataTest.java.\n
Download this example as a CM file."},{"location":"automations/languages/java/review-missing-java-tests/","title":"Review Missing Java Tests","text":"

Automatically request changes for Java PRs that lack test files.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Java files
  • The PR lacks new test files that match the name of the Java files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Java Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!.*Test\\.java$).*\\.java$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/src\\/.*Test\\.java$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!.*Test\\.java$).*\\.java$/) | filter(attr='original_file', regex=r/^$/) | length }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/src\\/.*Test\\.java$/) | filter(attr='original_file', regex=r/^$/) | length }}\nautomations:\nreview_missing_java_tests:\nif:\n- {{ newFilesCount != newTestsCount }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Tests\"\ncolor: {{ colors.orange }}    - action: request-changes@v1\nargs:\ncomment: |\nSome of your new Java files are missing corresponding tests. Please ensure that all new files have a corresponding test file.\n**New Files**: {{ newFilesCount }}\n{{ newFiles }}\n**New Tests**: {{ newTestsCount }}\n{{ newTests }}\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/javascript/","title":"Automation - Integrate gitStream with JavaScript","text":""},{"location":"automations/languages/javascript/#auto-approve-javascript-log-output-changes","title":"Auto-Approve JavaScript Log Output Changes","text":"

Approve changes to JavaScript files that only affect lines of code that invoke the console.log() method.

Configuration Description

Conditions (all must be true):

  • All files must end in .js or .ts
  • The changes only affect lines of code that invoke console.log()

Automation Actions:

  • Applies a log-output-only label
  • Approves the PR
  • Posts a comment explaining that the change only affects logging output.

Approve JavaScript Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_javascript_log_output:\n# Triggered for JavaScript changes that only affect the console.log() method\nif: - {{ files | match(regex=r/\\.js$|\\.ts$/) | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^[+-].*console\\.log/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file.

"},{"location":"automations/languages/javascript/#auto-approve-javascript-formatting-change","title":"Auto-Approve JavaScript Formatting Change","text":"

Approve PRs that only contain formatting changes to JavaScript or TypeScript files.

Configuration Description

Conditions (all must be true):

  • All of the files end in .js or .ts
  • All changes are non-functional

Automation Actions:

  • Approve the PR
  • Apply a code-formatting label.
  • Post a comment that explains the automation.

Approve JavaScript Formatting Change

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_javascript_formatting:\nif:\n- {{ files | extensions | match(list=['js', 'ts']) | every }}\n- {{ source.diff.files | isFormattingChange }}\nrun:\n- action: approve@v1\n- action: add-label@v1\nargs:\nlabel: code-formatting\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR only contains formatting changes and has been approved.\n
Download this example as a CM file.

"},{"location":"automations/languages/javascript/#review-missing-javascript-tests","title":"Review Missing JavaScript Tests","text":"

Request changes for JavaScript PRs that lack test files.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new JavaScript files
  • The PR lacks new test files that match the name of the JavaScript files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing JavaScript Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!.*\\.test\\.js$).*\\.js$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/src\\/.*\\.test\\.js$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!.*\\.test\\.js$).*\\.js$/) | filter(attr='original_file', regex=r/^$/) | length }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/src\\/.*\\.test\\.js$/) | filter(attr='original_file', regex=r/^$/) | length }}\nautomations:\nreview_missing_javascript_tests:\nif:\n- {{ newFilesCount != newTestsCount }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Tests\"\ncolor: {{ colors.orange }}    - action: request-changes@v1\nargs:\ncomment: |\nSome of your new JavaScript files are missing corresponding tests. Please ensure that all new files have a corresponding test file.\n**New Files**: {{ newFilesCount }}\n{{ newFiles }}\n**New Tests**: {{ newTestsCount }}\n{{ newTests }}\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/javascript/#review-javascript-test-name","title":"Review JavaScript Test Name","text":"

Automatically request changes for JavaScript test files that fail to match the required naming convention.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new JavaScript test files
  • The JavaScript test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the JavaScript test name requirements.

Review JavaScript Test Name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/^test/) }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^test/) | length }}\nautomations:\nreview_javascript_test_name:\nif:\n- {{ newTestsCount > 0}}     - {{ source.diff.files | filter(attr='new_file', regex=r/^test/) | match(attr='new_file', regex=r/.test.js$/) | nope }}\nrun: - action: request-changes@v1\nargs:\ncomment: |\nThe test file name does not follow the JavaScript test name conventions. A test file name needs to have the suffix .test after class name. For example, if you are testing a class file called Data.js then the test file name has to be data.test.js.\n
Download this example as a CM file."},{"location":"automations/languages/javascript/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/languages/javascript/approve-javascript-formatting-change/","title":"Approve JavaScript Formatting Changes","text":"

Approve PRs that only contain formatting changes to JavaScript or TypeScript files.

Configuration Description

Conditions (all must be true):

  • All of the files end in .js or .ts
  • All changes are non-functional

Automation Actions:

  • Approve the PR
  • Apply a code-formatting label.
  • Post a comment that explains the automation.

Approve JavaScript Formatting Change

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_javascript_formatting:\nif:\n- {{ files | extensions | match(list=['js', 'ts']) | every }}\n- {{ source.diff.files | isFormattingChange }}\nrun:\n- action: approve@v1\n- action: add-label@v1\nargs:\nlabel: code-formatting\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR only contains formatting changes and has been approved.\n
Download this example as a CM file.

"},{"location":"automations/languages/javascript/approve-javascript-log-output/","title":"Approve JavaScript Log Output Changes","text":"

Approve changes to JavaScript files that only affect lines of code that invoke the console.log() method.

Configuration Description

Conditions (all must be true):

  • All files must end in .js or .ts
  • The changes only affect lines of code that invoke console.log()

Automation Actions:

  • Applies a log-output-only label
  • Approves the PR
  • Posts a comment explaining that the change only affects logging output.

Approve JavaScript Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_javascript_log_output:\n# Triggered for JavaScript changes that only affect the console.log() method\nif: - {{ files | match(regex=r/\\.js$|\\.ts$/) | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^[+-].*console\\.log/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file.

"},{"location":"automations/languages/javascript/review-javascript-test-name/","title":"Review JavaScript Test Name","text":"

Automatically request changes for JavaScript test files that fail to match the required naming convention.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new JavaScript test files
  • The JavaScript test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the JavaScript test name requirements.

Review JavaScript Test Name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/^test/) }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^test/) | length }}\nautomations:\nreview_javascript_test_name:\nif:\n- {{ newTestsCount > 0}}     - {{ source.diff.files | filter(attr='new_file', regex=r/^test/) | match(attr='new_file', regex=r/.test.js$/) | nope }}\nrun: - action: request-changes@v1\nargs:\ncomment: |\nThe test file name does not follow the JavaScript test name conventions. A test file name needs to have the suffix .test after class name. For example, if you are testing a class file called Data.js then the test file name has to be data.test.js.\n
Download this example as a CM file."},{"location":"automations/languages/javascript/review-missing-javascript-tests/","title":"Review Missing JavaScript Tests","text":"

Request changes for JavaScript PRs that lack test files.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new JavaScript files
  • The PR lacks new test files that match the name of the JavaScript files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing JavaScript Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!.*\\.test\\.js$).*\\.js$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/src\\/.*\\.test\\.js$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!.*\\.test\\.js$).*\\.js$/) | filter(attr='original_file', regex=r/^$/) | length }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/src\\/.*\\.test\\.js$/) | filter(attr='original_file', regex=r/^$/) | length }}\nautomations:\nreview_missing_javascript_tests:\nif:\n- {{ newFilesCount != newTestsCount }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Tests\"\ncolor: {{ colors.orange }}    - action: request-changes@v1\nargs:\ncomment: |\nSome of your new JavaScript files are missing corresponding tests. Please ensure that all new files have a corresponding test file.\n**New Files**: {{ newFilesCount }}\n{{ newFiles }}\n**New Tests**: {{ newTestsCount }}\n{{ newTests }}\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/python/","title":"Automation - Integrate gitStream with Python","text":""},{"location":"automations/languages/python/#auto-approve-python-log-output-changes","title":"Auto-Approve Python Log Output Changes","text":"

Approve changes to Python files that only affect lines of code that invoke a specified logging object.

Configuration Description

Conditions (all must be true):

  • All files must end in .py
  • The changes only affect lines of code that invoke a logger object. This should be customized to your environment.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Python Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_python_log_output:\n# Triggered for python changes that only affect lines of code that invoke a logger object. \n# Modify 'logger' to match your dev environment.\nif: - {{ files | match(regex=r/\\.py$/) | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^[+-].*logger\\.(trace|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file.

"},{"location":"automations/languages/python/#auto-approve-python-formatting-changes","title":"Auto-Approve Python Formatting Changes","text":"

Approve PRs that only contain formatting changes to Python files.

Configuration Description

Conditions (all must be true):

  • All of the files end in .py.
  • All changes are non-functional

Automation Actions:

  • Approve the PR
  • Apply a code-formatting label.
  • Post a comment that explains the automation.

Approve Python Formatting Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_python_formatting:\nif:\n- {{ files | extensions | match(list=['py']) | every }}\n- {{ source.diff.files | isFormattingChange }}\nrun:\n- action: approve@v1\n- action: add-label@v1\nargs:\nlabel: code-formatting\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR only contains formatting changes and has been approved.\n
Download this example as a CM file.

"},{"location":"automations/languages/python/#review-missing-python-tests","title":"Review Missing Python Tests","text":"

Automatically request changes for Python PRs that lack test files.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Python files
  • The PR lacks new test files that match the name of the Python files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Python Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!test_.*\\.py$).*\\.py$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/^tests\\/test_.*\\.py$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!test_.*\\.py$).*\\.py$/) | filter(attr='original_file', regex=r/^$/) | length }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^tests\\/test_.*\\.py$/) | filter(attr='original_file', regex=r/^$/) | length }}\nautomations:\nreview_missing_python_tests:\nif:\n- {{ newFilesCount != newTestsCount }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Tests\"\ncolor: {{ colors.orange }}    - action: request-changes@v1\nargs:\ncomment: |\nSome of your new Python files are missing corresponding tests. Please ensure that all new files have a corresponding test file.\n**New Files**: {{ newFilesCount }}\n{{ newFiles }}\n**New Tests**: {{ newTestsCount }}\n{{ newTests }}\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/python/#review-python-test-name","title":"Review Python Test Name","text":"

Automatically request changes for Python test files that fail to match the required naming convention.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Python test files
  • The Python test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Python test name requirements.

Review Python Test Name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) | length }}\nautomations:\nreview_python_test_name:\nif:\n- {{ newTestsCount > 0}}     - {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) | match(attr='new_file', regex=r/test_.*\\.py$/) | nope }}   run: - action: request-changes@v1\nargs:\ncomment: |\nThe test file name does not follow the Python test name conventions. A test file name needs to have the prefix test_ before class name. For example, if you are testing a class file called Data.py then the test file name has to be test_data.py.\n
Download this example as a CM file."},{"location":"automations/languages/python/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/languages/python/approve-python-formatting-change/","title":"Approve Python Formatting Changes","text":"

Approve PRs that only contain formatting changes to Python files.

Configuration Description

Conditions (all must be true):

  • All of the files end in .py.
  • All changes are non-functional

Automation Actions:

  • Approve the PR
  • Apply a code-formatting label.
  • Post a comment that explains the automation.

Approve Python Formatting Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_python_formatting:\nif:\n- {{ files | extensions | match(list=['py']) | every }}\n- {{ source.diff.files | isFormattingChange }}\nrun:\n- action: approve@v1\n- action: add-label@v1\nargs:\nlabel: code-formatting\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR only contains formatting changes and has been approved.\n
Download this example as a CM file.

"},{"location":"automations/languages/python/approve-python-log-output/","title":"Approve Python Log Output Changes","text":"

Approve changes to Python files that only affect lines of code that invoke a specified logging object.

Configuration Description

Conditions (all must be true):

  • All files must end in .py
  • The changes only affect lines of code that invoke a logger object. This should be customized to your environment.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Python Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_python_log_output:\n# Triggered for python changes that only affect lines of code that invoke a logger object. \n# Modify 'logger' to match your dev environment.\nif: - {{ files | match(regex=r/\\.py$/) | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^[+-].*logger\\.(trace|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file.

"},{"location":"automations/languages/python/review-missing-python-tests/","title":"Review Missing Python Tests","text":"

Automatically request changes for Python PRs that lack test files.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Python files
  • The PR lacks new test files that match the name of the Python files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Python Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!test_.*\\.py$).*\\.py$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/^tests\\/test_.*\\.py$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^src\\/(?!test_.*\\.py$).*\\.py$/) | filter(attr='original_file', regex=r/^$/) | length }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^tests\\/test_.*\\.py$/) | filter(attr='original_file', regex=r/^$/) | length }}\nautomations:\nreview_missing_python_tests:\nif:\n- {{ newFilesCount != newTestsCount }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Tests\"\ncolor: {{ colors.orange }}    - action: request-changes@v1\nargs:\ncomment: |\nSome of your new Python files are missing corresponding tests. Please ensure that all new files have a corresponding test file.\n**New Files**: {{ newFilesCount }}\n{{ newFiles }}\n**New Tests**: {{ newTestsCount }}\n{{ newTests }}\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/python/review-python-test-name/","title":"Review Python Test Name","text":"

Automatically request changes for Python test files that fail to match the required naming convention.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Python test files
  • The Python test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Python test name requirements.

Review Python Test Name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) | length }}\nautomations:\nreview_python_test_name:\nif:\n- {{ newTestsCount > 0}}     - {{ source.diff.files | filter(attr='new_file', regex=r/^tests/) | match(attr='new_file', regex=r/test_.*\\.py$/) | nope }}   run: - action: request-changes@v1\nargs:\ncomment: |\nThe test file name does not follow the Python test name conventions. A test file name needs to have the prefix test_ before class name. For example, if you are testing a class file called Data.py then the test file name has to be test_data.py.\n
Download this example as a CM file."},{"location":"automations/languages/ruby/","title":"Automation - Integrate gitStream with Ruby","text":""},{"location":"automations/languages/ruby/#approve-ruby-log-output-changes","title":"Approve Ruby Log Output Changes","text":"

Approve changes to Ruby files that only affect lines of code that invoke the logger object.

Configuration Description

Conditions (all must be true):

  • All files end in .rb
  • The changes only affect lines of code that invoke logger object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Ruby Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_ruby_log_output:\n# Triggered for Ruby changes that only affect the logger method\nif: - {{ files | extensions | match(term='rb') | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^.*logger\\.(fatal|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file."},{"location":"automations/languages/ruby/#review-missing-ruby-tests","title":"Review Missing Ruby Tests","text":"

Automatically request changes for Ruby PRs that lack test files.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Ruby files
  • The PR lacks new test files that match the name of the Ruby files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Ruby Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^app\\/(?!.*\\_spec\\.rb$).*\\.rb$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/spec\\/.*\\_spec\\.rb$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^app\\/(?!.*\\_spec\\.rb$).*\\.rb$/) | filter(attr='original_file', regex=r/^$/) | length }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/spec\\/.*\\_spec\\.rb$/) | filter(attr='original_file', regex=r/^$/) | length }}\nautomations:\nreview_missing_ruby_tests:\nif:\n- {{ newFilesCount != newTestsCount }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Tests\"\ncolor: {{ colors.orange }}    - action: request-changes@v1\nargs:\ncomment: |\nSome of your new Ruby files are missing corresponding tests. Please ensure that all new files have a corresponding test file.\n**New Files**: {{ newFilesCount }}\n{{ newFiles }}\n**New Tests**: {{ newTestsCount }}\n{{ newTests }}\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/ruby/#review-ruby-test-name","title":"Review Ruby Test Name","text":"

Automatically request changes for Ruby test files that fail to match the required naming convention.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Ruby test files
  • The Ruby test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Ruby test name requirements.

Review Ruby Test Name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) | length }}\nautomations:\nreview_ruby_test_name:\nif:\n- {{ newTestsCount > 0}}     - {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) | match(attr='new_file', regex=r/_spec.rb$/) | nope }}\nrun: - action: request-changes@v1\nargs:\ncomment: |\nThe test file name does not follow the Ruby test name conventions. A test file name needs to have the suffix _spec after class name. For example, if you are testing a class file called data.rb then the test file name has to be data_spec.rb.\n
Download this example as a CM file."},{"location":"automations/languages/ruby/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"automations/languages/ruby/approve-ruby-log-output/","title":"Approve Ruby Log Output Changes","text":"

Approve changes to Ruby files that only affect lines of code that invoke the logger object.

Configuration Description

Conditions (all must be true):

  • All files end in .rb
  • The changes only affect lines of code that invoke logger object.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Ruby Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_ruby_log_output:\n# Triggered for Ruby changes that only affect the logger method\nif: - {{ files | extensions | match(term='rb') | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^.*logger\\.(fatal|debug|info|warn|error)/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file."},{"location":"automations/languages/ruby/review-missing-ruby-tests/","title":"Review Missing Ruby Tests","text":"

Automatically request changes for Ruby PRs that lack test files.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Ruby files
  • The PR lacks new test files that match the name of the Ruby files

Automation Actions:

  • Apply a red missing-tests label
  • Request changes and post a comment listing the files that need tests.

Review Missing Ruby Tests

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewFiles: {{ source.diff.files | filter(attr='new_file', regex=r/^app\\/(?!.*\\_spec\\.rb$).*\\.rb$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/spec\\/.*\\_spec\\.rb$/) | filter(attr='original_file', regex=r/^$/) | map(attr='new_file') }}\nnewFilesCount: {{ source.diff.files | filter(attr='new_file', regex=r/^app\\/(?!.*\\_spec\\.rb$).*\\.rb$/) | filter(attr='original_file', regex=r/^$/) | length }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/spec\\/.*\\_spec\\.rb$/) | filter(attr='original_file', regex=r/^$/) | length }}\nautomations:\nreview_missing_ruby_tests:\nif:\n- {{ newFilesCount != newTestsCount }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Tests\"\ncolor: {{ colors.orange }}    - action: request-changes@v1\nargs:\ncomment: |\nSome of your new Ruby files are missing corresponding tests. Please ensure that all new files have a corresponding test file.\n**New Files**: {{ newFilesCount }}\n{{ newFiles }}\n**New Tests**: {{ newTestsCount }}\n{{ newTests }}\ncolors:\norange: 'd93f0b'\n
Download this example as a CM file."},{"location":"automations/languages/ruby/review-ruby-test-name/","title":"Review Ruby Test Name","text":"

Automatically request changes for Ruby test files that fail to match the required naming convention.

Configuration Description

Conditions (all must be true):

  • The PR creates one or more new Ruby test files
  • The Ruby test fails to match the required naming convention.

Automation Actions:

  • Request changes and post a comment that explains the Ruby test name requirements.

Review Ruby Test Name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nnewTests: {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) }}\nnewTestsCount: {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) | length }}\nautomations:\nreview_ruby_test_name:\nif:\n- {{ newTestsCount > 0}}     - {{ source.diff.files | filter(attr='new_file', regex=r/^spec/) | match(attr='new_file', regex=r/_spec.rb$/) | nope }}\nrun: - action: request-changes@v1\nargs:\ncomment: |\nThe test file name does not follow the Ruby test name conventions. A test file name needs to have the suffix _spec after class name. For example, if you are testing a class file called data.rb then the test file name has to be data_spec.rb.\n
Download this example as a CM file."},{"location":"automations/languages/rust/","title":"Automation - Integrate gitStream with Rust","text":""},{"location":"automations/languages/rust/#approve-rust-log-output-changes","title":"Approve Rust Log Output Changes","text":"

Approve changes to Rust files that only affect lines of code that invoke the logging marcos.

Configuration Description

Conditions (all must be true):

  • All files end in .rs
  • The changes only affect lines of code that invoke print, println or dbg macros or use the log crate macros.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Rust Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_rust_log_output:\n# Triggered for Rust changes that only affect the logging macros\nif: - {{ files | extensions | match(term='rs') | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^.*\\b(println|print|dbg|error|warn|info|debug|trace)\\b!/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file."},{"location":"automations/languages/rust/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/languages/rust/approve-rust-log-output/","title":"Approve Rust Log Output Changes","text":"

Approve changes to Rust files that only affect lines of code that invoke the logging marcos.

Configuration Description

Conditions (all must be true):

  • All files end in .rs
  • The changes only affect lines of code that invoke print, println or dbg macros or use the log crate macros.

Automation Actions:

  • Apply a log-output-only label
  • Approve the PR
  • Post a comment explaining that the change only affects logging output.

Approve Rust Log Output Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_rust_log_output:\n# Triggered for Rust changes that only affect the logging macros\nif: - {{ files | extensions | match(term='rs') | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/^.*\\b(println|print|dbg|error|warn|info|debug|trace)\\b!/, ignoreWhiteSpaces=true) | every }}\nrun: - action: add-label@v1\nargs:\nlabel: 'log-output-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR has been approved because it only contains changes to log output\n
Download this example as a CM file."},{"location":"automations/percent-new-code/","title":"Calculate the Percentage of New Code","text":"

Post a comment that indicates what percentage of the PR contains new code.

Configuration Description

Conditions (all must be true):

  • Any PR

Automation Actions:

  • Use the changes custom expression to post a comment that indicates what percentage of the PR is new code.

Calculate the Percentage of New Code

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\npercent_new_code:\nif:\n- true\nrun: - action: add-comment@v1\nargs:\ncomment: |\nThis PR is {{ changes.ratio }}% new code.\nchanges:\n# Sum all the lines added/edited in the PR\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\n# Sum all the line removed in the PR\ndeletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}\n# Calculate the ratio of new code\nratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}\n
Download this example as a CM file."},{"location":"automations/percent-new-code/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/provide-estimated-time-to-review/","title":"Provide Estimated Time to Review","text":"

Label all PRs with an estimated number of minutes it would take someone to review. gitStream will automatically update this label whenever a PR changes.

Configuration Description

Conditions (all must be true):

  • Any new PR or change to an existing PR.

Automation Actions:

  • Apply a color coded label that provides an estimated number of minutes someone will need to review the PR.

Provide Estimated Time to Review

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nestimated_time_to_review:\nif:\n- true\nrun:\n- action: add-label@v1\nargs:\nlabel: \"{{ calc.etr }} min review\"\ncolor: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}\ncalc:\netr: {{ branch | estimatedReviewTime }}\ncolors:\nred: 'b60205'\nyellow: 'fbca04'\ngreen: '0e8a16'\n
Download this example as a CM file."},{"location":"automations/provide-estimated-time-to-review/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/request-screenshot/","title":"Request Screenshot","text":"

If the PR lacks an image file, or link to an image in the description, apply a no-screenshot label and post a comment to request a screenshot. If the PR author updates the description, gitStream will remove the label.

Configuration Description

Conditions (all must be true):

  • The PR description lacks an image or link to an image.

Automation Actions:

  • Apply a no-screenshot label.
  • Post a comment that requests a screenshot. Update this action to provide specific context for your project.

Request Screenshot

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations: request_screenshot:\n# Triggered for PRs that lack an image file or link to an image in the PR description\nif:\n- {{ not (has.screenshot_link or has.image_uploaded) }}\nrun:\n- action: add-label@v1\nargs:\nlabel: 'no-screenshot'\ncolor: '#FF000A'\n- action: add-comment@v1\nargs:\ncomment: |\nBe a life saver \ud83d\udedf by adding a screenshot of the changes you made.\nhas:\nscreenshot_link: {{ pr.description | includes(regex=r/!\\[.*\\]\\(.*(jpg|svg|png|gif|psd).*\\)/) }}\nimage_uploaded: {{ pr.description | includes(regex=r/<img.*src.*(jpg|svg|png|gif|psd).*>/) }}\n
Download this example as a CM file."},{"location":"automations/request-screenshot/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/branch-management/","title":"Manage git Branches With gitStream","text":"

Use gitStream to enforce branch naming conventions, review assignment, and other branch managment workflows.

Enforce Branch Naming Conventions - Automatically enforce prefixes or keywords in PR branch names.

Assign Reviewers Based on Target Branch - Automatically assign PR reviewers for target branches that include a specified keyword.

"},{"location":"automations/standard/branch-management/#enforce-branch-naming-conventions","title":"Enforce Branch Naming Conventions","text":""},{"location":"automations/standard/branch-management/#enforce-branch-naming-conventions_1","title":"Enforce Branch Naming Conventions","text":"

Automatically enforce prefixes or keywords in PR branch names.

Configuration Description

Conditions (all must be true):

  • The incoming branch name is missing a required prefix feature fix or stable
  • The invoming branch name fails to match a specified regex pattern. In this case abc- followed by a number.
  • The incoming branch name is not listed in an ignoreList custom expression.

Automation Actions:

  • Post a comment explaining the branch name requirements.
  • Apply a red label: \u2757 Incorrect Branch Name
  • Close the PR.

Enforce Branch Naming Conventions

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nenforce_branch_name: if:  - {{ not has.requiredBranchPrefix }}\n- {{ not has.requiredBranchKeyword }}\n- {{ not ignoreList }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u2757 Incorrect Branch Name\"\ncolor: {{ colors.red }}\n- action: add-comment@v1\nargs:\ncomment: |\nAll PR branch names must be prefixed by feature, stable, or fix, and must contain a reference to a Jira ticket. E.g. 'feature-abc-1234'\nPlease move your changes to a new branch that meets these requirements and open a new PR.\n- action: close@v1\nhas:\nrequiredBranchPrefix: {{ branch.name | includes(regex=r/^(feature|stable|fix)/) }}\nrequiredBranchKeyword: {{ branch.name | includes(regex=r/abc+-\\d+/) }}\nignoreList: {{ branch.name | match(regex=r/^(development|staging)/) }}\n
Download this example as a CM file.

"},{"location":"automations/standard/branch-management/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Assign additional reviewers for large PRs
  • Assign or suggest reviewers based on level of code expertise for the code changed in a PR.
  • Assign reviewers based on modified directories and files
  • Assign reviewers to share knowledge based on pre-determined criteria

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/branch-management/enforce-branch-name/","title":"Enforce Branch Naming Conventions","text":"

Automatically enforce prefixes or keywords in PR branch names.

Configuration Description

Conditions (all must be true):

  • The incoming branch name is missing a required prefix feature fix or stable
  • The invoming branch name fails to match a specified regex pattern. In this case abc- followed by a number.
  • The incoming branch name is not listed in an ignoreList custom expression.

Automation Actions:

  • Post a comment explaining the branch name requirements.
  • Apply a red label: \u2757 Incorrect Branch Name
  • Close the PR.

Enforce Branch Naming Conventions

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nenforce_branch_name: if:  - {{ not has.requiredBranchPrefix }}\n- {{ not has.requiredBranchKeyword }}\n- {{ not ignoreList }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u2757 Incorrect Branch Name\"\ncolor: {{ colors.red }}\n- action: add-comment@v1\nargs:\ncomment: |\nAll PR branch names must be prefixed by feature, stable, or fix, and must contain a reference to a Jira ticket. E.g. 'feature-abc-1234'\nPlease move your changes to a new branch that meets these requirements and open a new PR.\n- action: close@v1\nhas:\nrequiredBranchPrefix: {{ branch.name | includes(regex=r/^(feature|stable|fix)/) }}\nrequiredBranchKeyword: {{ branch.name | includes(regex=r/abc+-\\d+/) }}\nignoreList: {{ branch.name | match(regex=r/^(development|staging)/) }}\n
Download this example as a CM file.

"},{"location":"automations/standard/enforce-copyright-header/","title":"Enforce Copyright Headers","text":"

Automatically require copyright headers for all new source code files.

Configuration Description

Conditions (all must be true):

  • The PR creates a new file inside the /src directory that lacks a specified copyright header at the top of the file.

Automation Actions:

  • Request changes and post a comment that explains the copyright header requirement.

Enforce Copyright Headers

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nenforce_copyright_header: if:   - {{ source.diff.files | filter(attr='new_file', regex=r/src\\//) | map(attr='original_file') | match(regex=r/^$/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=licence.licenceRegex) | nope }}\nrun:\n- action: add-comment@v1\nargs: comment: | All new files in the '/src' directory must include the required copyright header at the top of the file. For example:\n// Copyright (c) ORG  and contributors. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for details.\nlicence:\nlicenceRegex: r/(Copyright \\(c\\) )|(Licensed under the MIT license)/\n
Download this example as a CM file.

"},{"location":"automations/standard/enforce-copyright-header/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Require changelog updates for PRs to specific branches
  • Flag the use of deprecated APIs, functions, or other components.
  • Restrict portions of your code base to authorized teams only.
  • Require changes when PRs include !important tags in CSS files

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/enforce-pr-title/","title":"Enforce PR Semantic Title Names","text":"

Automatically enforce PR naming conventions; this example expects the format: <type>(<scope>): <short summary>

Configuration Description

Conditions (all must be true):

  • The PR fails to follow a predefined semantic release format:

Automation Actions:

  • Request changes and post a comment explaining why.

Enforce PR Semantic Title Names

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nenforce_pr_title: if:       - {{ pr.title | match(regex=titlePolicy.titleRegex) | nope }}\nrun:\n- action: request-changes@v1\nargs: comment: | All PRs must be titled according to our semantic naming policy: `<type>(<scope>): <short summary>`\nType must be one of the following:\n* build\n* ci \n* docs\n* feature\n* fix\nScope must be one of the following:\n* common\n* core\n* elements\n* forms\n* http \ntitlePolicy:\ntitleRegex: r/\\b(build|ci|docs|feature|fix)\\b\\s*\\((common|core|elements|forms|http)\\):\\s*\\w+.*/\n
Download this example as a CM file."},{"location":"automations/standard/enforce-pr-title/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Require changelog updates for PRs to specific branches
  • Flag the use of deprecated APIs, functions, or other components.
  • Restrict portions of your code base to authorized teams only.
  • Require changes when PRs include !important tags in CSS files

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/explain-code-experts/","title":"Explain Code Experts","text":"

Post a comment that uses git blame and history to list the most relevant experts for all PRs. The comment will automatically update as additional commits are added to the PR.

Configuration Description

Conditions (all must be true):

  • A PR is created or modified.

Automation Actions:

  • Post a comment that identifies the people with the highest level of code expetise.

Explain Code Experts

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nexplain_code_experts:\nif:\n- {{ pr.labels | match(term='suggest-reviewer') | some }}\nrun:\n- action: explain-code-experts@v1 args:\ngt: 10 
Download this example as a CM file."},{"location":"automations/standard/explain-code-experts/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Assign additional reviewers for large PRs
  • Assign reviewers based on modified directories and files
  • Assign reviewers to share knowledge based on pre-determined criteria

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/flag-merged-no-review/","title":"Flag Code That's Merged Without Review","text":"

Automatically send notifications to your team when code is merged without review.

Configuration Description

Conditions (all must be true):

  • A PR is merged without at least one review.

Automation Actions:

  • Send a Slack notification to alert your team.
  • Apply a red DCF5-merged-without-review label.
  • Post a comment explaining SOC II requirements.

Flag Code That's Merged Without Review

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- merge\n# https://docs.gitstream.cm/automation-actions/#send-slack-message\nslack_webhook: {{ env.SLACK_WEBHOOK }}\n# Update security_team to match your organization\nsecurity_team: 'my-org/app-sec'\nautomations:\nflag_merged_no_review:\nif:\n- {{ pr.approvals | length == 0 }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"DCF5-merged-without-review\"\ncolor: {{ colors.red }}\n- action: send-slack-message@v1\nargs:\nmessage: \"PR #{{ pr.number }} - {{ pr.title }} - was merged without peer reviews. SOC2 requires code reviews for every code change. _SOC2 ref: CC8.1_\"\nwebhook_url: \"{{ slack_webhook }}\"\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR was merged without peer reviews. SOC2 requires code reviews for every code change.\n_SOC2 ref: CC8.1_\n@{{ security_team }}\ncolors:\nred: 'F6443B'\n
Download this example as a CM file."},{"location":"automations/standard/label-management/","title":"PR Label Management with gitStream","text":"

Use YAML to automate label management on your git repo with gitStream.

"},{"location":"automations/standard/label-management/#enforce-required-labels","title":"Enforce Required Labels","text":""},{"location":"automations/standard/label-management/#enforce-required-labels_1","title":"Enforce Required Labels","text":"

Automatically enforce the use of required PR labels.

Configuration Description

Conditions (all must be true):

  • The PR lacks one or more labels from a list of required labels.

Automation Actions:

  • Apply a Missing Required Labels label.
  • Post a comment explaining why the label was applied and which labels are required.

Enforce Required Labels

manifest:\nversion: 1.0\nautomations:\nenforce_required_labels:\nif:\n- {{ pr.labels | match(list=['Core', 'Mobile', 'UI']) | nope }}\nrun:\n- action: request-changes@v1\nargs:\ncomment: Please ensure that your PR is labeled with either 'Core', 'Mobile', or 'UI'. These labels help us to better track and manage your contribution. Thank you.\n
Download this example as a CM file.

"},{"location":"automations/standard/label-management/#label-modified-resources","title":"Label Modified Resources","text":""},{"location":"automations/standard/label-management/#label-changed-resources-by-percent","title":"Label Changed Resources By Percent","text":"

Apply a label to all PRs that indicates what percentage of new lines of code modify one or more specified resources.

Configuration Description

Conditions (all must be true):

  • A PR modifies resources listed in one or more specified locations.

Automation Actions:

  • Apply labels that indicate what percentage of new code lines modify the specified resources.

Label Changed Resources By Percent

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in labels %}\nlabel_resource_percent_{{ item.name }}:\nif:\n- {{ files | match(list=item.resources) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: '{{ item.additions | round }}% {{ item.name }}'\n{% endfor %}\nresources:\ncore:\n- src/app\n- src/core\nmobile: - src/android\n- src/ios\ndocs:\n- docs/\nlabels:\n- name: Core\nresources: {{ resources.core }}\nadditions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.core ) | map(attr='additions') | sum / total.additions * 100 }}\n- name: Mobile\nresources: {{ resources.mobile }}\nadditions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.mobile ) | map(attr='additions') | sum / total.additions * 100 }}\n- name: Docs\nresources: {{ resources.docs }}\nadditions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.docs ) | map(attr='additions') | sum / total.additions * 100 }}\ntotal:\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\n
Download this example as a CM file.

"},{"location":"automations/standard/label-management/#label-prs-by-language","title":"Label PRs by Language","text":"

Automatically detect which programming languages are contained in PRs and automatically label the PRs appropriately.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Label the PR for each programming language that is included.

Label PRs by Language

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in labels %}\nlabel_{{ item.name }}_pr:\nif:\n- {{ files | match(regex=item.resources) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: '{{ item.name }}'\n{% endfor %}\nlabels:\n- name: Java\nresources: r/.java$/\n- name: Rust\nresources: r/.rs$/\n- name: HTML\nresources: r/.html$/\n- name: JavaScript\nresources: r/.js$/\n- name: Python\nresources: r/.py$/\n- name: Golang\nresources: r/.go$/\n- name: Ruby\nresources: r/.rb$/\n- name: CSS\nresources: r/.css/\n
Download this example as a CM file.

"},{"location":"automations/standard/label-management/#label-the-number-of-unresolved-code-review-threads","title":"Label the Number of Unresolved Code Review Threads","text":""},{"location":"automations/standard/label-management/#label-unresolved-review-threads","title":"Label Unresolved Review Threads","text":"

Automatically label PRs when there are unresolved code review comments.

Configuration Description

Conditions (all must be true):

  • The PR has one or more unresolved code review comments.

Automation Actions:

  • Apply a label that indicates how many unresolved comments the PR has.

Label Unresolved Review Threads

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_unresolved_threads:  if:  - {{ pr.unresolved_threads }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ pr.unresolved_threads }} Unresolved Thread(s)\ncolor: {{ colors.yellow }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file.

"},{"location":"automations/standard/label-management/#automatically-recommend-labels-for-new-prs","title":"Automatically Recommend Labels for New PRs","text":""},{"location":"automations/standard/label-management/#suggest-labels","title":"Suggest Labels","text":"

Automatically suggest labels to apply to new PRs.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated that has no labels.

Automation Actions:

  • Post a comment that suggest labels the author can apply to the PR.

Suggest Labels

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nsuggest_labels:  if:  - {{ pr.labels | length == 0}}\nrun:\n- action: add-comment@v1\nargs: comment: | All PRs must contain labels that indicate which CI/CD systems must be run. PLease update your PR to include one of the following labels: `Build: Mobile`, `Build: UI`, `Build: All`, `Build: None`\nAdditionally, Here are some labels you can apply to this PR that may be helpful:\n* Suggest Reviewer - Use this if you aren't sure who to assign as the reviewer.\n* WIP - Indicate this is a work in progress that shouldn't be merged.\n
Download this example as a CM file.

"},{"location":"automations/standard/label-management/#label-prs-with-the-number-of-approvals","title":"Label PRs with the Number of Approvals","text":""},{"location":"automations/standard/label-management/#label-the-number-of-approvals","title":"Label the Number of Approvals","text":"

Automatically label PRs with the number of completed reviews that approve the PR.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Apply or update a label that indicates how many merge approvals have been granted.

Label the Number of Approvals

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_approvals: if:  - {{ pr.approvals | length > 0 }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ pr.approvals | length }} Approved Review(s)\n
Download this example as a CM file."},{"location":"automations/standard/label-management/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for help with these examples.

"},{"location":"automations/standard/label-management/enforce-labels/","title":"Enforce Required Labels","text":"

Automatically enforce the use of required PR labels.

Configuration Description

Conditions (all must be true):

  • The PR lacks one or more labels from a list of required labels.

Automation Actions:

  • Apply a Missing Required Labels label.
  • Post a comment explaining why the label was applied and which labels are required.

Enforce Required Labels

manifest:\nversion: 1.0\nautomations:\nenforce_required_labels:\nif:\n- {{ pr.labels | match(list=['Core', 'Mobile', 'UI']) | nope }}\nrun:\n- action: request-changes@v1\nargs:\ncomment: Please ensure that your PR is labeled with either 'Core', 'Mobile', or 'UI'. These labels help us to better track and manage your contribution. Thank you.\n
Download this example as a CM file."},{"location":"automations/standard/label-management/label-approvals/","title":"Label the Number of Approvals","text":"

Automatically label PRs with the number of completed reviews that approve the PR.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Apply or update a label that indicates how many merge approvals have been granted.

Label the Number of Approvals

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_approvals: if:  - {{ pr.approvals | length > 0 }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ pr.approvals | length }} Approved Review(s)\n
Download this example as a CM file."},{"location":"automations/standard/label-management/label-modified-resources/","title":"Label Based on Modified Resources","text":"

Automatically label PRs to indicate what resources are being changed.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Apply labels based on the branch name or modified resources.

Label Modified Resources

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in labels %}\nlabel_resource_{{ item.name }}:\nif:\n-{{ branch.name | includes(regex=item.branch) or files | match(list=item.resources) }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ item.name }}\n{% endfor %}\nlabels:\n- name: Core\nresources:\n- src/app\nbranch: r/^core-/\n- name: mobile\nresources:\n- src/android\n- src/ios\nbranch: r/^mobile-/\n
Download this example as a CM file.

"},{"location":"automations/standard/label-management/label-prs-by-language/","title":"Label PRs by Language","text":"

Automatically detect which programming languages are contained in PRs and automatically label the PRs appropriately.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Label the PR for each programming language that is included.

Label PRs by Language

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in labels %}\nlabel_{{ item.name }}_pr:\nif:\n- {{ files | match(regex=item.resources) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: '{{ item.name }}'\n{% endfor %}\nlabels:\n- name: Java\nresources: r/.java$/\n- name: Rust\nresources: r/.rs$/\n- name: HTML\nresources: r/.html$/\n- name: JavaScript\nresources: r/.js$/\n- name: Python\nresources: r/.py$/\n- name: Golang\nresources: r/.go$/\n- name: Ruby\nresources: r/.rb$/\n- name: CSS\nresources: r/.css/\n
Download this example as a CM file.

"},{"location":"automations/standard/label-management/label-resources-percent/","title":"Label Changed Resources By Percent","text":"

Apply a label to all PRs that indicates what percentage of new lines of code modify one or more specified resources.

Configuration Description

Conditions (all must be true):

  • A PR modifies resources listed in one or more specified locations.

Automation Actions:

  • Apply labels that indicate what percentage of new code lines modify the specified resources.

Label Changed Resources By Percent

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in labels %}\nlabel_resource_percent_{{ item.name }}:\nif:\n- {{ files | match(list=item.resources) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: '{{ item.additions | round }}% {{ item.name }}'\n{% endfor %}\nresources:\ncore:\n- src/app\n- src/core\nmobile: - src/android\n- src/ios\ndocs:\n- docs/\nlabels:\n- name: Core\nresources: {{ resources.core }}\nadditions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.core ) | map(attr='additions') | sum / total.additions * 100 }}\n- name: Mobile\nresources: {{ resources.mobile }}\nadditions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.mobile ) | map(attr='additions') | sum / total.additions * 100 }}\n- name: Docs\nresources: {{ resources.docs }}\nadditions: {{ branch.diff.files_metadata | filter(attr='file', list=resources.docs ) | map(attr='additions') | sum / total.additions * 100 }}\ntotal:\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\n
Download this example as a CM file."},{"location":"automations/standard/label-management/label-unresolved-threads/","title":"Label Unresolved Review Threads","text":"

Automatically label PRs when there are unresolved code review comments.

Configuration Description

Conditions (all must be true):

  • The PR has one or more unresolved code review comments.

Automation Actions:

  • Apply a label that indicates how many unresolved comments the PR has.

Label Unresolved Review Threads

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_unresolved_threads:  if:  - {{ pr.unresolved_threads }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ pr.unresolved_threads }} Unresolved Thread(s)\ncolor: {{ colors.yellow }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"automations/standard/label-management/suggest-labels/","title":"Suggest Labels","text":"

Automatically suggest labels to apply to new PRs.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated that has no labels.

Automation Actions:

  • Post a comment that suggest labels the author can apply to the PR.

Suggest Labels

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nsuggest_labels:  if:  - {{ pr.labels | length == 0}}\nrun:\n- action: add-comment@v1\nargs: comment: | All PRs must contain labels that indicate which CI/CD systems must be run. PLease update your PR to include one of the following labels: `Build: Mobile`, `Build: UI`, `Build: All`, `Build: None`\nAdditionally, Here are some labels you can apply to this PR that may be helpful:\n* Suggest Reviewer - Use this if you aren't sure who to assign as the reviewer.\n* WIP - Indicate this is a work in progress that shouldn't be merged.\n
Download this example as a CM file."},{"location":"automations/standard/link-issue-tracker/","title":"Automatic Project Tracker Links","text":"

Post a PR comment that links the associated resource in your issue tracker, such as Jira, Azure Boards, Shortcut, Asana, and more.

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to project tracking tickets in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated project tracking resource.

Link Issue Tracker

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n# Configure these to match your organization.\nprovider: jira\norgName: org\nasanaProject: 1234\nazureProject: my_project\n{% set ticketid = \"\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\ncomment_issue_tracker:\nif:\n- {{ has.ticket_in_title or has.ticket_in_branch }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})\nhas:\nticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}\nticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}\ntracker:\njira:\nbaseurl: https://[orgName].atlassian.net/browse/\npattern: r/\\b[A-Za-z]+-\\d+\\b/\nasana:\nbaseurl: https://app.asana.com/0/[asanaProject]/0/\npattern: r/asana-(\\d+)/\nazure:\nbaseurl: https://dev.azure.com/[orgName]/[azureProject]/_workitems/\npattern: r/(\\w+)-(\\w+)-(\\d+)/\nshortcut:\nbaseurl: https://app.shortcut.com/[orgName]/story/\npattern: r/(\\w+)\\/sc-(\\d+)/\ntickets:\n- {{branch.name | capture(regex=tracker[provider].pattern)}}\n- {{pr.title | capture(regex=tracker[provider].pattern)}}\n
Download this example as a CM file."},{"location":"automations/standard/review-assignment/","title":"Use gitStream for Automatic Code Review Assignment","text":"

Automatically assign code reviews based on changed resources, code expertise, branch, and more.

"},{"location":"automations/standard/review-assignment/#assign-code-experts","title":"Assign Code Experts","text":"

When someone applies a suggest-reviewers label to a PR, use codeExperts to assign recommended reviewers and post a comment with the explainCodeExperts automation action.

Configuration Description

Conditions (all must be true):

  • The PR has a suggest-reviewers label attached to it.

Automation Actions:

  • Use codeExperts to assign recommended reviewers.
  • Use explainCodeExperts to post a comment that lists the top code experts for the PR.

Assign Code Experts

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nassign_code_experts:\n# Triggered when someone applies a suggest-reviewer label to a PR.\nif: - {{ pr.labels | match(term='suggest-reviewer') | some }}\n# More info about code experts\n# https://docs.gitstream.cm/filter-functions/#codeexperts\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: {{ repo | codeExperts(gt=10) }}\n- action: explain-code-experts@v1 args:\ngt: 10 
Download this example as a CM file.

"},{"location":"automations/standard/review-assignment/#branch-based-review-policies","title":"Branch-Based Review Policies","text":"

Automatically route and manage PRs based on the target or destination branch.

Configuration Description

Conditions (all must be true):

  • The target or source branch name contains a specified prefix.

Automation Actions:

  • Implement custom review policies for the branch.
By Target BranchBy Source Branch

Review Target Branch

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in branches %}\nreview_target_branch_{{ item.name }}: if:       - {{ pr.target| match(regex=item.prefix) }}\nrun:\n- action: set-required-approvals@v1\nargs:\napprovals: {{ item.reviews }}\n- action: add-comment@v1\nargs: comment: | PRs to the {{ item.name }} branch require {{ item.reviews }} review(s).\n- action: add-reviewers@v1\nargs:\nreviewers: [{{ item.reviewers }}]\n{% endfor %}\nbranches:\n- prefix: r/^release/ reviews: 4\nname: Release\n- prefix: r/^experimental-/ reviews: 1\nname: Experimental\n
Download this example as a CM file.

Review Source Branch

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in branches %}\nreview_source_branch{{ item.name }}: if:       - {{ branch.name | match(regex=item.prefix) }}\nrun:\n- action: set-required-approvals@v1\nargs:\napprovals: {{ item.reviews }}\n- action: add-comment@v1\nargs: comment: | Reviewers from the {{ item.name }} team have automatically been assigned to this PR.\n- action: add-reviewers@v1\nargs:\nreviewers: [{{ item.reviewers }}]\n{% endfor %}\nbranches:\n- prefix: r/^ABC/ reviewers: org/a-team\nname: ABC\n- prefix: r/^XYZ-/ reviewers: org/x-team\nname: XYZ\n
Download this example as a CM file.

"},{"location":"automations/standard/review-assignment/#review-sensitive-files","title":"Review Sensitive Files","text":"

Compare the changed files to a pre-defined list of files and directories in. If any files match, require a review from the team my-organization/security.

Configuration Description

Conditions (all must be true):

  • Any files match the files or directories listed in the sensitive_files custom expression. Customize this list for your project.

Automation Actions:

  • Assign my-organization/security to review the PR. Customize this value to match your organization.
  • Require 2 approvals.
  • Post a comment that explains the automation.

Review Sensitive Files

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# Assign special teams to review sensitive files. \n# This requires the `sensitive` custom expression found at the bottom of this file.\nreview_sensitive_files:\n# For all files listed in the sensitive custom expression.\nif:\n- {{ files | match(list=sensitive_files) | some }}\nrun:\n# Add reviewers from the dev-leads team, and require two approvals\n# Modify `my-organization/security` to match your organization.\n- action: add-reviewers@v1\nargs:\nreviewers: [my-organization/security]\n- action: set-required-approvals@v1\nargs:\napprovals: 2\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR affects one or more sensitive files and requires review from the security team.\n# The `sensitive_file_review` automation requires this custom expression.\n# Modify this list to suit your security needs.\nsensitive_files:\n- src/app/auth/\n- src/app/routing/\n- src/app/resources/\n
Download this example as a CM file.

"},{"location":"automations/standard/review-assignment/#custom-team-review-policies","title":"Custom Team Review Policies","text":"

Automatically assign the PR author's team to review PRs.

Configuration Description

Conditions (all must be true):

  • The PR author is a member of one of the teams specified in the teams custom expression.

Automation Actions:

  • Assign that team to review the PR.

Assign the Author's Team for Review

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in teams %}\nreview_team_{{ item.name }}: if:  - {{ pr.author_teams | match(regex=item.regex) }}\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: [{{ item.team }}] - action: add-comment@v1\nargs: comment: | This {{ item.name }} team has been automatically assigned to review this PR.\n{% endfor %}\nteams:\n- regex: r/ui-team/\nname: UI Team\nteam: org/ui-team\n- regex: r/mobile-team/\nname: Mobile\nteam: org/mobile-team\n
Download this example as a CM file.

"},{"location":"automations/standard/review-assignment/#distribute-code-reviews-to-share-knowledge","title":"Distribute Code Reviews to Share Knowledge","text":"

Require the reviewer as a previous contributor with code expertise between set thresholds when PR contains Share Knowledge label.

Configuration Description

Conditions (all must be true):

  • A Share Knowledge label has been applied to the PR

Automation Actions:

  • Choose a previous contributor between specified expertise thresholds and assign them as a reviewer.
  • Post a comment explaining why this action was taken.

Knowledge Share

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nshare_knowledge:\nif:\n- {{ pr.labels | match(term='Share Knowledge') | some }}\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: {{ repo | codeExperts(gt=30, lt=60) | random }}\n- action: add-comment@v1\nargs:\ncomment: |\ngitStream has assigned a reviewer to increase knowledge sharing on this PR.\n
Download this example as a CM file.

"},{"location":"automations/standard/review-assignment/#notify-watcher","title":"Notify Watcher","text":"

Automatically notify code reviewers based on a resource watchlist.

Configuration Description

Conditions (all must be true):

  • The PR modifies any files listed under the watchers custom expression.

Automation Actions:

  • Post a comment that notifies the responsible team or individual of the changes.

Notify Watcher

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n## change orgName to match your git organization name.\norgName: company\nautomations:\n{% for item in watchers %}\nnotify_watcher_{{ item.owner if item.owner else item.team }}:\nif:\n- {{ (files | match(list=item.files) | some) or (source.diff.files | match(attr=\"diff\", list=item.diffs) | some) }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: |\n@{{ item.owner if item.owner else ([\"{{ orgName }}/\", item.team] | join) }} - this PR has changes you're watching\n{% if files | match(list=item.files) | some -%}\nfiles:\n{%- for file in files | filter(list=item.files) %}\n- {{ file }}\n{%- endfor -%}\n{%- endif %}\n{% if source.diff.files | match(attr=\"diff\", list=item.diffs) | some -%}\ndiffs:\n{%- for diff in item.diffs -%}\n{%- if source.diff.files | match(attr=\"diff\", list=diff) | some %}\n- {{ diff }}\n{%- for file in source.diff.files | filter(attr=\"diff\", list=diff) | map(attr=\"new_file\") %}\n- {{ file }}\n{%- endfor -%}\n{%- endif -%}\n{%- endfor -%}\n{%- endif %}\n- action: add-reviewers@v1\nargs:\nreviewers: {{ item.owner }}\nteam_reviewers: {{ item.team }}\n{% endfor %}\nwatchers:\n- owner: juliaspencer\nfiles:\n- src/auth\n- team: release\nfiles:\n- package.json\n- yarn.lock\n
Download this example as a CM file."},{"location":"automations/standard/review-assignment/assign-code-experts/","title":"Assign Code Experts","text":"

When someone applies a suggest-reviewers label to a PR, use codeExperts to assign recommended reviewers and post a comment with the explainCodeExperts automation action.

Configuration Description

Conditions (all must be true):

  • The PR has a suggest-reviewers label attached to it.

Automation Actions:

  • Use codeExperts to assign recommended reviewers.
  • Use explainCodeExperts to post a comment that lists the top code experts for the PR.

Assign Code Experts

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nassign_code_experts:\n# Triggered when someone applies a suggest-reviewer label to a PR.\nif: - {{ pr.labels | match(term='suggest-reviewer') | some }}\n# More info about code experts\n# https://docs.gitstream.cm/filter-functions/#codeexperts\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: {{ repo | codeExperts(gt=10) }}\n- action: explain-code-experts@v1 args:\ngt: 10 
Download this example as a CM file."},{"location":"automations/standard/review-assignment/assign-code-experts/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Assign additional reviewers for large PRs
  • Assign reviewers based on modified directories and files
  • Assign reviewers to share knowledge based on pre-determined criteria

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/review-assignment/notify-watcher/","title":"Notify Watchlist","text":"

Automatically notify code reviewers based on a resource watchlist.

Configuration Description

Conditions (all must be true):

  • The PR modifies any files listed under the watchers custom expression.

Automation Actions:

  • Post a comment that notifies the responsible team or individual of the changes.

Notify Watcher

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n## change orgName to match your git organization name.\norgName: company\nautomations:\n{% for item in watchers %}\nnotify_watcher_{{ item.owner if item.owner else item.team }}:\nif:\n- {{ (files | match(list=item.files) | some) or (source.diff.files | match(attr=\"diff\", list=item.diffs) | some) }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: |\n@{{ item.owner if item.owner else ([\"{{ orgName }}/\", item.team] | join) }} - this PR has changes you're watching\n{% if files | match(list=item.files) | some -%}\nfiles:\n{%- for file in files | filter(list=item.files) %}\n- {{ file }}\n{%- endfor -%}\n{%- endif %}\n{% if source.diff.files | match(attr=\"diff\", list=item.diffs) | some -%}\ndiffs:\n{%- for diff in item.diffs -%}\n{%- if source.diff.files | match(attr=\"diff\", list=diff) | some %}\n- {{ diff }}\n{%- for file in source.diff.files | filter(attr=\"diff\", list=diff) | map(attr=\"new_file\") %}\n- {{ file }}\n{%- endfor -%}\n{%- endif -%}\n{%- endfor -%}\n{%- endif %}\n- action: add-reviewers@v1\nargs:\nreviewers: {{ item.owner }}\nteam_reviewers: {{ item.team }}\n{% endfor %}\nwatchers:\n- owner: juliaspencer\nfiles:\n- src/auth\n- team: release\nfiles:\n- package.json\n- yarn.lock\n
Download this example as a CM file."},{"location":"automations/standard/review-assignment/notify-watcher/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Assign additional reviewers for large PRs
  • Assign or suggest reviewers based on level of code expertise for the code changed in a PR.
  • Assign reviewers based on modified directories and files
  • Assign reviewers to share knowledge based on pre-determined criteria

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/review-assignment/review-branch/","title":"Branch-Based Review Policies","text":"

Automatically route and manage PRs based on the target or destination branch.

Configuration Description

Conditions (all must be true):

  • The target or source branch name contains a specified prefix.

Automation Actions:

  • Implement custom review policies for the branch.
By Target BranchBy Source Branch

Review Target Branch

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in branches %}\nreview_target_branch_{{ item.name }}: if:       - {{ pr.target| match(regex=item.prefix) }}\nrun:\n- action: set-required-approvals@v1\nargs:\napprovals: {{ item.reviews }}\n- action: add-comment@v1\nargs: comment: | PRs to the {{ item.name }} branch require {{ item.reviews }} review(s).\n- action: add-reviewers@v1\nargs:\nreviewers: [{{ item.reviewers }}]\n{% endfor %}\nbranches:\n- prefix: r/^release/ reviews: 4\nname: Release\n- prefix: r/^experimental-/ reviews: 1\nname: Experimental\n
Download this example as a CM file.

Review Source Branch

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in branches %}\nreview_source_branch{{ item.name }}: if:       - {{ branch.name | match(regex=item.prefix) }}\nrun:\n- action: set-required-approvals@v1\nargs:\napprovals: {{ item.reviews }}\n- action: add-comment@v1\nargs: comment: | Reviewers from the {{ item.name }} team have automatically been assigned to this PR.\n- action: add-reviewers@v1\nargs:\nreviewers: [{{ item.reviewers }}]\n{% endfor %}\nbranches:\n- prefix: r/^ABC/ reviewers: org/a-team\nname: ABC\n- prefix: r/^XYZ-/ reviewers: org/x-team\nname: XYZ\n
Download this example as a CM file.

"},{"location":"automations/standard/review-assignment/review-branch/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Assign additional reviewers for large PRs
  • Assign or suggest reviewers based on level of code expertise for the code changed in a PR.
  • Assign reviewers based on modified directories and files
  • Assign reviewers to share knowledge based on pre-determined criteria

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/review-assignment/review-sensitive-files/","title":"Review Sensitive Files","text":"

Compare the changed files to a pre-defined list of files and directories in. If any files match, require a review from the team my-organization/security.

Configuration Description

Conditions (all must be true):

  • Any files match the files or directories listed in the sensitive_files custom expression. Customize this list for your project.

Automation Actions:

  • Assign my-organization/security to review the PR. Customize this value to match your organization.
  • Require 2 approvals.
  • Post a comment that explains the automation.

Review Sensitive Files

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# Assign special teams to review sensitive files. \n# This requires the `sensitive` custom expression found at the bottom of this file.\nreview_sensitive_files:\n# For all files listed in the sensitive custom expression.\nif:\n- {{ files | match(list=sensitive_files) | some }}\nrun:\n# Add reviewers from the dev-leads team, and require two approvals\n# Modify `my-organization/security` to match your organization.\n- action: add-reviewers@v1\nargs:\nreviewers: [my-organization/security]\n- action: set-required-approvals@v1\nargs:\napprovals: 2\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR affects one or more sensitive files and requires review from the security team.\n# The `sensitive_file_review` automation requires this custom expression.\n# Modify this list to suit your security needs.\nsensitive_files:\n- src/app/auth/\n- src/app/routing/\n- src/app/resources/\n
Download this example as a CM file."},{"location":"automations/standard/review-assignment/review-sensitive-files/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Assign additional reviewers for large PRs
  • Assign or suggest reviewers based on level of code expertise for the code changed in a PR.
  • Assign reviewers based on modified directories and files
  • Assign reviewers to share knowledge based on pre-determined criteria

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/review-assignment/review-team/","title":"Assign the Author's Team for Review","text":"

Automatically assign the PR author's team to review PRs.

Configuration Description

Conditions (all must be true):

  • The PR author is a member of one of the teams specified in the teams custom expression.

Automation Actions:

  • Assign that team to review the PR.

Assign the Author's Team for Review

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in teams %}\nreview_team_{{ item.name }}: if:  - {{ pr.author_teams | match(regex=item.regex) }}\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: [{{ item.team }}] - action: add-comment@v1\nargs: comment: | This {{ item.name }} team has been automatically assigned to review this PR.\n{% endfor %}\nteams:\n- regex: r/ui-team/\nname: UI Team\nteam: org/ui-team\n- regex: r/mobile-team/\nname: Mobile\nteam: org/mobile-team\n
Download this example as a CM file."},{"location":"automations/standard/review-assignment/review-team/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Assign additional reviewers for large PRs
  • Assign or suggest reviewers based on level of code expertise for the code changed in a PR.
  • Assign reviewers based on modified directories and files
  • Assign reviewers to share knowledge based on pre-determined criteria

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/review-assignment/share-knowledge/","title":"Knowledge Share","text":"

Require the reviewer as a previous contributor with code expertise between set thresholds when PR contains Share Knowledge label.

Configuration Description

Conditions (all must be true):

  • A Share Knowledge label has been applied to the PR

Automation Actions:

  • Choose a previous contributor between specified expertise thresholds and assign them as a reviewer.
  • Post a comment explaining why this action was taken.

Knowledge Share

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nshare_knowledge:\nif:\n- {{ pr.labels | match(term='Share Knowledge') | some }}\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: {{ repo | codeExperts(gt=30, lt=60) | random }}\n- action: add-comment@v1\nargs:\ncomment: |\ngitStream has assigned a reviewer to increase knowledge sharing on this PR.\n
Download this example as a CM file."},{"location":"automations/standard/review-assignment/share-knowledge/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Assign additional reviewers for large PRs
  • Assign or suggest reviewers based on level of code expertise for the code changed in a PR.
  • Assign reviewers based on modified directories and files

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/review-changelog/","title":"Enforce Changelog Updates","text":"

Request changes if a PR that meets specified criteria lacks an update to the project's changelog.

Configuration Description

Conditions (All must be true):

  • The branch name contains the phrase feature
  • The PR lacks changes to the docs/changelog.md file

Automation Actions:

  • Apply a yellow label that says \u26a0\ufe0f Missing Changelog
  • Request changes and post a comment explaining why.

Review Changelog

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# Request changes for new features that lack changelog updates.\nreview_changelog: if: - {{ branch.name | includes(term=\"feature\") }}\n- {{ files | match(regex=r/^docs\\/changelog\\.md$/) | nope }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Changelog\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | All new features require an update to the changelog. Please modify your PR to include any relevant changelog updates.\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file.

Special thanks to Boemo W Mmopelwa for providing this example.

"},{"location":"automations/standard/review-changelog/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Flag the use of deprecated APIs, functions, or other components.
  • Restrict portions of your code base to authorized teams only.
  • Require changes when PRs include !important tags in CSS files

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/standard/review-todo-comments/","title":"Review TODO Comments","text":"

Request changes for a PR that contains a TODO statement.

Configuration Description

Conditions (all must be true):

  • The PR contains a TODO statement

Automation Actions:

  • Request changes and post a comment explaining why.

Review TODO Comments

manifest:\nversion: 1.0\nautomations:\nreview_todo_comments:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/^[+].*(TODO|todo)/) | some }}\nrun:\n- action: request-changes@v1\nargs:\ncomment: |\nThis PR contains a TODO statement. Please check to see if they should be removed.\n
Download this example as a CM file."},{"location":"automations/standard/summarize-language-changes/","title":"Summarize Language Changes","text":"

Post a comment that summarizes which programming languages are contained in PRs.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • Post a comment containing a table that shows the percent of total changes for each programming language present in the PR.

Summarize Language Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non: - pr_created\nautomations:\nsummarize_language_changes:\nif:\n- true\nrun:\n- action: add-comment@v1\nargs:\ncomment:  <h3>Summary of Changes by Language</h3>\n<table>\n<tr>\n<td>Language</td>\n<td>Language Change Percentage</td>\n</tr>\n<tr>\n<td>Java</td>\n<td>{{ total.java | round }}%</td>\n</tr>\n<tr>\n<td>JavaScript</td>\n<td>{{ total.javascript | round }}%</td>\n</tr>\n<td>Rust</td>\n<td>{{ total.rust | round }}%</td>\n</tr>\n<tr>\n<td>Ruby</td>\n<td>{{ total.ruby  | round }}%</td>\n</tr>\n<td>HTML</td>\n<td>{{ total.html  | round }}%</td>\n</tr>\n<td>CSS</td>\n<td>{{ total.css  | round }}%</td>\n</tr>\n<tr>\n<td>Golang</td>\n<td>{{ total.golang  | round }}%</td>\n</tr>\n<tr>\n<td>Python</td>\n<td>{{ total.python  | round }}%</td>\n</tr>\n</table>\ntotal:\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\njava: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.java$/ ) | map(attr='additions') | sum / total.additions * 100 }}\njavascript: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.js$/ ) | map(attr='additions') | sum / total.additions * 100 }}\nrust: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.rs$/ ) | map(attr='additions') | sum / total.additions * 100 }}\nruby: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.rb$/ ) | map(attr='additions') | sum / total.additions * 100 }}\nhtml: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.html$/ ) | map(attr='additions') | sum / total.additions * 100 }}\ncss: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.css$/ ) | map(attr='additions') | sum / total.additions * 100 }}\ngolang: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.go$/ ) | map(attr='additions') | sum / total.additions * 100 }}\npython: {{ branch.diff.files_metadata | filter(attr='file', regex=r/.py$/ ) | map(attr='additions') | sum / total.additions * 100 }}\n
Download this example as a CM file."},{"location":"automations/standard/summarize-language-changes/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/utilities/cm-header/","title":"CM File Header","text":"

This header is useful to add to the top of any configuration files you create for your organization. This will help others who want to make improvements to your configurations in the future.

CM File Header

# -*- mode: yaml -*-\n# +----------------------------------------------------------------------------+\n# | WARNING: This file controls repo automations, use caution when modifying   |\n# +----------------------------------------------------------------------------+\n# | This file contains one or more /:\\ gitStream automations:                  |\n# | https:// docs.gitstream.cm                                                 |\n# |                                                                            |\n# | gitStream uses YAML syntax with nunjucks templating via Jinja 2.           |\n# |                                                                            |\n# | Automations follow an \"if this, then that\" execution format.               |\n# | More info here: https://docs.gitstream.cm/how-it-works/                    |\n# |                                                                            |\n# +----------------------------------------------------------------------------+\n# /:\\ gitStream Reference Docs: \n#    Context Variables: https://docs.gitstream.cm/context-variables/\n#    Filter Functions: https://docs.gitstream.cm/filter-functions/\n#    Automation Actions: https://docs.gitstream.cm/automation-actions/\n
Download this example as a CM file.

"},{"location":"automations/utilities/cm-header/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • A custom expression that makes it easy to implement color-coded labels that match the GitHub UI.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/utilities/colors-custom-expression/","title":"Colors Custom Expression","text":"

This automation demonstrates all of GitHub's default label colors, implemented as a colors custom expression. This is meant to help improve other automations rather than being used on its own.

Colors Custom Expression

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n# This automation demonstrates all of GitHub's default label colors.\n# This is meant to be used as a reference, not as an automation in your repo.\nautomations:\nlabel_colors:\nif:\n- true\nrun:\n- action: add-label@v1\nargs:\nlabel: \"Test Label\"\ncolor: {{ colors.green }}\n# These are all of the colors in GitHub's default label color palette.\ncolors:\nred: 'b60205'\norange: 'd93f0b'\nyellow: 'fbca04'\ngreen: '0e8a16'\nteal: '006b75'\nblue: '1d76db'\ndark-blue: '0052cc'\npurple: '5319e7'\nlight-red: 'e99695'\nlight-orange: 'f9d0c4'\nlight-yellow: 'fef2c0'\nlight-green: 'c2e0c6'\nlight-teal: 'bfdadc'\nlight-blue: 'c5def5'\nlight-dark-blue: 'bfd4f2'\nlight-purple: 'd4c5f9'\n
Download this example as a CM file.

"},{"location":"automations/utilities/colors-custom-expression/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • An informative header you can add to your CM files to help others.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"automations/welcome-newcomer/","title":"Welcome Newcomer","text":"

Post a welcome message when someone makes their first PR to a repo, and provide context to help them know what's next.

Configuration Description

Conditions (all must be true):

  • The PR author made their first contribution to the repo during the current day.

Automation Actions:

  • Add the my-organization/mentors team to review the PR. Customize this to match your organization.
  • Apply a new-contributor label to the PR.
  • Post a comment explaining the next steps. Customize this to match your project.

Welcome Newcomer

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# Help newcomers find mentors to guide them.\nwelcome_newcomer:\n# If the PR author made their first contirbution on the current day\nif:\n- {{ repo.author_age < 1 and repo.age > 0 }}\n# 1. Add reviewers from the team `my_organization/mentors`. Replace this string to match your organization\n# 2. Apply a new-contributor label.\n# 3 Post a comment that explains the next steps.\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: [my_organization/mentors]\n- action: add-label@v1\nargs:\nlabel: 'new-contributor'\ncolor: '#FBBD10'\n- action : add-comment@v1\nargs:\ncomment: |\nHello {{ pr.author }} \ud83d\udc4b Thanks for making your first PR, and welcome to our project!\nOur mentor team has automatically been assigned to review this PR and guide you through the process.\nPlease reach out to that team if you have questions about the next steps.\n
Download this example as a CM file."},{"location":"automations/welcome-newcomer/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/","title":"gitStream Integrations","text":"

LinearB

"},{"location":"integrations/#github-gitlab","title":"GitHub / GitLab","text":"

:: GitHub Actions

:: GitHub Copilot

PR Labels

Branch Management

PR Reviews

"},{"location":"integrations/#security-compliance","title":"Security & Compliance","text":"

Orca

SonarCloud

Dependabot

Jit

Renovate

Snyk

SOC 2

"},{"location":"integrations/#project-management","title":"Project Management","text":"

Jira

Asana

Shortcut

Azure Boards

"},{"location":"integrations/#chat-communications","title":"Chat & Communications","text":"

Slack

Microsoft Teams

"},{"location":"integrations/#feature-flags","title":"Feature Flags","text":"

DevCycle

Launch Darkly

Flagsmith

Unleash

Flagr

"},{"location":"integrations/#languages","title":"Languages","text":"

JavaScript

Go

Python

Java

Ruby

HTML/CSS

Rust

"},{"location":"integrations/#documentation","title":"Documentation","text":"

Swimm

Javadoc

JSDoc

RDoc

Godoc

"},{"location":"integrations/#other","title":"Other","text":"

Terraform

Zapier

"},{"location":"integrations/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

"},{"location":"integrations/asana/","title":"Integrate gitStream with Asana","text":"

Learn how to integrate gitStream with Asana

"},{"location":"integrations/asana/#label-missing-asana-info","title":"Label Missing Asana Info","text":"

Automatically label PRs that are missing references to Asana resources.

Configuration Description

Conditions (all must be true):

  • The PR is missing an Asana ticket reference in the PR title and a link to an Asana resource in the PR description.

Automation Actions:

  • Apply a red \u26a0\ufe0f Missing Asana Link label
  • Post a comment that asks the author to add an Asana reference to the PR.

Label Missing Asana

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_missing_asana:\nif:\n- {{not (has.asana.ticket_in_title or has.asana.ticket_in_desc)}}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Asana Link\"\ncolor: {{ colors.red }}\n- action: add-comment@v1\nargs:\ncomment: Please provide a link to the associated Asana resource.\nhas:\nasana:\nticket_in_title: {{ pr.title | includes(regex=r/asana-(\\d+)/) }}\nticket_in_desc: {{ pr.description | includes(regex=r/app\\.asana.\\com\\/(\\d+)\\/(\\d+)\\/(\\d+)\\/(\\d+)\\/(\\d+)/) }}\ncolors:\nred: 'b60205'\n
Download this example as a CM file.

"},{"location":"integrations/asana/#automatically-link-prs-to-related-asana-cards","title":"Automatically Link PRs to Related Asana Cards","text":"

Provide automatic links to Asana cards that are associated with PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Asana card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Asana Card.

Automatically Link to the Related Asana Card

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nprovider: asana\n# Configure this to match your organization. It is used in tracker.asana.baseurl.\nasanaProject: 1234\n{% set ticketid = \"\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\nlink_asana:\nif:\n- {{ has.ticket_in_title or has.ticket_in_branch }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})\nhas:\nticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}\nticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}\ntracker:\nasana:\nbaseurl: https://app.asana.com/0/[asanaProject]/0/\npattern: r/asana-(\\d+)/\ntickets:\n- {{branch.name | capture(regex=tracker[provider].pattern)}}\n- {{pr.title | capture(regex=tracker[provider].pattern)}}\n
Download this example as a CM file."},{"location":"integrations/asana/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/azure-boards/","title":"Integrate gitStream with Azure Boards","text":"

Learn how to integrate gitStream with Azure Boards.

"},{"location":"integrations/azure-boards/#label-missing-azure-boards-info","title":"Label Missing Azure Boards Info","text":"

Automatically label PRs that are missing references to Azure Boards resources.

Configuration Description

Conditions (all must be true):

  • The PR is missing one of the following:
    • An Azure Boards ticket reference in the PR title.
    • A link to an Azure Boards resource in the PR description.

Automation Actions:

  • Apply a red \u26a0\ufe0f Missing Azure Boards Link label
  • Post a comment that asks the author to add an Azure Boards reference to the PR.

Label Missing Azure Boards

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_missing_azure:\nif:\n- {{not (has.azure.ticket_in_title or has.azure.ticket_in_desc)}}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Azure Boards Link\"\ncolor: {{ colors.red }}\n- action: add-comment@v1\nargs:\ncomment: Please provide a link to the associated resource in Azure Boards.\nhas:\nazure:\nticket_in_title: {{ pr.title | includes(regex=r/(\\w+)-(\\w+)-(\\d+)/) }}\nticket_in_desc: {{ pr.description | includes(regex=r/(dev\\.azure\\.com|(\\w+)\\.visualstudio\\.com)\\/(\\w+)\\/(\\w+)\\/_workitems\\/edit\\/(\\d+)/) }}\ncolors:\nred: 'b60205'\n
Download this example as a CM file.

"},{"location":"integrations/azure-boards/#automatically-link-prs-to-related-azure-boards-resources","title":"Automatically Link PRs to Related Azure Boards Resources","text":"

Provide automatic links to Azure Boards resources that are associated with PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Azure Boards resource in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Azure Boards Resource.

Automatically Link to the Related Azure Boards Resource

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n# Configure these to match your organization.\nprovider: azure\n# The name of your Azure organization\norgName: org\n# The name of your Azure project\nazureProject: my_project\n{% set ticketid = \"\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\nlink_azure_boards:\nif:\n- {{ has.ticket_in_title or has.ticket_in_branch }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})\nhas:\nticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}\nticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}\ntracker:\nazure:\nbaseurl: https://dev.azure.com/[orgName]/[azureProject]/_workitems/\npattern: r/(\\w+)-(\\w+)-(\\d+)/\ntickets:\n- {{branch.name | capture(regex=tracker[provider].pattern)}}\n- {{pr.title | capture(regex=tracker[provider].pattern)}}\n
Download this example as a CM file."},{"location":"integrations/azure-boards/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/dependabot/","title":"Integrate gitStream with Dependabot","text":""},{"location":"integrations/dependabot/#approve-and-merge-dependabot-changes","title":"Approve and Merge Dependabot Changes","text":"

Auto-merge Dependabot PRs

By Release TypeAll Updates

Required gitStream Plugins

This example requires you to install the extractDependabotVersionBump and compareSemver plugins.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • The PR author is Dependabot.
  • The branch name includes 'dependabot'
  • The dependency change is a patch or minor update.

Automation Actions:

  • Approve the PR
  • Apply an approved-dependabot label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

manifest:\nversion: 1.0\nautomations:\nmerge_dependabot_minor:\nif:\n- {{ bump == 'minor' }}\n- {{ branch.name | includes(term=\"dependabot\") }}\n- {{ branch.author | includes(term=\"dependabot\") }}\nrun:\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nDependabot `minor` version bumps are approved automatically.\nmerge_dependabot_minor_patch:\nif:\n- {{ bump == 'patch' }}\n- {{ branch.name | includes(term=\"dependabot\") }}\n- {{ branch.author | includes(term=\"dependabot\") }}\nrun:\n- action: approve@v1\n- action: merge@v1\n- action: add-comment@v1\nargs:\ncomment: |\nDependabot `patch` version bumps are approved and merged automatically.\nbump: {{ pr.description | extractDependabotVersionBump | compareSemver }}\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • The PR author is Dependabot.
  • The branch name includes 'dependabot'

Automation Actions:

  • Approve the PR
  • Apply an approved-dependabot label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_dependabot:\nif:\n- {{ branch.name | includes(term=\"dependabot\") }}\n- {{ branch.author | includes(term=\"dependabot\") }}\nrun:\n- action: approve@v1\n- action: add-label@v1\nargs:\nlabel: \"approved-dependabot\"\n- action: merge@v1\nargs:\nwait_for_all_checks: true\nsquash_on_merge: true\n
Download this example as a CM file.

"},{"location":"integrations/dependabot/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/devcycle/","title":"Integrate gitStream with DevCycle","text":""},{"location":"integrations/devcycle/#label-devcycle-feature-flags","title":"Label DevCycle Feature Flags","text":"

Automatically label code that contians specified feature flags.

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in feature_flags %}\nlabel_ff_devcycle_{{ item.name }}:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/key = '/) | some }}\n      - {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}\n    run:\n      - action: add-label@v1\n        args:\n          label: {{ item.name }}\n          color: {{ colors.yellow }}\n  {% endfor %}\nfeature_flags:\n   - name: engineering_rollback_plan_activated \n     regex: r/engineering_rollback_plan_activated/\n   - name: marketing_premium_plan_features_unlocked \n     regex: r/marketing_premium_plan_features_unlocked/\n   - name: mobile_push_notifications_enabled\n     regex: r/mobile_push_notifications_enabled/\ncolors:\n  yellow: 'ffb300'   \n
Download this example as a CM file."},{"location":"integrations/devcycle/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/flagr/","title":"Integrate gitStream with Flagr","text":""},{"location":"integrations/flagr/#label-flagr-feature-flags","title":"Label Flagr Feature Flags","text":"

Automatically label code that contians specified feature flags.

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in feature_flags %}\nlabel_ff_flagr_{{ item.name }}:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/evaluation_result.variant_id ==/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ item.name }}\ncolor: {{ colors.yellow }}\n{% endfor %}\nfeature_flags:\n- name: engineering_rollback_plan_activated regex: r/engineering_rollback_plan_activated/\n- name: marketing_premium_plan_features_unlocked regex: r/marketing_premium_plan_features_unlocked/\n- name: mobile_push_notifications_enabled\nregex: r/mobile_push_notifications_enabled/\ncolors:\nyellow: 'ffb300'   
Download this example as a CM file."},{"location":"integrations/flagr/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/flagsmith/","title":"Integrate gitStream with Flagsmith","text":""},{"location":"integrations/flagsmith/#label-flagsmith-feature-flags","title":"Label Flagsmith Feature Flags","text":"

Automatically label code that contians specified feature flags.

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in feature_flags %}\nlabel_ff_flagsmith_{{ item.name }}:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/flagsmith.hasFeature\\(/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ item.name }}\ncolor: {{ colors.yellow }}\n{% endfor %}\nfeature_flags:\n- name: engineering_rollback_plan_activated regex: r/engineering_rollback_plan_activated/\n- name: marketing_premium_plan_features_unlocked regex: r/marketing_premium_plan_features_unlocked/\n- name: mobile_push_notifications_enabled\nregex: r/mobile_push_notifications_enabled/\ncolors:\nyellow: 'ffb300'   
Download this example as a CM file."},{"location":"integrations/flagsmith/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/github-actions/","title":"Integrate gitStream with GitHub Actions","text":""},{"location":"integrations/github-actions/#dispatch-github-actions","title":"Dispatch GitHub Actions","text":"

Automatically trigger GitHub Actions based on PR content like changed resources, source or target branch, slash commands, and more.

By BranchUsing LabelsBy Modified Resources

Configuration Description

Conditions (all must be true):

  • The PR source or target branch matches a specified format.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions by Branch

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n- commit\nautomations:\n{% for item in pipelines %}\n# Change pr.target to branch.name if you want to trigger on the source branch rather then the target branch.\ndispatch_github_action_{{ item.name }}:\nif:\n- {{ pr.target | includes(term=item.branch_prefix) }}\nrun:\n- action: run-github-workflow@v1\nargs:\nworkflow: .github/workflows/{{ item.workflow }}\ncheck_name: {{ item.name }}\n- action: add-label@v1\nargs:\nlabel: {{ item.label }}\n{% endfor %}\npipelines:\n- name: mobile_ci\nlabel: Mobile CI branch_prefix: 'mobile-'\nworkflow: mobile.yml\n- name: backend_ci\nlabel: Backend CI branch_prefix: 'backend-'\nworkflow: 'backend.yml'\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • The PR has one or more specified labels applied to it.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions Using Labels

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- label_added\n- label_removed\nautomations:\n{% for item in pipelines %}\ndispatch_github_action_{{ item.name }}:\nif:\n- {{ pr.labels | match(term=item.label) | some }}\nrun:\n- action: run-github-workflow@v1\nargs:\nworkflow: .github/workflows/{{ item.workflow }}\ncheck_name: {{ item.name }}\n{% endfor %}\npipelines:\n- name: mobile-ci\nlabel: Mobile CI workflow: mobile.yml\n- name: backend-ci\nlabel: Backend CI workflow: 'backend.yml'\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • The PR modifies one or more specified resources.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions Based on Modified Resources

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n- commit\nautomations:\n{% for item in pipelines %}\ndispatch_github_action_{{ item.name }}:\nif:\n- {{ files | match(list=item.resources) | some }}\nrun:\n- action: run-github-workflow@v1\nargs:\nworkflow: .github/workflows/{{ item.workflow }}\ncheck_name: {{ item.name }}\n- action: add-label@v1\nargs:\nlabel: {{ item.label }}\n{% endfor %}\npipelines:\n- name: mobile-ci\nlabel: Mobile CI resources:\n- 'src/android/'\n- 'src/ios/'\nworkflow: mobile.yml\n- name: backend-ci\nlabel: Backend CI resources:\n- 'src/api/'\n- 'src/services'\nworkflow: 'backend.yml'\n- name: frontend-ci\nlabel: Frontend CI\nresources:\n- 'src/app/'\nworkflow: 'frontend.yml'\n
Download this example as a CM file.

"},{"location":"integrations/github-actions/#skip-github-actions","title":"Skip GitHub Actions","text":"

Automatically skip GitHub Actions based on branch names, modified resource, slash commands, and more.

Prerequisite Config for Required Statuses

If you want to skip a required status check, you will need to make sure that your branch protection is configured to allow gitStream to bypass status check requirements.

By BranchUsing LabelsBy Modified Resource

Configuration Description

Conditions (all must be true):

  • The target branch name includes a specified keyword. Optionally, you can modify this to detect the source branch name.

Automation Actions:

  • Skip the specified CI pipelines.

Automatically Skip GitHub Actions by Branch

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n- commit\n# Optionally, you can change pr.target to branch.name\n# if you want to trigger based on the source branch name rather then the target branch name.\nautomations:\nskip_github_action_branch:\nif:\n- {{ pr.target | includes(term='release') }}\nrun:\n- action: add-github-check@v1\nargs:\ncheck_name: staging-ci\nconclusion: skipped\n- action: add-comment@v1\nargs:\ncomment: |\n[gitStream](https://docs.gitstream.cm) automatically skipped staging CI pipelines because this PR targets the release branch.\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • Someone applies one or more specified labels to a PR.

Automation Actions:

  • Skip the specified CI pipelines.

Use Labels to Automatically Skip GitHub Actions

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- label_added\n- label_removed\nautomations:\nskip_github_action_label:\nif:\n- {{ pr.labels | match(term='experimental') | some }}\nrun:\n- action: add-github-check@v1\nargs:\ncheck_name: production-ci\nconclusion: skipped\n- action: add-comment@v1\nargs:\ncomment: |\n[gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this is labeled for experimental release.\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • A PR modifies specific files or directories.

Automation Actions:

  • Skip a specified GitHub Action.

Automatically Skip GitHub Actions Based on Modified Resources

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n- commit\nautomations:\nskip_github_action_resource:\nif:\n- {{ files | match(term='docs/') | every }}\nrun:\n- action: add-github-check@v1\nargs:\ncheck_name: release-ci\nconclusion: skipped\n- action: add-github-check@v1\nargs:\ncheck_name: mobile-ci\nconclusion: skipped\n- action: add-comment@v1\nargs:\ncomment: |\n[gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this PR only contains docs changes.\n
Download this example as a CM file.

"},{"location":"integrations/github-actions/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/github-copilot/","title":"Integrate gitStream with GitHub Copilot","text":""},{"location":"integrations/github-copilot/#automatically-label-copilot-assisted-prs","title":"Automatically Label Copilot-Assisted PRs","text":"

Automatically apply labels to PRs that are assisted by GitHub Copilot. You can apply labels based on a known list of Copilot users, PR tags, or by prompting the PR author to indicate if they used Copilot.

Label by PromptLabel by Known UsersLabel by Tag

Prompt PR authors to indicate if they used Copilot for the PR and automatically label the PR if they did. This requires two separate automation files to handle posting the prompt and labeling accordingly.

Configuration Description

Conditions:

  • A PR is created

Automation Actions:

  • Post a comment prompting the author to indicate if Copilot assisted the author with writing the code in the PR.

Ask the PR author about Copilot usage.

-*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\nautomations:\ncomment_copilot_prompt:\n# Post a comment for all PRs to prompt the PR author to indicate whether they used Copilot to assist coding in this PR\nif:\n- true\nrun:\n- action: add-comment@v1\nargs:\ncomment: |\nPlease mark whether you used Copilot to assist coding in this PR\n- [ ] Copilot Assisted\n- [ ] Not Copilot Assisted\n
Download this example as a CM file.

Configuration Description

Conditions:

  • A PR is updated or merged where the author indicates they used Copilot via a prompt.

Automation Actions:

  • Apply a \ud83e\udd16 Copilot label to the PR

Label PRs where the user indicated Copilot usage

-*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# You should use this automation in conjunction with comment_copilot_prompt.cm\nlabel_copilot_pr:\n# If the PR author has indicated that they used Copilot to assist coding in this PR, \n# apply a label indicating the PR was supported by Copilot\nif:\n- {{ pr.comments | filter(attr='commenter', term='gitstream-cm') | filter (attr='content', regex=r/\\- \\[x\\] Copilot Assisted/) | some}}\nrun:\n- action: add-label@v1\nargs:\nlabel: '\ud83e\udd16 Copilot'\n
Download this example as a CM file.

Automatically apply labels to PRs that are created by known users of generative AI coding tools.

Configuration Description

Conditions:

  • The PR author is one of a specified list of contributors

Automation Actions:

  • Apply a \ud83e\udd16 Copilot label to the PR

Label by Contributors

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_genai:\n# For all PRs authored by someone who is specified in the genai_contributors list\nif:\n- {{ pr.author | match(list=genai_contributors) | some  }}\n# Apply a label indicating the user has adopted Copilot\nrun:\n- action: add-label@v1\nargs:\nlabel: '\ud83e\udd16 Copilot'\ngenai_contributors:\n- username1\n- username2\n- etc\n
Download this example as a CM file.

Look for a specific tag in the PR title, description, comments or commit messages and if found add a label to the PR

Configuration Description

Conditions:

  • The #copilot# tag is found in any of the PR title, description, comments or commit messages for commits in the PR

Automation Actions:

  • Apply a \ud83e\udd16 Copilot label to the PR

Label Copilot by Tag

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- comment_added\n- commit\n- pr_created\nautomations:\nlabel_copilot:\n# Detect PRs that contain the text '#copilot#' in the title, description, comments, or commit messages\nif:\n- {{ copilot_tag.pr_title or copilot_tag.pr_desc or copilot_tag.pr_comments or copilot_tag.commit_messages  }}\n# Apply a label indicating the user has adopted Copilot\nrun:\n- action: add-label@v1\nargs:\nlabel: '\ud83e\udd16 Copilot'\ncopilot_tag:\npr_title: {{ pr.title | includes(regex=r/#copilot#/) }}\npr_desc: {{pr.description | includes(regex=r/#copilot#/) }}\npr_comments: {{ pr.comments | map(attr='content') | match(regex=r/#copilot#/) | some }}\ncommit_messages: {{ branch.commits.messages | match(regex=r/#copilot#/) | some }}\n
Download this example as a CM file.

"},{"location":"integrations/github-copilot/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/godoc/","title":"Integrate gitStream with Godoc","text":""},{"location":"integrations/godoc/#review-godoc-changes","title":"Review Godoc Changes","text":"

Approve PRs that only contain changes to Godoc and assign optional reviewers.

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to Godoc content.

Automation Actions:

  • Assign the org/tech-writers team for optional review.
  • Apply a green \ud83d\udcd3 Godoc Only label
  • Approve the PR

Review Godoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Assign PRs that only affect godocs to the technical writing team and add docs label\nreview_godoc:\nif:\n- {{ source.diff.files | match(attr='diff', regex=r/^\\/\\/.*/) | every }}\n- {{ files | extensions | match(regex=r/go/) | every }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\ud83d\udcd3godoc Only\"\ncolor: {{ colors.green }}\n- action: add-reviewers@v1\nargs:\nreviewers: [org/tech-writers]\n- action: approve@v1\ncolors:\ngreen: '0e8a16'\n
Download this example as a CM file."},{"location":"integrations/godoc/#enforce-godoc-requirements-for-new-classes","title":"Enforce Godoc Requirements for New Classes","text":"

Require Godoc for all new Golang classes.

Configuration Description

Conditions (all must be true):

  • The PR creates a new Golang class.
  • The PR lacks Godoc content.

Automation Actions:

  • Request changes and post a comment explaining that Godoc is required
  • Apply a yellow \u26a0\ufe0f Missing Godoc label.

Enforce Godoc for New Golang Classes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_godoc_new_class: if:  - {{ is.go and is.new }} - {{ source.diff.files | match(attr='diff', regex=r/\\/*[\\s\\S]*?\\//) | nope }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing godoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | godoc is required for all Golang classes. Please add godoc to all new classes in this PR.\nis:\ngo: {{ files | extensions | match(regex=r/go/) | every }}\nnew: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"integrations/godoc/#review-godoc-for-large-changes","title":"Review Godoc for Large changes","text":"

Require more extensive reviews for large Golang changes that lack Godoc updates.

Configuration Description

Conditions (all must be true):

  • The PR changes more than 100 lines of Golang code.

Automation Actions:

  • Post a comment asking the author to review all relevant Godoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow \u26a0\ufe0f Missing Godoc Label

Review Godoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Require more extensive reviews for large Golang changes that lack Godoc updates.\nreview_godoc_large:\nif:\n- {{ changes.additions > 100}}\n- {{ source.diff.files | matchDiffLines(regex=r/^\\/\\/.*/) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Godoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | This PR makes major changes to Golang classes, but is missing updates to Godoc. Please double check for any necessary Godoc updates.\n- action: add-reviewers@v1\nargs:\nreviewers: [fourth-organization/tech-writers]\nchanges:\n# Sum all the lines added/edited in the PR\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"integrations/godoc/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"integrations/javadoc/","title":"Integrate gitStream with Javadoc","text":"

Javadoc Examples:

  • Review Javadoc Changes
  • Review Java Input Parameters for Javadoc Changes
  • Review Javadoc for Large Changes
  • Enforce Javadoc Requirements for New Classes

"},{"location":"integrations/javadoc/#review-javadoc-changes","title":"Review Javadoc Changes","text":""},{"location":"integrations/javadoc/#review-javadoc-changes_1","title":"Review Javadoc Changes","text":"

Unblock PRs that only change Javadoc content.

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to Javadoc content.

Automation Actions:

  • Assign the org/tech-writersteam for optional review.
  • Apply a green \ud83d\udcd3 Javadoc Only label
  • Approve the PR

Review Javadoc Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# Assign PRs that only affect JavaDocs to the technical writing team and add docs label\nreview_javadoc:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/\\/*\\*([\\s\\S]*?)\\//) | every }}\n- {{ source.diff.files | matchDiffLines(regex=r/\\b(public|protected|private|static|final|synchronized)?\\s+\\w+\\s+\\w+\\s*\\(([^)]*)\\)\\s*\\{/) | nope }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\ud83d\udcd3 Javadoc Only\"\ncolor: {{ colors.green }}\n- action: add-reviewers@v1\nargs:\nreviewers: [org/tech-writers]\n- action: approve@v1\ncolors:\ngreen: '0e8a16'\n
Download this example as a CM file.

"},{"location":"integrations/javadoc/#review-java-input-parameters-for-javadoc-changes","title":"Review Java Input Parameters for Javadoc Changes","text":""},{"location":"integrations/javadoc/#review-java-input-parameters-for-javadoc-changes_1","title":"Review Java Input Parameters for Javadoc Changes","text":"

If a PR modifies the input parameters for a Java method, but not the associated Javadocs, notify reviewers to check for Javadoc updates.

Configuration Description

Conditions (all must be true):

  • The PR changes one or more input parameters in Java methods.
    • Note: This may not trigger for methods with annotations, methods that throw exceptions, multi-line method definitions, and other non-standard use cases.
  • The PR lacks changes to \u2018@param\u2019 declarations.

Automation Actions:

  • Post a comment warning the user to review the method\u2019s Javadoc to identify necessary updates.

Review Javadoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_javadoc_input_parameters: if:  - {{ source.diff.files | matchDiffLines(regex=r/\\*\\s@param/) | nope }}\n- {{ source.diff.files | matchDiffLines(regex=r/\\b(public|protected|private|static|final|synchronized)?\\s+\\w+\\s+\\w+\\s*\\(([^)]*)\\)\\s*\\{/) | some }}\nrun:\n- action: add-comment@v1\nargs: comment: | This PR modifies method input parameters, but is missing Javadoc changes. Please check to ensure no Javadoc changes are necessary.\n
Download this example as a CM file.

"},{"location":"integrations/javadoc/#review-javadoc-for-large-changes","title":"Review Javadoc for Large Changes","text":""},{"location":"integrations/javadoc/#review-javadoc-for-large-changes_1","title":"Review Javadoc for Large Changes","text":"

Require more extensive reviews for large Java changes that lack Javadoc updates.

Configuration Description

Conditions (all must be true):

  • The PR changes more than 25% of a Java class.
  • The PR lacks Javadoc changes.

Automation Actions:

  • Post a comment asking the author to review all relevant Javadoc to identify necessary updates.
  • Require a review from the my-organization/tech-writers team.
  • Apply a yellow \u26a0\ufe0f Missing Javadoc Label

Review Javadoc for Large Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Require more extensive reviews for large Java changes that lack Javadoc updates.\nreview_javadoc_large:\nif:\n- {{ changes.ratio > 25}}\n- {{ source.diff.files | matchDiffLines(regex=r/\\/*\\*([\\s\\S]*?)\\//) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Javadoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | This PR makes major changes to Java classes, but is missing updates to Javadoc. Please double check for any necessary Javadoc updates.\n- action: add-reviewers@v1\nargs:\nreviewers: [fourth-organization/tech-writers]\nchanges:\n# Sum all the lines added/edited in the PR\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\n# Sum all the line removed in the PR\ndeletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}\n# Calculate the ratio of new code\nratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file.

"},{"location":"integrations/javadoc/#enforce-javadoc-requirements-for-new-classes","title":"Enforce Javadoc Requirements for New Classes","text":""},{"location":"integrations/javadoc/#enforce-javadoc-requirements-for-new-classes_1","title":"Enforce Javadoc Requirements for New Classes","text":"

Automatically request changes when someone creates a new Java class that lacks Javadoc content.

Configuration Description

Conditions (all must be true):

  • The PR creates a new Java class.
  • The PR lacks Javadoc content.

Automation Actions:

  • Apply a \u26a0\ufe0f Missing Javadoc label.
  • Request changes, and post a comment explaining that Javadoc is required

Review Javadoc Requirements for New Classes

manifest:\nversion: 1.0\nautomations:\nreview_new_class_javadoc:\n# Triggered for new Java files that lack Javadoc content.\nif:\n- {{ is.java and is.new }}\n- {{ source.diff.files | matchDiffLines(regex=r/\\/*\\*([\\s\\S]*?)\\//) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Javadoc\"\ncolor: {{ colors.yellow }}\n- action: request-changes@v1\nargs:\ncomment: | This PR creates new Java classes, but is missing updates to Javadoc. Please double check for any necessary Javadoc updates.\nis:\njava: {{ files | extensions | match(term='java') | every }}\nnew: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file.

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"integrations/jit/","title":"Integrate gitStream with Jit","text":"

Included with gitStream Core Functionality

This integration is part of gitStream core functionality, and requires no additional configuration.

Jit Examples:

  • Review Jit Alerts
  • Review Jit Secret Detections
  • Label Jit Alerts
  • Review Jit Ignore and Accept Risk

"},{"location":"integrations/jit/#review-jit-security-alerts","title":"Review Jit Security Alerts","text":""},{"location":"integrations/jit/#review-jit-security-alerts_1","title":"Review Jit Security Alerts","text":"

Manage review assignment for high and medium risk Jit security alerts.

Configuration Description

**Review Jit High Alerts**\n\n* Conditions (all must be true):\n    * Jit reports one or more high vulnerabilities for the PR\n* Automation Actions:\n    * Require a review from the organization\u2019s security team.\n    * Require 2 reviewers.\n    * Post a comment explaining why this action was taken.\n\n**Review Jit Medium Alerts**\n\n* Conditions (all must be true):\n    * Jit reports one or more medium vulnerabilities for the PR\n* Automation Actions:\n    * Require 2 reviewers\n    * Post a comment explaining why this action was taken.\n

Review Jit Security Alerts

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_jit_high_alerts:\nif:\n- {{ jit.metrics.HIGH > 0 }}\nrun:\n- action: require-reviewers@v1\nargs:\nreviewers: [my-organization/security-team]\n- action: set-required-approvals@v1\nargs:\napprovals: 2\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR requires additional review because Jit reported one or more high risk vulnerabilities.\nreview_jit_medium_alerts:\nif:\n- {{ jit.metrics.MEDIUM > 0 }}\nrun:\n- action: set-required-approvals@v1\nargs:\napprovals: 2\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR requires additional reviewers because Jit reported one or more medium risk vulnerabilities.\njit: {{ pr | extractJitFindings }}\n
Download this example as a CM file.

"},{"location":"integrations/jit/#review-jit-secret-detection","title":"Review Jit Secret Detection","text":""},{"location":"integrations/jit/#review-jit-secret-detection_1","title":"Review Jit Secret Detection","text":"

Close PRs where Jit detects a secret and post a comment explaining steps to remedy the situation.

Configuration Description

Conditions (all must be true):

  • Jit detects a secret in the PR.

Automation Actions:

  • Close the PR
  • Post a comment explaining why this action was taken and to outline the necessary steps to remedy the situation.

Review Jit Security Control

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_jit_secret:\nif:\n- true\n- {{ jit.vulnerabilities | match(attr='security_control', term='Secret Detection') | some }}\nrun:\n- action: add-comment@v1\nargs: comment: |\nJit detects secrets in this PR. Please complete the following steps:\n1. Undo the commit with git reset and remove all secrets from the files you modified.\n2. Deactivate the secret in any locations its used and replace it with a new key\n3. Commit your changes and resubmit your PR.\n- action: close@v1\njit: {{ pr | extractJitFindings }}\n
Download this example as a CM file.

"},{"location":"integrations/jit/#label-jit-alerts","title":"Label Jit Alerts","text":""},{"location":"integrations/jit/#label-jit-alerts_1","title":"Label Jit Alerts","text":"

Label the number of high, medium, and low risk vulnerabilities Jit reports for PRs.

Configuration Description

Conditions (all must be true):

  • Jit reports one or more high, medium, or low risk security vulnerabilities for the PR.

Automation Actions:

  • Apply labels to indicate the number of each type of vulnerability

Label Jit Alerts

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in reports %}\nlabel_jit_{{ item.name }}:\nif:\n- {{ item.count > 0}}\nrun:\n- action: add-label@v1\nargs:\nlabel: 'Jit: {{ item.count }} {{ item.name }} vulnerabilities'\ncolor: {{ colors.red if (item.name == 'high') else (colors.orange if (item.name == 'medium' ) else colors.yellow) }}\n{% endfor %}\njit: {{ pr | extractJitFindings }}\nreports:\n- name: high\ncount: {{ jit.metrics.HIGH }}\n- name: medium\ncount: {{ jit.metrics.MEDIUM }}\n- name: low\ncount: {{ jit.metrics.LOW }}\ncolors:\nred: 'b60205'\norange: 'd93f0b'\nyellow: 'fbca04'\n
Download this example as a CM file.

"},{"location":"integrations/jit/#review-jit-ignore-and-accept","title":"Review Jit Ignore and Accept","text":""},{"location":"integrations/jit/#review-jit-ignore-and-accept_1","title":"Review Jit Ignore and Accept","text":"

Notify your Security team when someone ignores a Jit vulnerability report and accepts the risk.

Configuration Description

Conditions (all must be true):

  • Someone ignores and accepts a Jit finding

Automation Actions:

  • Request review from the organization\u2019s security team.
  • Label the PR to indicate someone accepted the risk of a Jit security alert.
  • Post a comment explaining why this action was taken.

Review Jit Ignore and Accept

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_jit_ignore_accept:\nif:\n- {{ pr.conversations | reject(attr='commenter', term='jit-ci') | filter(attr='content', term='#jit_ignore_accept') | some }}\nrun:\n- action: add-reviewers@v1\nargs:\nreviewers: [my-organziation/security]\n- action: add-label@v1\nargs:\nlabel: '\u2755 Jit: Ignore - Accept Risk'\n- action: add-comment@v1\nargs:\ncomment: |\nThe security team has been assigned for optional review because this PR ignores a Jit alert and accepts the associated risks.\njit: {{ pr | extractJitFindings }}\n
Download this example as a CM file."},{"location":"integrations/jsdoc/","title":"Integrate gitStream with JSDoc","text":"

JSDoc Examples:

  • Review JSDoc Changes
  • Review JavaScript Input Parameters for JSDoc Changes
  • Review JSDoc for Large Changes
  • Enforce JSDoc Requirements for New Classes

"},{"location":"integrations/jsdoc/#review-jsdoc-changes","title":"Review JSDoc Changes","text":""},{"location":"integrations/jsdoc/#review-jsdoc-changes_1","title":"Review JSDoc Changes","text":"

Approve PRs that only contain changes to JSDoc and assign optional reviewers.

Configuration Description

Conditions (all must be true):

  • The PR only affects JavaScript and TypeScript files
  • The PR only contains changes to JSDoc content.

Automation Actions:

  • Assign the ORG/tech-writers team.
  • Apply a green \ud83d\udcd3 JSDoc Only label
  • Approve the PR

Review JSDoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Assign PRs that only affect JSDocs to the technical writing team and add docs label\nreview_jsdoc:\nif:\n- {{ source.diff.files | match(attr='diff', regex=r/\\/*\\*[\\s\\S]*?\\//) | every }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\ud83d\udcd3JSDoc Only\"\ncolor: {{ colors.green }}\n- action: add-reviewers@v1\nargs:\nreviewers: [fourth-organization/tech-writers]\n- action: approve@v1\ncolors:\ngreen: '0e8a16'\n
Download this example as a CM file.

"},{"location":"integrations/jsdoc/#review-jsdoc-input-parameters","title":"Review JSDoc Input Parameters","text":""},{"location":"integrations/jsdoc/#review-jsdoc-input-parameters_1","title":"Review JSDoc Input Parameters","text":"

Warn PR authors when they change JavaScript function or constructor input parameters without updating JSDoc content.

Configuration Description

Conditions (all must be true):

  • The PR changes an input parameter in one or more JavaScript methods.
  • The PR lacks changes to \u2018@param\u2019 declarations.

Automation Actions:

  • Post a comment warning the user to review the method\u2019s JSDoc to identify necessary updates.

Review JSDoc Input Parameters

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_jsdoc_input: if:  - {{ source.diff.files | matchDiffLines(regex=r/.*\\s@param/) | nope }}\n- {{ source.diff.files | matchDiffLines(regex=r/\\((?:.*\\:.*\\))/) | some }}\nrun:\n- action: add-comment@v1\nargs: comment: | This PR appears to modify method input parameters, but is missing JSDoc changes. Please check to ensure no JSDoc changes are necessary.\n
Download this example as a CM file.

"},{"location":"integrations/jsdoc/#review-jsdoc-for-large-changes","title":"Review JSDoc for Large Changes","text":""},{"location":"integrations/jsdoc/#review-jsdoc-for-large-changes_1","title":"Review JSDoc for Large Changes","text":"

Require more extensive reviews for large JavaScript changes that lack JSDoc updates.

Configuration Description

Conditions (all must be true):

  • The PR changes more than 25% of a JavaScript class.

Automation Actions:

  • Post a comment asking the author to review all relevant JSDoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow \u26a0\ufe0f Missing JSDoc Label

Review JSDoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Require more extensive reviews for large Javascript changes that lack JSDoc updates.\nreview_jsdoc_large:\nif:\n- {{ changes.ratio > 25}}\n- {{ source.diff.files | matchDiffLines(regex=r/\\/*\\*([\\s\\S]*?)\\//) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f No JSDoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | This PR makes major changes to JavaScript classes, but is missing updates to JSDoc. Please double check for any necessary JSDoc updates.\n- action: add-reviewers@v1\nargs:\nreviewers: [fourth-organization/tech-writers]\nchanges:\n# Sum all the lines added/edited in the PR\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\n# Sum all the line removed in the PR\ndeletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}\n# Calculate the ratio of new code\nratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file.

"},{"location":"integrations/jsdoc/#enforce-jsdoc-for-new-javascript-classes","title":"Enforce JSDoc for New JavaScript Classes","text":""},{"location":"integrations/jsdoc/#enforce-jsdoc-for-new-javascript-classes_1","title":"Enforce JSDoc for New JavaScript Classes","text":"

Require JSDoc for all new JavaScript classes.

Configuration Description

Conditions (all must be true):

  • The PR creates a new JavaScript class.
  • The PR lacks JSDoc content.

Automation Actions:

  • Request changes and post a comment explaining that JSDoc is required
  • Apply a yellow \u26a0\ufe0f Missing JSDoc label.

Enforce JSDoc for New JavaScript Classes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_jsdoc_new_class: if:  - {{ is.javascript and is.new }} - {{ source.diff.files | matchDiffLines(regex=r/\\/*\\*([\\s\\S]*?)\\//) | nope }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing JSDoc\"\ncolor: {{ colors.yellow }}\n- action: request-changes@v1\nargs: comment: | JSDoc is required for all JavaScript classes. Please add JSDoc to all new classes in this PR.\nis:\njavascript: {{ files | extensions | match(list=['js', 'ts']) | every }}\nnew: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file.

Special thanks to Boemo W Mmopelwa for help with these examples.

"},{"location":"integrations/launch-darkly/","title":"Integrate gitStream with Launch Darkly","text":""},{"location":"integrations/launch-darkly/#label-launch-darkly-feature-flags","title":"Label Launch Darkly Feature Flags","text":"

Automatically label code that contians specified feature flags.

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in feature_flags %}\nlabel_ff_launchdarkly_{{ item.name }}:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/var flagValue = ldclient/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ item.name }}\ncolor: {{ colors.yellow }}\n{% endfor %}\nfeature_flags:\n- name: engineering_rollback_plan_activated regex: r/engineering_rollback_plan_activated/\n- name: marketing_premium_plan_features_unlocked regex: r/marketing_premium_plan_features_unlocked/\n- name: mobile_push_notifications_enabled\nregex: r/mobile_push_notifications_enabled/\ncolors:\nyellow: 'ffb300'   
Download this example as a CM file."},{"location":"integrations/launch-darkly/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/linearb/","title":"Integrate gitStream with LinearB","text":"

LinearB is a software delivery management platform that makes it easy to benchmark your engineering organization, track engineering metrics and identify opportunities for improvement.

"},{"location":"integrations/linearb/#track-the-impact-of-generative-ai-initiatives","title":"Track the Impact of Generative AI Initiatives","text":"

These examples show how to label PRs that are assisted by GitHub Copilot so you can easily track productivity within LinearB. These examples can be adapted for any other generative AI solutions you might use.

Automatically apply labels to PRs that are assisted by GitHub Copilot. You can apply labels based on a known list of Copilot users, PR tags, or by prompting the PR author to indicate if they used Copilot.

Label by PromptLabel by Known UsersLabel by Tag

Prompt PR authors to indicate if they used Copilot for the PR and automatically label the PR if they did. This requires two separate automation files to handle posting the prompt and labeling accordingly.

Configuration Description

Conditions:

  • A PR is created

Automation Actions:

  • Post a comment prompting the author to indicate if Copilot assisted the author with writing the code in the PR.

Ask the PR author about Copilot usage.

-*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\nautomations:\ncomment_copilot_prompt:\n# Post a comment for all PRs to prompt the PR author to indicate whether they used Copilot to assist coding in this PR\nif:\n- true\nrun:\n- action: add-comment@v1\nargs:\ncomment: |\nPlease mark whether you used Copilot to assist coding in this PR\n- [ ] Copilot Assisted\n- [ ] Not Copilot Assisted\n
Download this example as a CM file.

Configuration Description

Conditions:

  • A PR is updated or merged where the author indicates they used Copilot via a prompt.

Automation Actions:

  • Apply a \ud83e\udd16 Copilot label to the PR

Label PRs where the user indicated Copilot usage

-*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n# You should use this automation in conjunction with comment_copilot_prompt.cm\nlabel_copilot_pr:\n# If the PR author has indicated that they used Copilot to assist coding in this PR, \n# apply a label indicating the PR was supported by Copilot\nif:\n- {{ pr.comments | filter(attr='commenter', term='gitstream-cm') | filter (attr='content', regex=r/\\- \\[x\\] Copilot Assisted/) | some}}\nrun:\n- action: add-label@v1\nargs:\nlabel: '\ud83e\udd16 Copilot'\n
Download this example as a CM file.

Automatically apply labels to PRs that are created by known users of generative AI coding tools.

Configuration Description

Conditions:

  • The PR author is one of a specified list of contributors

Automation Actions:

  • Apply a \ud83e\udd16 Copilot label to the PR

Label by Contributors

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_genai:\n# For all PRs authored by someone who is specified in the genai_contributors list\nif:\n- {{ pr.author | match(list=genai_contributors) | some  }}\n# Apply a label indicating the user has adopted Copilot\nrun:\n- action: add-label@v1\nargs:\nlabel: '\ud83e\udd16 Copilot'\ngenai_contributors:\n- username1\n- username2\n- etc\n
Download this example as a CM file.

Look for a specific tag in the PR title, description, comments or commit messages and if found add a label to the PR

Configuration Description

Conditions:

  • The #copilot# tag is found in any of the PR title, description, comments or commit messages for commits in the PR

Automation Actions:

  • Apply a \ud83e\udd16 Copilot label to the PR

Label Copilot by Tag

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- comment_added\n- commit\n- pr_created\nautomations:\nlabel_copilot:\n# Detect PRs that contain the text '#copilot#' in the title, description, comments, or commit messages\nif:\n- {{ copilot_tag.pr_title or copilot_tag.pr_desc or copilot_tag.pr_comments or copilot_tag.commit_messages  }}\n# Apply a label indicating the user has adopted Copilot\nrun:\n- action: add-label@v1\nargs:\nlabel: '\ud83e\udd16 Copilot'\ncopilot_tag:\npr_title: {{ pr.title | includes(regex=r/#copilot#/) }}\npr_desc: {{pr.description | includes(regex=r/#copilot#/) }}\npr_comments: {{ pr.comments | map(attr='content') | match(regex=r/#copilot#/) | some }}\ncommit_messages: {{ branch.commits.messages | match(regex=r/#copilot#/) | some }}\n
Download this example as a CM file.

"},{"location":"integrations/linearb/#label-changes-to-track-in-linearb","title":"Label Changes to Track in LinearB","text":"

These examples show how to label PRs based on the changed code so you can more easily compare metrics across languages, frameworks, changed directories, and more.

by Modified Resourceby Language

Automatically label PRs to indicate what resources are being changed.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Apply labels based on the branch name or modified resources.

Label Modified Resources

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in labels %}\nlabel_resource_{{ item.name }}:\nif:\n-{{ branch.name | includes(regex=item.branch) or files | match(list=item.resources) }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ item.name }}\n{% endfor %}\nlabels:\n- name: Core\nresources:\n- src/app\nbranch: r/^core-/\n- name: mobile\nresources:\n- src/android\n- src/ios\nbranch: r/^mobile-/\n
Download this example as a CM file.

Automatically detect which programming languages are contained in PRs and automatically label the PRs appropriately.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • Label the PR for each programming language that is included.

Label PRs by Language

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in labels %}\nlabel_{{ item.name }}_pr:\nif:\n- {{ files | match(regex=item.resources) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: '{{ item.name }}'\n{% endfor %}\nlabels:\n- name: Java\nresources: r/.java$/\n- name: Rust\nresources: r/.rs$/\n- name: HTML\nresources: r/.html$/\n- name: JavaScript\nresources: r/.js$/\n- name: Python\nresources: r/.py$/\n- name: Golang\nresources: r/.go$/\n- name: Ruby\nresources: r/.rb$/\n- name: CSS\nresources: r/.css/\n
Download this example as a CM file.

"},{"location":"integrations/linearb/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/orca-security/","title":"Integrate gitStream with Orca Security","text":""},{"location":"integrations/orca-security/#auto-label-orca-security-scan-results","title":"Auto-Label Orca Security Scan Results","text":"

Automatically apply labels to PRs that indicate the result of Orca Security scans.

Required gitStream Plugin

This example requires you to install the extractOrcaFindings plugin.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • Orca Security detects one or more issues with the code in the PR.

Automation Actions:

  • Apply a label that indicates which issue was identified.

Auto-Label Orca Scan Results

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in reports %}\nlabel_orca_{{ item.name }}:\nif:\n- {{ item.count > 0 }}\nrun:\n- action: add-label@v1\nargs:\nlabel: 'orca:{{ item.name }}'\n{% endfor %}\norca: {{ pr | extractOrcaFindings }}\nreports:\n- name: introduced-cves\ncount: {{ orca.vulnerabilities.count }}\n- name: iac-misconfigurations\ncount: {{ orca.infrastructure_as_code.count }}\n- name: exposed-secrets count: {{ orca.secrets.count }}\ncolors:\nred: 'b60205'\n
Download this example as a CM file."},{"location":"integrations/orca-security/#require-security-review-for-orca-violations","title":"Require Security Review for Orca Violations","text":"

Automatically require review from your SecOps team for Orca Security violations in pull requests.

Configuration Description

Conditions (all must be true):

  • The PR contains a vulnerability, IAC problem, or secret that is flagged as High or Medium.

Automation Actions:

  • Require review from your organization's security team.
  • Post a comment explaining the requirement.

Review Orca Security Alerts

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_orca_alerts:\nif:\n- {{ has.vulnerability or has.iac_violation or has.secret }}\nrun:\n- action: require-reviewers@v1\nargs:\nreviewers: [my-organization/security-team]\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR requires additional review because it fails to meet Orca Security safe code standards.\norca: {{ pr | extractOrcaFindings }}\nhas:\nvulnerability: {{ orca.vulnerabilities.priority == 'High' or orca.vulnerabilities.priority == 'Medium' }}\niac_violation: {{ orca.infrastructure_as_code.priority == 'High' or orca.infrastructure_as_code.priority == 'Medium' }}\nsecret: {{ orca.secrets.priority == 'High' or orca.secrets.priority == 'Medium' }}\n
Download this example as a CM file."},{"location":"integrations/orca-security/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/rdoc/","title":"Integrate gitStream with RDoc","text":"

Integrate gitStream with RDoc: a documentation generation framework for Ruby.

"},{"location":"integrations/rdoc/#review-rdoc-changes","title":"Review RDoc Changes","text":"

Approve PRs that only contain changes to RDoc and assign optional reviewers.

Configuration Description

Conditions (all must be true):

  • The PR only contains changes to RDoc content.

Automation Actions:

  • Assign the org/tech-writers team for optional review.
  • Apply a green \ud83d\udcd3 RDoc Only label
  • Approve the PR

Review RDoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_rdoc:\nif:\n- {{ source.diff.files | match(attr='diff', regex=r/^[\\s\\t]*#.*/) | every }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\ud83d\udcd3RDoc Only\"\ncolor: {{ colors.green }}\n- action: add-reviewers@v1\nargs:\nreviewers: [org/tech-writers]\n- action: approve@v1\ncolors:\ngreen: '0e8a16'\n
Download this example as a CM file."},{"location":"integrations/rdoc/#enforce-rdoc-requirements-for-new-classes","title":"Enforce RDoc Requirements for New Classes","text":"

Require RDoc for all new Ruby classes.

Configuration Description

Conditions (all must be true):

  • The PR creates a new Ruby class.
  • The PR lacks RDoc content.

Automation Actions:

  • Request changes and post a comment explaining that RDoc is required
  • Apply a yellow \u26a0\ufe0f Missing RDoc label.

Enforce RDoc for New Ruby Classes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_rdoc_new_class: if:  - {{ is.rb and is.new }} - {{ source.diff.files | match(attr='diff', regex=r/(\\#.*\\n.*)*def/) | nope }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing RDoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | RDoc is required for all Ruby classes. Please add documentation for this PR.\nis:\nrb: {{ files | extensions | match(regex=r/rb/) | every }}\nnew: {{ source.diff.files | map(attr='original_file') | match(regex=r/^$/) | some }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"integrations/rdoc/#review-rdoc-for-large-changes","title":"Review RDoc for Large changes","text":"

Require more extensive reviews for large Ruby changes that lack RDoc updates.

Configuration Description

Conditions (all must be true):

  • The PR changes more than 150 lines of Ruby code.

Automation Actions:

  • Post a comment asking the author to review all relevant RDoc to identify necessary updates.
  • Require a review from the ORG/tech-writers team.
  • Apply a yellow \u26a0\ufe0f Missing RDoc Label

Review RDoc

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n#Require more extensive reviews for large Ruby changes that lack RDoc updates.\nreview_rdoc_large:\nif:\n- {{ changes.additions > 150}}\n- {{ source.diff.files | matchDiffLines(regex=r/(\\#.*\\n.*)*def/) | nope }}\nrun: - action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing RDoc\"\ncolor: {{ colors.yellow }}\n- action: add-comment@v1\nargs: comment: | This PR makes major changes to Ruby methods, but is missing updates to RDoc. Please double check for any necessary RDoc updates.\n- action: add-reviewers@v1\nargs:\nreviewers: [fourth-organization/tech-writers]\nchanges:\n# Sum all the lines added/edited in the PR\nadditions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file."},{"location":"integrations/rdoc/#review-rdoc-for-function-parameter-changes","title":"Review RDoc For Function Parameter Changes","text":"

Warn PR authors when they change Ruby function or constructor input parameters without updating RDoc content.

Configuration Description

Conditions (all must be true):

  • The PR changes one or more input parameters in Ruby methods.
  • The PR lacks RDoc updates.

Automation Actions:

  • Post a comment warning the user to review the method\u2019s RDoc to identify necessary updates.

Review RDoc Input Parameters

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_rdoc_input: if:  - {{ source.diff.files | match(attr='diff', regex=r/(\\#.*\\n.*)*def/) | nope }}\n- {{ source.diff.files | match(attr='diff', regex=r/def.*\\(.*\\)/ | some }}\nrun:\n- action: add-comment@v1\nargs: comment: | This PR modifies method input parameters, but is missing RDoc changes. Please check to ensure no RDoc changes are necessary.\n
Download this example as a CM file."},{"location":"integrations/rdoc/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"integrations/renovate/","title":"Integrate gitStream with Mend Renovate","text":""},{"location":"integrations/renovate/#auto-merge-renovate-dependency-updates","title":"Auto-Merge Renovate Dependency Updates","text":"

Auto-merge Renovate PRs

By Release TypeAll Updates

Required gitStream Plugins

This example requires you to install the extractRenovateVersionBump, compareMultiSemver and compareSemver plugins.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • The PR author is Renovate.
  • The branch name includes 'renovate'
  • The dependency change is a patch or minor update.

Automation Actions:

  • Approve the PR
  • Apply an approved-renovate label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

manifest:\nversion: 1.0\nautomations:\nmerge_renovate_minor:\nif:\n- {{ bump == 'minor' }}\n- {{ branch.name | includes(term=\"renovate\") }}\n- {{ branch.author | includes(term=\"renovate\") }}\nrun:\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nRenovate `minor` version bumps are approved automatically.\nmerge_renovate_minor_patch:\nif:\n- {{ bump == 'patch' }}\n- {{ branch.name | includes(term=\"renovate\") }}\n- {{ branch.author | includes(term=\"renovate\") }}\nrun:\n- action: approve@v1\n- action: merge@v1\n- action: add-comment@v1\nargs:\ncomment: |\nRenovate `patch` version bumps are approved and merged automatically.\nbump: {{ pr.description | extractRenovateVersionBump | compareMultiSemver }}\n
Download this example as a CM file.

Configuration Description

Conditions (all must be true):

  • The PR author is Renovate.
  • The branch name includes 'renovate'

Automation Actions:

  • Approve the PR
  • Apply an approved-renovate label to the PR
  • Merge the PR if all status checks pass.

Configuration Example

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_renovate:\nif:\n- {{ branch.author | includes(term=\"renovate\") }}\nrun:\n- action: approve@v1\n- action: add-label@v1\nargs:\nlabel: \"approved-renovate\"\n- action: merge@v1\nargs:\nwait_for_all_checks: true\nsquash_on_merge: true\n
Download this example as a CM file.

"},{"location":"integrations/review-todo-comments/","title":"Automation - Review TODO Comments","text":""},{"location":"integrations/review-todo-comments/#review-todo-comments","title":"Review TODO Comments","text":"

Request changes for a PR that contains a TODO statement.

Configuration Description

Conditions (all must be true):

  • The PR contains a TODO statement

Automation Actions:

  • Request changes and post a comment explaining why.

Review TODO Comments

manifest:\nversion: 1.0\nautomations:\nreview_todo_comments:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/^[+].*(TODO|todo)/) | some }}\nrun:\n- action: request-changes@v1\nargs:\ncomment: |\nThis PR contains a TODO statement. Please check to see if they should be removed.\n
Download this example as a CM file.

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"integrations/shortcut/","title":"Integrate gitStream with Shortcut","text":"

Learn how to integrate gitStream with Shortcut

"},{"location":"integrations/shortcut/#label-missing-shortcut-info","title":"Label Missing Shortcut Info","text":"

Automatically label PRs that are missing references to Shortcut resources.

Configuration Description

Conditions (all must be true):

  • The PR is missing one of the following:
    • An Shortcut ticket reference in the PR title.
    • A link to an Shortcut resource in the PR description.

Automation Actions:

  • Apply a red \u26a0\ufe0f Missing Shortcut Link label
  • Post a comment that asks the author to add an Shortcut reference to the PR.

Label Missing Shortcut

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_missing_shortcut:\nif:\n- {{not (has.shortcut.ticket_in_title or has.shortcut.ticket_in_desc)}}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"\u26a0\ufe0f Missing Shortcut Link\"\ncolor: {{ colors.red }}\n- action: add-comment@v1\nargs:\ncomment: Please provide a link to the associated Shortcut resource.\nhas:\nshortcut:\nticket_in_title: {{ pr.title | includes(regex=r/(\\w+)\\/sc-(\\d+)/) }}\nticket_in_desc: {{ pr.description | includes(regex=r/(app\\.shortcut\\.com)\\/(\\w+)\\/story\\/(\\d+)\\/(\\w+)/) }}\ncolors:\nred: 'b60205'\n
Download this example as a CM file.

"},{"location":"integrations/shortcut/#automatically-link-prs-to-related-shortcut-tasks","title":"Automatically Link PRs to Related Shortcut Tasks","text":"

Provide automatic links to Shortcut tasks that are associated with PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Shortcut card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Shortcut Task.

Automatically Link to the Related Shortcut Task

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n# Configure these to match your organization.\nprovider: jira\n# Change this to match the name of your Shortcut organization. This is used in tracker.shortcut.baseurl\norgName: org\n{% set ticketid = \"\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\nlink_shortcut:\nif:\n- {{ has.ticket_in_title or has.ticket_in_branch }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})\nhas:\nticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}\nticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}\ntracker:\nshortcut:\nbaseurl: https://app.shortcut.com/[orgName]/story/\npattern: r/(\\w+)\\/sc-(\\d+)/\ntickets:\n- {{branch.name | capture(regex=tracker[provider].pattern)}}\n- {{pr.title | capture(regex=tracker[provider].pattern)}}\n
Download this example as a CM file."},{"location":"integrations/shortcut/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/slack/","title":"Integrate gitStream with Slack","text":"

This page demonstrates uses cases for how to connect gitStream to Slack to post messages via webhooks.

"},{"location":"integrations/slack/#prerequisite-configurations","title":"Prerequisite Configurations","text":"

To use gitStream with Slack, you first need to do two things:

  1. Create a Slack app with incoming webhooks enabled.
  2. Provide your Slack webhook URL to gitStream as an organization environment variable.
"},{"location":"integrations/slack/#setup-incoming-webhooks-in-slack","title":"Setup Incoming Webhooks in Slack","text":"

Follow this tutorial to configure your Slack instance to receive webhooks from gitStream.You\u2019ll end up with a webhook URL like this:

https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX\n

Your webhook URL is secret information!

Slack webhook URLs allow anyone with access to the URL to post to the channel its configured for. Do not publish this URL to public locations.

"},{"location":"integrations/slack/#configure-environment-variable","title":"Configure Environment Variable","text":"

gitStream can access GitHub orgnization secrets as environment variables, and you'll need to do this to provide gitStream with access to your Slack webhook URL.

  1. Create an organization secret in GitHub and ensure it isn't being overridden by a repo-level secret of the same name.
  2. Pass the organization secret to gitStream as an environment variable in your gitstream.yml workflow file. We recommend using an easy to understand term like SLACK_WEBHOOK_CHANNEL_NAME.
"},{"location":"integrations/slack/#how-to-send-slack-messages-from-gitstream","title":"How to Send Slack Messages From gitStream","text":"

Example

To send Slack messages from gitStream, use the send-slack-message automation action, and pass the value you stored your Slack webhook URL to the webhook_url argument.

automations:\nsend_slack:\nif:\n- true\nrun:\n- action: send-slack-message@v1\nargs:\nmessage: \"A message sent from GitStream!\"\nwebhook_url: \"{{ env.SLACK_WEBHOOK }}\"\n
"},{"location":"integrations/slack/#auto-recognition-for-meeting-team-goals","title":"Auto-Recognition For Meeting Team Goals","text":"

A good choice to reward developers for submitting great PRs would be to automate a Slack message that gives the developer recognition among their colleagues. To do this, you\u2019ll need to create a Slack webhook that sends to a channel full of reviewers, managers, and anybody else who should see the recognition.

Automatic Slack Recognition

Automatically post positive recognition messages in Slack for well-structured PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains updates to tests.
  • The PR has fewer than 5 modified files.
  • The PR branch references a Jira ticket.
  • The PR has fewer than 150 lines of code changed.

Automation Actions:

  • Post a Slack message that automatically recognizes the PR author and provides a link to the PR.

Automatic Slack Messages

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nslack_auto_recognition:\nif:\n- {{ files | match(regex=r/(test|spec)/) | some }} # this pr has at least 1 test\n- {{ files | length <= 5 }} # this pr has 5 or less files\n- {{ branch.name | includes(regex=r/[A-Z]{2,}-\\d+.*/) }} # this branch has the Jira ticket prefix\n- {{ branch.diff.size <= 150 }} # this branch has 150 lines of code or less changed\nrun:\n- action: send-slack-message@v1\nargs:\nwebhook_url: \"{{ env.SLACK_WEBHOOK }}\"\nmessage: \":tada: Congrats to {{ pr.author }} for the amazing new PR, '{{ pr.title }}'! Check it out at https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\n
Download this example as a CM file.

"},{"location":"integrations/slack/#message-specific-teams-based-on-pr-content","title":"Message Specific Teams Based on PR content","text":"

You can also use the Slack integration to automatically keep in touch with code owners and others who should be connected to the PR. You could check for certain conditions that require a more personal review from an experienced maintainer, like:

  • Will the PR take too long to review?
  • Did SonarCloud find vulnerabilities?
  • Is this the author\u2019s first commit or are they new to the codebase?
  • Is this an automated PR that for some reason didn\u2019t pass the automatic approval tests?

On the other hand, some PRs might not have anything wrong, but still need to be assigned to a certain team based on expertise. In that case, you could set up several Slack automation actions at once, all with different webhooks and conditions. In an organization with different secrets for Slack webhooks to the #security-team channel, the #qa-team channel, and the #docs-team channel.

Send Slack Notifications

Automatically send Slack notifications to specific channels based on the contents of a pull request.

Configuration Description

Conditions (all must be true):

  • The PR meets one or more of the specified trigger criteria for Slack notifications.

Automation Actions:

  • Post a Slack message based on the contents of the PR.

Send Slack Notifications

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nsend_slack_security:\n# use your custom logic here to determine whether this needs a security review\nif:\n- true\nrun:\n- action: send-slack-message@v1\nargs:\nwebhook_url: \"{{ env.SLACK_WEBHOOK_SECURITY }}\"\nmessage: \"A PR requires a security review. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\nsend_slack_qa:\n# use your custom logic here to determine whether this needs a qa review\nif:\n- {{ not (files | match(regex=r/(test|spec)/) | some) }}\nrun:\n- action: send-slack-message@v1\nargs:\nwebhook_url: \"{{ env.SLACK_WEBHOOK_QA }}\"\nmessage: \"A PR was submitted without tests. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\nsend_slack_docs:\n# use your custom logic here to determine whether this needs a docs review\nif:\n- {{ files | match(regex=r/(docs)/) | some }}\nrun:\n- action: send-slack-message@v1\nargs:\nwebhook_url: \"{{ env.SLACK_WEBHOOK_DOCS }}\"\nmessage: \"A PR has modified the docs. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\n
Download this example as a CM file.

Using this template and custom logic specific to your company, you can build a complete repo management system that gets the right people actively involved by pinging them where they are in Slack.

"},{"location":"integrations/slack/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/snyk/","title":"Integrate gitStream with Snyk","text":""},{"location":"integrations/snyk/#auto-merge-snyk-dependency-updates","title":"Auto-Merge Snyk Dependency Updates","text":"

Approve PRs from Snyk

Configuration Description

Conditions (all must be true):

  • The PR author is Snyk.

Automation Actions:

  • Approve the PR
  • Apply an approved-snyk label to the PR
  • Merge the PR if all status checks pass.

Approve Snyk

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_snyk:\nif:\n- {{ branch.author | includes(term=\"snyk\") }}\nrun:\n- action: approve@v1\n- action: add-label@v1\nargs:\nlabel: \"approved-snyk\"\n- action: merge@v1\nargs:\nwait_for_all_checks: true\nsquash_on_merge: true\n
Download this example as a CM file."},{"location":"integrations/soc2/","title":"Use gitStream for SOC 2 compliance.","text":"

gitStream policy-as-code makes it easy to implement workflow automations that help your team remain SOC 2 compliant during the code review process.

"},{"location":"integrations/soc2/#flag-code-thats-merged-without-review","title":"Flag Code That's Merged Without Review","text":"

Automatically send notifications to your team when code is merged without review.

Configuration Description

Conditions (all must be true):

  • A PR is merged without at least one review.

Automation Actions:

  • Send a Slack notification to alert your team.
  • Apply a red DCF5-merged-without-review label.
  • Post a comment explaining SOC II requirements.

Flag Code That's Merged Without Review

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- merge\n# https://docs.gitstream.cm/automation-actions/#send-slack-message\nslack_webhook: {{ env.SLACK_WEBHOOK }}\n# Update security_team to match your organization\nsecurity_team: 'my-org/app-sec'\nautomations:\nflag_merged_no_review:\nif:\n- {{ pr.approvals | length == 0 }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"DCF5-merged-without-review\"\ncolor: {{ colors.red }}\n- action: send-slack-message@v1\nargs:\nmessage: \"PR #{{ pr.number }} - {{ pr.title }} - was merged without peer reviews. SOC2 requires code reviews for every code change. _SOC2 ref: CC8.1_\"\nwebhook_url: \"{{ slack_webhook }}\"\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR was merged without peer reviews. SOC2 requires code reviews for every code change.\n_SOC2 ref: CC8.1_\n@{{ security_team }}\ncolors:\nred: 'F6443B'\n
Download this example as a CM file."},{"location":"integrations/soc2/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

"},{"location":"integrations/sonar/","title":"Integrate gitStream with SonarCloud","text":"

Included with gitStream Core Functionality

This integration is part of gitStream core functionality, and requires no additional configuration.

SonarCloud Examples:

  • Approve Sonar Clean Code
  • Label SonarCloud Quality Reports
  • Review Sonar Duplications
  • Review Sonar Security Alerts

"},{"location":"integrations/sonar/#approve-sonar-clean-code","title":"Approve Sonar Clean Code","text":""},{"location":"integrations/sonar/#approve-sonar-clean-code_1","title":"Approve Sonar Clean Code","text":"

Approve PRs that pass SonarCloud's quality gate.

Configuration Description

Conditions (all must be true):

  • SonarCloud reports an 'A' rating for vulnerabilities, bugs, security hotspots, and code smells.
  • There is no duplicated code.

Automation Actions:

  • Apply a Sonar: Clean Code label to the PR.
  • Approve the PR.
  • Post a comment that explains why the PR was approved.

Aprove Sonar Clean Code

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_sonar_clean_code:\nif:\n- {{ sonar.bugs.rating == 'A' }}\n- {{ sonar.code_smells.rating == 'A' }}\n- {{ sonar.vulnerabilities.rating == 'A' }}\n- {{ sonar.security_hotspots.rating == 'A' }}\n- {{ sonar.duplications == null or sonar.duplications == 0 }}\nrun: - action: add-label@v1\nargs:\nlabel: '\u2705 Sonar: Clean Code'\ncolor: {{ colors.green }}\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR passes the SonarCloud quality gate check and as been automatically approved.\nsonar: {{ pr | extractSonarFindings }}\ncolors:\ngreen: '0e8a16'\n
Download this example as a CM file.

"},{"location":"integrations/sonar/#label-sonarcloud-quality-reports","title":"Label SonarCloud Quality Reports","text":""},{"location":"integrations/sonar/#label-sonarcloud-quality-reports_1","title":"Label SonarCloud Quality Reports","text":"

Label the number of bugs, vulnerabilities, security hotspots, and code smells reported by SonarCloud.

Configuration Description

Conditions (all must be true):

  • There is at least one vulnerability, code smell, security hotspot, or bug reported by SonarCloud. Uses the extractSonarFindings filter function

Automation Actions:

  • Apply color-coded labels to indicate the number of vulnerabilities, code smells, security hotspots, and bugs.

Label SonarCloud Quality Reports

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in reports %}\nlabel_sonar_{{ item.name }}:\nif:\n- {{ item.count > 0}}\nrun:\n- action: add-label@v1\nargs:\nlabel: '{{ item.icon }} sonar:{{ item.name }}-{{ item.rating }}'\ncolor: {{ colors.red if (item.rating == 'E' or item.rating == 'D') else (colors.orange if (item.rating == 'C' ) else colors.yellow) }}\n{% endfor %}\nsonar: {{ pr | extractSonarFindings }}\nreports:\n- name: vulnerabilities\ncount: {{ sonar.vulnerabilities.count }}\nicon: \ud83d\udd13\nrating: {{ sonar.vulnerabilities.rating }}\n- name: code smells\ncount: {{ sonar.code_smells.count }}\nicon: \u2623\ufe0f\nrating: {{ sonar.code_smells.rating }}\n- name: security hotspots\ncount: {{ sonar.security_hotspots.count }}\nicon: \ud83d\udee1\ufe0f\nrating: {{ sonar.security_hotspots.rating }}\n- name: bugs\ncount: {{ sonar.bugs.count }}\nicon: \ud83e\udeb2\nrating: {{ sonar.bugs.rating }}\ncolors:\nred: 'b60205'\norange: 'd93f0b'\nyellow: 'fbca04'\n
Download this example as a CM file.

"},{"location":"integrations/sonar/#review-sonar-duplications","title":"Review Sonar Duplications","text":""},{"location":"integrations/sonar/#review-sonar-duplications_1","title":"Review Sonar Duplications","text":"

Request changes when Sonar reports an excessive level of duplicated code.

Configuration Description

Conditions (all must be true):

  • The PR contains more than 3% duplicated code.

Automation Actions:

  • Apply a label that indicates how much duplicated code Sonar detected.
  • Request changes and post a comment explaining why.

Review Sonar Duplications

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_sonar_duplications:\nif:\n- {{ sonar.duplications > 3 }}\nrun: - action: add-label@v1\nargs:\nlabel: 'Sonar: {{ sonar.duplications}}% duplication'\ncolor: {{ colors.yellow }}\n- action: request-changes@v1\nargs:\ncomment: |\nSonar reports an excessive level of code duplication. Please consider refactoring your PR to reduce duplications.\nsonar: {{ pr | extractSonarFindings }}\ncolors:\nyellow: 'fbca04'\n
Download this example as a CM file.

"},{"location":"integrations/sonar/#review-sonar-security-alerts","title":"Review Sonar Security Alerts","text":""},{"location":"integrations/sonar/#review-sonar-security-alerts_1","title":"Review Sonar Security Alerts","text":"

Require additional reviews for Sonar security alerts. gitStream will remove this requirement if the alerts are resolved.

Configuration Description

Conditions (all must be true):

  • The SonarCloud quality gate check fails to pass for code smells, vulnerabilities, or security hotspots.

Automation Actions:

  • Require a review from the my-organization/security-team team. Customize this to match your organization.
  • Post a comment explaining why this PR requires additional review.

Review Sonar Alerts

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_sonar_alerts:\nif:\n- {{ sonar.code_smells.rating != 'A' or sonar.vulnerabilities.rating != 'A' or sonar.security_hotspots.rating != 'A'}}\nrun:\n- action: require-reviewers@v1\nargs:\nreviewers: [my-organization/security-team]\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR requires additional review because it fails to meet SonarCloud clean code standards.\nsonar: {{ pr | extractSonarFindings }}\n
Download this example as a CM file."},{"location":"integrations/swimm/","title":"Integrate gitStream with Swimm","text":""},{"location":"integrations/swimm/#approve-swimm-changes","title":"Approve Swimm Changes","text":""},{"location":"integrations/swimm/#approve-swimm-changes_1","title":"Approve Swimm Changes","text":"

Approve changes that only affect Swimm documentation.

Configuration Description

Conditions (all must be true):

  • The PR only affects files that end in a .swm extension.

Automation Actions:

  • Add a swimm-docs-only label
  • Approve the PR
  • Post a comment that explains that this is a Swimm docs change only.

Approve Swimm Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\napprove_swimm_changes:\n# Triggered for any changes to Swimm documentation\nif:\n- {{ branch.diff.files_metadata | match(attr='file', regex=r/\\.swm\\//) | every }}\n# Apply a swimm-docs-only label, approve the PR and explain why in a comment.\nrun: - action: add-label@v1\nargs:\nlabel: 'swimm-docs-only'\n- action: approve@v1\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR is considered a safe change as it only affects Swimm Docs. \nIt has been automatically approved.\n
Download this example as a CM file.

Special thanks to Omerr for providing this example.

"},{"location":"integrations/teams/","title":"Integrate gitStream with Microsoft Teams","text":"

This page demonstrates uses cases for how to connect gitStream to Microsoft Teams to post messages via webhooks.

"},{"location":"integrations/teams/#prerequisite-configurations","title":"Prerequisite Configurations","text":"

To use gitStream with MS Teams, you first need to do two things:

  1. Create an incoming webhook in Teams.
  2. Provide your Teams webhook URL to gitStream as an organization environment variable.
"},{"location":"integrations/teams/#set-up-incoming-webhooks-in-teams","title":"Set Up Incoming Webhooks in Teams","text":"

Microsoft Teams can accept incoming webhooks to send fully-featured messages to channels and individuals. Here\u2019s the complete tutorial from Microsoft.

Here is an overview of the process:

Step 1: Add the Incoming Webhook connector inside MS Teams.

Step 2: Give it a name and an image so your teammates can identify it easily and click create.

Once created, copy the webhook URL, you'll need this in the next step.

Your webhook URL is secret information!

Teams webhook URLs allow anyone with access to the URL to post to the channel its configured for. Do not publish this URL to public locations.

"},{"location":"integrations/teams/#configure-gitstream-environment-variable","title":"Configure gitStream Environment Variable","text":"

gitStream can access GitHub orgnization secrets as environment variables, and you'll need to do this to provide gitStream with access to your Slack webhook URL.

  1. Create an organization secret in GitHub and ensure it isn't being overridden by a repo-level secret of the same name.
  2. Pass the organization secret to gitStream as an environment variable in your gitstream.yml workflow file. We recommend using an easy to understand term like MS_TEAMS_WEBHOOK_CHANNEL_NAME.

"},{"location":"integrations/teams/#how-to-send-microsoft-teams-messages-from-gitstream","title":"How to Send Microsoft Teams Messages From gitStream","text":"

Example

To send Teams messages from gitStream, use the send-http-request automation action and pass the value you stored your webhook URL to the url argument.

automations:\nsend_teams_message:\nif:\n- true\nrun:\n- action: send-http-request@v1\nargs:\nmethod: \"POST\"\nheaders: '{\"Content-type\": \"application/json\"}'\nurl: \"{{ env.MS_TEAMS_WEBHOOK }}\"\nbody: '{\"text\": \"Hello, world!\"}'\n
"},{"location":"integrations/teams/#auto-recognition-for-meeting-team-goals","title":"Auto-Recognition For Meeting Team Goals","text":"

A good choice to reward developers for submitting great PRs would be to automate an MS Teams message that gives the developer recognition among their colleagues. To do this, you\u2019ll need to create a MS Teams webhook that sends to a channel full of reviewers, managers, and anybody else who should see the recognition.

Automatic MS Teams Recognition

Automatically post positive recognition messages in MS Teams for well-structured PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains updates to tests.
  • The PR has fewer than 5 modified files.
  • The PR branch references a Jira ticket.
  • The PR has fewer than 150 lines of code changed.

Automation Actions:

  • Post an MS Teams message that automatically recognizes the PR author and provides a link to the PR.

Automatic MS Teams Notifications

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nteams_auto_recognition:\nif:\n- {{ files | match(regex=r/(test|spec)/) | some }} # this pr has at least 1 test\n- {{ files | length <= 5 }} # this pr has 5 or less files\n- {{ branch.name | includes(regex=r/[A-Z]{2,}-\\d+.*/) }} # this branch has the Jira ticket prefix\n- {{ branch.diff.size <= 150 }} # this branch has 150 lines of code or less changed\nrun:\n- action: send-http-request@v1\nargs:\nmethod: \"POST\"\nheaders: '{\"Content-type\": \"application/json\"}'\nurl: \"{{ env.MS_TEAMS_WEBHOOK }}\"\nbody: '{\"text\": \"Congrats to {{ pr.author }} for the amazing new PR, {{ pr.title }}! Check it out at https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"}'\n
Download this example as a CM file.

"},{"location":"integrations/teams/#message-specific-teams-based-on-pr-content","title":"Message Specific Teams Based on PR content","text":"

You can also use the Slack integration to automatically keep in touch with code owners and others who should be connected to the PR. You could check for certain conditions that require a more personal review from an experienced maintainer, like:

  • Will the PR take too long to review?
  • Did SonarCloud find vulnerabilities?
  • Is this the author\u2019s first commit or are they new to the codebase?
  • Is this an automated PR that for some reason didn\u2019t pass the automatic approval tests?

On the other hand, some PRs might not have anything wrong, but still need to be assigned to a certain team based on expertise. In that case, you could set up several Teams automation actions at once, all with different webhooks and conditions. In an organization with different secrets for Teams webhooks to the #security-team channel, the #qa-team channel, and the #docs-team channel.

MS Teams Channels Notifications

Automatically send Slack notifications to specific channels based on the contents of a pull request.

Configuration Description

Conditions (all must be true):

  • The PR meets one or more of the specified trigger criteria for MS Teams notifications.

Automation Actions:

  • Post an MS Teams message based on the contents of the PR.

Automatically Notify MS Teams Channels

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nsend_teams_security:\nif:\n# use your custom logic here to determine whether this needs a security review\n- true\nrun:\n- action: send-http-request@v1\nargs:\nmethod: \"POST\"\nheaders: '{\"Content-type\": \"application/json\"}'\nurl: \"{{ env.MS_TEAMS_WEBHOOK_SECURITY }}\"\nbody: '{\"text\": \"A PR requires a security review. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"}'\nsend_teams_qa:\nif:\n# use your custom logic here to determine whether this needs a qa review\n- {{ not (files | match(regex=r/(test|spec)/) | some) }}\nrun:\n- action: send-http-request@v1\nargs:\nmethod: \"POST\"\nheaders: '{\"Content-type\": \"application/json\"}'\nurl: \"{{ env.MS_TEAMS_WEBHOOK_QA }}\"\nbody: '{\"text\": \"A PR was submitted without tests. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"}'\nsend_teams_docs:\nif:\n# use your custom logic here to determine whether this needs a docs review\n- {{ files | match(regex=r/(docs)/) | some }}\nrun:\n- action: send-http-request@v1\nargs:\nmethod: \"POST\"\nheaders: '{\"Content-type\": \"application/json\"}'\nurl: \"{{ env.MS_TEAMS_WEBHOOK_DOCS }}\"\nbody: '{\"text\": \"A PR has modified the docs. See https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"}'\n
Download this example as a CM file.

Using this template and custom logic specific to your company, you can build a complete repo management system that gets the right people actively involved by pinging them where they are in Teams.

"},{"location":"integrations/teams/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/terraform/","title":"Integrate gitStream with Terraform","text":"

Terraform Examples:

  • Assign Reviewers for Terraform Changes

  • Review New Terraform Module

  • Review Terraform Source Version

  • Review Terraform Module Name

"},{"location":"integrations/terraform/#review-terraform-changes","title":"Review Terraform Changes","text":"

title: Automation - Automatically assign infrastructure team for Terraform changes description: Require specific reviewers for Terraform module changes category: [quality, terraform] quickstart: false

"},{"location":"integrations/terraform/#require-reviewers-for-terraform-changes","title":"Require Reviewers for Terraform changes","text":"

Automatically assign org/infrastructure team for reviewing changes when PR contains Terraform file changes.

Configuration Description

Conditions (all must be true):

  • The PR contains changes to one or more Terraform configuration files.

Automation Actions:

  • Require a review from the org/infrastructure team.

Review Terraform Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_terraform:\n# Triggered for any changes to Terraform files\nif:\n- {{ files | match(regex=r/.*\\.tf.*/) | some }}\n# Assign infrastructure team as reviewer for change in Terraform files\nrun:\n- action: require-reviewers@v1\nargs:\nreviewers: [org/infrastructure]\n- action: add-comment@v1\nargs:\ncomment: |\nThis PR affects Terraform configurations and requires a review from the Infra team.\n
Download this example as a CM file.

"},{"location":"integrations/terraform/#enforce-requirements-for-new-terraform-modules","title":"Enforce Requirements for New Terraform Modules","text":"

title: Automation - Review Terraform Module Directory description: Enforce directory structure conventions for new Terraform module category: [quality, terraform] quickstart: false

"},{"location":"integrations/terraform/#review-new-terraform-modules","title":"Review New Terraform Modules","text":"

Request changes if a PR that creates a new Terraform module which do not conform to the required directory structure.

Configuration Description

Conditions (all must be true):

  • The PR creates a new Terraform module
    • A new sub-directory is created inside the /modules directory.
  • The PR lacks one or more required components from the list in the terraform custom expression.

Automation Actions:

  • Request changes and post a comment explaining the missing parts of the module.
  • Apply Label : \u26a0\ufe0f Missing Terraform Components

Review New Module

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n{% set misslist = [] %}\n{% for pattern in terraform %}\n{% if (newfilesinpr | match(term=pattern) | nope) %}\n{% set misslist = misslist + [pattern+' '] %}\n{% endif %}\n{% endfor %} automations:\nreview_new_terraform_module:\nif: - {{misslist | match(regex=r/.*/) | some}}\n- {{is.mainfile and is.mainfilenotinroot }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: |\nNew terraform modules must contain all required components before merging. Please update your PR with the required components and gitStream will automatically remove this comment once completed.\nHere are the required components, {{misslist}} should be customized appropriately:\nmy_module/\n\u251c\u2500\u2500 main.tf\n\u251c\u2500\u2500 outputs.tf\n\u251c\u2500\u2500 providers.tf\n- action: add-label@v1\nargs:\nlabel: '\u26a0\ufe0f Missing Terraform Components'\ncolor: '#FFA500'\nresources:\nmodule_directory: 'modules'\nterraform:\n- main.tf\n- outputs.tf\n- providers.tf\nis:\nmainfile: {{newfilesinpr | match(term = \"main.tf\") | some}}\nmainfilenotinroot: {{source.diff.files | map(attr='original_file') | match(term = \"main.tf\") | nope }}\nnewfilesinpr:\n{{ branch.diff.files_metadata | map(attr='new_file')}}\n
Download this example as a CM file.

"},{"location":"integrations/terraform/#ensure-terraform-source-urls-have-version-numbers","title":"Ensure Terraform Source URLs have version numbers","text":"

title: Automation - Review Terraform Module Imports description: Enforce Terraform modules use version when importing via URL source category: [quality, terraform] quickstart: false

"},{"location":"integrations/terraform/#review-terraform-source-version","title":"Review Terraform Source Version","text":"

Ensure that all Terraform modules imported via a source URL specify a version.

Configuration Description

Conditions (all must be true):

  • The PR contains a Terraform source declaration via URL that lacks a version reference.
  • The source is not included in a whitelist custom expression that defines one or more whitelisted source locations.

Automation Actions:

  • Request review changes on the PR with a comment explaining version number requirement.

Review Terraform Changes

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nreview_terraform_source_version:\n# Check if New Content contains a source URL, the URL is not part of allow list and lacks version reference\nif: - {{ source.diff.files | match(attr='new_content', regex=r/source.*?=.*\\\".*(http|https).*\\\"/) | some }}\n- {{ source.diff.files | match(attr='new_content', list=allowlist) | nope }}\n- {{ source.diff.files | match(attr='new_content', regex=r/source.*?=.*\\?ref=v.*/) | nope }}\nrun:\n- action: request-changes@v1\nargs:\ncomment: |\nYou must reference a specific version when accessing Terraform module sources via URL, e.g. `?ref=v1.0.0`. Please update your Terraform files to follow this practice.\nallowlist:\n- 'https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git'\n- 'https://github.com/terraform-aws-modules/terraform-aws-vpc.git'\n- 'https://github.com/terraform-aws-modules/terraform-aws-eks.git'\n
Download this example as a CM file.

"},{"location":"integrations/terraform/#ensure-new-terraform-modules-conform-to-a-naming-pattern","title":"Ensure New Terraform Modules conform to a Naming Pattern","text":"

title: Automation - Review Terraform Module Name description: Enforce naming conventions in Terraform module changes category: [quality, terraform] quickstart: false

"},{"location":"integrations/terraform/#review-terraform-module-name","title":"Review Terraform Module Name","text":"

Request changes if a PR creates a new Terraform module that is missing a required prefix or keyword in the name.

Configuration Description

Conditions (all must be true):

  • The PR creates a new Terraform module.
  • The module name lacks a required name prefix, or one or more keywords.

Automation Actions:

  • Request review changes on the PR with a comment explaining the structure of module name.

Review Terraform Module Name

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n# Prefix Check Logic\n{% set prefixcheck = [] %}\n{% for pattern in terraform.prefixes %}\n{% if(newfilesinpr | match(term=module_location + pattern) | some) %}\n{% set prefixcheck = prefixcheck + [true]%}\n{% else %}\n{% set prefixcheck = prefixcheck + [false]  %}\n{% endif %}\n{% endfor %}\nautomations:\nreview_new_terraform_module:\nif: - {{is.mainfile and is.mainfilenotinroot}}\n- {{module_name_checks.prefix or module_name_checks.keyword}}\nrun:\n- action: request-changes@v1\nargs:\ncomment: |\nTerraform module names must contain a required prefix and keyword:\n* Prefixes: {{ terraform.prefixes }}\n* Keywords: {{ terraform.keywords }}\nmodule_name_checks:\nprefix: {{prefixcheck | match(term='true') | nope}}\nkeyword: {{newfilesinpr | match(list=terraform.keywords) | nope}}\nmodule_location: infrastructure/modules/\nterraform:\nprefixes: ['aws', 'gcp', 'azure']\nkeywords: ['db', 'networking', 'security']\nis:\nmainfile: {{newfilesinpr | match(term = \"main.tf\") | some}}\nmainfilenotinroot: {{source.diff.files | map(attr='original_file') | match(term = \"main.tf\") | nope }}\nnewfilesinpr:\n{{ branch.diff.files_metadata | map(attr='new_file')}}\n
Download this example as a CM file."},{"location":"integrations/unleash/","title":"Integrate gitStream with Unleash","text":""},{"location":"integrations/unleash/#label-unleash-feature-flags","title":"Label Unleash Feature Flags","text":"

Automatically label code that contians specified feature flags.

Configuration Description

Conditions (all must be true):

  • The PR adds one or more feature flag keys.

Automation Actions:

  • Label the PR for each feature flag key introduced in the PR.

Label PRs Based on Feature Flags

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\n{% for item in feature_flags %}\nlabel_ff_unleash_{{ item.name }}:\nif:\n- {{ source.diff.files | matchDiffLines(regex=r/const notificationBadgeEnabled = useFlag/) | some }}\n- {{ source.diff.files | matchDiffLines(regex=item.regex) | some }}\nrun:\n- action: add-label@v1\nargs:\nlabel: {{ item.name }}\ncolor: {{ colors.yellow }}\n{% endfor %}\nfeature_flags:\n- name: engineering_rollback_plan_activated regex: r/engineering_rollback_plan_activated/\n- name: marketing_premium_plan_features_unlocked regex: r/marketing_premium_plan_features_unlocked/\n- name: mobile_push_notifications_enabled\nregex: r/mobile_push_notifications_enabled/\ncolors:\nyellow: 'ffb300'   
Download this example as a CM file."},{"location":"integrations/unleash/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/zapier/","title":"Integrate gitStream with Zapier","text":"

Zapier is a workflow automation tool that connects to more than 7,000 apps and APIs and allows you to pass data between them using processes called Zaps. After something triggers the Zap, it\u2019ll sequentially call the different pieces of your workflow.

"},{"location":"integrations/zapier/#prerequisite-configurations","title":"Prerequisite Configurations","text":"

To use gitStream with Zapier, you first need to do two things:

  1. Create a Zap with incoming webhooks enabled.
  2. Provide your Zapier webhook URL to gitStream as an organization environment variable.
"},{"location":"integrations/zapier/#setup-incoming-webhooks-in-zapier","title":"Setup Incoming Webhooks in Zapier","text":"

Premium Zapier Subscription Required.

As of December 2023, Zapier\u2019s Incoming Webhooks app is only available to premium members.

Get started by signing into Zapier and clicking Create Zap:

Then, select the trigger and find the latest version of the Webhooks by Zapier app:

Choose Catch Hook (to pass JSON data from gitStream to Zapier), but don\u2019t add any child key (so the root object you send is parsed by Zapier). Then copy the URL it gives you and proceed to the next step

Your webhook URL is secret information!

Zapier webhook URLs allow anyone with access to the URL to use it. Do not publish this URL to public locations.

"},{"location":"integrations/zapier/#configure-environment-variable","title":"Configure Environment Variable","text":"

gitStream can access GitHub orgnization secrets as environment variables, and you'll need to do this to provide gitStream with access to your Slack webhook URL.

  1. Create an organization secret in GitHub and ensure it isn't being overridden by a repo-level secret of the same name.
  2. Pass the organization secret to gitStream as an environment variable in your gitstream.yml workflow file. We recommend using an easy to understand term like ZAPIER_WEBHOOK.

You should now be ready to send data from gitStream to Zapier.

"},{"location":"integrations/zapier/#export-pr-data-to-zapier","title":"Export PR Data to Zapier","text":"

In your .cm file, you can include an automation that sends data to Zapier. Likely, you won\u2019t be using exactly the workflow that we\u2019re demonstrating here, but that\u2019s alright; you can send any of the context variables in the body of the request for you to make use of in your Zap. It\u2019s best practice to only send as much information as you need, so avoid sending unecessary data.

A Simple Zapier Example

This is an example of how to send data from gitStream to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends a webhook to Zapier that contains the PR number

Export PR Number to Zapier

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nzapier_export_pr_number:\nif:\n- true\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ ZAPIER_WEBHOOK }}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{ \"pr_number\":\"{{ pr.number }}\" }'\n
Download this example as a CM file.

"},{"location":"integrations/zapier/#store-pr-data-in-a-table","title":"Store PR Data in a Table","text":"

Zapier can store data it gets from incoming webhooks in its internal database. In Zapier, click on the menu on the left side and select Tables. Then, create a new table called PRs with fields PR number, PR title, and PR URL, with types Number, Text, and Link respectively:

Return to the home page and create a new Zap following the instructions above, with twos changes. First, the webhook should only be run when the PR is created. Notice the on condition in the new .cm file below. Also, you\u2019ll notice the example sends additional data points. This could be any data you want; gitStream makes numerous useful resources available via context variables.

Storing PR Data in a Table

Export new PR titles, numbers, and URLs to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends the PR number, title, and URL to Zapier via webhook.

Export PR Number, Title, and URL to Zapier

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\npr_url: \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\non:\n- pr_created\nautomations:\nzapier_export_pr_number_title_url:\nif:\n- true\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ ZAPIER_WEBHOOK }}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{ \"pr_number\":\"{{ pr.number }}\", \"pr_title\":\"{{ pr.title }}\", \"pr_url\":\"{{ pr_url }}\" }'\n
Download this example as a CM file.

After the webhook triggers, use the Tables app in the Zap to create a new record in your PR table with the available data.

Then, PRs will start showing up in the table as they\u2019re created:

Now, you can integrate this PR data into the rest of your workflow! You could expand on this, adding date and status information so that other applications could automatically injest this data.

"},{"location":"integrations/zapier/#create-project-management-tasks-from-prs","title":"Create Project Management Tasks From PRs","text":"

The next example follows similar conventions as the last, except this on includes the PR description instead of the number:

Create PM Tasks From PR Data

Export new PR titles, description, and URL to Zapier.

Configuration Description

Conditions (all must be true):

  • A PR is created.

Automation Actions:

  • gitStream sends a webhook to Zapier that contains the PR title, description, and URL.

Create Project Management Tasks Via Zapier

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\npr_url: \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\non:\n- pr_created\nautomations:\nzapier_export_pr_description_title_url:\nif:\n- true\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ ZAPIER_WEBHOOK }}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{ \"pr_description\":\"{{ pr.description }}\", \"pr_title\":\"{{ pr.title }}\", \"pr_url\":\"{{ pr_url }}\" }'\n
Download this example as a CM file.

Now, in the Zap,you can pass this data to Trello to create a new task on the QA board. First, add the Trello app, select the Create Card event, and connect your Trello account. Then, you can build the card according to the information from gitStream:

This example puts the task in a the 'To Do\" column of the QA tasklist to make it easy for QA engineers to take it from there. The title, description and URL are all formatted to fit into Trello.

"},{"location":"integrations/zapier/#automatically-schedule-sync-meetings","title":"Automatically Schedule Sync Meetings","text":"

The next example can help if you're responsible for all the PR reviews that come in. You might want to schedule a synchronous group meeting for the last half hour of every day for all of that day\u2019s PRs to be reviewed. Everyone assigned to review a PR that day is invited. gitStream and Zapier can help build those meetings, invite all the right people automatically, and skip the meeting altogether if it\u2019s not necessary.

Start with this CM example:

Send PR Reviewer Info to Zapier

Automatically update Zapier with a list of PR reviewers.

Configuration Description

Conditions (all must be true):

  • A PR is created or updated.

Automation Actions:

  • gitStream sends the list of reviewers to Zapier via webooks.

Auto-Schedule Sync Meetings via Zapier

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\npr_url: \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\nautomations:\nzapier_export_pr_reviewers:\nif:\n- true\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ env.ZAPIER_WEBHOOK }}\"\nmethod: \"POST\"\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{ \"reviewers\": \"{{ pr.reviewers }}\" }'\n
Download this example as a CM file.

Then in Zapier, set up a Zap like this:

In the second piece of the Zap, you can write JavaScript (or Python) to format whatever you get from gitStream. If you return an array of the reviewer usernames, Zapier will run the rest of the steps of the Zap *once per reviewer*, which is what you want. Zapier also has a built-in lookup table you can use, but this example will use a Google Sheet for simplicity.

In the Find Event action of the Google Calendar app, search for the daily standup and create one if it doesn\u2019t yet. If you set the new event not to repeat, then the standup will only be created when you have PRs to review. Just make sure the search term and the title of the new event match:

Lastly, search for the new calendar entry with the Add Attendee/s to Event action, and add the reviewer\u2019s email as an attendee. Remember, this will run *for each reviewer* so you only need to build out this linear path.

Once you\u2019re done, you\u2019ll have your standup automatically added to the schedule whenever it\u2019s needed:

"},{"location":"integrations/zapier/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/golang/golang-testing-automations/","title":"Golang Testing Automations","text":""},{"location":"integrations/golang/golang-testing-automations/#review-missing-golang-tests","title":"Review Missing Golang Tests","text":""},{"location":"integrations/golang/golang-testing-automations/#review-python-golang-test-name","title":"Review Python Golang Test Name","text":"

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"integrations/html/html-css-automations/","title":"HTML/CSS Automations","text":""},{"location":"integrations/html/html-css-automations/#flag-missing-html-tags","title":"Flag Missing HTML Tags","text":""},{"location":"integrations/html/html-css-automations/#flag-duplicate-h1","title":"Flag Duplicate H1","text":""},{"location":"integrations/html/html-css-automations/#enforce-html-title-length-requirements","title":"Enforce HTML Title Length Requirements","text":""},{"location":"integrations/html/html-css-automations/#enforce-image-alt-attributes","title":"Enforce Image Alt Attributes","text":"

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"integrations/java/java-testing-automations/","title":"Java Testing Automations","text":""},{"location":"integrations/java/java-testing-automations/#review-missing-java-tests","title":"Review Missing Java Tests","text":""},{"location":"integrations/java/java-testing-automations/#review-python-java-test-name","title":"Review Python Java Test Name","text":"

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"integrations/javascript/javascript-testing-automations/","title":"JavaScript Testing Automations","text":""},{"location":"integrations/javascript/javascript-testing-automations/#review-missing-javascript-tests","title":"Review Missing JavaScript Tests","text":""},{"location":"integrations/javascript/javascript-testing-automations/#review-python-javascript-test-name","title":"Review Python JavaScript Test Name","text":"

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"integrations/jira/","title":"Integrate gitStream with Jira","text":"

gitStream makes it easy to build workflows that link your GitHub repo to your Jira workspace. Automatically update Jira issues, enforce Jira best-practices, and reduce the amount of context switching developers experience by reducing their need to interact with third-party project management tools.

"},{"location":"integrations/jira/#automation-examples","title":"Automation Examples","text":""},{"location":"integrations/jira/#label-missing-jira-info","title":"Label Missing Jira Info","text":"

Label PRs that don't reference a Jira ticket in the title or description. This uses regex to detect Jira ticket formats in the title (e.g. ABC-1234), and URLs to Jira tickets in the description.

Configuration Description

Conditions (all must be true):

  • The PR lacks a Jira ticket number in the title, or a link to a Jira ticket in the PR description.

Automation Actions:

  • Apply a missing-jira label.

Label Missing Jira Info

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nautomations:\nlabel_missing_jira_info:\n# Triggered for PRs that don't have either a Jira ticket number in the title,\n# or a link to a Jira ticket in the PR description.\nif:\n- {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}\nrun:\n- action: add-label@v1\nargs:\nlabel: \"missing-jira\"\ncolor: 'F6443B'\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\\/browse\\/\\w{1,}-\\d{3,4}/) }}\n
Download this example as a CM file."},{"location":"integrations/jira/#automatically-link-prs-to-related-jira-issues","title":"Automatically Link PRs to Related Jira Issues","text":"

Provide automatic links to Jira issues that are associated with PRs.

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Jira card in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Jira Card.

Automatically Link to the Related Jira Card

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nprovider: jira\n# Change this to the name of your Jira organization\norgName: org\n{% set ticketid = \"\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\nlink_jira:\nif:\n- {{ has.ticket_in_title or has.ticket_in_branch }}\nrun:\n- action: add-comment@v1\nargs:\ncomment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})\nhas:\nticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}\nticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}\ntracker:\njira:\nbaseurl: https://[orgName].atlassian.net/browse/\npattern: r/\\b[A-Za-z]+-\\d+\\b/\ntickets:\n- {{branch.name | capture(regex=tracker[provider].pattern)}}\n- {{pr.title | capture(regex=tracker[provider].pattern)}}\n
Download this example as a CM file."},{"location":"integrations/jira/#update-jira-fields-when-prs-are-created","title":"Update Jira Fields When PRs are Created","text":"

Automatically update Jira tickets with pull request information. You can modify this to send any PR metadata to Jira.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Configuration Description

Conditions (all must be true):

  • A PR is created that contains a Jira ticket reference in the title or branch name.

Automation Actions:

  • Send a webhook to Jira containing metadata to add to the Issue.

Automatic Jira Updates

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n{% set ticketid = \"\\b[A-Za-z]+-\\d+\\b\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\njira_update_field: if:\n- {{ has.jira_ticket_in_title or has.jira_ticket_in_branch }}\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ env.JIRA_UPDATE_PR_FIELD_WEBHOOK }}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{\"issues\":[\"{{ticketid}}\"],\"data\":{\"pr_url\":\"https://github.com/{{repo.owner}}/{{repo.name}}/pull/{{pr.number}}\"}}'\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_branch: {{ branch.name | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\n
Download this example as a CM file."},{"location":"integrations/jira/#automatically-create-jira-issues-for-new-prs","title":"Automatically Create Jira Issues for New PRs","text":"

Automatically create Jira tickets for new pull/merge requests.

Jira API & Webhook Integration Required.

This automation requires you to connect to the Jira API and incoming webooks.

Required gitStream Plugins

This example requires you to install the hasJiraIssue plugin.

Learn more about gitStream plugins.

Configuration Description

Conditions (all must be true):

  • The PR description contains the text - [x] Auto-create Jira Issue
  • No existing Jira issues reference the PRs URL.

Automation Actions:

  • Send an HTTP request to create a new Jira issue.

Automatically Create Jira Issues

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\n###### ** Configure This Section ** ######\n# Configure this for your Jira instance and the email associated with your API key.\n# You can safely use these values because only your API key is sensitive. \njiraSpaceName: \"my-company\" # e.g. my-company.atlassian.net\nemail: \"my.email@example.com\"\n# If you're concerned about exposing this information,\n# we recommend using environment variables for your production environment.\n# -----------\n# Pass the API token associated with the email above to gitStream via an environment variable.\njiraAuth: {{ env.JIRA_API_TOKEN }}\n# Learn more about env: https://docs.gitstream.cm/context-variables/#env\n# -----------\n# Change this to the Jira field you want to match the input string against.\njiraField: \"myField\"\n# If you want to search a custom field, you should provide the ID like so:\n# jiraField: \"cf[XXXXX]\"\n# Replace XXXXX with the ID of the custom field you want to search.\n# More information:\n# Using JQL to search the Jira API: https://support.atlassian.com/jira-service-management-cloud/docs/jql-fields/\n# How to find the ID of a custom field: https://confluence.atlassian.com/jirakb/how-to-find-any-custom-field-s-ids-744522503.html\n# -----------\n###### ** Automation ** ######\n# You may want to update the text in the comment gitStream posts;\n# otherwise, this section shouldn't need to be changed.\nprUrl: \"https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ pr.number }}\"\nhas_jira_issue: {{ prUrl  | hasJiraIssue(jiraAuth, jiraField, jiraSpaceName, email) }}\nautomations:\nautomatic_jira_task: if:\n- {{ not has_jira_issue }}\n- {{ pr.description | includes(regex=r/\\- \\[x\\] Auto-create Jira Task/)}}\nrun:\n- action: send-http-request@v1\nargs:\nurl: {{ env.JIRA_WEBHOOK }}\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{\"data\":{\"pr_url\": \"{{ prUrl }}\",\"title\":\"{{ pr.title }}\"}}'\n- action: add-comment@v1\nargs:\ncomment: \"gitStream automatically created a Jira task for this PR\"\n
Download this example as a CM file."},{"location":"integrations/jira/#update-jira-ticket-status-when-prs-are-created","title":"Update Jira Ticket Status When PRs are Created","text":"

Automatically update the status of Jira tickets when a PR is opened.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Configuration Description

Conditions (all must be true):

  • A PR is created that references a Jira ticket in the title or description.

Automation Actions:

  • Make an HTTP request to a Jira webhook that is pre-configured to update the ticket status.

Automatic Jira Status Updates

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\non:\n- pr_created\n{% set ticketid = \"\\b[A-Za-z]+-\\d+\\b\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\njira_change_status: if:\n- {{ has.jira_ticket_in_title or has.jira_ticket_in_desc }}\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ env.JIRA_CHANGE_STATUS_WEBHOOK }}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{\"issues\":[\"{{ticketid}}\"],\"data\":{\"pr_url\":\"https://github.com/{{repo.owner}}/{{repo.name}}/pull/{{pr.number}}\"}}'\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_branch: {{ branch.name | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\ntickets:\n- {{branch.name | capture(regex=r/\\b[A-Za-z]+-\\d+\\b/)}}\n- {{pr.title | capture(regex=r/\\b[A-Za-z]+-\\d+\\b/)}}\n
Download this example as a CM file."},{"location":"integrations/jira/#use-slash-commands-to-assign-tickets-in-jira","title":"Use Slash Commands to Assign Tickets in Jira","text":"

Automatically assign Jira tickets based on code review actions.

Jira Webhook Integration Required

You need to configure an incoming Jira webhook to use this automation.

Configuration Description

Conditions (all must be true):

  • The PR description contains the slash command: /gitstream assign-jira followed by a Jira username.

Automation Actions:

  • Trigger a Jira webhook to update the assignee field with the username provided in the slash command.

Automatically Assign Jira Tickets

# -*- mode: yaml -*-\nmanifest:\nversion: 1.0\nassigneeRegex: r/(?<=\\/gitstream assign-jira ).*(?=<br \\/>)/\n{% set ticketid = \"\" %}\n{% for ticket in tickets %}\n{% if (ticket | includes(regex=r/.+/)) %}\n{% set ticketid = ticket %}\n{% endif %}\n{% endfor %} automations:\njira_assign: if:\n- {{ pr.description | includes(regex=assigneeRegex) }}\nrun:\n- action: send-http-request@v1\nargs:\nurl: \"{{ env.JIRA_WEBHOOK }}}\"\nmethod: POST\nheaders: '{\"Content-type\": \"application/json\"}'\nbody: '{\"issues\":[\"{{ticketid}}\"],\"data\":{\"assignee\":\"{{pr.description | capture(regex=assigneeRegex)}}\"}}'\nhas:\njira_ticket_in_title: {{ pr.title | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\njira_ticket_in_branch: {{ branch.name | includes(regex=r/\\b[A-Za-z]+-\\d+\\b/) }}\ntickets:\n- {{branch.name | capture(regex=r/\\b[A-Za-z]+-\\d+\\b/)}}\n- {{pr.title | capture(regex=r/\\b[A-Za-z]+-\\d+\\b/)}}\n
Download this example as a CM file."},{"location":"integrations/jira/#configure-jira-for-gitstream-integrations","title":"Configure Jira for gitStream Integrations","text":"

If you want to build gitStream automations to interact with the Jira API or Jira webhooks, you'll need to complete some setup in Jira, GitHub, and gitStream. This section outlines the setup process depending on the type of automation you want to build.

These guides are for sending HTTP requests to Jira

If the gitStream automations you want to use don't make any HTTP requests to a Jira API or webhook, you can ignore this section.

"},{"location":"integrations/jira/#use-webhooks-to-trigger-jira-automations","title":"Use Webhooks to Trigger Jira Automations","text":"

Jira automations are the preferred method for gitStream to trigger actions within Jira, so you should use them whenever possible. If webhooks don't provide access to the data you need, or acheive the functionality you want, use the Jira API instead.

First, create a Jira automation that uses an incoming webhook as the trigger and add whatever automation components you want after this trigger. Save the webhook URL in a secure place, you'll need it later.

Here is an example of an automation that uses the webhookData property of the incoming data payload to create a new task. It expects the incoming data payload to contain title and pr_url fields to set the task summary and a pr_url custom field our demo environment already has configured.

Learn more about working with incoming webhooks in the Jira docs

Next, in GitHub, create an organization secret to store your Jira webhook URL and pass it to gitStream's env context variable by adding a line to .github/workflows/gitstream.yml inside your repo. Make sure to give this a unique name, such as JIRA_CREATE_ISSUE_WEBHOOK: ${{ secrets.JIRA_CREATE_ISSUE_WEBHOOK }}.

Once finished, you can use the env.JIRA_CREATE_ISSUE_WEBHOOK context variable inside CM files to send HTTP requests to Jira from your GitHub repo. For an example of how to do this, check out the create Jira issue automation.

"},{"location":"integrations/jira/#connect-to-the-jira-api","title":"Connect to the Jira API","text":"

The Jira API is useful in situations where you need to retreive data from Jira or need to access capabilities that aren't available via Jira Automations. The Jira API uses an account-based token system that follows a basic auth model; this means you'll need an individual account to connect to Jira's APIs and will pass the account email address and API token in the headers of your API requests.

Here's the process to grant gitStream access to the Jira API:

  1. Create an API token for your Jira account, and give it a unique name. Copy the API token, you'll need it in the next step.
  2. Create a GitHub organization secret to store the token and make the secret available to gitStream's env context variable.
  3. Add env.MY_API_TOKEN to any of your CM automations to access the API token and pass it to plugins and automation actions.

Check out the hasJiraIssue filter plugin for an example of how to use Jira API tokens.

"},{"location":"integrations/jira/#additional-resources","title":"Additional Resources","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"integrations/python/python-testing-automations/","title":"Python Testing Automations","text":""},{"location":"integrations/python/python-testing-automations/#review-missing-python-tests","title":"Review Missing Python Tests","text":""},{"location":"integrations/python/python-testing-automations/#review-python-test-name","title":"Review Python Test Name","text":"

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"integrations/ruby/ruby-testing-automations/","title":"Ruby Testing Automations","text":""},{"location":"integrations/ruby/ruby-testing-automations/#review-missing-ruby-tests","title":"Review Missing Ruby Tests","text":""},{"location":"integrations/ruby/ruby-testing-automations/#review-python-ruby-test-name","title":"Review Python Ruby Test Name","text":"

Special thanks to Boemo W Mmopelwa for providing these examples.

"},{"location":"snippets/automation-footer/","title":"Automation footer","text":"

More Automations can be found on the Automation Library and Integrations pages.

"},{"location":"snippets/change-request-automation/","title":"Change request automation","text":"
  • Require changelog updates for PRs to specific branches
  • Flag the use of deprecated APIs, functions, or other components.
  • Restrict portions of your code base to authorized teams only.
  • Require changes when PRs include !important tags in CSS files
"},{"location":"snippets/context-automation/","title":"Context automation","text":"
  • Estimate the amount of time it would require someone to complete a PR review.
  • Flag missing Jira ticket information
  • Label PRs that delete files.
  • Label PRs that lack tests
  • Provide information about what percent of a PR is new code.
  • Request PR authors to provide screenshots in relevant PRs.
"},{"location":"snippets/general/","title":"General","text":"

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

"},{"location":"snippets/javascript-automation/","title":"Javascript automation","text":"
  • Automatically approve PRs that conly contain changes to JavaScript log output
  • Implement custom review policies for JSDoc
  • Automatically Approve non-functional formatting updates to JavaScript files
"},{"location":"snippets/python-automation/","title":"Python automation","text":"
  • Automatically approve PRs that only change Python log output
  • Automatically approve PRs that only include non-functional Python formatting changes
"},{"location":"snippets/review-assignment-automation/","title":"Review assignment automation","text":"
  • Assign additional reviewers for large PRs
  • Assign or suggest reviewers based on level of code expertise for the code changed in a PR.
  • Assign reviewers based on modified directories and files
  • Assign reviewers to share knowledge based on pre-determined criteria
"},{"location":"snippets/safe-merge-automation/","title":"Safe merge automation","text":"
  • Automatically approve changes to docs, tests, and other safe assets.
  • Approve low-risk PRs from trusted teams.
  • Approve Python or JavaScript formatting changes.
  • Approve Tiny Changes
  • Approve JSDoc or Javadoc changes.
  • Approve and Merge Dependabot PRs
"},{"location":"snippets/utility-automation/","title":"Utility automation","text":"
  • An informative header you can add to your CM files to help others.
  • A custom expression that makes it easy to implement color-coded labels that match the GitHub UI.
"}]} \ No newline at end of file diff --git a/sitemap.xml b/sitemap.xml new file mode 100644 index 00000000..0f8724ef --- /dev/null +++ b/sitemap.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz new file mode 100644 index 00000000..b9b00a2b Binary files /dev/null and b/sitemap.xml.gz differ diff --git a/snippets/automation-footer/index.html b/snippets/automation-footer/index.html new file mode 100644 index 00000000..6cecea00 --- /dev/null +++ b/snippets/automation-footer/index.html @@ -0,0 +1 @@ + Automation footer - gitStream Documentation
\ No newline at end of file diff --git a/snippets/change-request-automation/index.html b/snippets/change-request-automation/index.html new file mode 100644 index 00000000..a765e448 --- /dev/null +++ b/snippets/change-request-automation/index.html @@ -0,0 +1 @@ + Change request automation - gitStream Documentation
\ No newline at end of file diff --git a/snippets/context-automation/index.html b/snippets/context-automation/index.html new file mode 100644 index 00000000..4df83620 --- /dev/null +++ b/snippets/context-automation/index.html @@ -0,0 +1 @@ + Context automation - gitStream Documentation
\ No newline at end of file diff --git a/snippets/general/index.html b/snippets/general/index.html new file mode 100644 index 00000000..d5e00a42 --- /dev/null +++ b/snippets/general/index.html @@ -0,0 +1 @@ + General - gitStream Documentation

General

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

\ No newline at end of file diff --git a/snippets/javascript-automation/index.html b/snippets/javascript-automation/index.html new file mode 100644 index 00000000..fab65c7c --- /dev/null +++ b/snippets/javascript-automation/index.html @@ -0,0 +1 @@ + Javascript automation - gitStream Documentation
\ No newline at end of file diff --git a/snippets/partials/body.hbs b/snippets/partials/body.hbs new file mode 100644 index 00000000..d24f65bb --- /dev/null +++ b/snippets/partials/body.hbs @@ -0,0 +1,28 @@ +{{>deprecated~}} +{{>description~}} +{{>summary~}} +{{>augments~}} +{{>implements~}} +{{>mixes~}} +{{>default~}} +{{>chainable~}} +{{>overrides~}} +{{>returns~}} +{{>category~}} +{{>throws~}} +{{>fires~}} +{{>this~}} +{{>access~}} +{{>readOnly~}} +{{>requires~}} +{{>customTags~}} +{{>see~}} +{{>since~}} +{{>version~}} +{{>authors~}} +{{>license~}} +{{>copyright~}} +{{>todo~}} +{{>params~}} +{{>properties~}} +{{>examples~}} \ No newline at end of file diff --git a/snippets/partials/sig-name.hbs b/snippets/partials/sig-name.hbs new file mode 100644 index 00000000..bcbfde2e --- /dev/null +++ b/snippets/partials/sig-name.hbs @@ -0,0 +1,13 @@ +{{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}} +{{#if name}}{{#sig~}} +{{{@depOpen}~}} +{{{@codeOpen}~}} +{{#if @prefix}}{{@prefix}} {{/if~}} +{{@parent~}} +{{@accessSymbol}}{{#if (isEvent)}}"{{{name}}}"{{else}}{{{escape name}}}{{/if~}} +{{#if @methodSign}}{{#if (isEvent)}} {{@methodSign}}{{else}}{{@methodSign}}{{/if}}{{/if~}} +{{{@codeClose}~}} +{{#if @suffix}} {{@suffix}}{{/if~}} +{{{@depClose}~}} +{{~/sig}}{{/if~}} +{{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}} \ No newline at end of file diff --git a/snippets/python-automation/index.html b/snippets/python-automation/index.html new file mode 100644 index 00000000..d5a157c3 --- /dev/null +++ b/snippets/python-automation/index.html @@ -0,0 +1 @@ + Python automation - gitStream Documentation
\ No newline at end of file diff --git a/snippets/review-assignment-automation/index.html b/snippets/review-assignment-automation/index.html new file mode 100644 index 00000000..1e016119 --- /dev/null +++ b/snippets/review-assignment-automation/index.html @@ -0,0 +1 @@ + Review assignment automation - gitStream Documentation
\ No newline at end of file diff --git a/snippets/safe-merge-automation/index.html b/snippets/safe-merge-automation/index.html new file mode 100644 index 00000000..99299730 --- /dev/null +++ b/snippets/safe-merge-automation/index.html @@ -0,0 +1 @@ + Safe merge automation - gitStream Documentation
\ No newline at end of file diff --git a/snippets/utility-automation/index.html b/snippets/utility-automation/index.html new file mode 100644 index 00000000..c2675db1 --- /dev/null +++ b/snippets/utility-automation/index.html @@ -0,0 +1 @@ + Utility automation - gitStream Documentation
\ No newline at end of file diff --git a/stylesheets/extra.css b/stylesheets/extra.css new file mode 100644 index 00000000..555582f8 --- /dev/null +++ b/stylesheets/extra.css @@ -0,0 +1,214 @@ + +.md-header{ + background-color: #3F2B95; +} + +h2 { + padding-top: 4%; +} + +h4 { + padding-top: 4%; +} + +/* make the first column wider as usually this is a variable name that cant wrap normally */ +th:nth-child(1){ + width: 35%; +} + +div.big-summary th:nth-child(1){ + width: 30%; +} + +div.filter-details th:nth-child(1){ + width: 20%; +} + +/* change the table colors for light mode */ +[data-md-color-scheme="default"] table th{ + background: #D8DADE; +} + +[data-md-color-scheme="default"] table tr td{ + background: white; +} + +/* Dark mode to match the app*/ +[data-md-color-scheme="slate"] { + --md-default-bg-color: #1F2025; +} + +/* change the table colors for dark mode */ +[data-md-color-scheme="slate"] table th{ + background: #2B4252; +} + +[data-md-color-scheme="slate"] table tr td{ + background: #2E2F3E; +} + +[data-md-color-scheme="slate"] { + --md-primary-fg-color: #FFFFFF; +} + +/* change links colors for dark mode */ +[data-md-color-scheme="slate"] { + --md-primary-fg-color: #40A0B5; +} + +/* fix so tables takes the whole page width */ +.md-typeset__table { + min-width: 100%; +} + +.md-typeset table:not([class]) { + display: table; +} + +/*div.tabbed-block code { + max-height: 250px; +} +*/ + +.video-wrapper { + position: relative; + display: block; + height: 0; + padding: 0; + overflow: hidden; + padding-bottom: 56.25%; +} + +.video-wrapper > iframe { + position: absolute; + top: 0; + bottom: 0; + left: 0; + width: 100%; + height: 100%; + border: 0; +} + +div.flow-chart { +} + +.md-typeset .md-button { + border: .05rem solid; + border-radius: .3rem; + padding: 0 0.25em 0 0.25em; + font-weight: 400; +} + +.result .extra { + font-weight: 100; + color: gray; +} + +.tabbed-content .md-typeset .admonition { + font-size: .8rem; +} + +.md-typeset .admonition, .md-typeset details { + font-size: .8rem +} + +.automationDescription{ + width:40%; +} +.automationImage{ + width: 59%; + float: right; +} + +.automationExample{ + width: 100%; + clear: both; +} + +@media (max-width: 769px) { + .automationImage, .automationDescription { + width: 100%; + } +} + +.integrations-list { + display:flex; + flex-wrap: wrap; + justify-content: center; +} + +.integrations-card { + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + border-radius: 10px; + width: 200px; + margin: 10px; + padding-bottom: 15px; +} + +/* change the integrations-card colors for light mode */ +[data-md-color-scheme="default"] .integrations-card{ + border: 2px solid #212121; +} + +/* change the integrations-card colors for dark mode */ +[data-md-color-scheme="slate"] .integrations-card{ + border: 2px solid white; +} + +.integrations-card-title p{ + font-size: 1.2em; + margin-bottom: 1px; +} + +.integrations-card-title a{ + color: inherit; +} + +.integrations-card-title img{ + padding:2px; + width:auto; + height: 1.2em; +} + +.integrations-card-logo-only img{ + padding:2px; + width:auto; + height: 3em; +} + +.integrations-card-labels { + font-size: 0.7em; + color: #9aa4ad; /* this is a medium grey color */ + margin-bottom: 5px; +} + +a[href='ff5757'] { + color: #ff5757; + pointer-events: none; + cursor: default; + text-decoration: none; +} + +a[href='7ed957'] { + color: #7ed957; + pointer-events: none; + cursor: default; + text-decoration: none; +} + +a[href='0cc0df'] { + color: #0cc0df; + pointer-events: none; + cursor: default; + text-decoration: none; +} + +a[href='ffde59'] { + color: #ffcc59; + pointer-events: none; + cursor: default; + text-decoration: none; +} diff --git a/troubleshooting/index.html b/troubleshooting/index.html new file mode 100644 index 00000000..20d2f77b --- /dev/null +++ b/troubleshooting/index.html @@ -0,0 +1,25 @@ + Troubleshoot gitStream - gitStream Documentation

Troubleshooting

I can't see any action running

Did you install gitStream in your repo?

Check that you see gitStream app on repository's Settings > GitHub apps:

GitHub App installed In case you don't see it, visit the marketplace and install it for free: https://github.com/marketplace/gitstream-by-linearb

Did you set the workflow files correctly?

Check you have placed these two files in your repository with these exact names:

  1. gitstream.cm in the cm repo, (for org level installs), or .cm/gitstream.cm on all other repositories
  2. .github/workflows/gitstream.yml

These files must be committed to the repository default branch (usually master or main). Notice that the action will not run until these files are found on the default branch.

Check that you see "gitStream workflow automation" in the Action section in your repository:

GitHub action

Next, if you see failed action, check out the details:

GitHub action log

Some organization limit which actions can run, in that case in the repository settings you should enable it:

GitHub allow marketplace actions

Also, add

linear-b/gitstream-github-action@v2,*/*/.github/workflows/gitstream.yml*
+
to the Allow specified actions and reusable workflows list, if it is shown. GitHub allow marketplace actions

Using org level? Did you enable gitStream for your cm repo

Make sure you have added the cm repo to the repos gitStream should run on GitHub cm repo

Is the PR in Draft mode?

gitStream automations won't trigger for PRs that are in Draft mode.

I see 'gitStream workflow file not found' error

This error indicates that gitStream is unable to locate the file .github/workflows/gitstream.yml. The tool first searches for this file in the cm repository and then in the PR's repository. If the CI file is not found, this error message is displayed. To resolve this issue, ensure that your setup is correct and that the specified file exists in your repository.

I have rules that should have blocked merge, but the PR can be merged still

For example, when using the set-required-approvals action, gitStream can ensure the PR got enough approvals before it can be merged. gitStream does that by running as a check and marking the check conclusion as failed. In order for the PR to be blocked, gitStream should be set as a required check in the repo: instructions here.

Merge enabled

I can't set gitStream as required check

In order for gitStream to be listed as a required check, it needs to be triggered at least once in that repo. First create a new PR so gitStream is triggered.

Check it under repository's Settings > Branches:

Branch protection rules

Required checks

I don't want gitStream to run on PRs that was generated by a bot

When using repository level rules, you can edit the .github/workflows/gitstream.yml and uncomment the if line, you can edit and replace the bot name with the bot name you want to ignore (dependabot[bot] in the example below).

Note

This will not work for org level rules

.github/workflows/gitstream.yml
jobs:
+  gitStream:
+    timeout-minutes: 5
+    # uncomment this condition, if you don't want any automation on dependabot PRs
+    if: github.actor != 'dependabot[bot]'
+    runs-on: ubuntu-latest
+    name: gitStream workflow automation
+    steps:
+      - name: Evaluate Rules
+        uses: linear-b/gitstream-github-action@v2
+

gitStream fails and I don't understand why

gitStream check run can fail from different reasons, and these are shown in the check result.

Missing workflow file

When it says gitStream.cm Skipped — gitStream workflow file not found, it means that the GitHub action was not found, check again that you have this file in your repository root: .github/workflows/gitstream.yml, see instructions on GitHub installation.

Syntax error in the cm files

Check failure

Clicking the Details button will show more information and context.

Check error details

You can add this automation to see details on context variable.

How can I debug expressions and see their content?

You can dump any context value to the PR comment. For example, to see the list of changed files, use:

automations:
+  show_changed_files:
+    if:
+      - true
+    run:
+      - action: add-comment@v1
+        args:
+          comment: |
+            FILES DUMP {{ files | dump | safe }}
+            JS FILES DUMP {{ files | filter(regex=r/\.js$/) | dump | safe }}
+

gitStream fails with syntax error after adding new rules

IntelliJ IDEA has automatic code styling for YAML that can break the .cm syntax, check the following Settings/Preferences | Editor | Code Style | YAML --> Spaces | Code braces and make sure it is unchecked.

Intellij settings

VS Code YAML plugin by Red Hat extension [vscode-yaml](https://github.com/redhat-developer/vscode-yaml) has automatic code styling for YAML that can break the .cm syntax, make sure you disable bracketSpacing

{
+    "yaml.format.bracketSpacing": false,
+}
+

Not here?

Create a new issue in the project's issues

\ No newline at end of file