Refactor figure internals and add complexity reporting #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Complexity Report | |
| on: | |
| pull_request: | |
| branches: [main, devel] | |
| paths: | |
| - "**/*.py" | |
| - "pyproject.toml" | |
| - ".github/workflows/complexity.yml" | |
| push: | |
| branches: [main, devel] | |
| paths: | |
| - "**/*.py" | |
| - "pyproject.toml" | |
| - ".github/workflows/complexity.yml" | |
| jobs: | |
| report: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: python -m pip install --upgrade pip radon | |
| - name: Resolve diff base | |
| id: refs | |
| shell: bash | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | |
| else | |
| BASE_SHA="${{ github.event.before }}" | |
| if [ -z "${BASE_SHA}" ] || [ "${BASE_SHA}" = "0000000000000000000000000000000000000000" ]; then | |
| BASE_SHA="$(git rev-parse "${GITHUB_SHA}^" 2>/dev/null || true)" | |
| fi | |
| fi | |
| if [ -z "${BASE_SHA}" ]; then | |
| echo "has_base=false" >> "${GITHUB_OUTPUT}" | |
| exit 0 | |
| fi | |
| echo "has_base=true" >> "${GITHUB_OUTPUT}" | |
| echo "base_sha=${BASE_SHA}" >> "${GITHUB_OUTPUT}" | |
| echo "head_sha=${GITHUB_SHA}" >> "${GITHUB_OUTPUT}" | |
| - name: Generate complexity report | |
| if: steps.refs.outputs.has_base == 'true' | |
| run: | | |
| python tools/ci/complexity_report.py \ | |
| --base-ref "${{ steps.refs.outputs.base_sha }}" \ | |
| --head-ref "${{ steps.refs.outputs.head_sha }}" \ | |
| --output-json .ci/complexity-report.json \ | |
| --output-markdown .ci/complexity-summary.md | |
| - name: Summarize skipped report | |
| if: steps.refs.outputs.has_base != 'true' | |
| run: | | |
| mkdir -p .ci | |
| cat <<'EOF' > .ci/complexity-summary.md | |
| ## Complexity Report | |
| No suitable base commit was available for comparison. | |
| EOF | |
| - name: Publish job summary | |
| run: cat .ci/complexity-summary.md >> "${GITHUB_STEP_SUMMARY}" | |
| - name: Upload complexity report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: complexity-report | |
| path: | | |
| .ci/complexity-report.json | |
| .ci/complexity-summary.md | |
| if-no-files-found: ignore |