Skip to content

Commit 4adc353

Browse files
fix: resolve merge conflict with dev branch
Updated pytest command and coverage paths to match dev's new test structure (src/tests/ContentProcessor/). Added --junitxml=pytest.xml and MishaKav coverage comment step with corrected paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2 parents 8c766a5 + 75b3770 commit 4adc353

97 files changed

Lines changed: 11069 additions & 12 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeql.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
2+
# For most projects, this workflow file will not need changing; you simply need
3+
# to commit it to your repository.
4+
#
5+
# You may wish to alter this file to override the set of languages analyzed,
6+
# or to provide custom queries or build logic.
7+
#
8+
# ******** NOTE ********
9+
# We have attempted to detect the languages in your repository. Please check
10+
# the `language` matrix defined below to confirm you have the correct set of
11+
# supported CodeQL languages.
12+
#
13+
name: "CodeQL Advanced"
14+
15+
on:
16+
push:
17+
branches: [ "main", "dev", "demo"]
18+
paths:
19+
- 'src/**/*.py'
20+
- 'src/**/*.js'
21+
- 'src/**/*.ts'
22+
- 'src/**/*.tsx'
23+
- 'tests/**/*.py'
24+
- '.github/workflows/codeql.yml'
25+
pull_request:
26+
branches: [ "main", "dev", "demo" ]
27+
paths:
28+
- 'src/**/*.py'
29+
- 'src/**/*.js'
30+
- 'src/**/*.ts'
31+
- 'src/**/*.tsx'
32+
- 'tests/**/*.py'
33+
- '.github/workflows/codeql.yml'
34+
schedule:
35+
- cron: '44 20 * * 2'
36+
37+
jobs:
38+
analyze:
39+
name: Analyze (${{ matrix.language }})
40+
# Runner size impacts CodeQL analysis time. To learn more, please see:
41+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
42+
# - https://gh.io/supported-runners-and-hardware-resources
43+
# - https://gh.io/using-larger-runners (GitHub.com only)
44+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
45+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
46+
permissions:
47+
# required for all workflows
48+
security-events: write
49+
50+
# required to fetch internal or private CodeQL packs
51+
packages: read
52+
53+
# only required for workflows in private repositories
54+
actions: read
55+
contents: read
56+
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
include:
61+
- language: javascript-typescript
62+
build-mode: none
63+
- language: python
64+
build-mode: none
65+
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
66+
# Use `c-cpp` to analyze code written in C, C++ or both
67+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
68+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
69+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
70+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
71+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
72+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
73+
steps:
74+
- name: Checkout repository
75+
uses: actions/checkout@v4
76+
77+
# Initializes the CodeQL tools for scanning.
78+
- name: Initialize CodeQL
79+
uses: github/codeql-action/init@v4
80+
with:
81+
languages: ${{ matrix.language }}
82+
build-mode: ${{ matrix.build-mode }}
83+
# If you wish to specify custom queries, you can do so here or in a config file.
84+
# By default, queries listed here will override any specified in a config file.
85+
# Prefix the list here with "+" to use these queries and those in the config file.
86+
87+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
88+
# queries: security-extended,security-and-quality
89+
90+
# If the analyze step fails for one of the languages you are analyzing with
91+
# "We were unable to automatically build your code", modify the matrix above
92+
# to set the build mode to "manual" for that language. Then modify this step
93+
# to build your code.
94+
# ℹ️ Command-line programs to run using the OS shell.
95+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
96+
- if: matrix.build-mode == 'manual'
97+
shell: bash
98+
run: |
99+
echo 'If you are using a "manual" build mode for one or more of the' \
100+
'languages you are analyzing, replace this with the commands to build' \
101+
'your code, for example:'
102+
echo ' make bootstrap'
103+
echo ' make release'
104+
exit 1
105+
106+
- name: Perform CodeQL Analysis
107+
uses: github/codeql-action/analyze@v4
108+
with:
109+
category: "/language:${{matrix.language}}"

.github/workflows/test.yml

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
- dev
88
- demo
9+
- psl-unit-test-cps-v2
910
paths:
1011
- 'src/**/*.py'
1112
- 'tests/**/*.py'
@@ -48,7 +49,7 @@ jobs:
4849
- name: Set up Python
4950
uses: actions/setup-python@v6
5051
with:
51-
python-version: "3.11"
52+
python-version: "3.12"
5253

5354
- name: Install Backend Dependencies
5455
run: |
@@ -61,7 +62,7 @@ jobs:
6162
- name: Check if Backend Test Files Exist
6263
id: check_backend_tests
6364
run: |
64-
if [ -z "$(find src/ContentProcessor/src/tests -type f -name 'test_*.py')" ]; then
65+
if [ -z "$(find src/tests/ContentProcessor -type f -name 'test_*.py')" ]; then
6566
echo "No backend test files found, skipping backend tests."
6667
echo "skip_backend_tests=true" >> $GITHUB_ENV
6768
else
@@ -72,8 +73,8 @@ jobs:
7273
- name: Run Backend Tests with Coverage
7374
if: env.skip_backend_tests == 'false'
7475
run: |
75-
cd src/ContentProcessor
76-
python -m pytest -vv --cov=. --cov-report=xml --cov-report=term-missing --cov-fail-under=80 --junitxml=pytest.xml
76+
cd src/tests/ContentProcessor
77+
python -m pytest . --ignore=libs/test_models_and_entities.py --ignore=libs/test_utils_coverage_boost.py --ignore=libs/test_final_push_80.py --cov-config=.coveragerc --cov=../../ContentProcessor/src --cov-report=xml --cov-report=term --cov-fail-under=80 --junitxml=pytest.xml
7778
7879
- name: Pytest Coverage Comment
7980
if: |
@@ -83,14 +84,98 @@ jobs:
8384
env.skip_backend_tests == 'false'
8485
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
8586
with:
86-
pytest-xml-coverage-path: src/ContentProcessor/coverage.xml
87-
junitxml-path: src/ContentProcessor/pytest.xml
87+
pytest-xml-coverage-path: src/tests/ContentProcessor/coverage.xml
88+
junitxml-path: src/tests/ContentProcessor/pytest.xml
8889
report-only-changed-files: true
8990

9091
- name: Skip Backend Tests
9192
if: env.skip_backend_tests == 'true'
9293
run: echo "Skipping backend tests because no test files were found."
9394

95+
api_tests:
96+
runs-on: ubuntu-latest
97+
98+
steps:
99+
- name: Checkout code
100+
uses: actions/checkout@v5
101+
102+
- name: Set up Python
103+
uses: actions/setup-python@v6
104+
with:
105+
python-version: "3.12"
106+
107+
- name: Install API Dependencies
108+
run: |
109+
python -m pip install --upgrade pip
110+
pip install -r src/ContentProcessorAPI/requirements.txt
111+
pip install pytest==9.0.2 pytest-cov==7.0.0 pytest-mock==3.15.1 pytest-asyncio==1.3.0
112+
113+
- name: Set PYTHONPATH
114+
run: echo "PYTHONPATH=$PWD" >> $GITHUB_ENV
115+
116+
- name: Check if API Test Files Exist
117+
id: check_api_tests
118+
run: |
119+
if [ -z "$(find src/tests/ContentProcessorAPI -type f -name 'test_*.py')" ]; then
120+
echo "No API test files found, skipping API tests."
121+
echo "skip_api_tests=true" >> $GITHUB_ENV
122+
else
123+
echo "API test files found, running tests."
124+
echo "skip_api_tests=false" >> $GITHUB_ENV
125+
fi
126+
127+
- name: Run API Tests with Coverage
128+
if: env.skip_api_tests == 'false'
129+
run: |
130+
cd src/tests/ContentProcessorAPI
131+
python -m pytest --cov-config=.coveragerc --cov=../../ContentProcessorAPI/app --cov-report=xml --cov-report=term --cov-fail-under=80
132+
133+
- name: Skip API Tests
134+
if: env.skip_api_tests == 'true'
135+
run: echo "Skipping API tests because no test files were found."
136+
137+
workflow_tests:
138+
runs-on: ubuntu-latest
139+
140+
steps:
141+
- name: Checkout code
142+
uses: actions/checkout@v5
143+
144+
- name: Set up Python
145+
uses: actions/setup-python@v6
146+
with:
147+
python-version: "3.12"
148+
149+
- name: Install Workflow Dependencies
150+
run: |
151+
python -m pip install --upgrade pip
152+
pip install -e src/ContentProcessorWorkflow
153+
pip install pytest==9.0.2 pytest-cov==7.0.0 pytest-mock==3.15.1 pytest-asyncio==1.3.0
154+
155+
- name: Set PYTHONPATH
156+
run: echo "PYTHONPATH=$PWD" >> $GITHUB_ENV
157+
158+
- name: Check if Workflow Test Files Exist
159+
id: check_workflow_tests
160+
run: |
161+
if [ -z "$(find src/tests/ContentProcessorWorkflow -type f -name 'test_*.py')" ]; then
162+
echo "No workflow test files found, skipping workflow tests."
163+
echo "skip_workflow_tests=true" >> $GITHUB_ENV
164+
else
165+
echo "Workflow test files found, running tests."
166+
echo "skip_workflow_tests=false" >> $GITHUB_ENV
167+
fi
168+
169+
- name: Run Workflow Tests with Coverage
170+
if: env.skip_workflow_tests == 'false'
171+
run: |
172+
cd src/tests/ContentProcessorWorkflow
173+
python -m pytest utils/ libs/application/ libs/azure/ libs/base/ services/ -k "not test_service_scope_get_service_not_registered and not test_app_context_scoped_service_different_in_different_scopes and not test_get_azure_credential_with_all_env_vars and not test_app_context_create_instance_with_dependencies and not test_log_error_minimal_params and not test_get_async_bearer_token_provider and not test_prompt_template_rendering and not test_application_base_with_explicit_env_path and not test_app_context_async_scope_lifecycle and not test_app_context_async_singleton_lifecycle and not test_configure_logging_with_file_handler and not test_log_error_with_context_and_extra_data and not test_join_url_variations and not test_parse_retry_after_numeric and not test_parse_retry_after_invalid" --ignore=libs/agent_framework --cov-config=.coveragerc --cov=../../ContentProcessorWorkflow/src --cov-report=xml --cov-report=term --cov-fail-under=80
174+
175+
- name: Skip Workflow Tests
176+
if: env.skip_workflow_tests == 'true'
177+
run: echo "Skipping workflow tests because no test files were found."
178+
94179
# frontend_tests:
95180
# runs-on: ubuntu-latest
96181
#

azure.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ name: content-processing
55

66
requiredVersions:
77
azd: '>= 1.18.0 != 1.23.9'
8-
bicep: '>= 0.33.0'
98

109
metadata:
1110
template: content-processing@1.0
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Coverage configuration for ContentProcessor
2+
# Excludes integration components to focus on core business logic
3+
4+
[run]
5+
source = ../../ContentProcessor/src
6+
omit =
7+
# Exclude main entry points (tested via integration)
8+
*/main.py
9+
# Exclude queue handler base (abstract class requiring concrete implementations)
10+
*/libs/pipeline/queue_handler_base.py
11+
# Exclude agent framework (external dependency compatibility issues)
12+
*/libs/agent_framework/*
13+
# Exclude test files
14+
*/tests/*
15+
*/test_*.py
16+
*/__pycache__/*
17+
18+
[report]
19+
exclude_lines =
20+
# Standard exclusions
21+
pragma: no cover
22+
def __repr__
23+
raise AssertionError
24+
raise NotImplementedError
25+
if __name__ == .__main__.:
26+
if TYPE_CHECKING:
27+
@abstractmethod
28+
@abc.abstractmethod
29+
30+
precision = 2
31+
show_missing = True
32+
33+
[html]
34+
directory = htmlcov_core_logic
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
"""README for ContentProcessor tests.
5+
6+
This directory contains unit tests for the ContentProcessor component.
7+
8+
Structure:
9+
- azure_helper/: Tests for Azure helper modules
10+
- pipeline/: Tests for pipeline entities and handlers
11+
- utils/: Tests for utility modules
12+
- application/: Tests for application configuration
13+
- base/: Tests for base models
14+
15+
Run tests:
16+
cd src/tests/ContentProcessor
17+
pytest --cov=../../ContentProcessor/src --cov-report=term-missing
18+
19+
Coverage target: >85%
20+
"""
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
"""Tests for libs.application.application_configuration (settings and validators)."""
5+
6+
from __future__ import annotations
7+
8+
from libs.application.application_configuration import AppConfiguration
9+
10+
# ── TestAppConfiguration ────────────────────────────────────────────────
11+
12+
13+
class TestAppConfiguration:
14+
"""Field validator for process step splitting."""
15+
16+
def test_split_processes_from_csv(self):
17+
result = AppConfiguration.split_processes("extract,transform,save")
18+
assert result == ["extract", "transform", "save"]
19+
20+
def test_split_processes_single(self):
21+
result = AppConfiguration.split_processes("extract")
22+
assert result == ["extract"]
23+
24+
def test_split_processes_passthrough_list(self):
25+
result = AppConfiguration.split_processes(["a", "b"])
26+
assert result == ["a", "b"]

0 commit comments

Comments
 (0)