From 511d97b912f1c19491686e5c57d08c1f95379e3a Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 4 Mar 2026 23:45:26 +0100 Subject: [PATCH] re-enable codspeed (#11457) * re-enable codspeed * fix style * use 2 step check * use more verbose syntax * run performance even if not needed otherwise * fix possible injection * another possible injection * fix syntax * run python api instead of backend perf test forced * only submit tests when running in correct enviroment --- .github/workflows/qc_checks.yaml | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/qc_checks.yaml b/.github/workflows/qc_checks.yaml index 985c0e213d..a24f42520c 100644 --- a/.github/workflows/qc_checks.yaml +++ b/.github/workflows/qc_checks.yaml @@ -23,8 +23,6 @@ env: INVENTREE_SITE_URL: http://localhost:8000 INVENTREE_DEBUG: true - use_performance: false - permissions: contents: read @@ -42,6 +40,8 @@ jobs: cicd: ${{ steps.filter.outputs.cicd }} requirements: ${{ steps.filter.outputs.requirements }} runner-perf: ${{ steps.runner-perf.outputs.runner }} + performance: ${{ steps.performance.outputs.force-performance }} + submit-performance: ${{ steps.runner-perf.outputs.submit-performance }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pin@v6.0.2 @@ -77,10 +77,29 @@ jobs: if: | contains(github.event.pull_request.labels.*.name, 'dependency') || contains(github.event.pull_request.labels.*.name, 'full-run') + - name: Is performance testing being forced? + run: echo "force-performance=true" >> $GITHUB_OUTPUT + id: performance + if: | + contains(github.event.pull_request.labels.*.name, 'performance-run') - name: Which runner to use? + env: + GITHUB_REF: ${{ github.ref }} + PERFORMANCE: ${{ steps.performance.outputs.force-performance }} id: runner-perf # decide if we are running in inventree/inventree -> use codspeed-macro runner else ubuntu-24.04 - run: echo "runner=$([[ '${{ github.repository }}' == 'inventree/InvenTree' && '${{ env.use_performance }}' == 'true' ]] && echo 'codspeed-macro' || echo 'ubuntu-24.04')" >> $GITHUB_OUTPUT + run: | + is_main_push=false + if [[ '${{ github.event_name }}' == 'push' && "$GITHUB_REF" == 'refs/heads/master' ]]; then + is_main_push=true + fi + if [[ '${{ github.repository }}' == 'inventree/InvenTree' && ( "$is_main_push" == 'true' || "$PERFORMANCE" == 'true' ) ]]; then + echo "runner=codspeed-macro" >> "$GITHUB_OUTPUT" + echo "submit-performance=true" >> "$GITHUB_OUTPUT" + else + echo "runner=ubuntu-24.04" >> "$GITHUB_OUTPUT" + echo "submit-performance=false" >> "$GITHUB_OUTPUT" + fi pre-commit: name: Style [pre-commit] @@ -292,7 +311,7 @@ jobs: runs-on: ${{ needs.paths-filter.outputs.runner-perf }} needs: ["pre-commit", "paths-filter"] - if: needs.paths-filter.outputs.server == 'true' || needs.paths-filter.outputs.force == 'true' + if: needs.paths-filter.outputs.server == 'true' || needs.paths-filter.outputs.force == 'true' || needs.paths-filter.outputs.performance == 'true' permissions: contents: read id-token: write @@ -341,10 +360,11 @@ jobs: pip uninstall pytest-django -y cd ${WRAPPER_NAME} pip install . + if: needs.paths-filter.outputs.submit-performance == 'true' - name: Performance Reporting uses: CodSpeedHQ/action@dbda7111f8ac363564b0c51b992d4ce76bb89f2f # pin@v4 # check if we are in inventree/inventree - reporting only works in that OIDC context - if: github.repository == 'inventree/InvenTree' + if: github.repository == 'inventree/InvenTree' && needs.paths-filter.outputs.submit-performance == 'true' with: mode: walltime run: pytest ./src/performance --codspeed @@ -406,7 +426,7 @@ jobs: needs: ["pre-commit", "paths-filter"] # check if we are in inventree/inventree - reporting only works in that OIDC context - if: (needs.paths-filter.outputs.server == 'true' || needs.paths-filter.outputs.force == 'true') && github.repository == 'inventree/InvenTree' + if: (needs.paths-filter.outputs.server == 'true' || needs.paths-filter.outputs.force == 'true') && github.repository == 'inventree/InvenTree' && needs.paths-filter.outputs.submit-performance == 'true' permissions: contents: read id-token: write