Skip to content

Bring project up to standards of Python development tooling in 2025 #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions devops/CI.Dockerfile → .github/CI.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
ARG PYTHON_VERSION="3.10"
FROM python:${PYTHON_VERSION}-bullseye as base
ARG PYTHON_VERSION="3.13"
FROM python:${PYTHON_VERSION}-bookworm AS base

# Setup dependencies for pyodbc
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-transport-https \
curl \
gnupg2 \
unixodbc-dev \
lsb-release && \
apt-get install -y --no-install-recommends curl && \
apt-get autoremove -yqq --purge && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# enable Microsoft package repo
RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl -sL https://packages.microsoft.com/config/debian/$(lsb_release -sr)/prod.list | tee /etc/apt/sources.list.d/msprod.list
# enable Azure CLI package repo
RUN echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/azure-cli.list

# install Azure CLI
ENV ACCEPT_EULA=Y
RUN apt-get update && \
apt-get install -y --no-install-recommends \
azure-cli && \
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash && \
apt-get autoremove -yqq --purge && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

FROM base as msodbc17
# Download the package to configure the Microsoft repo
RUN curl -sSL -O https://packages.microsoft.com/config/debian/$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2 | cut -d '.' -f 1)/packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
rm packages-microsoft-prod.deb

FROM base AS msodbc17

# install ODBC driver 17
ENV ACCEPT_EULA=Y
Expand All @@ -43,7 +34,7 @@ RUN apt-get update && \
# add sqlcmd to the path
ENV PATH="$PATH:/opt/mssql-tools/bin"

FROM base as msodbc18
FROM base AS msodbc18

# install ODBC driver 18
ENV ACCEPT_EULA=Y
Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
version: 2
updates:
- package-ecosystem: pip
- package-ecosystem: uv
directory: "/"
schedule:
interval: daily
Expand Down
70 changes: 0 additions & 70 deletions .github/workflows/integration-tests-azure.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Integration tests on Fabric DW
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
integration-tests-fabric-dw:
name: Regular
strategy:
fail-fast: false
max-parallel: 1
matrix:
python_version: ["3.12", "3.13"]
msodbc_version: ["17", "18"]

runs-on: ubuntu-latest
permissions:
contents: read # Required to access repository files
packages: read # Grant explicit read access to packages
id-token: write # Needed if using OIDC authentication
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python_version }}

- name: Install dependencies
run: uv sync

- name: Run functional tests
env:
FABRIC_TEST_ENDPOINT: ${{ secrets.DBT_AZURESQL_SERVER }}
FABRIC_TEST_DWH_NAME: ${{ secrets.DBT_AZURESQL_DB }}
FABRIC_TEST_DRIVER: "ODBC Driver ${{ matrix.msodbc_version }} for SQL Server"
run: uv run pytest -ra -v tests/functional
25 changes: 14 additions & 11 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: Publish Docker images for CI/CD
on: # yamllint disable-line rule:truthy
on:
workflow_dispatch:
push:
paths:
- 'devops/**'
- '.github/CI.Dockerfile'
- '.github/workflows/publish-docker.yml'
branches:
- main
Expand All @@ -14,7 +14,7 @@ jobs:
publish-docker-client:
strategy:
matrix:
python_version: ["3.8", "3.9", "3.10", "3.11"]
python_version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
docker_target: ["msodbc17", "msodbc18"]
runs-on: ubuntu-latest
permissions:
Expand All @@ -23,24 +23,27 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3.3.0
uses: docker/login-action@v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5.1.0
uses: docker/build-push-action@v6
with:
context: devops
context: .github
build-args: PYTHON_VERSION=${{ matrix.python_version }}
file: devops/CI.Dockerfile
file: .github/CI.Dockerfile
push: true
platforms: linux/amd64
target: ${{ matrix.docker_target }}
tags: ghcr.io/${{ github.repository }}:CI-${{ matrix.python_version }}-${{ matrix.docker_target }}

- name: List Docker images
run: docker images ghcr.io/${{ github.repository }}
platforms: ${{ matrix.docker_target == 'msodbc17' && 'linux/amd64' || 'linux/amd64,linux/arm64' }}
27 changes: 12 additions & 15 deletions .github/workflows/release-version.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Release new version

on: # yamllint disable-line rule:truthy
on:
push:
tags:
- 'v*'
Expand All @@ -13,23 +13,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version-file: ".python-version"

- name: Install dependencies
run: pip install -r dev_requirements.txt

- name: Verify version match
run: python setup.py verify

- name: Initialize .pypirc
run: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = __token__" >> ~/.pypirc
echo -e "password = ${{ secrets.PYPI_DBT_FABRIC }}" >> ~/.pypirc
run: uv sync

- name: Build and publish package
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
uv build
uv publish
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_DBT_FABRIC }}
22 changes: 9 additions & 13 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Unit tests
on: # yamllint disable-line rule:truthy
on:
workflow_dispatch:
push:
branches:
Expand All @@ -16,22 +16,18 @@ jobs:
name: Unit tests
strategy:
matrix:
python_version: ["3.10", "3.11"]
python_version: ["3.10", "3.11", "3.12", "3.13"]
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
container:
image: ghcr.io/${{ github.repository }}:CI-${{ matrix.python_version }}-msodbc18
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
steps:

- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python_version }}

- name: Install dependencies
run: pip install -r dev_requirements.txt
run: uv sync

- name: Run unit tests
run: pytest -n auto -ra -v tests/unit
run: uv run pytest -n auto -ra -v tests/unit
Loading
Loading