diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95c29c6..39d0f4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,8 @@ on: permissions: checks: write contents: write + # deployments permission to deploy GitHub pages website + deployments: write pull-requests: write @@ -85,3 +87,19 @@ jobs: echo "Coverage Tests - ${{ steps.coverageComment.outputs.tests }}" echo "Coverage Time - ${{ steps.coverageComment.outputs.time }}" echo "Not Success Test Info - ${{ steps.coverageComment.outputs.notSuccessTestInfo }}" + + - name: Run benchmarks + run: | + pytest -m benchmark --benchmark-json=./output.json + + - name: Publish benchmark results + uses: benchmark-action/github-action-benchmark@v1 + with: + tool: 'pytest' + auto-push: false + output-file-path: output.json + github-token: ${{ secrets.GITHUB_TOKEN }} + comment-on-alert: true + save-data-file: false + skip-fetch-gh-pages: true + summary-always: true diff --git a/dev-requirements.txt b/dev-requirements.txt index 1e37df5..19242af 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,5 +1,7 @@ -r requirements.txt # Include all main requirements django>=4.2,<5.0 pytest +pytest-benchmark +pytest-django ruff pre-commit diff --git a/edtf/parser/grammar.py b/edtf/parser/grammar.py index 1747341..9840bde 100644 --- a/edtf/parser/grammar.py +++ b/edtf/parser/grammar.py @@ -2,9 +2,10 @@ # It's recommended to `enablePackrat()` immediately after importing pyparsing # https://github.com/pyparsing/pyparsing/wiki/Performance-Tips -import pyparsing -pyparsing.ParserElement.enablePackrat() +# TODO: uncomment this once benchmark testing has run once in CI +# import pyparsing +# pyparsing.ParserElement.enablePackrat() from pyparsing import ( Combine,