From 4c5bf0ae9f20057288b943750ef6a8bebcd09a00 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Mon, 20 Dec 2021 22:47:07 +0200 Subject: [PATCH] gh/actions: run benchmark & diff-npm-package only on PRs --- .github/workflows/ci.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01eefbfec4..10b4b2b832 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -160,14 +160,15 @@ jobs: benchmark: name: Run benchmark runs-on: ubuntu-latest - env: - COMMITS_TO_TEST: ${{ github.event.pull_request.commits || 1 }} + if: github.event_name == 'pull_request' steps: - name: Checkout repo uses: actions/checkout@v2 - name: Deepen cloned repo - run: 'git fetch --deepen=$COMMITS_TO_TEST' + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: 'git fetch --depth=1 origin $BASE_SHA:refs/tags/BASE' - name: Setup Node.js uses: actions/setup-node@v2 @@ -179,19 +180,20 @@ jobs: run: npm ci --ignore-scripts - name: Run Benchmark - run: 'npm run benchmark -- --revs HEAD "HEAD~$COMMITS_TO_TEST"' + run: 'npm run benchmark -- --revs HEAD BASE' diff-npm-package: name: Diff content of NPM package runs-on: ubuntu-latest - env: - COMMITS_TO_TEST: ${{ github.event.pull_request.commits || 1 }} + if: github.event_name == 'pull_request' steps: - name: Checkout repo uses: actions/checkout@v2 - name: Deepen cloned repo - run: 'git fetch --deepen=$COMMITS_TO_TEST' + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: 'git fetch --depth=1 origin $BASE_SHA:refs/tags/BASE' - name: Setup Node.js uses: actions/setup-node@v2 @@ -203,7 +205,7 @@ jobs: run: npm ci --ignore-scripts - name: Generate report - run: 'node resources/diff-npm-package.js HEAD~$COMMITS_TO_TEST HEAD' + run: 'node resources/diff-npm-package.js BASE HEAD' - name: Upload generated report uses: actions/upload-artifact@v2