microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
.github/workflows/memory_profile.yml
75lines · modecode
| 1 | name: Benchmark Reports |
| 2 | |
| 3 | on: |
| 4 | pull_request: |
| 5 | branches: "main" |
| 6 | types: |
| 7 | - opened |
| 8 | - reopened |
| 9 | - synchronize |
| 10 | - ready_for_review |
| 11 | merge_group: |
| 12 | workflow_dispatch: |
| 13 | |
| 14 | env: |
| 15 | CARGO_TERM_COLOR: always |
| 16 | NODE_VERSION: "20.18.2" |
| 17 | PYTHON_VERSION: "3.11" |
| 18 | RUST_TOOLCHAIN_VERSION: "1.88" |
| 19 | RUST_TOOLCHAIN_COMPONENTS: rustfmt clippy |
| 20 | |
| 21 | jobs: |
| 22 | runMemoryProfile: |
| 23 | if: ${{ !github.event.pull_request.draft }} |
| 24 | name: run memory profile |
| 25 | runs-on: ubuntu-latest |
| 26 | permissions: |
| 27 | contents: read |
| 28 | pull-requests: write |
| 29 | steps: |
| 30 | - uses: actions/checkout@v2 |
| 31 | with: |
| 32 | ref: main |
| 33 | - uses: Swatinem/rust-cache@v2 |
| 34 | - run: | |
| 35 | MAIN_MEASUREMENT=$(cargo run --bin memtest) |
| 36 | echo "MAIN_MEASUREMENT<<EOF" >> $GITHUB_ENV |
| 37 | echo "$MAIN_MEASUREMENT" >> $GITHUB_ENV |
| 38 | echo "EOF" >> $GITHUB_ENV |
| 39 | - run: | |
| 40 | echo "${{env.MAIN_MEASUREMENT}}" |
| 41 | echo $MAIN_MEASUREMENT |
| 42 | |
| 43 | - uses: actions/checkout@v2 |
| 44 | - run: | |
| 45 | BRANCH_MEASUREMENT=$(cargo run --bin memtest) |
| 46 | echo "BRANCH_MEASUREMENT<<EOF" >> $GITHUB_ENV |
| 47 | echo "$BRANCH_MEASUREMENT" >> $GITHUB_ENV |
| 48 | echo "EOF" >> $GITHUB_ENV |
| 49 | - run: | |
| 50 | echo "${{env.BRANCH_MEASUREMENT}}" |
| 51 | echo $BRANCH_MEASUREMENT |
| 52 | - uses: actions/github-script@v6 |
| 53 | with: |
| 54 | script: | |
| 55 | if (${{ env.BRANCH_MEASUREMENT }} !== ${{ env.MAIN_MEASUREMENT }}) { |
| 56 | const difference = ${{ env.BRANCH_MEASUREMENT }} - ${{ env.MAIN_MEASUREMENT }}; |
| 57 | try { |
| 58 | await github.rest.issues.createComment({ |
| 59 | issue_number: context.issue.number, |
| 60 | owner: context.repo.owner, |
| 61 | repo: context.repo.repo, |
| 62 | body: `_Change in memory usage detected by benchmark._ |
| 63 | ## Memory Report for ${{ github.sha }} |
| 64 | |
| 65 | | Test | This Branch | On Main | Difference | |
| 66 | |-----------------------------|-------------|----------| ---------- | |
| 67 | | compile core + standard lib | ${{ env.BRANCH_MEASUREMENT }} bytes | ${{ env.MAIN_MEASUREMENT }} bytes | ${difference} bytes` |
| 68 | }) |
| 69 | } catch (err) { |
| 70 | core.warning(`Failed writing comment on GitHub issue: ${err}`) |
| 71 | } |
| 72 | } else { |
| 73 | console.log("no change in memory usage detected by benchmark"); |
| 74 | } |
| 75 | if: ${{ github.base_ref != null }} |
| 76 | |