Skip to content
Merged
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
49 changes: 36 additions & 13 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,39 @@ name: Builds and tests the Python Package on pull requests
on:
pull_request:
workflow_dispatch:
workflow_call:
inputs:
cache-key:
description: 'Cache key for the build artifacts'
required: false
type: string
default: ''

jobs:
build-package:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v6

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

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install dependencies and build package
run: |
pip install pipenv wheel
pipenv sync --system
./build.sh
uv sync
uv run ./build.sh

- name: Cache build
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ./dist
key: build-cache-${{ github.sha }}
key: ${{ inputs.cache-key || format('build-cache-{0}', github.sha) }}

test-package:
needs: build-package
Expand All @@ -34,21 +46,32 @@ jobs:
fail-fast: true

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v6

- name: "Set up Python"
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Recover cache
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ./dist
key: build-cache-${{ github.sha }}
key: ${{ inputs.cache-key || format('build-cache-{0}', github.sha) }}

- name: Install SDK from cache
env:
UV_SYSTEM_PYTHON: 1
run: |
PACKAGE=$(ls ./dist/ | grep -P .+\.whl$)
pip install ./dist/$PACKAGE --no-cache-dir
uv pip install "./dist/$PACKAGE[snowflake,bigquery,athena]"
uv pip install pytest

- name: Run unit tests
run: ./test_installed.sh
71 changes: 18 additions & 53 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,90 +3,55 @@ name: Build, test and publish Python Package
on:
release:
types: [published]
branches: [main]
workflow_dispatch:

jobs:
build-package:
validate-version:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Check git tag against package version and get python version
run: |
./check_package_version.sh
echo "::set-output name=VERSION::$(<.python-version)"
id: python-version

- uses: actions/setup-python@v5
with:
python-version: ${{ steps.python-version.outputs.VERSION }}

- name: Install dependencies and build package
run: |
pip install pipenv wheel
pipenv sync --system
./build.sh

- name: Cache build
uses: actions/cache@v4
with:
path: ./dist
key: build-cache

test-package:
needs: build-package
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
fail-fast: true

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Recover cache
uses: actions/cache@v4
- name: Set up Python
uses: actions/setup-python@v6
with:
path: ./dist
key: build-cache
python-version-file: ".python-version"

- name: Install SDK from cache
run: |
PACKAGE=$(ls ./dist/ | grep -P .+\.whl$)
pip install ./dist/$PACKAGE --no-cache-dir
- name: Check git tag against package version
run: ./check_package_version.sh

- name: Run unit tests
run: ./test_installed.sh
build-and-test:
needs: validate-version
uses: ./.github/workflows/build_test.yml
with:
cache-key: 'build-cache'

publish-package-to-pypi:
if: always()
needs: test-package
needs: build-and-test
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write

steps:
- name: Recover cache
if: needs.test-package.result == 'success'
uses: actions/cache@v4
if: needs.build-and-test.result == 'success'
uses: actions/cache@v5
with:
path: ./dist
key: build-cache

- name: Publish package to PyPI
if: needs.test-package.result == 'success'
if: needs.build-and-test.result == 'success'
uses: pypa/gh-action-pypi-publish@release/v1

- name: Post status to Slack
if: ${{ success() }}
uses: ravsamhq/notify-slack-action@2.5.0
with:
status: ${{ needs.test-package.result == 'success' && 'success' || 'failure' }}
status: ${{ needs.build-and-test.result == 'success' && 'success' || 'failure' }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.NOTIFY_SLACK_ACTION_WEBHOOK_URL }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_installability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: true

steps:
- uses: actions/setup-python@v5
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
16 changes: 14 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
build
# Distribution
dist
*.egg-info
*.pyc
__pycache__
/.idea/
.DS_Store

# Virtual environment
.venv

# Linters
.mypy_cache
.pytest_cache
.ruff_cache

# IDE
/.idea/
.claude/
.vscode/
60 changes: 60 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# See https://pre-commit.com for more information
# pre-commit can be installed using uv or pipx:
# - uv tool install pre-commit
# - pipx install pre-commit
#
# The hooks needs to be installed in the git repository by using:
#
# pre-commit install
#
# Then pre-commit runs the hooks on each commit.
# To run the pre-commit hooks manually on all staged files use:
#
# pre-commit run
#

default_language_version:
python: python3.10

exclude: (^|/)stubs/
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
exclude: \.md$
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: debug-statements # no lines with breakpoints()
- id: check-merge-conflict
- id: no-commit-to-branch
args: [--branch, main]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.13
hooks:
- id: ruff-check
types_or: [ python ]
args: [ --fix, --show-fixes, --config=pyproject.toml ]
- id: ruff-format
types_or: [ python ]
args: [ --config=pyproject.toml ]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
hooks:
- id: mypy
types: [python]
args:
[
"--config-file=pyproject.toml",
# https://mypy.readthedocs.io/en/stable/running_mypy.html#following-imports
"--follow-imports=silent",
"--disable-error-code=unused-ignore",
]
additional_dependencies:
- types-protobuf
- types-python-dateutil
- types-requests
36 changes: 0 additions & 36 deletions Pipfile

This file was deleted.

Loading