microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
5fd075d26743cbe6a23edb9ff62a51fbb0be004b

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/workflows/bench-reports.yml

90lines · modecode

1name: Benchmark Reports
2
3on:
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
14env:
15 CARGO_TERM_COLOR: always
16 NODE_VERSION: "18.17.1"
17 PYTHON_VERSION: "3.11"
18 RUST_TOOLCHAIN_VERSION: "1.78"
19 RUST_TOOLCHAIN_COMPONENTS: rustfmt clippy
20
21jobs:
22 runBenchmark:
23 if: ${{ !github.event.pull_request.draft }}
24 name: run benchmark
25 runs-on: ubuntu-latest
26 permissions:
27 contents: read
28 pull-requests: write
29 steps:
30 - uses: actions/checkout@v3
31 - uses: boa-dev/criterion-compare-action@v3
32 with:
33 branchName: ${{ github.base_ref }}
34 cwd: "compiler/qsc"
35 if: ${{ github.base_ref != null }}
36
37 runMemoryProfile:
38 if: ${{ !github.event.pull_request.draft }}
39 name: run memory profile
40 runs-on: ubuntu-latest
41 permissions:
42 contents: read
43 pull-requests: write
44 steps:
45 - uses: actions/checkout@v2
46 with:
47 ref: main
48 - uses: Swatinem/rust-cache@v2
49 - run: |
50 MAIN_MEASUREMENT=$(cargo run --bin memtest)
51 echo "MAIN_MEASUREMENT<<EOF" >> $GITHUB_ENV
52 echo "$MAIN_MEASUREMENT" >> $GITHUB_ENV
53 echo "EOF" >> $GITHUB_ENV
54 - run: |
55 echo "${{env.MAIN_MEASUREMENT}}"
56 echo $MAIN_MEASUREMENT
57
58 - uses: actions/checkout@v2
59 - run: |
60 BRANCH_MEASUREMENT=$(cargo run --bin memtest)
61 echo "BRANCH_MEASUREMENT<<EOF" >> $GITHUB_ENV
62 echo "$BRANCH_MEASUREMENT" >> $GITHUB_ENV
63 echo "EOF" >> $GITHUB_ENV
64 - run: |
65 echo "${{env.BRANCH_MEASUREMENT}}"
66 echo $BRANCH_MEASUREMENT
67 - uses: actions/github-script@v6
68 with:
69 script: |
70 if (${{ env.BRANCH_MEASUREMENT }} !== ${{ env.MAIN_MEASUREMENT }}) {
71 const difference = ${{ env.BRANCH_MEASUREMENT }} - ${{ env.MAIN_MEASUREMENT }};
72 try {
73 await github.rest.issues.createComment({
74 issue_number: context.issue.number,
75 owner: context.repo.owner,
76 repo: context.repo.repo,
77 body: `_Change in memory usage detected by benchmark._
78 ## Memory Report for ${{ github.sha }}
79
80 | Test | This Branch | On Main | Difference |
81 |-----------------------------|-------------|----------| ---------- |
82 | compile core + standard lib | ${{ env.BRANCH_MEASUREMENT }} bytes | ${{ env.MAIN_MEASUREMENT }} bytes | ${difference} bytes`
83 })
84 } catch (err) {
85 core.warning(`Failed writing comment on GitHub issue: ${err}`)
86 }
87 } else {
88 console.log("no change in memory usage detected by benchmark");
89 }
90 if: ${{ github.base_ref != null }}