|
| 1 | +# Copyright 2023-2026 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# This is a reusable workflow for tracking test performance, individual limits, and regressions. |
| 16 | + |
| 17 | +name: Track Performance |
| 18 | + |
| 19 | +on: |
| 20 | + workflow_call: |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: write |
| 24 | + id-token: write |
| 25 | + pull-requests: write |
| 26 | + |
| 27 | +jobs: |
| 28 | + track: |
| 29 | + name: Track Test Performance |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v5 |
| 33 | + |
| 34 | + - name: Mark git repositories as safe |
| 35 | + run: git config --global --add safe.directory ${GITHUB_WORKSPACE} |
| 36 | + |
| 37 | + - name: Download all test results |
| 38 | + uses: actions/download-artifact@v4 |
| 39 | + with: |
| 40 | + path: test-results |
| 41 | + pattern: test-results-*-${{ github.run_id }} |
| 42 | + merge-multiple: true |
| 43 | + |
| 44 | + - name: Fetch per-test baseline from gh-pages |
| 45 | + continue-on-error: true |
| 46 | + run: | |
| 47 | + git fetch origin gh-pages || true |
| 48 | + git show origin/gh-pages:dev/bench/per_test_baseline.json > per_test_baseline.json || echo "{}" > per_test_baseline.json |
| 49 | +
|
| 50 | + - name: Process Test Results (Limits, Regressions, and Dashboard Formatting) |
| 51 | + run: | |
| 52 | + python3 tests/utils/process_test_results.py test-results \ |
| 53 | + --baseline per_test_baseline.json \ |
| 54 | + --save-baseline new_per_test_baseline.json \ |
| 55 | + --output-benchmark benchmark-results.json \ |
| 56 | + ${{ (github.event_name == 'schedule' && github.ref == 'refs/heads/main' || github.head_ref == 'ci/test-duration-tracking') && '--warn-only' || '' }} |
| 57 | +
|
| 58 | + - name: Push per-test baseline to gh-pages |
| 59 | + if: ${{ github.event_name == 'schedule' && github.ref == 'refs/heads/main' }} |
| 60 | + run: | |
| 61 | + git fetch origin gh-pages || true |
| 62 | + git worktree add gh-pages origin/gh-pages |
| 63 | + mkdir -p gh-pages/dev/bench |
| 64 | + cp new_per_test_baseline.json gh-pages/dev/bench/per_test_baseline.json |
| 65 | + cd gh-pages |
| 66 | + git config user.name "github-actions[bot]" |
| 67 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 68 | + git add dev/bench/per_test_baseline.json |
| 69 | + git diff-index --quiet HEAD || git commit -m "Update per-test baseline [skip ci]" |
| 70 | + git push origin HEAD:refs/heads/gh-pages |
| 71 | + cd .. |
| 72 | + git worktree remove gh-pages |
| 73 | +
|
| 74 | + - name: Track Test Durations (Macro-level Dashboard) |
| 75 | + uses: benchmark-action/github-action-benchmark@v1 |
| 76 | + with: |
| 77 | + name: MaxText Test Execution Times |
| 78 | + tool: 'customSmallerIsBetter' |
| 79 | + output-file-path: benchmark-results.json |
| 80 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + alert-threshold: '115%' |
| 82 | + comment-on-alert: true |
| 83 | + fail-on-alert: ${{ github.ref != 'refs/heads/main' && github.head_ref != 'ci/test-duration-tracking' }} |
| 84 | + auto-push: ${{ github.event_name == 'schedule' && github.ref == 'refs/heads/main' }} |
| 85 | + gh-pages-branch: 'gh-pages' |
| 86 | + benchmark-data-dir-path: 'dev/bench' |
0 commit comments