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

Commit 9f060de

Browse files
author
Sheng Zha
committed
refactor CI pipelines
1 parent bb3ab0c commit 9f060de

File tree

5 files changed

+307
-83
lines changed

5 files changed

+307
-83
lines changed

Jenkinsfile

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

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ ROOTDIR = $(CURDIR)
1919
MD2IPYNB = $(ROOTDIR)/docs/md2ipynb.py
2020

2121
flake8:
22-
flake8 . --exclude conda --count --select=E901,E999,F821,F822,F823 --show-source --statistics
22+
flake8 --exclude conda --count --select=E901,E999,F821,F822,F823 --show-source --statistics $(lintdir)
2323

2424
pylint:
25-
pylint --rcfile=$(ROOTDIR)/.pylintrc src/gluonnlp scripts/*/*.py
25+
pylint --rcfile=$(ROOTDIR)/.pylintrc $(lintdir)
2626

2727
restruc:
2828
python setup.py check --restructuredtext --strict
2929

3030
lint:
31-
make flake8
32-
make pylint
31+
make lintdir=$(lintdir) flake8
32+
make lintdir=$(lintdir) pylint
3333
make restruc
3434

3535
docs: release
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 = 180
25+
26+
node {
27+
// Loading the utilities requires a node context unfortunately
28+
checkout scm
29+
utils = load('ci/jenkins/utils.groovy')
30+
steps = load('ci/jenkins/steps.groovy')
31+
}
32+
utils.assign_node_labels(linux_gpu: 'linux-gpu')
33+
34+
utils.main_wrapper(
35+
core_logic: {
36+
utils.parallel_stage('Sanity', [
37+
steps.sanity_lint('src/gluonnlp', 'py2', 'src/gluonnlp')
38+
])
39+
40+
utils.parallel_stage('Tests', [
41+
steps.test_unittest('gluon-nlp-py2', 'py2', 'tests/unittest', 'src/gluonnlp', 'gpu and not serial', 4),
42+
steps.test_unittest('gluon-nlp-py2', 'py2', 'tests/unittest', 'src/gluonnlp', 'gpu and serial', 0)
43+
])
44+
}
45+
)

ci/jenkins/steps.groovy

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
// This file contains the steps that will be used in the
21+
// Jenkins pipelines
22+
23+
utils = load('ci/jenkins/utils.groovy')
24+
25+
def sanity_lint(workspace_name, conda_env_name, path) {
26+
return ['Lint':
27+
{
28+
node(NODE_LINUX_GPU) {
29+
ws("workspace/${workspace_name}") {
30+
utils.init_git()
31+
sh """
32+
set -ex
33+
source ci/prepare_clean_env.sh ${conda_env_name}
34+
make lintdir=${path} lint
35+
set +ex
36+
"""
37+
}
38+
}
39+
}]
40+
}
41+
42+
def test_unittest(workspace_name, conda_env_name, test_path, cov_path, mark, threads) {
43+
capture_flag = env.BRANCH_NAME.startsWith('PR-')?'':'--capture=no'
44+
cov_flag = env.BRANCH_NAME.startsWith('PR-')?('PR'+env.CHANGE_ID):env.BRANCH_NAME
45+
return ['Python2: ':
46+
{
47+
node(NODE_LINUX_GPU) {
48+
ws("workspace/${workspace_name}") {
49+
utils.init_git()
50+
sh """
51+
set -ex
52+
export LD_LIBRARY_PATH=/usr/local/cuda/lib64
53+
export CUDA_VISIBLE_DEVICES=\$EXECUTOR_NUMBER
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
57+
"""
58+
utils.publish_test_coverage()
59+
}
60+
}
61+
}]
62+
}
63+
64+
return this

0 commit comments

Comments
 (0)