From 85cb35a9fedbb3da1709f41e905c4f04a5410bb8 Mon Sep 17 00:00:00 2001 From: Cosmin Paunel Date: Mon, 26 Jan 2026 13:17:46 +0200 Subject: [PATCH] fix: multiple workflow invocations for lint and test --- .github/scripts/detect_changed_packages.py | 14 +-- .github/workflows/integration_tests.yml | 7 +- .github/workflows/lint-custom-version.yml | 7 +- .github/workflows/lint-packages.yml | 132 +++++++-------------- .github/workflows/publish-dev.yml | 7 +- .github/workflows/publish.yml | 7 +- .github/workflows/test-custom-version.yml | 7 +- .github/workflows/test-packages.yml | 79 ++++-------- 8 files changed, 95 insertions(+), 165 deletions(-) diff --git a/.github/scripts/detect_changed_packages.py b/.github/scripts/detect_changed_packages.py index 128f77e..6ea89bb 100755 --- a/.github/scripts/detect_changed_packages.py +++ b/.github/scripts/detect_changed_packages.py @@ -87,17 +87,11 @@ def main(): base_sha = os.getenv("BASE_SHA", "") head_sha = os.getenv("HEAD_SHA", "") - # On push to main, test all packages - if event_name == "push": - packages = get_all_packages() - print(f"Push to main - testing all {len(packages)} packages:") - for pkg in packages: - print(f" - {pkg}") - - # On PR with explicit SHAs, detect changed packages - elif event_name == "pull_request" and base_sha and head_sha: + # If we have explicit SHAs (from PR or push), detect changed packages + if base_sha and head_sha: packages = get_changed_packages(base_sha, head_sha) - print(f"Pull request - detected {len(packages)} changed package(s):") + event_type = "pull request" if event_name == "pull_request" else "push" + print(f"{event_type.capitalize()} - detected {len(packages)} changed package(s):") for pkg in packages: print(f" - {pkg}") diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index c3ef5d0..555567d 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -38,8 +38,11 @@ jobs: - name: Detect changed packages id: detect - run: | - python .github/scripts/detect_changed_packages.py + env: + GITHUB_EVENT_NAME: ${{ github.event_name }} + BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.event.after }} + run: python .github/scripts/detect_changed_packages.py discover-testcases: needs: detect-changed-packages diff --git a/.github/workflows/lint-custom-version.yml b/.github/workflows/lint-custom-version.yml index b666d15..86ae316 100644 --- a/.github/workflows/lint-custom-version.yml +++ b/.github/workflows/lint-custom-version.yml @@ -33,8 +33,11 @@ jobs: - name: Detect changed packages id: detect - run: | - python .github/scripts/detect_changed_packages.py + env: + GITHUB_EVENT_NAME: ${{ github.event_name }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: python .github/scripts/detect_changed_packages.py lint-with-custom-version: name: Lint ${{ matrix.package }} - Custom Version diff --git a/.github/workflows/lint-packages.yml b/.github/workflows/lint-packages.yml index df54d77..2cbe1c5 100644 --- a/.github/workflows/lint-packages.yml +++ b/.github/workflows/lint-packages.yml @@ -31,120 +31,66 @@ jobs: HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: python .github/scripts/detect_changed_packages.py - lint: - name: Lint ${{ matrix.package }} - needs: detect-changed-packages - if: needs.detect-changed-packages.outputs.count > 0 && !contains(github.event.pull_request.labels.*.name, 'test-core-dev-version') - runs-on: ubuntu-latest - defaults: - run: - working-directory: packages/${{ matrix.package }} - strategy: - fail-fast: false - matrix: - package: ${{ fromJson(needs.detect-changed-packages.outputs.packages) }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup uv - uses: astral-sh/setup-uv@v5 - with: - enable-cache: true - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version-file: "packages/${{ matrix.package }}/.python-version" - - - name: Install dependencies - run: uv sync --all-extras - - - name: Check static types - run: uv run mypy --config-file pyproject.toml . - - - name: Check linting - run: uv run ruff check . - - - name: Check formatting - run: uv run ruff format --check . - - skip-lint: - name: Skip Lint (Custom Version Testing) - runs-on: ubuntu-latest - if: contains(github.event.pull_request.labels.*.name, 'test-core-dev-version') - permissions: - contents: read - steps: - - name: Skip lint for custom version testing - run: | - echo "Custom version testing enabled - skipping normal lint process" - echo "This job completes successfully to allow PR merging" - - # Per-package gate jobs that always run lint-llamaindex: name: Lint uipath-llamaindex needs: detect-changed-packages runs-on: ubuntu-latest steps: - - name: Check if should skip + - name: Check if package changed id: check run: | - # Check for test-core-dev-version label if [[ "${{ contains(github.event.pull_request.labels.*.name, 'test-core-dev-version') }}" == "true" ]]; then - echo "changed=false" >> $GITHUB_OUTPUT + echo "skip=true" >> $GITHUB_OUTPUT echo "reason=custom-version-testing" >> $GITHUB_OUTPUT - # Check if package changed - elif echo '${{ needs.detect-changed-packages.outputs.packages }}' | grep -q 'uipath-llamaindex'; then - echo "changed=true" >> $GITHUB_OUTPUT + elif echo '${{ needs.detect-changed-packages.outputs.packages }}' | jq -e 'index("uipath-llamaindex")' > /dev/null; then + echo "skip=false" >> $GITHUB_OUTPUT else - echo "changed=false" >> $GITHUB_OUTPUT + echo "skip=true" >> $GITHUB_OUTPUT echo "reason=no-changes" >> $GITHUB_OUTPUT fi - - name: Skip if no changes or custom version testing - if: steps.check.outputs.changed != 'true' + - name: Skip + if: steps.check.outputs.skip == 'true' run: | if [[ "${{ steps.check.outputs.reason }}" == "custom-version-testing" ]]; then - echo "Custom version testing enabled - skipping lint" + echo "Skipping - custom version testing enabled" else - echo "No changes to uipath-llamaindex, skipping lint" + echo "Skipping - no changes to uipath-llamaindex" fi - name: Checkout - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: actions/checkout@v4 - name: Setup uv - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: astral-sh/setup-uv@v5 with: enable-cache: true - name: Setup Python - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: actions/setup-python@v5 with: python-version-file: "packages/uipath-llamaindex/.python-version" - name: Install dependencies - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-llamaindex run: uv sync --all-extras - name: Check static types - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-llamaindex run: uv run mypy --config-file pyproject.toml . - name: Check linting - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-llamaindex run: uv run ruff check . - name: Check formatting - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-llamaindex run: uv run ruff format --check . @@ -153,62 +99,72 @@ jobs: needs: detect-changed-packages runs-on: ubuntu-latest steps: - - name: Check if should skip + - name: Check if package changed id: check run: | - # Check for test-core-dev-version label if [[ "${{ contains(github.event.pull_request.labels.*.name, 'test-core-dev-version') }}" == "true" ]]; then - echo "changed=false" >> $GITHUB_OUTPUT + echo "skip=true" >> $GITHUB_OUTPUT echo "reason=custom-version-testing" >> $GITHUB_OUTPUT - # Check if package changed - elif echo '${{ needs.detect-changed-packages.outputs.packages }}' | grep -q 'uipath-openai-agents'; then - echo "changed=true" >> $GITHUB_OUTPUT + elif echo '${{ needs.detect-changed-packages.outputs.packages }}' | jq -e 'index("uipath-openai-agents")' > /dev/null; then + echo "skip=false" >> $GITHUB_OUTPUT else - echo "changed=false" >> $GITHUB_OUTPUT + echo "skip=true" >> $GITHUB_OUTPUT echo "reason=no-changes" >> $GITHUB_OUTPUT fi - - name: Skip if no changes or custom version testing - if: steps.check.outputs.changed != 'true' + - name: Skip + if: steps.check.outputs.skip == 'true' run: | if [[ "${{ steps.check.outputs.reason }}" == "custom-version-testing" ]]; then - echo "Custom version testing enabled - skipping lint" + echo "Skipping - custom version testing enabled" else - echo "No changes to uipath-openai-agents, skipping lint" + echo "Skipping - no changes to uipath-openai-agents" fi - name: Checkout - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: actions/checkout@v4 - name: Setup uv - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: astral-sh/setup-uv@v5 with: enable-cache: true - name: Setup Python - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: actions/setup-python@v5 with: python-version-file: "packages/uipath-openai-agents/.python-version" - name: Install dependencies - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-openai-agents run: uv sync --all-extras - name: Check static types - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-openai-agents run: uv run mypy --config-file pyproject.toml . - name: Check linting - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-openai-agents run: uv run ruff check . - name: Check formatting - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-openai-agents run: uv run ruff format --check . + + skip-lint: + name: Skip Lint (Custom Version Testing) + runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'test-core-dev-version') + permissions: + contents: read + steps: + - name: Skip lint for custom version testing + run: | + echo "Custom version testing enabled - skipping normal lint process" + echo "This job completes successfully to allow PR merging" diff --git a/.github/workflows/publish-dev.yml b/.github/workflows/publish-dev.yml index 27cd07b..40f5bd1 100644 --- a/.github/workflows/publish-dev.yml +++ b/.github/workflows/publish-dev.yml @@ -32,8 +32,11 @@ jobs: - name: Detect changed packages id: detect - run: | - python .github/scripts/detect_changed_packages.py + env: + GITHUB_EVENT_NAME: ${{ github.event_name }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: python .github/scripts/detect_changed_packages.py publish-dev: name: Publish Dev Build - ${{ matrix.package }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4283bc5..badbd86 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -31,8 +31,11 @@ jobs: - name: Detect changed packages id: detect - run: | - python .github/scripts/detect_changed_packages.py + env: + GITHUB_EVENT_NAME: ${{ github.event_name }} + BASE_SHA: ${{ github.event.before }} + HEAD_SHA: ${{ github.event.after }} + run: python .github/scripts/detect_changed_packages.py build: name: Build ${{ matrix.package }} diff --git a/.github/workflows/test-custom-version.yml b/.github/workflows/test-custom-version.yml index 4ef55fc..c166414 100644 --- a/.github/workflows/test-custom-version.yml +++ b/.github/workflows/test-custom-version.yml @@ -40,8 +40,11 @@ jobs: - name: Detect changed packages id: detect - run: | - python .github/scripts/detect_changed_packages.py + env: + GITHUB_EVENT_NAME: ${{ github.event_name }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: python .github/scripts/detect_changed_packages.py test-core-dev-version: name: Test ${{ matrix.package }} - Custom Version diff --git a/.github/workflows/test-packages.yml b/.github/workflows/test-packages.yml index 3d8e41f..6a875fc 100644 --- a/.github/workflows/test-packages.yml +++ b/.github/workflows/test-packages.yml @@ -32,41 +32,6 @@ jobs: HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: python .github/scripts/detect_changed_packages.py - test: - name: Test ${{ matrix.package }} (py${{ matrix.python-version }}, ${{ matrix.os }}) - needs: detect-changed-packages - if: needs.detect-changed-packages.outputs.count > 0 - runs-on: ${{ matrix.os }} - defaults: - run: - working-directory: packages/${{ matrix.package }} - - strategy: - fail-fast: false - matrix: - package: ${{ fromJson(needs.detect-changed-packages.outputs.packages) }} - python-version: ["3.11", "3.12", "3.13"] - os: [ubuntu-latest, windows-latest] - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup uv - uses: astral-sh/setup-uv@v5 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: uv sync --all-extras --python ${{ matrix.python-version }} - - - name: Run tests - run: uv run pytest - - # Per-package gate jobs that always run test-llamaindex: name: Test (uipath-llamaindex, ${{ matrix.python-version }}, ${{ matrix.os }}) needs: detect-changed-packages @@ -81,38 +46,38 @@ jobs: id: check shell: bash run: | - if echo '${{ needs.detect-changed-packages.outputs.packages }}' | grep -q 'uipath-llamaindex'; then - echo "changed=true" >> $GITHUB_OUTPUT + if echo '${{ needs.detect-changed-packages.outputs.packages }}' | jq -e 'index("uipath-llamaindex")' > /dev/null; then + echo "skip=false" >> $GITHUB_OUTPUT else - echo "changed=false" >> $GITHUB_OUTPUT + echo "skip=true" >> $GITHUB_OUTPUT fi - - name: Skip if no changes - if: steps.check.outputs.changed != 'true' + - name: Skip + if: steps.check.outputs.skip == 'true' shell: bash - run: echo "No changes to uipath-llamaindex, skipping tests" + run: echo "Skipping - no changes to uipath-llamaindex" - name: Checkout - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: actions/checkout@v4 - name: Setup uv - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: astral-sh/setup-uv@v5 - name: Setup Python - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-llamaindex run: uv sync --all-extras --python ${{ matrix.python-version }} - name: Run tests - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-llamaindex run: uv run pytest @@ -130,37 +95,37 @@ jobs: id: check shell: bash run: | - if echo '${{ needs.detect-changed-packages.outputs.packages }}' | grep -q 'uipath-openai-agents'; then - echo "changed=true" >> $GITHUB_OUTPUT + if echo '${{ needs.detect-changed-packages.outputs.packages }}' | jq -e 'index("uipath-openai-agents")' > /dev/null; then + echo "skip=false" >> $GITHUB_OUTPUT else - echo "changed=false" >> $GITHUB_OUTPUT + echo "skip=true" >> $GITHUB_OUTPUT fi - - name: Skip if no changes - if: steps.check.outputs.changed != 'true' + - name: Skip + if: steps.check.outputs.skip == 'true' shell: bash - run: echo "No changes to uipath-openai-agents, skipping tests" + run: echo "Skipping - no changes to uipath-openai-agents" - name: Checkout - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: actions/checkout@v4 - name: Setup uv - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: astral-sh/setup-uv@v5 - name: Setup Python - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-openai-agents run: uv sync --all-extras --python ${{ matrix.python-version }} - name: Run tests - if: steps.check.outputs.changed == 'true' + if: steps.check.outputs.skip != 'true' working-directory: packages/uipath-openai-agents run: uv run pytest