From e026b4f54ecd3eaa89e225051a14db7cab844632 Mon Sep 17 00:00:00 2001 From: Kaede Hoshikawa Date: Wed, 3 Aug 2022 21:35:47 +0900 Subject: [PATCH] Fix SSR Benchmark. (#2805) --- .github/workflows/benchmark-ssr.yml | 14 +++++++++++--- .github/workflows/post-benchmark-ssr.yml | 13 +++++++++++-- ci/make_benchmark_ssr_cmt.py | 1 - 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/benchmark-ssr.yml b/.github/workflows/benchmark-ssr.yml index 7db9d3052a6..a5ebe1e6b2d 100644 --- a/.github/workflows/benchmark-ssr.yml +++ b/.github/workflows/benchmark-ssr.yml @@ -6,9 +6,12 @@ on: branches: [master] paths: - .github/workflows/benchmark-ssr.yml - - "packages/yew" - - "examples/function_router" - - "tools/benchmark-ssr" + - "packages/yew/**" + - "packages/yew-macro/**" + - "packages/yew-router/**" + - "packages/yew-router-macro/**" + - "examples/function_router/**" + - "tools/benchmark-ssr/**" jobs: benchmark-ssr: @@ -55,11 +58,16 @@ jobs: run: cargo run --profile=bench --bin benchmark-ssr -- --output-path ./output.json working-directory: yew-master/tools + - name: Write Pull Request ID + run: | + echo "${{ github.event.number }}" > .PR_NUMBER + - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: benchmark-ssr path: | + .PR_NUMBER yew-master/tools/output.json current-pr/tools/output.json retention-days: 1 diff --git a/.github/workflows/post-benchmark-ssr.yml b/.github/workflows/post-benchmark-ssr.yml index e564e93fb6b..69f5892e4e2 100644 --- a/.github/workflows/post-benchmark-ssr.yml +++ b/.github/workflows/post-benchmark-ssr.yml @@ -9,6 +9,7 @@ on: jobs: post-benchmark-ssr: + if: github.event.workflow_run.event == 'pull_request' name: Post Comment on Pull Request runs-on: ubuntu-latest @@ -16,8 +17,7 @@ jobs: - name: Download Repository uses: actions/checkout@v2 - - if: github.event.workflow_run.event == 'pull_request' - name: Download Artifact + - name: Download Artifact uses: Legit-Labs/action-download-artifact@v2 with: github_token: "${{ secrets.GITHUB_TOKEN }}" @@ -29,6 +29,15 @@ jobs: - name: Make pull request comment run: python3 ci/make_benchmark_ssr_cmt.py + - name: Read Pull Request ID + run: | + PR_NUMBER=$(cat "benchmark-ssr/.PR_NUMBER") + if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then + echo "pr number invalid" + exit 1 + fi + echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV + - name: Post Comment uses: actions/github-script@v6 with: diff --git a/ci/make_benchmark_ssr_cmt.py b/ci/make_benchmark_ssr_cmt.py index 068ecb25f09..5d49f21a05c 100644 --- a/ci/make_benchmark_ssr_cmt.py +++ b/ci/make_benchmark_ssr_cmt.py @@ -49,7 +49,6 @@ def main() -> None: with open(os.environ["GITHUB_ENV"], "a+") as f: f.write(f"YEW_BENCH_SSR={json.dumps(output)}\n") - f.write(f"PR_NUMBER={issue_number}\n") if __name__ == "__main__":