Purpose
This guide will help your team register data assets, author and publish Data Contracts, and enforce those contracts pre-merge using Gable’s CLI and CI/CD integrations. By the end of this process, you’ll have:- A production environment ready for contract enforcement
- Your first Data Contract defined and published
- Confidence that breaking changes will be detected before code is merged
Prerequisites
- TypeScript service that emits data
- What project/repo(s) do you want to run on?
- What data flows out of your service or application do you want to put contracts on?
- Access to relevant GitHub or GitLab repositories for code scanning
- [Bonus] Slack channel for alerts
Access
- Once the prod environment is ready, you’ll receive email invites
- Log in to your Gable environment
- Once logged in, you can add more users by going to Settings > Users > Invite User.
Register relevant assets
First, register the code paths that emit data in your TypeScript application.- Identify the data flow patterns and points of interest that you’d like to put contracts on. Gable natively supports some common event publishing libraries like Segment & Amplitude.
- If you are interested in patterns that are not currently supported, share those patterns with the Gable team and we will register them with our static analysis engine.
- You can also register an asset based on function parameter or key.
- In your project root, run the appropriate
gable data-asset register
command. You can find examples here. - Verify in the CLI output that assets have been registered successfully.
Create your first contract
- Go to the Gable Dashboard and access Assets in the left hand nav.
- Select the asset you want to put a contract on.
- Select
Create contract
in the upper right- Add a Name, Domain, and Description for your contract.
- The schema and type definition will be populated automatically based on the static analysis of the code during asset registration. Review the schema and make any desired changes. You can also restrict PII in the asset by checking the
Restrict PII
checkbox above the schema definition.- Click
Check asset
to see whether asset violates the contract.
- Click
- Select an Enforcement Level for the contract. We recommend setting the Enforcement Level to
Alert
in order to warn on risky PRs. - Save the contract.
Integrate Gable into your CI/CD
- Add the
GABLE_API_KEY
as a secret in your repo (e.g. GitHub Secrets). - Access the
GABLE_API_ENDPOINT
from Settings > API > API Endpoint. - Configure a Github Action with the same
data-asset-options
as thegable data-asset register
command used above.
[Bonus] Set up notifications for contract violations
- In the Gable Dashboard, go to Actions > Create an Action.
- Select the project as the Asset Origin and under Change Event select “Contract violation”.
- Select Create Action and fill in Action Name, e.g. “Contract violation”.
- Set a destination, e.g. a team (or dedicated Gable alert) Slack channel.
- To connect Slack, go to Settings > Slack.
How to test
- Follow the steps above to register assets, create a contract, and integrate Gable into your CI/CD.
- Make a code change that should violate an existing contract.
- Open a pull request.
- View Gable notification in Github on the PR.