├── datacontract.yaml ├── .github └── workflows │ ├── breaking.yml │ └── test.yml └── README.md /datacontract.yaml: -------------------------------------------------------------------------------- 1 | dataContractSpecification: 0.9.0 2 | id: my-data-contract-id 3 | info: 4 | title: My Data Contract 5 | version: 0.0.1 6 | schema: 7 | type: dbt 8 | specification: |- 9 | version: 2 10 | models: 11 | - name: my_table 12 | description: "contains data" 13 | config: 14 | materialized: table 15 | columns: 16 | - name: my_column 17 | data_type: text 18 | description: "contains values" 19 | -------------------------------------------------------------------------------- /.github/workflows/breaking.yml: -------------------------------------------------------------------------------- 1 | name: Breaking Changes 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | checkBreakingChanges: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | - name: Get CLI 11 | run: | 12 | curl -L https://github.com/datacontract/cli/releases/download/v0.4.0/datacontract-v0.4.0-linux-amd64.tar.gz -o datacontract.tar.gz 13 | tar -xf datacontract.tar.gz 14 | - name: Check backwards compatibility 15 | run: ./datacontract breaking --with https://raw.githubusercontent.com/datacontract/cli-examples/main/datacontract.yaml 16 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Quality Checks 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | qualityChecks: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | - name: Set up Python 11 | uses: actions/setup-python@v4 12 | with: 13 | python-version: 3.11 14 | - name: Set up Soda Core 15 | run: pip install -U soda-core-duckdb 16 | - name: Get CLI 17 | run: | 18 | curl -L https://github.com/datacontract/cli/releases/download/v0.4.0/datacontract-v0.4.0-linux-amd64.tar.gz -o datacontract.tar.gz 19 | tar -xf datacontract.tar.gz 20 | - name: Check data quality 21 | run: ./datacontract test --soda-config soda-configuration.yaml -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cli-examples 2 | Usage examples for the data contract CLI 3 | 4 | ## Find breaking changes on pull request 5 | In this example the `breaking` command is used in a [simple GitHub action](.github/workflows/breaking.yml) to find breaking changes on pull requests. Take a look at [the failing pull request](https://github.com/datacontract/cli-examples/pull/2). 6 | 7 | ### Action 8 | ```yaml 9 | name: Breaking Changes 10 | 11 | on: [pull_request] 12 | 13 | jobs: 14 | test: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v4 18 | - name: Get CLI 19 | run: | 20 | curl -L https://github.com/datacontract/cli/releases/download/v0.3.2/datacontract-v0.3.2-linux-amd64.tar.gz -o datacontract.tar.gz 21 | tar -xf datacontract.tar.gz 22 | - name: Check backwards compatibility 23 | run: ./datacontract breaking --with https://raw.githubusercontent.com/datacontract/cli-examples/main/datacontract.yaml 24 | ``` 25 | 26 | ### Result Log 27 | ```yaml 28 | Run ./datacontract breaking --with https://raw.githubusercontent.com/datacontract/cli-examples/main/datacontract.yaml 29 | Found 1 differences between the data contracts! 30 | 31 | 🔴 Difference 1: 32 | Description: field 'my_table.my_column' was removed 33 | Type: field-removed 34 | Severity: breaking 35 | Level: field 36 | Model: my_table 37 | Field: my_column 38 | Exiting application with error: found breaking differences between the data contracts 39 | Error: Process completed with exit code 1. 40 | ``` 41 | --------------------------------------------------------------------------------