Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit 0e518d2

Browse files
author
Sheng Zha
committed
add documentation pipeline
1 parent 8d70e24 commit 0e518d2

File tree

7 files changed

+128
-25
lines changed

7 files changed

+128
-25
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// -*- mode: groovy -*-
2+
3+
// Licensed to the Apache Software Foundation (ASF) under one
4+
// or more contributor license agreements. See the NOTICE file
5+
// distributed with this work for additional information
6+
// regarding copyright ownership. The ASF licenses this file
7+
// to you under the Apache License, Version 2.0 (the
8+
// "License"); you may not use this file except in compliance
9+
// with the License. You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing,
14+
// software distributed under the License is distributed on an
15+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
// KIND, either express or implied. See the License for the
17+
// specific language governing permissions and limitations
18+
// under the License.
19+
//
20+
// Jenkins pipeline
21+
// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/
22+
23+
// timeout in minutes
24+
max_time = 120
25+
26+
node {
27+
// Loading the utilities requires a node context unfortunately
28+
checkout scm
29+
utils = load('ci/jenkins/utils.groovy')
30+
build_steps = load('ci/jenkins/build_steps.groovy')
31+
}
32+
utils.assign_node_labels(linux_gpu: 'linux-gpu', linux_cpu: 'linux-cpu')
33+
34+
utils.main_wrapper(
35+
core_logic: {
36+
utils.parallel_stage('Doc Test', [
37+
build_steps.test_doctest('gluon-nlp-gpu-py3-master', 'gpu/py3-master',
38+
'src/gluonnlp', 'src/gluonnlp', 4)
39+
])
40+
41+
utils.parallel_stage('Documentation', [
42+
build_steps.create_website('gluon-nlp-gpu-py3-master', 'gpu/py3-master')
43+
])
44+
45+
utils.parallel_stage('Deploy', [
46+
build_steps.post_website_link()
47+
])
48+
}
49+
,
50+
failure_handler: {}
51+
)

ci/jenkins/build_steps.groovy

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,81 @@ def test_unittest(workspace_name, conda_env_name,
4343
mark,
4444
threads, gpu, skip_report) {
4545
capture_flag = env.BRANCH_NAME.startsWith('PR-')?'':'--capture=no'
46-
cov_flag = env.BRANCH_NAME.startsWith('PR-')?('PR'+env.CHANGE_ID):env.BRANCH_NAME
4746
node_type = gpu?NODE_LINUX_GPU:NODE_LINUX_CPU
48-
return ["Python2: ${test_path} -m '${mark}'": {
47+
return ["${conda_env_name}: ${test_path} -m '${mark}'": {
4948
node(node_type) {
5049
ws("workspace/${workspace_name}") {
5150
utils.init_git()
5251
sh """
53-
set -ex
54-
source ci/prepare_clean_env.sh ${conda_env_name}
55-
pytest -v ${capture_flag} -n ${threads} -m '${mark}' --durations=30 ${test_path} --cov ${cov_path}
56-
set +ex
52+
set -ex
53+
source ci/prepare_clean_env.sh ${conda_env_name}
54+
pytest -v ${capture_flag} -n ${threads} -m '${mark}' --durations=30 --cov ${cov_path} ${test_path}
55+
set +ex
5756
"""
5857
if (!skip_report) utils.publish_test_coverage('GluonNLPCodeCov')
5958
}
6059
}
6160
}]
6261
}
6362

63+
def test_doctest(workspace_name, conda_env_name,
64+
test_path, cov_path, threads) {
65+
capture_flag = env.BRANCH_NAME.startsWith('PR-')?'':'--capture=no'
66+
return ["${conda_env_name}: doctest ${test_path}'": {
67+
node(NODE_LINUX_CPU) {
68+
ws("workspace/${workspace_name}") {
69+
utils.init_git()
70+
sh """
71+
set -ex
72+
source ci/prepare_clean_env.sh ${conda_env_name}
73+
pytest -v ${capture_flag} -n ${threads} --durations=30 --cov ${cov_path} --doctest-modules ${test_path}
74+
set +ex
75+
"""
76+
utils.publish_test_coverage('GluonNLPCodeCov')
77+
}
78+
}
79+
}]
80+
}
81+
82+
def create_website(workspace_name, conda_env_name) {
83+
if (env.BRANCH_NAME.startsWith('PR-')){
84+
enforce_linkcheck = 'false'
85+
bucket = 'gluon-nlp-staging'
86+
path = env.BRANCH_NAME+'/'+env.BUILD_NUMBER
87+
} else {
88+
enforce_linkcheck = 'true'
89+
bucket = 'gluon-nlp'
90+
path = env.BRANCH_NAME
91+
}
92+
return ["${conda_env_name}: website'": {
93+
node(NODE_LINUX_CPU) {
94+
ws("workspace/${workspace_name}") {
95+
utils.init_git()
96+
sh """
97+
set -ex
98+
source ci/prepare_clean_env.sh ${conda_env_name}
99+
make docs
100+
if [[ ${enforce_linkcheck} == true ]]; then
101+
make -C docs linkcheck SPHINXOPTS=-W
102+
else
103+
set +ex
104+
make -C docs linkcheck
105+
fi;
106+
107+
ci/upload_doc.sh ${bucket} ${path}
108+
set +ex
109+
"""
110+
}
111+
}
112+
}]
113+
}
114+
115+
def post_website_link() {
116+
if (env.BRANCH_NAME.startsWith("PR-")) {
117+
node {
118+
pullRequest.comment("Job ${env.BRANCH_NAME}/${env.BUILD_NUMBER} is complete. \nDocs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/index.html")
119+
}
120+
}
121+
}
122+
64123
return this

ci/step_doc_test.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import numpy as np
3333
import mxnet as mx
34+
import gluonnlp
3435
import pytest
3536

3637

@@ -187,3 +188,12 @@ def test_not_ok_with_random_data():
187188
@pytest.fixture(params=[True, False])
188189
def hybridize(request):
189190
return request.param
191+
192+
@pytest.fixture(autouse=True)
193+
def doctest(doctest_namespace):
194+
doctest_namespace['np'] = np
195+
doctest_namespace['gluonnlp'] = gluonnlp
196+
doctest_namespace['mx'] = mx
197+
doctest_namespace['gluon'] = mx.gluon
198+
import doctest
199+
doctest.ELLIPSIS_MARKER = '-etc-'

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33

44
# You can set these variables from the command line.
5-
SPHINXOPTS =
5+
SPHINXOPTS = -j 4
66
SPHINXBUILD = sphinx-build
77
PAPER =
88
BUILDDIR = _build

docs/conf.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,6 @@
6161
'sphinx_autorun',
6262
]
6363

64-
doctest_global_setup = '''
65-
import gluonnlp
66-
import mxnet as mx
67-
from mxnet import gluon
68-
import numpy as np
69-
import doctest
70-
doctest.ELLIPSIS_MARKER = '-etc-'
71-
'''
72-
7364
# Add any paths that contain templates here, relative to this directory.
7465
templates_path = ['_templates']
7566

scripts/tests/test_sanity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_sanity_gpu_serial():
3434

3535
@pytest.mark.gpu
3636
@pytest.mark.integration
37-
def test_sanity_gpu_serial():
37+
def test_sanity_gpu_integ():
3838
# sanity test that makes sure every marker combination has at least 1 test.
3939
# due to https://github.com/pytest-dev/pytest/issues/812
4040
import gluonnlp as nlp

0 commit comments

Comments
 (0)