-
Notifications
You must be signed in to change notification settings - Fork 41
185 lines (156 loc) · 5.27 KB
/
docs.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Documentations & Explorer
on:
push:
branches:
- 'main'
pull_request:
types: [opened, reopened, synchronize]
concurrency:
group: ci-docs-${{ github.ref }}
cancel-in-progress: true
jobs:
cargo-doc:
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install stable toolchain and restore cache
uses: ./.github/workflows/actions/toolchain-and-cache
with:
cache-version: ${{ secrets.CACHE_VERSION }}
cargo-tools: clippy-sarif sarif-fmt
- name: Generate cargo doc
run: |
cargo doc --no-deps -p mithril-stm -p mithril-common -p mithril-aggregator \
-p mithril-signer -p mithril-client --message-format=json \
| clippy-sarif | tee rust-cargo-doc-results.sarif | sarif-fmt
# Update tool sarif metadata from "clippy" to "cargo-doc" (since it's set this way by clippy-sarif)
contents=$(cat rust-cargo-doc-results.sarif \
| jq '.runs[].tool.driver.name = "cargo-doc"' \
| jq '.runs[].tool.driver.informationUri = "https://doc.rust-lang.org/cargo/commands/cargo-doc.html"' \
)
echo -E "${contents}" > rust-cargo-doc-results.sarif
# Make this step fail if any warning has been found
if [[ $(cat rust-cargo-doc-results.sarif | jq '.runs[0].results') != "[]" ]]; then
false
fi
- name: Upload cargo-doc results to GitHub
if: success() || failure()
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: rust-cargo-doc-results.sarif
wait-for-processing: true
- name: Publish Mithril-rust-doc
uses: actions/upload-artifact@v3
with:
name: mithril-rust-doc
if-no-files-found: error
path: |
target/doc/
build-docusaurus:
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
cache-dependency-path: docs/website/yarn.lock
- name: Build Docusaurus site
working-directory: docs/website
run: |
yarn && yarn build
- name: Publish Docusaurus build
uses: actions/upload-artifact@v3
with:
name: docusaurus-build
if-no-files-found: error
path: |
docs/website/build/*
build-test-explorer:
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
cache-dependency-path: mithril-explorer/yarn.lock
- name: Install dependencies
working-directory: mithril-explorer
run: yarn install --frozen-lockfile
- name: Test explorer
working-directory: mithril-explorer
run: make test
- name: Check explorer
working-directory: mithril-explorer
run: make lint
- name: Build Explorer
working-directory: mithril-explorer
run: make build
- name: Publish Explorer build
uses: actions/upload-artifact@v3
with:
name: explorer-build
if-no-files-found: error
path: |
mithril-explorer/out/*
build-open-api-ui:
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Build OpenAPI UI
uses: Legion2/swagger-ui-action@v1
with:
output: out/
spec-file: ./openapi.yaml
- name: Publish OpenAPI UI build
uses: actions/upload-artifact@v3
with:
name: openapi-ui-build
if-no-files-found: error
path: |
out/*
publish-docs:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
needs:
- cargo-doc
- build-docusaurus
- build-test-explorer
- build-open-api-ui
steps:
- name: Download mithril-rust-doc artifact
uses: actions/download-artifact@v3
with:
name: mithril-rust-doc
path: ./github-pages/rust-doc
- name: Download Docusaurus build
uses: actions/download-artifact@v3
with:
name: docusaurus-build
path: ./github-pages/doc
- name: Download Explorer build
uses: actions/download-artifact@v3
with:
name: explorer-build
path: ./github-pages/explorer
- name: Download OpenAPI UI build
uses: actions/download-artifact@v3
with:
name: openapi-ui-build
path: ./github-pages/openapi-ui
- name: Add CNAME & Redirect
run: |
echo "mithril.network" > ./github-pages/CNAME
echo '<!DOCTYPE html><html><head><meta http-equiv="Refresh" content="0; URL=https://mithril.network/doc"></head></html>' > ./github-pages/index.html
- name: Mithril / Publish GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN || github.token }}
publish_dir: ./github-pages