Python: move all tests under tests and initial work on int tests (#206)

* move all tests under tests and initial work on int tests

* added updated tests setup and merge tests

* without failing step

* fixed upload

* updated file names for coverage

* reenable surface tests

* removed package matrix

* simplified variables

* correct path

* removed mistake

* fix mistake in path

* fix path

* windows specific env set

* updated merge tests

* slight update in marker

* added run integration tests settings

* updated setup, moved foundry int tests and updated merge test
This commit is contained in:
Eduard van Valkenburg
2025-07-22 17:26:00 +02:00
committed by GitHub
Unverified
parent f89c0be0ea
commit 5c992eb7ae
31 changed files with 978 additions and 639 deletions
+48
View File
@@ -0,0 +1,48 @@
name: Label issues
on:
issues:
types:
- reopened
- opened
jobs:
label_issues:
name: "Issue: add labels"
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' }}
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_ACTIONS_PR_WRITE }}
script: |
// Get the issue body and title
const body = context.payload.issue.body
let title = context.payload.issue.title
// Define the labels array
let labels = ["triage"]
// Check if the body or the title contains the word 'python' (case-insensitive)
if ((body != null && body.match(/python/i)) || (title != null && title.match(/python/i))) {
// Add the 'python' label to the array
labels.push("python")
}
// Check if the body or the title contains the words 'dotnet', '.net', 'c#' or 'csharp' (case-insensitive)
if ((body != null && body.match(/.net/i)) || (title != null && title.match(/.net/i)) ||
(body != null && body.match(/dotnet/i)) || (title != null && title.match(/dotnet/i)) ||
(body != null && body.match(/C#/i)) || (title != null && title.match(/C#/i)) ||
(body != null && body.match(/csharp/i)) || (title != null && title.match(/csharp/i))) {
// Add the '.NET' label to the array
labels.push(".NET")
}
// Add the labels to the issue
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
});
+21
View File
@@ -0,0 +1,21 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler
name: Label pull request
on: [pull_request_target]
jobs:
add_label:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GH_ACTIONS_PR_WRITE }}"
+188
View File
@@ -0,0 +1,188 @@
name: Python - Tests - Merge
on:
workflow_dispatch:
merge_group:
branches: ["main"]
permissions:
contents: read
id-token: "write"
env:
# Configure a constant location for the uv cache
UV_CACHE_DIR: /tmp/.uv-cache
RUN_INTEGRATION_TESTS: "true"
jobs:
python-tests-main:
name: Python Tests - Main
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
python-version: ["3.10"]
os: [ubuntu-latest]
env:
UV_PYTHON: ${{ matrix.python-version }}
OPENAI_CHAT_MODEL_ID: ${{ vars.OPENAI__CHATMODELID }}
OPENAI_API_KEY: ${{ secrets.OPENAI__APIKEY }}
PACKAGE_NAME: "main"
permissions:
contents: write
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
version: "0.7.x"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
cache-dependency-glob: "**/uv.lock"
- name: Install the project
run: |
uv sync --all-packages --all-extras --dev -U --prerelease=if-necessary-or-explicit
- name: Test with pytest
run: uv run poe --directory ./packages/${{ env.PACKAGE_NAME }} test --junitxml=coverage.xml
working-directory: ./python
- name: Move coverage file
run: |
mv ./packages/${{ env.PACKAGE_NAME }}/coverage.xml coverage_${{ env.PACKAGE_NAME }}.xml
working-directory: ./python
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-${{ env.PACKAGE_NAME }}
path: ./python/coverage_${{ env.PACKAGE_NAME }}.xml
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@v0.7.2
with:
path: ./python/**.xml
summary: true
display-options: fEX
fail-on-empty: true
title: Test results
python-tests-azure:
name: Python Tests - Azure
runs-on: ${{ matrix.os }}
environment: "integration"
strategy:
fail-fast: true
matrix:
python-version: ["3.10"]
os: [ubuntu-latest]
env:
UV_PYTHON: ${{ matrix.python-version }}
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME: ${{ vars.AZUREAI__DEPLOYMENTNAME }}
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZUREAI__ENDPOINT }}
PACKAGE_NAME: "azure"
permissions:
contents: write
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
version: "0.7.x"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
cache-dependency-glob: "**/uv.lock"
- name: Install the project
run: |
uv sync --all-packages --all-extras --dev -U --prerelease=if-necessary-or-explicit
- name: Azure CLI Login
if: github.event_name != 'pull_request'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Test with pytest
run: uv run poe --directory ./packages/${{ env.PACKAGE_NAME }} test --junitxml=coverage.xml
working-directory: ./python
- name: Move coverage file
run: |
mv ./packages/${{ env.PACKAGE_NAME }}/coverage.xml coverage_${{ env.PACKAGE_NAME }}.xml
working-directory: ./python
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-${{ env.PACKAGE_NAME }}
path: ./python/coverage_${{ env.PACKAGE_NAME }}.xml
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@v0.7.2
with:
path: ./python/**.xml
summary: true
display-options: fEX
fail-on-empty: true
title: Test results
python-tests-foundry:
name: Python Tests - Foundry
runs-on: ${{ matrix.os }}
environment: "integration"
strategy:
fail-fast: true
matrix:
python-version: ["3.10"]
os: [ubuntu-latest]
env:
UV_PYTHON: ${{ matrix.python-version }}
FOUNDRY_PROJECT_ENDPOINT: ${{ vars.FOUNDRY_PROJECT_ENDPOINT }}
FOUNDRY_MODEL_DEPLOYMENT_NAME: ${{ vars.FOUNDRY_MODEL_DEPLOYMENT_NAME }}
PACKAGE_NAME: "foundry"
permissions:
contents: write
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
version: "0.7.x"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
cache-dependency-glob: "**/uv.lock"
- name: Install the project
run: |
uv sync --all-packages --all-extras --dev -U --prerelease=if-necessary-or-explicit
- name: Azure CLI Login
if: github.event_name != 'pull_request'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Test with pytest
run: uv run poe --directory ./packages/${{ env.PACKAGE_NAME }} test --junitxml=coverage.xml
working-directory: ./python
- name: Move coverage file
run: |
mv ./packages/${{ env.PACKAGE_NAME }}/coverage.xml coverage_${{ env.PACKAGE_NAME }}.xml
working-directory: ./python
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-${{ env.PACKAGE_NAME }}
path: ./python/coverage_${{ env.PACKAGE_NAME }}.xml
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@v0.7.2
with:
path: ./python/**.xml
summary: true
display-options: fEX
fail-on-empty: true
title: Test results
+111
View File
@@ -0,0 +1,111 @@
name: Python - Tests
on:
pull_request:
branches: ["main", "feature*"]
paths:
- "python/**"
env:
# Configure a constant location for the uv cache
UV_CACHE_DIR: /tmp/.uv-cache
jobs:
python-tests:
name: Python Tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, windows-latest, macos-latest]
env:
UV_PYTHON: ${{ matrix.python-version }}
permissions:
contents: write
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
version: "0.7.x"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
cache-dependency-glob: "**/uv.lock"
- name: Install the project
run: |
uv sync --all-packages --all-extras --dev -U --prerelease=if-necessary-or-explicit
# Main package tests
- name: Set environment variables - main - win
if: ${{ matrix.os == 'windows-latest' }}
run: |
echo "PACKAGE_NAME=main" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Set environment variables - main
if: ${{ matrix.os != 'windows-latest' }}
run: |
echo "PACKAGE_NAME=main" >> $GITHUB_ENV
- name: Test with pytest - main
run: uv run poe --directory ./packages/${{ env.PACKAGE_NAME }} test --junitxml=coverage.xml
working-directory: ./python
- name: Move coverage file - main
run: |
mv ./packages/${{ env.PACKAGE_NAME }}/coverage.xml coverage_${{ matrix.OS }}_${{ matrix.python-version }}_${{ env.PACKAGE_NAME }}.xml
working-directory: ./python
- name: Upload coverage artifact - main
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.OS }}-${{ matrix.python-version }}-${{ env.PACKAGE_NAME }}
path: ./python/coverage_${{ matrix.OS }}_${{ matrix.python-version }}_${{ env.PACKAGE_NAME }}.xml
# Azure package tests
- name: Set environment variables - azure - win
if: ${{ matrix.os == 'windows-latest' }}
run: |
echo "PACKAGE_NAME=azure" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Set environment variables - azure
if: ${{ matrix.os != 'windows-latest' }}
run: |
echo "PACKAGE_NAME=azure" >> $GITHUB_ENV
- name: Test with pytest - azure
run: uv run poe --directory ./packages/${{ env.PACKAGE_NAME }} test --junitxml=coverage.xml
working-directory: ./python
- name: Move coverage file - azure
run: |
mv ./packages/${{ env.PACKAGE_NAME }}/coverage.xml coverage_${{ matrix.OS }}_${{ matrix.python-version }}_${{ env.PACKAGE_NAME }}.xml
working-directory: ./python
- name: Upload coverage artifact - azure
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.OS }}-${{ matrix.python-version }}-${{ env.PACKAGE_NAME }}
path: ./python/coverage_${{ matrix.OS }}_${{ matrix.python-version }}_${{ env.PACKAGE_NAME }}.xml
# Foundry package tests
- name: Set environment variables - foundry - win
if: ${{ matrix.os == 'windows-latest' }}
run: |
echo "PACKAGE_NAME=foundry" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Set environment variables - foundry
if: ${{ matrix.os != 'windows-latest' }}
run: |
echo "PACKAGE_NAME=foundry" >> $GITHUB_ENV
- name: Test with pytest - foundry
run: uv run poe --directory ./packages/${{ env.PACKAGE_NAME }} test --junitxml=coverage.xml
working-directory: ./python
- name: Move coverage file - foundry
run: |
mv ./packages/${{ env.PACKAGE_NAME }}/coverage.xml coverage_${{ matrix.OS }}_${{ matrix.python-version }}_${{ env.PACKAGE_NAME }}.xml
working-directory: ./python
- name: Upload coverage artifact - foundry
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.OS }}-${{ matrix.python-version }}-${{ env.PACKAGE_NAME }}
path: ./python/coverage_${{ matrix.OS }}_${{ matrix.python-version }}_${{ env.PACKAGE_NAME }}.xml
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@v0.7.2
with:
path: ./python/**.xml
summary: true
display-options: fEX
fail-on-empty: true
title: Test results
-49
View File
@@ -1,49 +0,0 @@
name: Python - Unit Tests
on:
pull_request:
branches: ["main", "feature*"]
paths:
- "python/**"
env:
# Configure a constant location for the uv cache
UV_CACHE_DIR: /tmp/.uv-cache
jobs:
python-unit-tests:
name: Python Unit Tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, windows-latest, macos-latest]
env:
UV_PYTHON: ${{ matrix.python-version }}
permissions:
contents: write
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
version: "0.7.x"
enable-cache: true
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
cache-dependency-glob: "**/uv.lock"
- name: Install the project
run: uv sync --all-packages --all-extras --dev -U --prerelease=if-necessary-or-explicit
- name: Test with pytest
run: uv run --frozen poe test --junitxml=pytest.xml
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@v0.7.2
with:
path: python/**/pytest.xml
summary: true
display-options: fEX
fail-on-empty: true
title: Test results