Skip to content

fix(neutron): refactor palo_alto to move pure functions out of class #4393

fix(neutron): refactor palo_alto to move pure functions out of class

fix(neutron): refactor palo_alto to move pure functions out of class #4393

Workflow file for this run

name: code tests
on:
push:
branches:
- main
paths:
- "python/**"
- ".github/workflows/code-test.yaml"
pull_request:
paths:
- "python/**"
- ".github/workflows/code-test.yaml"
workflow_dispatch:
merge_group:
types: [checks_requested]
# limit rapid succession from pushes
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
discover:
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.set-projects.outputs.projects }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- name: Find all projects with pyproject.toml
id: set-projects
run: |
# grabs all paths with pyproject.toml, snips the 2nd dir, grabs only unique ones, makes a JSON list
projects=$(find python -mindepth 2 ! -wholename 'python/understack-tests/*' -name pyproject.toml | awk -F/ '{print $2}' | sort -u | jq -R -s -c 'split("\n")[:-1]')
echo "projects=$projects" >> "$GITHUB_OUTPUT"
uv:
needs: [discover]
runs-on: ubuntu-latest
strategy:
matrix:
project: ${{ fromJson(needs.discover.outputs.projects) }}
defaults:
run:
working-directory: ./python/${{ matrix.project }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
with:
python-version-file: python/${{ matrix.project }}/pyproject.toml
- run: uv sync
- run: uv build --wheel
- run: |
set -e
if [ -e .stestr.conf ]; then
uv run stestr run
else
uv run pytest --cov --cov-report xml:coverage.xml --junitxml=junit.xml
fi
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: coverage-${{ matrix.project }}
path: python/${{ matrix.project }}/coverage.xml
retention-days: 1
# Publish the ML2 scenario traceability matrix (scenario ID -> status) to
# the job summary and keep the JUnit as an artifact. neutron-understack
# only: its scenario tests tag each JUnit case with a `scenario` property.
- name: ML2 scenario traceability report
if: ${{ always() && matrix.project == 'neutron-understack' }}
run: |
if [ -f junit.xml ]; then
uv run python ../../scripts/scenario-report.py \
--catalog neutron_understack/tests/scenarios/SCENARIOS.md \
--junit junit.xml >> "$GITHUB_STEP_SUMMARY"
else
echo "No junit.xml produced (tests did not run)." >> "$GITHUB_STEP_SUMMARY"
fi
# Keep each project's JUnit for the consolidated publish-test-results job.
# if-no-files-found=ignore: stestr projects don't emit junit.xml.
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: ${{ always() }}
with:
name: junit-${{ matrix.project }}
path: python/${{ matrix.project }}/junit.xml
if-no-files-found: ignore
retention-days: 1
coverage-upload:
needs: [uv]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: coverage-*
merge-multiple: true
- run: |
npx cobertura-merge-globby -o output.xml --files=python/**/coverage.xml
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: coverage.xml
path: coverage.xml
retention-days: 1
# Consolidated pass/fail/skip report from every project's JUnit, posted as a
# PR comment + check. Same-repo PRs only get write permissions; fork PRs would
# need a separate workflow_run-triggered workflow (not wired up here).
publish-test-results:
needs: [uv]
# Skip on fork PRs: the token is read-only there, so the action cannot post
# the check/comment. Forks would need a separate workflow_run workflow.
if: ${{ always() && github.event.pull_request.head.repo.fork != true }}
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
contents: read
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: junit-*
merge-multiple: true
path: junit
- uses: EnricoMi/publish-unit-test-result-action@d0a4676d0e0b938bc201470d88276b7c74c712b3 # v2.24.0
with:
check_name: Python test results
junit_files: junit/**/*.xml