-
-
Notifications
You must be signed in to change notification settings - Fork 7
161 lines (127 loc) · 3.88 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: CI
on:
push:
branches:
- main
tags-ignore:
- 'v*'
pull_request:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
- name: oxLint
run: pnpm dlx oxlint@latest
- name: Set node
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: pnpm
- name: Setup
run: npm i -g @antfu/ni
- name: Install
run: nci
- name: Lint
run: nr lint
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Set node
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: pnpm
- name: Setup
run: npm i -g @antfu/ni
- name: Install
run: nci
- name: Typecheck
run: nr typecheck
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [18.x, 20.x]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Set node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: pnpm
- name: Setup
run: npm i -g @antfu/ni
- name: Install
run: nci
- name: Build
run: nr build
- uses: actions/cache/save@v4
id: cache
with:
path: dist/outfile.cjs
key: ${{ github.sha }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ matrix.os }}-${{ matrix.node }}
test:
needs: build
strategy:
matrix:
flag-for-ts: ['', --ts]
flag-for-eslint: ['', -e]
flag-for-plugin: ['', -p import -p pages -p layouts -p manifest -p filePlatform -p platformModifier -p middleware -m pinia -m unocss -m uniNetwork -m uniUse -m uniPromises]
flag-for-ui: ['', -u uni, -u ano, -u wot, -u nut, -u uv]
node: [18.x]
os: [windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
env:
FEATURE_FLAGS: ${{ matrix.flag-for-ts }} ${{ matrix.flag-for-eslint }} ${{ matrix.flag-for-plugin }} ${{ matrix.flag-for-ui }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: pnpm
- uses: actions/cache/restore@v4
id: cache-restore
with:
path: dist/outfile.cjs
key: ${{ github.sha }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ matrix.os }}-${{ matrix.node }}
- name: 当没有缓存时,执行构建
if: steps.cache-restore.outputs.cache-hit != 'true'
run: pnpm install && pnpm build
- if: ${{ (contains(env.FEATURE_FLAGS, '-')) }}
name: 创建多参数项目
working-directory: ../
run: node ./create-uni/dist/outfile.cjs sample-project ${{ env.FEATURE_FLAGS }}
- if: ${{ !(contains(env.FEATURE_FLAGS, '-')) }}
name: 创建基础项目
working-directory: ../
run: node ./create-uni/dist/outfile.cjs sample-project
- name: 安装项目依赖
working-directory: ../sample-project
run: pnpm install
- name: 打包H5项目
working-directory: ../sample-project
run: pnpm build
- name: dev小程序项目
working-directory: ../sample-project
run: node ./../create-uni/scripts/dev.cjs
- name: 打包小程序项目
working-directory: ../sample-project
run: pnpm build:mp-weixin
- name: 输出环境信息
working-directory: ../sample-project
run: node ./../create-uni/dist/outfile.cjs --info all