You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2022/04/11 13:11:03 UTC

[echarts] 01/01: ci: fix lint may not work when pr synchronizes.

This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch ci/lint
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit 0062d99382a3cc9ffcd2c39fae694b82e6caf9a5
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Mon Apr 11 21:08:31 2022 +0800

    ci: fix lint may not work when pr synchronizes.
---
 .github/workflows/ci.yml | 67 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 55 insertions(+), 12 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 3db384476..3df9cac7c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -5,8 +5,7 @@ on:
     types: [opened, synchronize]
 
 jobs:
-  build:
-
+  lint:
     runs-on: ubuntu-latest
 
     strategy:
@@ -14,31 +13,75 @@ jobs:
         node-version: [12.x]
 
     steps:
-      - uses: actions/checkout@v2
+      - name: Fetch commit count
+        env:
+          PR_COMMIT_COUNT: ${{ github.event.pull_request.commits }}
+        run: |
+          echo "FETCH_DEPTH=$(($PR_COMMIT_COUNT + 1))" >> $GITHUB_ENV
+
+      - uses: actions/checkout@v3
+        with:
+          fetch-depth: ${{ env.FETCH_DEPTH }}
+
       - name: Use Node.js ${{ matrix.node-version }}
-        uses: actions/setup-node@v2
+        uses: actions/setup-node@v3
         with:
           node-version: ${{ matrix.node-version }}
 
       - name: Cache node modules
-        uses: actions/cache@v2
+        uses: actions/cache@v3
         env:
           cache-name: cache-node-modules
         with:
           # npm cache files are stored in `~/.npm` on Linux/macOS
           path: ~/.npm
-          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
+          key: ${{ runner.os }}-lint-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
 
-      - name: npm install
+      - name: Install dependencies
+        if: steps.cache.outputs.cache-hit != 'true'
         run: npm ci
 
-      # - name: check type
-      #   run: npm run checktype
+      - name: Collect changed files
+        run: |
+          mkdir ~/tmp/
+          git diff ${{ github.event.pull_request.base.sha }} ${{ github.sha }} --name-only --relative '*src/**/*.ts' > ~/tmp/changed_files
+          echo -e "Changed files: \n$(cat ~/tmp/changed_files)"
+
+      - name: Lint
+        run: npx eslint $(cat ~/tmp/changed_files)
+
+      - name: Check types
+        run: npm run checktype
+
+  build:
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        node-version: [12.x]
 
-      - name: lint
-        run: npm run lint
+    steps:
+      - uses: actions/checkout@v3
+
+      - name: Use Node.js ${{ matrix.node-version }}
+        uses: actions/setup-node@v3
+        with:
+          node-version: ${{ matrix.node-version }}
+
+      - name: Cache node modules
+        uses: actions/cache@v3
+        env:
+          cache-name: cache-node-modules
+        with:
+          # npm cache files are stored in `~/.npm` on Linux/macOS
+          path: ~/.npm
+          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
+
+      - name: Install dependencies
+        if: steps.cache.outputs.cache-hit != 'true'
+        run: npm ci
 
-      - name: build release
+      - name: Build release
         run: npm run release
 
       - name: Test generated DTS


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org