|
| 1 | +name: Save cargo build timing information |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + types: [closed] |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +jobs: |
| 13 | + linux-ubuntu: |
| 14 | + name: Add build timing information to another repository |
| 15 | + runs-on: ubuntu-latest |
| 16 | + env: |
| 17 | + CARGO_TERM_COLOR: always |
| 18 | + |
| 19 | + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) |
| 20 | + steps: |
| 21 | + - name: Checkout main repo |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + path: debate-map |
| 25 | + - name: Build Timing |
| 26 | + working-directory: debate-map |
| 27 | + run: cargo build --package app_server --timings |
| 28 | + |
| 29 | + - name: Get commit hash |
| 30 | + working-directory: debate-map |
| 31 | + run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 32 | + |
| 33 | + - name: Checkout compile timings repo |
| 34 | + uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + repository: debate-map/compile-timings |
| 37 | + path : compile-timings |
| 38 | + token : ${{ secrets.PAT }} |
| 39 | + |
| 40 | + - name: Copy raw timing files to target repo |
| 41 | + run: | |
| 42 | + mkdir -p compile-timings/docs/timings/raw_html |
| 43 | + for file in debate-map/target/cargo-timings/cargo-timing-*.html; do |
| 44 | + mv "$file" "compile-timings/docs/timings/raw_html/$(basename "$file" .html)_${{ env.COMMIT_HASH }}.html" |
| 45 | + done |
| 46 | +
|
| 47 | + - name: Commit and push changes |
| 48 | + working-directory: compile-timings |
| 49 | + run: | |
| 50 | + git config user.name "compile-timings[bot]" |
| 51 | + git config user.email debatemap@gmail.com |
| 52 | + git add docs/timings/raw_html |
| 53 | + NEW_BUILD_HTML_FILE=$(ls -t docs/timings/raw_html/ | head -n1) |
| 54 | + git commit -m "ci: add build timing html $NEW_BUILD_HTML_FILE" |
| 55 | + git push |
0 commit comments