|  | 
| 1 |  | -# This is a basic workflow to help you get started with Actions | 
| 2 |  | - | 
| 3 | 1 | name: CI | 
| 4 | 2 | 
 | 
| 5 |  | -# Triggers the workflow on push or pull request events but only for the master branch | 
| 6 | 3 | on: | 
| 7 |  | -    push: | 
| 8 |  | -        branches: [master] | 
| 9 |  | -    pull_request: | 
| 10 |  | -        branches: [master] | 
|  | 4 | +  push: | 
|  | 5 | +    branches: [master] | 
|  | 6 | +  pull_request: | 
|  | 7 | +    branches: [master] | 
| 11 | 8 | 
 | 
| 12 |  | -# A workflow run is made up of one or more jobs that can run sequentially or in parallel | 
| 13 | 9 | jobs: | 
| 14 |  | -    setup: | 
| 15 |  | -        runs-on: ubuntu-latest | 
| 16 |  | -        steps: | 
| 17 |  | -            - name: Checkout code | 
| 18 |  | -              uses: actions/checkout@v4 | 
| 19 |  | - | 
| 20 |  | -            - name: Cache yarn.lock | 
| 21 |  | -              uses: actions/cache@v4 | 
| 22 |  | -              with: | 
| 23 |  | -                  path: package-temp-dir | 
| 24 |  | -                  key: lock-${{ github.sha }} | 
| 25 |  | - | 
| 26 |  | -            - name: Create yarn.lock | 
| 27 |  | -              run: yarn generate-lock-entry | 
| 28 |  | - | 
| 29 |  | -            - name: Hack for single file | 
| 30 |  | -              run: | | 
| 31 |  | -                  if [ ! -d "package-temp-dir" ]; then | 
| 32 |  | -                    mkdir package-temp-dir | 
| 33 |  | -                  fi | 
| 34 |  | -                  cp yarn.lock package-temp-dir | 
| 35 |  | -            - name: Cache node_modules | 
| 36 |  | -              id: node_modules_cache_id | 
| 37 |  | -              uses: actions/cache@v4 | 
| 38 |  | -              with: | 
| 39 |  | -                  path: node_modules | 
| 40 |  | -                  key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }} | 
| 41 |  | - | 
| 42 |  | -            - name: Install dependencies | 
| 43 |  | -              if: steps.node_modules_cache_id.outputs.cache-hit != 'true' | 
| 44 |  | -              run: yarn | 
| 45 |  | - | 
| 46 |  | -    prettier: | 
| 47 |  | -        needs: [setup] | 
| 48 |  | -        runs-on: ubuntu-latest | 
| 49 |  | -        steps: | 
| 50 |  | -            - uses: actions/checkout@v2 | 
| 51 |  | - | 
| 52 |  | -            - name: Restore cache from yarn.lock | 
| 53 |  | -              uses: actions/cache@v4 | 
| 54 |  | -              with: | 
| 55 |  | -                  path: package-temp-dir | 
| 56 |  | -                  key: lock-${{ github.sha }} | 
| 57 |  | - | 
| 58 |  | -            - name: Restore cache from node_modules | 
| 59 |  | -              uses: actions/cache@v4 | 
| 60 |  | -              with: | 
| 61 |  | -                  path: node_modules | 
| 62 |  | -                  key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }} | 
| 63 |  | - | 
| 64 |  | -            - name: Prettier check | 
| 65 |  | -              run: yarn prettier | 
| 66 |  | - | 
| 67 |  | -    eslint: | 
| 68 |  | -        needs: [setup] | 
| 69 |  | -        runs-on: ubuntu-latest | 
| 70 |  | -        steps: | 
| 71 |  | -            - uses: actions/checkout@v2 | 
| 72 |  | - | 
| 73 |  | -            - name: Restore cache from yarn.lock | 
| 74 |  | -              uses: actions/cache@v4 | 
| 75 |  | -              with: | 
| 76 |  | -                  path: package-temp-dir | 
| 77 |  | -                  key: lock-${{ github.sha }} | 
| 78 |  | - | 
| 79 |  | -            - name: Restore cache from node_modules | 
| 80 |  | -              uses: actions/cache@v4 | 
| 81 |  | -              with: | 
| 82 |  | -                  path: node_modules | 
| 83 |  | -                  key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }} | 
| 84 |  | - | 
| 85 |  | -            - name: Eslint check | 
| 86 |  | -              run: yarn eslint | 
| 87 |  | - | 
| 88 |  | -    test: | 
| 89 |  | -        needs: [setup] | 
| 90 |  | -        runs-on: ubuntu-latest | 
| 91 |  | -        steps: | 
| 92 |  | -            - uses: actions/checkout@v2 | 
| 93 |  | - | 
| 94 |  | -            - name: Restore cache from yarn.lock | 
| 95 |  | -              uses: actions/cache@v4 | 
| 96 |  | -              with: | 
| 97 |  | -                  path: package-temp-dir | 
| 98 |  | -                  key: lock-${{ github.sha }} | 
| 99 |  | - | 
| 100 |  | -            - name: Restore cache from node_modules | 
| 101 |  | -              uses: actions/cache@v4 | 
| 102 |  | -              with: | 
| 103 |  | -                  path: node_modules | 
| 104 |  | -                  key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }} | 
| 105 |  | - | 
| 106 |  | -            - name: Setup timezone | 
| 107 |  | -              uses: zcong1993/setup-timezone@master | 
| 108 |  | -              with: | 
| 109 |  | -                timezone: Asia/Shanghai | 
| 110 |  | - | 
| 111 |  | -            - name: Unit Test | 
| 112 |  | -              run: yarn test | 
| 113 |  | - | 
| 114 |  | -    build: | 
| 115 |  | -        runs-on: ubuntu-latest | 
| 116 |  | -        needs: [setup, prettier, eslint, test] | 
| 117 |  | -        steps: | 
| 118 |  | -            - uses: actions/checkout@v2 | 
| 119 |  | - | 
| 120 |  | -            - name: Restore cache from yarn.lock | 
| 121 |  | -              uses: actions/cache@v4 | 
| 122 |  | -              with: | 
| 123 |  | -                  path: package-temp-dir | 
| 124 |  | -                  key: lock-${{ github.sha }} | 
| 125 |  | - | 
| 126 |  | -            - name: Restore cache from node_modules | 
| 127 |  | -              uses: actions/cache@v4 | 
| 128 |  | -              with: | 
| 129 |  | -                  path: node_modules | 
| 130 |  | -                  key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }} | 
| 131 |  | - | 
| 132 |  | -            - name: Build test | 
| 133 |  | -              run: yarn build | 
|  | 10 | +  setup: | 
|  | 11 | +    runs-on: ubuntu-latest | 
|  | 12 | +    steps: | 
|  | 13 | +      - uses: actions/checkout@v4 | 
|  | 14 | +      - uses: ./.github/actions/setup-pnpm | 
|  | 15 | + | 
|  | 16 | +  prettier: | 
|  | 17 | +    needs: setup | 
|  | 18 | +    runs-on: ubuntu-latest | 
|  | 19 | +    steps: | 
|  | 20 | +      - uses: actions/checkout@v4 | 
|  | 21 | +      - uses: ./.github/actions/setup-pnpm-cli | 
|  | 22 | +      - run: pnpm prettier | 
|  | 23 | + | 
|  | 24 | +  eslint: | 
|  | 25 | +    needs: setup | 
|  | 26 | +    runs-on: ubuntu-latest | 
|  | 27 | +    steps: | 
|  | 28 | +      - uses: actions/checkout@v4 | 
|  | 29 | +      - uses: ./.github/actions/setup-pnpm-cli | 
|  | 30 | +      - run: pnpm eslint | 
|  | 31 | + | 
|  | 32 | +  test: | 
|  | 33 | +    needs: setup | 
|  | 34 | +    runs-on: ubuntu-latest | 
|  | 35 | +    steps: | 
|  | 36 | +      - uses: actions/checkout@v4 | 
|  | 37 | +      - uses: ./.github/actions/setup-pnpm-cli | 
|  | 38 | +      - uses: zcong1993/setup-timezone@master | 
|  | 39 | +        with: | 
|  | 40 | +          timezone: Asia/Shanghai | 
|  | 41 | +      - run: pnpm test | 
|  | 42 | + | 
|  | 43 | +  build: | 
|  | 44 | +    needs: [setup, prettier, eslint, test] | 
|  | 45 | +    runs-on: ubuntu-latest | 
|  | 46 | +    steps: | 
|  | 47 | +      - uses: actions/checkout@v4 | 
|  | 48 | +      - uses: ./.github/actions/setup-pnpm-cli | 
|  | 49 | +      - run: pnpm build | 
0 commit comments