Skip to content

Commit 8cb4069

Browse files
committed
docs: enhance ci build
1 parent cdfba22 commit 8cb4069

File tree

4 files changed

+33
-73
lines changed

4 files changed

+33
-73
lines changed

.github/workflows/test.yaml

Lines changed: 26 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
name: Test
22

33
on:
4-
- push
5-
- pull_request
6-
- workflow_dispatch
7-
8-
env:
9-
CI: true
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
schedule:
8+
- cron: 30 1/6 * * *
109

1110
jobs:
1211
prepare:
@@ -18,10 +17,7 @@ jobs:
1817
- name: Set up Node
1918
uses: actions/setup-node@v2
2019
with:
21-
node-version: 14
22-
- id: random
23-
name: Generate UUID
24-
run: echo "::set-output name=value::$(openssl rand -hex 10)"
20+
node-version: 16
2521
- id: cache
2622
name: Yarn Cache Dir
2723
run: echo "::set-output name=value::$(yarn cache dir)"
@@ -31,15 +27,14 @@ jobs:
3127
uses: actions/cache@v2
3228
with:
3329
path: yarn.lock
34-
key: yarn-lock-${{ runner.os }}-${{ steps.random.outputs.value }}
30+
key: yarn-lock-${{ runner.os }}-${{ github.sha }}
3531
- name: Prepare Cache
3632
uses: actions/cache@v2
3733
with:
3834
path: ${{ steps.cache.outputs.value }}
39-
key: yarn-cache-${{ runner.os }}-${{ steps.random.outputs.value }}-node-14
35+
key: yarn-cache-${{ runner.os }}-${{ github.sha }}-node-16
4036

4137
outputs:
42-
random-uuid: ${{ steps.random.outputs.value }}
4338
cache-dir: ${{ steps.cache.outputs.value }}
4439

4540
build:
@@ -53,17 +48,17 @@ jobs:
5348
- name: Set up Node
5449
uses: actions/setup-node@v2
5550
with:
56-
node-version: 14
51+
node-version: 16
5752
- name: Restore Lockfile
5853
uses: actions/cache@v2
5954
with:
6055
path: yarn.lock
61-
key: yarn-lock-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}
56+
key: yarn-lock-${{ runner.os }}-${{ github.sha }}
6257
- name: Restore Cache
6358
uses: actions/cache@v2
6459
with:
6560
path: ${{ needs.prepare.outputs.cache-dir }}
66-
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}-node-14
61+
key: yarn-cache-${{ runner.os }}-${{ github.sha }}-node-16
6762
- name: Install
6863
run: yarn
6964
- name: Build JS
@@ -81,6 +76,7 @@ jobs:
8176
plugins
8277
8378
lint:
79+
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
8480
runs-on: ubuntu-latest
8581
needs:
8682
- prepare
@@ -91,23 +87,24 @@ jobs:
9187
- name: Set up Node
9288
uses: actions/setup-node@v2
9389
with:
94-
node-version: 14
90+
node-version: 16
9591
- name: Restore Lockfile
9692
uses: actions/cache@v2
9793
with:
9894
path: yarn.lock
99-
key: yarn-lock-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}
95+
key: yarn-lock-${{ runner.os }}-${{ github.sha }}
10096
- name: Restore Cache
10197
uses: actions/cache@v2
10298
with:
10399
path: ${{ needs.prepare.outputs.cache-dir }}
104-
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}-node-14
100+
key: yarn-cache-${{ runner.os }}-${{ github.sha }}-node-16
105101
- name: Install
106102
run: yarn
107103
- name: Lint
108104
run: yarn lint
109105

110106
unit-test:
107+
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
111108
runs-on: ubuntu-latest
112109
needs:
113110
- prepare
@@ -128,20 +125,20 @@ jobs:
128125
uses: actions/cache@v2
129126
with:
130127
path: yarn.lock
131-
key: yarn-lock-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}
128+
key: yarn-lock-${{ runner.os }}-${{ github.sha }}
132129
- name: Restore Cache
133130
uses: actions/cache@v2
134131
with:
135132
path: ${{ needs.prepare.outputs.cache-dir }}
136-
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}-node-${{ matrix.node-version }}
133+
key: yarn-cache-${{ runner.os }}-${{ github.sha }}-node-${{ matrix.node-version }}
137134
restore-keys: |
138-
yarn-lock-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}-node
135+
yarn-lock-${{ runner.os }}-${{ github.sha }}-node
139136
- name: Install
140137
run: yarn
141138
- name: Build JS
142139
run: yarn compile
143140
- name: Unit Test
144-
run: yarn test:json --mongo-ports=27017 --mysql-ports=3306,3307,3308
141+
run: yarn test:json
145142
- name: Report Coverage
146143
if: ${{ matrix.node-version == 14 }}
147144
uses: codecov/codecov-action@v1
@@ -150,45 +147,6 @@ jobs:
150147
file: ./coverage/coverage-final.json
151148
name: codecov
152149

153-
publish:
154-
if: ${{ github.ref == 'refs/heads/master' }}
155-
runs-on: ubuntu-latest
156-
needs:
157-
- prepare
158-
- build
159-
- unit-test
160-
161-
env:
162-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
163-
164-
steps:
165-
- name: Check out
166-
uses: actions/checkout@v3
167-
- name: Create .npmrc
168-
run: 'echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc'
169-
- name: Set up Node
170-
uses: actions/setup-node@v2
171-
with:
172-
node-version: 14
173-
- name: Restore Lockfile
174-
uses: actions/cache@v2
175-
with:
176-
path: yarn.lock
177-
key: yarn-lock-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}
178-
- name: Restore Cache
179-
uses: actions/cache@v2
180-
with:
181-
path: ${{ needs.prepare.outputs.cache-dir }}
182-
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}-node-14
183-
- name: Install
184-
run: yarn
185-
- name: Download
186-
uses: actions/download-artifact@v3
187-
with:
188-
name: packages
189-
- name: Publish
190-
run: yarn pub
191-
192150
docs:
193151
if: ${{ github.ref == 'refs/heads/master' }}
194152
runs-on: ubuntu-latest
@@ -202,17 +160,17 @@ jobs:
202160
- name: Set up Node
203161
uses: actions/setup-node@v2
204162
with:
205-
node-version: 14
163+
node-version: 16
206164
- name: Restore Lockfile
207165
uses: actions/cache@v2
208166
with:
209167
path: yarn.lock
210-
key: yarn-lock-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}
168+
key: yarn-lock-${{ runner.os }}-${{ github.sha }}
211169
- name: Restore Cache
212170
uses: actions/cache@v2
213171
with:
214172
path: ${{ needs.prepare.outputs.cache-dir }}
215-
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}-node-14
173+
key: yarn-cache-${{ runner.os }}-${{ github.sha }}-node-16
216174
- name: Install
217175
run: yarn
218176
- name: Download
@@ -263,17 +221,17 @@ jobs:
263221
- name: Set up Node
264222
uses: actions/setup-node@v2
265223
with:
266-
node-version: 14
224+
node-version: 16
267225
- name: Restore Lockfile
268226
uses: actions/cache@v2
269227
with:
270228
path: yarn.lock
271-
key: yarn-lock-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}
229+
key: yarn-lock-${{ runner.os }}-${{ github.sha }}
272230
- name: Restore Cache
273231
uses: actions/cache@v2
274232
with:
275233
path: ${{ needs.prepare.outputs.cache-dir }}
276-
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.random-uuid }}-node-14
234+
key: yarn-cache-${{ runner.os }}-${{ github.sha }}-node-16
277235
- name: Install
278236
run: yarn
279237
- name: Download

docs/.vuepress/config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { execSync } from 'child_process'
21
import { resolve } from 'path'
32
import { remove as removeDiacritics } from 'diacritics'
43
import { readdirSync } from 'fs'
@@ -18,6 +17,10 @@ for (const dirent of dirents) {
1817
communitySidebar.push(require(communityFolder + '/' + dirent.name))
1918
}
2019

20+
const hash = process.env.GITHUB_SHA
21+
? ` (${process.env.GITHUB_SHA.slice(0, 7)})`
22+
: ''
23+
2124
module.exports = {
2225
base: '/',
2326
title: 'Koishi',
@@ -47,7 +50,7 @@ module.exports = {
4750
theme: theme({
4851
logo: '/koishi.png',
4952
navbar: [{
50-
text: `v4.x (${execSync('git log -1 --format=%h').toString().trim()})`,
53+
text: 'v4.x' + hash,
5154
children: [{
5255
text: 'v3.x',
5356
link: 'https://koishi.js.org/v3/',

docs/.vuepress/layouts/home/screen-6.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const { width, height } = useWindowSize()
3232
const config = useThemeLocaleData().value
3333
3434
function getSidebarItems(route: string) {
35-
return resolveArraySidebarItems(config.sidebar[route].filter(item => item.isGroup), 1)
35+
return resolveArraySidebarItems(config.sidebar[route].filter(item => item.children), 1)
3636
}
3737
3838
</script>

docs/.vuepress/theme.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import popup from '@vuepress/plugin-pwa-popup'
66
import container from '@vuepress/plugin-container'
77
import docsearch from '@vuepress/plugin-docsearch'
88
import zoom from '@vuepress/plugin-medium-zoom'
9-
import { redirect } from 'vuepress-plugin-redirect2'
109

1110
export default (options: DefaultThemeOptions): Theme => ({
1211
name: 'vuepress-theme-local',
13-
extends: defaultTheme(),
12+
extends: defaultTheme(options),
1413

1514
layouts: {
1615
Layout: require.resolve('./layouts/Layout.vue'),

0 commit comments

Comments
 (0)