PageSourceSearch

https://docs-pactflow-preview.netlify.app/assets/js/293f8e1a.36d12343.js

js docs-pactflow-preview.netlify.app collected 2026-10-03 10:39:45 UTC 9,675 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkpartners=self.webpackChunkpartners||[]).push([[1160],{15680:(e,t,n)=>{n.d(t,{xA:()=>c,yg:()=>m});var r=n(96540);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var p=r.createContext({}),s=function(e){var t=r.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=s(e.components);return r.createElement(p.Provider,{value:t},e.children)},d="mdxType",h={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},u=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,i=e.originalType,p=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),d=s(n),u=a,m=d["".concat(p,".").concat(u)]||d[u]||h[u]||i;return n?r.createElement(m,o(o({ref:t},c),{},{components:n})):r.createElement(m,o({ref:t},c))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var i=n.length,o=new Array(i);o[0]=u;var l={};for(var p in t)hasOwnProperty.call(t,p)&&(l[p]=t[p]);l.originalType=e,l[d]="string"==typeof e?e:a,o[1]=l;for(var s=2;s<i;s++)o[s]=n[s];return r.createElement.apply(null,o)}return r.createElement.apply(null,n)}u.displayName="MDXCreateElement"},24463:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>p,contentTitle:()=>o,default:()=>h,frontMatter:()=>i,metadata:()=>l,toc:()=>s});var r=n(58168),a=(n(96540),n(15680));const i={id:"how-not-to-break-everything",title:"How not to break everything"},o=void 0,l={unversionedId:"docs/workshops/ci-cd/workshop/how-not-to-break-everything",id:"docs/workshops/ci-cd/workshop/how-not-to-break-everything",title:"How not to break everything",description:"When we made first made the change to the pact on the master branch of the consumer, we ended up with broken consumer build, stopping them from being released, and without pending pacts, the provider would have been blocked. In the previous step, we learned how to configure the provider so that it could still continue to be released, even if it was not able to successfully verify the new pact.",source:"@site/docs/docs/workshops/ci-cd/workshop/04_how_not_to_break_everything.md",sourceDirName:"docs/workshops/ci-cd/workshop",slug:"/docs/workshops/ci-cd/workshop/how-not-to-break-everything",permalink:"/docs/workshops/ci-cd/workshop/how-not-to-break-everything",draft:!1,editUrl:"https://github.com/pactflow/docs.pactflow.io/edit/master/website/docs/docs/workshops/ci-cd/workshop/04_how_not_to_break_everything.md",tags:[],version:"current",lastUpdatedBy:"Yousaf Nabi",lastUpdatedAt:1674493712,formattedLastUpdatedAt:"Jan 23, 2023",sidebarPosition:4,frontMatter:{id:"how-not-to-break-everything",title:"How not to break everything"},sidebar:"university",previous:{title:"Protecting provider builds from changed pacts",permalink:"/docs/workshops/ci-cd/workshop/protecting-the-provider"},next:{title:"Implementing the provider changes",permalink:"/docs/workshops/ci-cd/workshop/implementing-the-provider-changes"}},p={},s=[{value:"Expected state by the end of this step",id:"expected-state-by-the-end-of-this-step",level:2},{value:"Conclusion",id:"conclusion",level:2}],c={toc:s},d="wrapper";
1function h(e){let{components:t,...n}=e;return(0,a.yg)(d,(0,r.A)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,a.yg)("p",null,"When we made first made the change to the pact on the master branch of the consumer, we ended up with broken consumer build, stopping them from being released, and without pending pacts, the provider would have been blocked. In the previous step, we learned how to configure the provider so that it could still continue to be released, even if it was not able to successfully verify the new pact."),(0,a.yg)("p",null,"The consumer is still unable to make a release from its master however, as the ",(0,a.yg)("inlineCode",{parentName:"p"},"can-i-deploy")," step correctly identifies that the verification for the ",(0,a.yg)("inlineCode",{parentName:"p"},"master")," pact has failed. This is a correct report on the state of this integration - the API does not yet implement the features we require to deploy."),(0,a.yg)("p",null,"Let's make our changes on a branch this time."),(0,a.yg)("ol",null,(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"In the consumer codebase, revert the change to master and push to make the build go green again."),(0,a.yg)("pre",{parentName:"li"},(0,a.yg)("code",{parentName:"pre"},"git revert HEAD\ngit push\n"))),(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"Create a new branch"),(0,a.yg)("pre",{parentName:"li"},(0,a.yg)("code",{parentName:"pre"},"  git checkout -b feat/new-field\n"))),(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"open up ",(0,a.yg)("inlineCode",{parentName:"p"},"src/api.pact.spec.js"),", scroll down to the first test, and in the ",(0,a.yg)("inlineCode",{parentName:"p"},"expectedProduct")," definition, add a new field e.g. ",(0,a.yg)("inlineCode",{parentName:"p"},'color: "red"'),".")),(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"Make sure the tests pass locally by running ",(0,a.yg)("inlineCode",{parentName:"p"},"make test"),".")),(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"Commit & Push your changes by running"),(0,a.yg)("ol",{parentName:"li"},(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("inlineCode",{parentName:"li"},"git add src/api.pact.spec.js")),(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("inlineCode",{parentName:"li"},"git commit -m 'feat: add color'")),(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("inlineCode",{parentName:"li"},"git push --set-upstream origin feat/new-field"))),(0,a.yg)("ul",{parentName:"li"},(0,a.yg)("li",{parentName:"ul"},"The consumer tests will pass, and then the CI build will fail as ",(0,a.yg)("inlineCode",{parentName:"li"},"can-i-deploy")," correctly identifies that this branch is not yet compatible with the API (there is no verifications against this changed pact content, and therefore the provider must verify it).",(0,a.yg)("ul",{parentName:"li"},(0,a.yg)("li",{parentName:"ul"},"Our pact associated with the feature branch ",(0,a.yg)("inlineCode",{parentName:"li"},"feat/new-field")," will be unverified and the consumer cannot deploy this feature branch until the provider implements the feature."))),(0,a.yg)("li",{parentName:"ul"},"The webhook-triggered pact verification provider build will be triggered",(0,a.yg)("ul",{parentName:"li"},(0,a.yg)("li",{parentName:"ul"},"It will verify the changed pact against the latest providers main branch and any deployed (or released) in production"),(0,a.yg)("li",{parentName:"ul"},"It will fail, that's ok, as it wouldn't stop the provider from deploying as we have enabled the ",(0,a.yg)("inlineCode",{parentName:"li"},"pendingPacts")," feature"),(0,a.yg)("li",{parentName:"ul"},"Our pact associated with the feature branch ",(0,a.yg)("inlineCode",{parentName:"li"},"feat/new-field")," will be verified as incompatible and the consumer cannot deploy."),(0,a.yg)("li",{parentName:"ul"},"If we re-run our can-i-deploy step of the failed consumer build, we will see it will now show a failed verification.")))))),(0,a.yg)("p",null,"\ud83d\udc49 The ",(0,a.yg)("inlineCode",{parentName:"p"},"can-i-deploy")," step acts as a \"can I merge?\" check when run from a branch. We'll know we're safe to merge this branch into master if/when ",(0,a.yg)("inlineCode",{parentName:"p"},"can-i-deploy")," passes. \ud83d\udc48"),(0,a.yg)("h2",{id:"expected-state-by-the-end-of-this-step"},"Expected state by the end of this step"),(0,a.yg)("ul",null,(0,a.yg)("li",{parentName:"ul"},"In Github Actions:",(0,a.yg)("ul",{parentName:"li"},(0,a.yg)("li",{parentName:"ul"},"A ",(0,a.yg)("inlineCode",{parentName:"li"},"master")," consumer build that passes and deploys."),(0,a.yg)("li",{parentName:"ul"},"A ",(0,a.yg)("inlineCode",{parentName:"li"},"feat/new-field")," consumer build that fails at ",(0,a.yg)("inlineCode",{parentName:"li"},"can-i-deploy"),"."))),(0,a.yg)("li",{parentName:"ul"},"In PactFlow:",(0,a.yg)("ul",{parentName:"li"},(0,a.yg)("li",{parentName:"ul"},"A ",(0,a.yg)("inlineCode",{parentName:"li"},"master")," pact with a successful verification result."),(0,a.yg)("li",{parentName:"ul"},"A ",(0,a.yg)("inlineCode",{parentName:"li"},"feat/new-field")," pact with a failed verification result")))),(0,a.yg)("h2",{id:"conclusion"},"Conclusion"),(0,a.yg)("p",null,"By making changes on a branch of the consumer, and publishing a 'feature pact', we keep our main release branch green, and make sure we're not blocked from deploying. The ",(0,a.yg)("inlineCode",{parentName:"p"},"can-i-deploy"),' call acts as a "can I merge?" check when we\'re on a branch.'))}h.isMDXComponent=!0}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.