forked from bids-standard/bids-specification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
217 lines (211 loc) · 7.59 KB
/
config.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
version: 2
jobs:
build_docs:
docker:
- image: cimg/python:3.8
steps:
# checkout code to default ~/project
- checkout
- run:
name: install dependencies
command: |
python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e ~/project/tools/schemacode/
- run:
name: generate docs
command: |
source env/bin/activate
mkdocs build --clean --strict --verbose
- persist_to_workspace:
# the mkdocs build outputs are in ~/project/site
root: ~/project
paths: site
- store_artifacts:
path: ~/project/site/
destination: dev_docs
linkchecker:
docker:
- image: cimg/python:3.8
steps:
# checkout code to default ~/project
- checkout
- attach_workspace:
# mkdocs build outputs will be in ~/project/site
at: ~/project
- run:
name: install linkchecker
command: |
python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
python -m pip install linkchecker
- run:
name: check links
command: |
source env/bin/activate
git status
if (! git log -1 --pretty=oneline | grep REL:) ; then
chmod a+rX -R ~
linkchecker -t 1 ~/project/site/
# check external separately by pointing to all *html so no
# failures for local file:/// -- yoh found no better way,
linkchecker -t 1 --check-extern \
--ignore-url 'file:///.*' \
--ignore-url 'https://fonts.gstatic.com' \
--ignore-url 'https://github.com/bids-standard/bids-specification/(pull|tree)/.*' \
--ignore-url 'https://github.com/[^/]*' \
--ignore-url 'https://doi.org/.*' \
--ignore-url 'https://bids-specification.readthedocs.io/en/stable/.*' \
~/project/site/*html ~/project/site/*/*.html
else
echo "Release PR - do nothing"
fi
build_docs_pdf:
docker:
- image: danteev/texlive:latest
steps:
# checkout code to default ~/project
- checkout
- run:
name: install dependencies
command: |
apt-get update && apt install -y python3-pip
python3 -m pip install --upgrade pip
python3 -m pip install -r ~/project/requirements.txt
- run:
name: install font that works with unicode emojis
command: apt-get update && apt-get install -y fonts-symbola
- run:
name: generate pdf version docs
command: |
cd ~/project/pdf_build_src
bash build_pdf.sh
mv ~/project/pdf_build_src/bids-spec.pdf ~/project/bids-spec.pdf
- store_artifacts:
path: bids-spec.pdf
# Auto changelog collector
github-changelog-generator:
docker:
- image: ferrarimarco/github-changelog-generator:1.14.3
steps:
- setup_remote_docker:
version: 18.06.0-ce
# checkout code to default ~/project
- checkout
- run:
name: Build changelog
# $CHANGE_TOKEN is generated via the GitHub web UI, and then securely stored within CircleCI web UI
command: |
mkdir ~/changelog_build
git status
if (git log -1 --pretty=%s | grep Merge*) && (! git log -1 --pretty=%b | grep REL:) ; then
github_changelog_generator \
--user bids-standard \
--project bids-specification \
--token ${CHANGE_TOKEN} \
--output ~/changelog_build/CHANGES.md \
--base ~/project/src/pregh-changes.md \
--header-label "# Changelog" \
--no-issues \
--no-issues-wo-labels \
--no-filter-by-milestone \
--no-compare-link \
--pr-label "" \
--release-branch master
cat ~/changelog_build/CHANGES.md
else
echo "Commit or Release, do nothing"
fi
- persist_to_workspace:
# raw generated changelog in ~/changelog_build/CHANGES.md
root: ~/.
paths: changelog_build
# Run remark on the auto generated changes.md file
remark:
docker:
- image: cimg/node:lts
steps:
# checkout code to default ~/project
- checkout
- attach_workspace:
# the freshly built CHANGES.md will be in ~/changelog_build/CHANGES.md
at: ~/.
- run:
name: install remark and extensions
command: npm install `cat npm-requirements.txt`
- run:
name: remark on autogenerated CHANGES.md
# format changelog, then use sed to change * to -, then lint changelog
command: |
git status
if (git log -1 --pretty=%s | grep Merge*) && (! git log -1 --pretty=%b | grep REL:) ; then
head -n 100 ~/changelog_build/CHANGES.md
npx remark-cli ~/changelog_build/CHANGES.md --rc-path ~/project/.remarkrc --output ~/changelog_build/CHANGES.md
head -n 100 ~/changelog_build/CHANGES.md
sed -i 's/* /- /' ~/changelog_build/CHANGES.md
head -n 100 ~/changelog_build/CHANGES.md
npx remark-cli ~/changelog_build/CHANGES.md --frail --rc-path ~/project/.remarkrc
else
echo "Commit or Release, do nothing"
fi
- persist_to_workspace:
# fixed+linted changelog in ~/changelog_build/CHANGES.md
root: ~/.
paths: changelog_build
# Push built changelog to repo
Changelog-bot:
docker:
- image: cimg/base:stable
steps:
- setup_remote_docker:
version: 17.11.0-ce
# checkout code to default ~/project
- checkout
- attach_workspace:
# fixed+linted changelog in ~/changelog_build/CHANGES.md
at: ~/.
- deploy:
name: Changelog deployment
# $CHANGE_TOKEN is generated via the GitHub web UI, and then securely stored within CircleCI web UI
command: |
if (git log -1 --pretty=%s | grep Merge*) && (! git log -1 --pretty=%b | grep REL:) ; then
mv ~/changelog_build/CHANGES.md ~/project/src/CHANGES.md
merge_message=$(git log -1 | grep Merge | grep "pull")
PR_number=$(echo $merge_message | cut -d ' ' -f 4)
git config credential.helper 'cache --timeout=120'
git config user.email "[email protected]"
git config user.name "bids-maintenance"
git add ~/project/src/CHANGES.md
git commit -m "[DOC] Auto-generate changelog entry for PR ${PR_number}"
git push https://${CHANGE_TOKEN}@github.com/bids-standard/bids-specification.git master
else
echo "Commit or Release, do nothing"
fi
workflows:
version: 2
search_build:
jobs:
- build_docs
- linkchecker:
requires:
- build_docs
- github-changelog-generator:
filters:
branches:
only: master
- remark:
requires:
- github-changelog-generator
filters:
branches:
only: master
- Changelog-bot:
requires:
- remark
filters:
branches:
only: master
- build_docs_pdf