@@ -21,21 +21,25 @@ parameters:
21
21
type : boolean
22
22
default : false
23
23
24
- # Define a job to be invoked later in a workflow.
25
- # See: https://circleci.com/docs/2.0/configuration-reference/#jobs
26
- jobs :
27
- linux_ut :
28
- # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
29
- # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
30
- docker :
31
- - image : secretflow/ubuntu-base-ci:latest
24
+ executors :
25
+ linux_executor : # declares a reusable executor
32
26
parameters :
33
27
resource_class :
34
28
type : string
29
+ docker :
30
+ - image : secretflow/ubuntu-base-ci:latest
35
31
resource_class : << parameters.resource_class >>
36
32
shell : /bin/bash --login -eo pipefail
37
- # Add steps to the job
38
- # See: https://circleci.com/docs/2.0/configuration-reference/#steps
33
+
34
+ commands :
35
+ build_and_test :
36
+ parameters :
37
+ targets :
38
+ type : string
39
+ default : " //..."
40
+ extra_bazel_test_args :
41
+ type : string
42
+ default : " "
39
43
steps :
40
44
# Kill the whole ci after 1hr
41
45
- run :
@@ -45,14 +49,12 @@ jobs:
45
49
sleep 7200
46
50
echo "Canceling workflow as too much time has elapsed"
47
51
curl -X POST --header "Content-Type: application/json" "https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/cancel?circle-token=${BUILD_TIMER_TOKEN}"
48
- - checkout
49
52
- run :
50
53
name : Checkout devtools
51
54
command : git clone https://github.com/secretflow/devtools.git ../devtools
52
55
- run :
53
56
name : " Install dependencies"
54
57
command : |
55
- python3 -m pip install -U pip
56
58
python3 -m pip install -r requirements.txt
57
59
python3 -m pip install -r requirements-dev.txt
58
60
- run :
@@ -62,83 +64,57 @@ jobs:
62
64
../devtools/bazel_cache_setup.py --in_file=../gcs.data --out_file=../gcs.json --min_download
63
65
- run :
64
66
name : " build"
65
- command : bazel build //... -c opt --ui_event_filters=-info,-debug,-warning --jobs 20
67
+ command : bazel build <<parameters.targets>> -c opt --ui_event_filters=-info,-debug,-warning --jobs 20
66
68
- run :
67
69
name : " test"
68
70
command : |
69
71
set +e
70
72
declare -i test_status
71
- bazel test //... -c opt --ui_event_filters=-info,-debug,-warning --test_output=errors| tee test_result.log; test_status=${PIPESTATUS[0]}
73
+ bazel test <<parameters.extra_bazel_test_args>> <<parameters.targets>> -c opt --ui_event_filters=-info,-debug,-warning --test_output=errors| tee test_result.log; test_status=${PIPESTATUS[0]}
72
74
73
75
sh ../devtools/rename-junit-xml.sh
74
- find bazel-bin/ -executable -type f -name "*_test" -print0 | xargs -0 tar -cvzf test_binary.tar.gz
75
76
find bazel-testlogs/ -type f -name "test.log" -print0 | xargs -0 tar -cvzf test_logs.tar.gz
76
77
77
78
exit ${test_status}
78
79
- store_test_results :
79
80
path : test-results
80
- - store_artifacts :
81
- path : test_binary.tar.gz
82
81
- store_artifacts :
83
82
path : test_logs.tar.gz
84
- linux_ml_ut :
85
- docker :
86
- - image : secretflow/ubuntu-base-ci:latest
87
- # arm is not supported
88
- resource_class : 2xlarge
89
- shell : /bin/bash --login -eo pipefail
83
+
84
+ # Define a job to be invoked later in a workflow.
85
+ # See: https://circleci.com/docs/2.0/configuration-reference/#jobs
86
+ jobs :
87
+ linux_ut :
88
+ parameters :
89
+ resource_class :
90
+ type : string
91
+ executor :
92
+ name : linux_executor
93
+ resource_class : << parameters.resource_class >>
94
+ # Add steps to the job
95
+ # See: https://circleci.com/docs/2.0/configuration-reference/#steps
90
96
steps :
91
- - run :
92
- name : Cancel build after set time
93
- background : true
94
- command : |
95
- sleep 7200
96
- echo "Canceling workflow as too much time has elapsed"
97
- curl -X POST --header "Content-Type: application/json" "https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/cancel?circle-token=${BUILD_TIMER_TOKEN}"
98
97
- checkout
98
+ - build_and_test
99
+ linux_ml_ut :
100
+ executor :
101
+ name : linux_executor
102
+ resource_class : 2xlarge+
103
+ steps :
99
104
- run :
100
- name : Checkout devtools
101
- command : git clone https://github.com/secretflow/devtools.git ../devtools
102
- - run :
103
- name : " Install dependencies"
105
+ name : Install extra deps
104
106
command : |
105
- python3 -m pip install -U pip
106
- python3 -m pip install -r requirements.txt
107
- python3 -m pip install -r requirements-dev.txt
108
107
python3 -m pip install tzdata
109
108
python3 -m pip install -r examples/python/ml/requirements.txt
110
- - run :
111
- name : Setup GCS
112
- command : |
113
- echo ${gcs_content} > ../gcs.data
114
- ../devtools/bazel_cache_setup.py --in_file=../gcs.data --out_file=../gcs.json --min_download
115
- - run :
116
- name : " build"
117
- command : bazel build //examples/python/ml:ml_test -c opt --ui_event_filters=-info,-debug,-warning --jobs 20
118
- - run :
119
- name : " test"
120
- command : |
121
- set +e
122
- declare -i test_status
123
- bazel test --test_env LD_LIBRARY_PATH=/root/miniconda3/lib/ //examples/python/ml:ml_test -c opt --ui_event_filters=-info,-debug,-warning --test_timeout=3600 --test_output=errors| tee test_result.log; test_status=${PIPESTATUS[0]}
124
-
125
- sh ../devtools/rename-junit-xml.sh
126
- find bazel-testlogs/ -type f -name "test.log" -print0 | xargs -0 tar -cvzf test_logs.tar.gz
127
-
128
- exit ${test_status}
129
- - store_test_results :
130
- path : test-results
131
- - store_artifacts :
132
- path : test_logs.tar.gz
109
+ - build_and_test :
110
+ targets : //examples/python/ml:ml_test
111
+ extra_bazel_test_args : --test_env LD_LIBRARY_PATH=/root/miniconda3/lib/
133
112
macOS_ut :
134
113
macos :
135
- xcode : 15.1
114
+ xcode : 15.1.0
136
115
resource_class : macos.m1.large.gen1
137
116
steps :
138
117
- checkout
139
- - run :
140
- name : Checkout devtools
141
- command : git clone https://github.com/secretflow/devtools.git ../devtools
142
118
- run :
143
119
name : " Install homebrew dependencies"
144
120
command : brew install bazelisk cmake ninja libomp wget md5sha1sum
@@ -151,45 +127,21 @@ jobs:
151
127
conda init bash zsh
152
128
pip install -r requirements.txt
153
129
pip install -r requirements-dev.txt
154
- - run :
155
- name : Setup GCS
156
- command : |
157
- echo ${gcs_content} > ../gcs.data
158
- ../devtools/bazel_cache_setup.py --in_file=../gcs.data --out_file=../gcs.json --min_download
159
- - run :
160
- name : " build"
161
- command : bazel build //... -c opt --ui_event_filters=-info,-debug,-warning
162
- - run :
163
- name : " test"
164
- command : |
165
- set +e
166
- declare -i test_status
167
- bazel test //... -c opt --ui_event_filters=-info,-debug,-warning --test_output=errors | tee test_result.log; test_status=${PIPESTATUS[0]}
168
-
169
- sh ../devtools/rename-junit-xml.sh
170
- find bazel-bin/ -perm +111 -type f -name "*_test" -print0 | xargs -0 tar -cvzf test_binary.tar.gz
171
- find bazel-testlogs/ -type f -name "test.log" -print0 | xargs -0 tar -cvzf test_logs.tar.gz
172
-
173
- exit ${test_status}
174
- - store_test_results :
175
- path : test-results
176
- - store_artifacts :
177
- path : test_binary.tar.gz
178
- - store_artifacts :
179
- path : test_logs.tar.gz
130
+ - build_and_test
180
131
# Invoke jobs via workflows
181
132
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
182
133
workflows :
183
134
unittest :
184
135
when : << pipeline.parameters.build-and-run >>
185
136
jobs :
186
137
- linux_ut :
138
+ name : linux_ut-<<matrix.resource_class>>
187
139
matrix :
188
140
parameters :
189
- resource_class : ["2xlarge", "arm.2xlarge"]
141
+ resource_class : ["2xlarge+ ", "arm.2xlarge"]
190
142
- linux_ml_ut :
191
143
requires :
192
- - linux_ut
144
+ - linux_ut-2xlarge+
193
145
filters :
194
146
branches :
195
147
only :
0 commit comments