Skip to content

Add the polars export format #4731

Add the polars export format

Add the polars export format #4731

Workflow file for this run

on:
push:
branches: [ "main" ]
paths-ignore:
- 'docs/**'
pull_request:
branches: [ "main" ]
paths-ignore:
- 'docs/**'
workflow_call:
permissions:
contents: read
name: CI
jobs:
lint:
name: "Linting & Formatting (fix with: uv run ruff check --fix && uv run ruff format)"
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install uv
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
python-version: '3.11'
prune-cache: true
- name: Install the project
run: uv sync --all-extras --dev
- name: Check linting
run: uv run ruff check
- name: Check formatting
run: uv run ruff format --check
- name: Lint example data contracts
run: uv run python lint_examples.py
- name: Check the vendored ODCS Excel template and conformance pair
run: uv run python update_excel_template.py --check
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
matrix:
os:
- 'ubuntu-24.04'
python-version:
- '3.10'
- '3.11'
- '3.12'
- '3.13'
- '3.14'
include:
# The CLI is installed with pip on macOS laptops as much as on Linux,
# and path handling, locale, and filesystem case sensitivity are where
# that breaks first. One Python version is enough to catch it; the
# macOS runners have no Docker daemon, so the container tests are left
# uncollected and named in the test output (see tests/conftest.py).
- os: 'macos-latest'
python-version: '3.11'
fail-fast: false
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install system dependencies (msodbcsql18)
# The SQL Server driver is only needed by the container tests, which do
# not run on the Docker-less macOS runner.
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y msodbcsql18
- name: Install uv
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
python-version: ${{ matrix.python-version }}
prune-cache: true
- name: Install the project
run: uv sync --all-extras --dev
- name: Run tests
run: uv run pytest -n0
slow-tests:
name: "Slow tests (testcontainers)"
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install system dependencies (msodbcsql18)
run: |
sudo apt-get update
sudo apt-get install -y msodbcsql18
- name: Install uv
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
python-version: '3.11'
prune-cache: true
- name: Install the project
run: uv sync --all-extras --dev
- name: Run slow tests
run: uv run pytest -n0 -m slow
integration-tests:
runs-on: ${{ matrix.os }}
timeout-minutes: 5
strategy:
matrix:
os:
- 'ubuntu-24.04'
python-version:
- '3.11'
fail-fast: false
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python ${{matrix.python-version}}
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{matrix.python-version}}
cache: 'pip' # caching pip dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip uv
pip install -e '.' # do not install dev dependencies or other extras
- name: Build wheel and verify [all] extra resolves without local overrides
run: |
uv build --wheel
WHEEL=$(ls dist/datacontract_cli-*.whl)
uv pip install --dry-run --system --no-config "${WHEEL}[all]"
- name: Test datacontract --help
run: datacontract --help
- name: Test datacontract --version
run: datacontract --version
- name: Test datacontract init
run: datacontract init new-datacontract.yaml
- name: Test datacontract export
run: datacontract export sql tests/fixtures/export/datacontract.odcs.yaml
- name: Install dependencies with duckdb
run: |
pip install -e '.[duckdb]'
- name: Test datacontract test
run: cd tests && datacontract test fixtures/local-delta/datacontract.yaml
docker:
runs-on: ubuntu-24.04
# The multi-arch build+push runs ~9.5 min and had been getting cancelled
# right at a 10 min limit; 20 gives headroom.
timeout-minutes: 20
needs:
- test
if: github.event_name != 'pull_request' && github.repository == 'datacontract/datacontract-cli'
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Docker meta
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: |
datacontract/cli
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Login to Docker Hub
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Docker Hardened Images (dhi.io)
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
registry: dhi.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
# linux/arm64 is disabled
# duckdb currently does not support linux_arm64_gcc4
# https://duckdb.org/docs/extensions/working_with_extensions#platforms
platforms: linux/amd64,linux/arm64
push: ${{ github.ref == 'refs/heads/main' }}
tags: datacontract/cli:snapshot-latest
labels: ${{ steps.meta.outputs.labels }}
sbom: true
provenance: mode=max