|
| 1 | +name: Benchmark |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: [labeled] |
| 6 | + |
| 7 | +jobs: |
| 8 | + benchmark: |
| 9 | + if: ${{ github.event.label.name == 'benchmark' }} |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + PR-BENCH-12: ${{ steps.benchmark-pr.outputs.BENCH_RESULT12 }} |
| 13 | + PR-BENCH-14: ${{ steps.benchmark-pr.outputs.BENCH_RESULT14 }} |
| 14 | + PR-BENCH-16: ${{ steps.benchmark-pr.outputs.BENCH_RESULT16 }} |
| 15 | + MAIN-BENCH-12: ${{ steps.benchmark-main.outputs.BENCH_RESULT12 }} |
| 16 | + MAIN-BENCH-14: ${{ steps.benchmark-main.outputs.BENCH_RESULT14 }} |
| 17 | + MAIN-BENCH-16: ${{ steps.benchmark-main.outputs.BENCH_RESULT16 }} |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + node-version: [12, 14, 16] |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + with: |
| 24 | + ref: ${{github.event.pull_request.head.ref}} |
| 25 | + repository: ${{github.event.pull_request.head.repo.full_name}} |
| 26 | + |
| 27 | + - uses: actions/setup-node@v2 |
| 28 | + with: |
| 29 | + node-version: ${{ matrix.node-version }} |
| 30 | + |
| 31 | + - name: Install |
| 32 | + run: | |
| 33 | + npm install --ignore-scripts |
| 34 | +
|
| 35 | + - name: Run benchmark |
| 36 | + id: benchmark-pr |
| 37 | + run: | |
| 38 | + npm run --silent benchmark > ./bench-result |
| 39 | + content=$(cat ./bench-result) |
| 40 | + content="${content//'%'/'%25'}" |
| 41 | + content="${content//$'\n'/'%0A'}" |
| 42 | + content="${content//$'\r'/'%0D'}" |
| 43 | + echo "::set-output name=BENCH_RESULT${{matrix.node-version}}::$content" |
| 44 | +
|
| 45 | + # main benchmark |
| 46 | + - uses: actions/checkout@v2 |
| 47 | + with: |
| 48 | + ref: 'master' |
| 49 | + |
| 50 | + - name: Install |
| 51 | + run: | |
| 52 | + npm install --ignore-scripts |
| 53 | +
|
| 54 | + - name: Run benchmark |
| 55 | + id: benchmark-master |
| 56 | + run: | |
| 57 | + npm run --silent benchmark > ./bench-result |
| 58 | + content=$(cat ./bench-result) |
| 59 | + content="${content//'%'/'%25'}" |
| 60 | + content="${content//$'\n'/'%0A'}" |
| 61 | + content="${content//$'\r'/'%0D'}" |
| 62 | + echo "::set-output name=BENCH_RESULT${{matrix.node-version}}::$content" |
| 63 | +
|
| 64 | + output-benchmark: |
| 65 | + needs: [benchmark] |
| 66 | + runs-on: ubuntu-latest |
| 67 | + steps: |
| 68 | + - name: Comment PR |
| 69 | + uses: thollander/actions-comment-pull-request@v1 |
| 70 | + with: |
| 71 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + message: | |
| 73 | + **Node**: 12 |
| 74 | + **PR**: |
| 75 | + ``` |
| 76 | + ${{ needs.benchmark.outputs.PR-BENCH-12 }} |
| 77 | + ``` |
| 78 | + **MAIN**: |
| 79 | + ``` |
| 80 | + ${{ needs.benchmark.outputs.MAIN-BENCH-12 }} |
| 81 | + ``` |
| 82 | + |
| 83 | + --- |
| 84 | + |
| 85 | + **Node**: 14 |
| 86 | + **PR**: |
| 87 | + ``` |
| 88 | + ${{ needs.benchmark.outputs.PR-BENCH-14 }} |
| 89 | + ``` |
| 90 | + **MAIN**: |
| 91 | + ``` |
| 92 | + ${{ needs.benchmark.outputs.MAIN-BENCH-14 }} |
| 93 | + ``` |
| 94 | + |
| 95 | + --- |
| 96 | + |
| 97 | + **Node**: 16 |
| 98 | + **PR**: |
| 99 | + ``` |
| 100 | + ${{ needs.benchmark.outputs.PR-BENCH-16 }} |
| 101 | + ``` |
| 102 | + **MAIN**: |
| 103 | + ``` |
| 104 | + ${{ needs.benchmark.outputs.MAIN-BENCH-16 }} |
| 105 | + ``` |
| 106 | + |
| 107 | + - uses: actions-ecosystem/action-remove-labels@v1 |
| 108 | + with: |
| 109 | + labels: | |
| 110 | + benchmark |
| 111 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments