Skip to content
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
14 changes: 0 additions & 14 deletions .github/actions/python-package-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,6 @@ runs:
echo "dist-path=dist" >> $GITHUB_OUTPUT
echo "Built wheel: $WHEEL_FILE"

- name: Test package as CLI tool
if: inputs.test-package == 'true'
shell: bash
run: |
uv venv --python ${{ inputs.python-version }}
uv pip install "${{ steps.build.outputs.wheel-file }}[cli]"
uv run ${{ inputs.cli-test-command }}

- name: Publish package
if: inputs.publish == 'true'
shell: bash
run: |
uv publish

branding:
icon: "package"
color: "blue"
5 changes: 3 additions & 2 deletions .github/workflows/build-test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Build and Test Docker Image
on:
pull_request:
branches: ["main"]
workflow_dispatch:
push:
branches: ["main"]

jobs:
should-test-docker-build:
Expand Down Expand Up @@ -37,7 +38,7 @@ jobs:
needs: [should-test-docker-build]
name: Test Docker build ${{ matrix.arch }}
runs-on: ubuntu-latest
if: (needs.should-test-docker-build.outputs.workflow == 'true' || needs.should-test-docker-build.outputs.docker == 'true')
if: (needs.should-test-docker-build.outputs.workflow == 'true' || needs.should-test-docker-build.outputs.docker == 'true') || (github.ref_name == github.event.repository.default_branch)
permissions:
contents: read
packages: read
Expand Down
53 changes: 46 additions & 7 deletions .github/workflows/build-test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,62 @@ name: Build and Test Python Package
on:
pull_request:
branches: ["main"]
workflow_dispatch:
push:
branches: ["main"]

env:
PYTHON_VERSION: "3.10"

jobs:
test-build-package:
name: Test package build
test-build-package-extras:
name: Test package build ${{ matrix.name}}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
include:
- name: cli
test-args: "twyn --version"
- name: mcp
test-args: |
cat <<EOF > init_msg.json
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}
EOF
cat init_msg.json | uv run python src/twyn/mcp/main.py | grep -q "capabilities"
steps:
- name: Check out the repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Build package
uses: ./.github/actions/python-package-build
id: build
with:
uv-version: "0.8.22"
python-version: "$PYTHON_VERSION"
- name: Test package
run: |
uv venv --python $PYTHON_VERSION
uv pip install "${{ steps.build.outputs.wheel-file }}[${{ matrix.name }}]"
uv run ${{ matrix.test-args }}

test-build-package:
name: Test package build no extras
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Test build package
- name: Build package
uses: ./.github/actions/python-package-build
id: build
with:
test-package: "true"
uv-version: "0.8.22"
cli-test-command: "twyn --version"
python-version: "3.10"
python-version: "$PYTHON_VERSION"
- name: Test package
run: |
uv venv --python $PYTHON_VERSION
uv pip install "${{ steps.build.outputs.wheel-file }}"
uv run python -c 'import twyn; twyn.check_dependencies()'
93 changes: 5 additions & 88 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,92 +1,14 @@
# This workflow will publish our package on pypi

name: Publish

on:
push:
tags:
- "v*.*.*"

env:
UV_VERSION: "0.8.22"

jobs:
build_and_test_package:
name: Build and test package
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Build and test package
id: build-test
uses: ./.github/actions/python-package-build
with:
test-package: "true"
publish: "false"
uv-version: ${{ env.UV_VERSION }}
cli-test-command: "twyn --version"
python-version: "3.10"

- name: Upload package artifacts
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: python-package-${{ github.sha }}
path: ${{ steps.build-test.outputs.dist-path }}
retention-days: 1

build_and_test_docker:
name: Build and test Docker image (${{ matrix.arch }})
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- arch: amd64
platform: linux/amd64
cache-ref: buildcache-amd64
needs-qemu: false
- arch: arm64
platform: linux/arm64
cache-ref: buildcache-arm64
needs-qemu: true
steps:
- name: Check out the repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Log in to GitHub Container Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker image (${{ matrix.arch }})
uses: ./.github/actions/docker-build
with:
push: false
load: true
platforms: ${{ matrix.platform }}
dockerfile: ./Dockerfile
context: .
image-name: elementsinteractive/twyn
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:${{ matrix.cache-ref }}
cache-to: type=registry,ref=ghcr.io/elementsinteractive/twyn:${{ matrix.cache-ref }},mode=max,compression=zstd,force-compression=true,oci-mediatypes=true
setup-qemu: ${{ matrix.needs-qemu }}

- name: Test Docker image (${{ matrix.arch }})
run: |
docker run --platform ${{ matrix.platform }} --rm elementsinteractive/twyn --version
publish_to_pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build_and_test_package, build_and_test_docker]

permissions:
id-token: write
Expand All @@ -95,16 +17,12 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Download package artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: python-package-${{ github.sha }}
path: dist

- name: Install uv
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
- name: Build package
uses: ./.github/actions/python-package-build
id: build
with:
version: ${{ env.UV_VERSION }}
uv-version: "0.8.22"
python-version: "3.10"

- name: Publish package
run: |
Expand All @@ -113,7 +31,6 @@ jobs:
publish_to_dockerhub:
name: Push Docker images to registries
runs-on: ubuntu-latest
needs: [build_and_test_docker, build_and_test_package]
permissions:
contents: read
packages: write
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ cli = [
"click<9.0.0,>=8.1.8",
"rich<15.0.0,>=14.0.0",
]
mcp = [
"fastmcp>=3.0.2",
]

[tool.hatch.version]
path = "VERSION"
Expand Down
Loading
Loading