|
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 | 4 | push: |
8 | 5 | branches: [master] |
9 | 6 | pull_request: |
10 | 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 | 10 | setup: |
15 | 11 | runs-on: ubuntu-latest |
16 | 12 | steps: |
17 | | - - name: Checkout code |
18 | | - uses: actions/checkout@v4 |
| 13 | + - uses: actions/checkout@v4 |
19 | 14 |
|
20 | | - - name: Cache yarn.lock |
21 | | - uses: actions/cache@v4 |
| 15 | + - name: Set up Node.js |
| 16 | + uses: actions/setup-node@v4 |
22 | 17 | with: |
23 | | - path: package-temp-dir |
24 | | - key: lock-${{ github.sha }} |
| 18 | + node-version: 16.x |
25 | 19 |
|
26 | | - - name: Create yarn.lock |
27 | | - run: yarn generate-lock-entry |
| 20 | + - name: Install pnpm |
| 21 | + uses: pnpm/action-setup@v2 |
| 22 | + with: |
| 23 | + version: 6.32.12 |
| 24 | + run_install: false |
28 | 25 |
|
29 | | - - name: Hack for single file |
| 26 | + - name: Get pnpm store directory |
| 27 | + id: pnpm-cache |
| 28 | + shell: bash |
30 | 29 | 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 |
| 30 | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT |
| 31 | +
|
| 32 | + - name: Cache pnpm store |
37 | 33 | uses: actions/cache@v4 |
38 | 34 | with: |
39 | | - path: node_modules |
40 | | - key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }} |
| 35 | + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 36 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 37 | + restore-keys: | |
| 38 | + ${{ runner.os }}-pnpm-store- |
41 | 39 |
|
42 | 40 | - name: Install dependencies |
43 | | - if: steps.node_modules_cache_id.outputs.cache-hit != 'true' |
44 | | - run: yarn |
| 41 | + shell: bash |
| 42 | + run: pnpm install |
45 | 43 |
|
46 | 44 | prettier: |
47 | | - needs: [setup] |
| 45 | + needs: setup |
48 | 46 | runs-on: ubuntu-latest |
49 | 47 | steps: |
50 | | - - uses: actions/checkout@v2 |
| 48 | + - uses: actions/checkout@v4 |
51 | 49 |
|
52 | | - - name: Restore cache from yarn.lock |
53 | | - uses: actions/cache@v4 |
| 50 | + - name: Set up Node.js |
| 51 | + uses: actions/setup-node@v4 |
54 | 52 | with: |
55 | | - path: package-temp-dir |
56 | | - key: lock-${{ github.sha }} |
| 53 | + node-version: 16.x |
57 | 54 |
|
58 | | - - name: Restore cache from node_modules |
59 | | - uses: actions/cache@v4 |
| 55 | + - name: Install pnpm |
| 56 | + uses: pnpm/action-setup@v2 |
60 | 57 | with: |
61 | | - path: node_modules |
62 | | - key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }} |
| 58 | + version: 6.32.12 |
| 59 | + run_install: false |
| 60 | + |
| 61 | + - run: pnpm install |
63 | 62 |
|
64 | | - - name: Prettier check |
65 | | - run: yarn prettier |
| 63 | + - name: Run Prettier |
| 64 | + run: pnpm prettier |
66 | 65 |
|
67 | 66 | eslint: |
68 | | - needs: [setup] |
| 67 | + needs: setup |
69 | 68 | runs-on: ubuntu-latest |
70 | 69 | steps: |
71 | | - - uses: actions/checkout@v2 |
| 70 | + - uses: actions/checkout@v4 |
72 | 71 |
|
73 | | - - name: Restore cache from yarn.lock |
74 | | - uses: actions/cache@v4 |
| 72 | + - name: Set up Node.js |
| 73 | + uses: actions/setup-node@v4 |
75 | 74 | with: |
76 | | - path: package-temp-dir |
77 | | - key: lock-${{ github.sha }} |
| 75 | + node-version: 16.x |
78 | 76 |
|
79 | | - - name: Restore cache from node_modules |
80 | | - uses: actions/cache@v4 |
| 77 | + - name: Install pnpm |
| 78 | + uses: pnpm/action-setup@v2 |
81 | 79 | with: |
82 | | - path: node_modules |
83 | | - key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }} |
| 80 | + version: 6.32.12 |
| 81 | + run_install: false |
84 | 82 |
|
85 | | - - name: Eslint check |
86 | | - run: yarn eslint |
| 83 | + - run: pnpm install |
| 84 | + |
| 85 | + - name: Run ESLint |
| 86 | + run: pnpm eslint |
87 | 87 |
|
88 | 88 | test: |
89 | | - needs: [setup] |
| 89 | + needs: setup |
90 | 90 | runs-on: ubuntu-latest |
91 | 91 | steps: |
92 | | - - uses: actions/checkout@v2 |
| 92 | + - uses: actions/checkout@v4 |
93 | 93 |
|
94 | | - - name: Restore cache from yarn.lock |
95 | | - uses: actions/cache@v4 |
| 94 | + - name: Set up Node.js |
| 95 | + uses: actions/setup-node@v4 |
96 | 96 | with: |
97 | | - path: package-temp-dir |
98 | | - key: lock-${{ github.sha }} |
| 97 | + node-version: 16.x |
99 | 98 |
|
100 | | - - name: Restore cache from node_modules |
101 | | - uses: actions/cache@v4 |
| 99 | + - name: Install pnpm |
| 100 | + uses: pnpm/action-setup@v2 |
102 | 101 | with: |
103 | | - path: node_modules |
104 | | - key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }} |
| 102 | + version: 6.32.12 |
| 103 | + run_install: false |
| 104 | + - run: pnpm install |
105 | 105 |
|
106 | | - - name: Setup timezone |
| 106 | + - name: Set up timezone |
107 | 107 | uses: zcong1993/setup-timezone@master |
108 | 108 | with: |
109 | | - timezone: Asia/Shanghai |
| 109 | + timezone: Asia/Shanghai |
110 | 110 |
|
111 | | - - name: Unit Test |
112 | | - run: yarn test |
| 111 | + - name: Run Tests |
| 112 | + run: pnpm test |
113 | 113 |
|
114 | 114 | build: |
115 | | - runs-on: ubuntu-latest |
116 | 115 | needs: [setup, prettier, eslint, test] |
| 116 | + runs-on: ubuntu-latest |
117 | 117 | steps: |
118 | | - - uses: actions/checkout@v2 |
| 118 | + - uses: actions/checkout@v4 |
119 | 119 |
|
120 | | - - name: Restore cache from yarn.lock |
121 | | - uses: actions/cache@v4 |
| 120 | + - name: Set up Node.js |
| 121 | + uses: actions/setup-node@v4 |
122 | 122 | with: |
123 | | - path: package-temp-dir |
124 | | - key: lock-${{ github.sha }} |
| 123 | + node-version: 16.x |
125 | 124 |
|
126 | | - - name: Restore cache from node_modules |
127 | | - uses: actions/cache@v4 |
| 125 | + - name: Install pnpm |
| 126 | + uses: pnpm/action-setup@v2 |
128 | 127 | with: |
129 | | - path: node_modules |
130 | | - key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }} |
| 128 | + version: 6.32.12 |
| 129 | + run_install: false |
| 130 | + |
| 131 | + - run: pnpm install |
131 | 132 |
|
132 | | - - name: Build test |
133 | | - run: yarn build |
| 133 | + - name: Run Build |
| 134 | + run: pnpm build |
0 commit comments