Skip to content

Commit d4bcdd4

Browse files
authored
Support CI summary in PR comments (#1624)
Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com> Signed-off-by: chensuyue <suyue.chen@intel.com>
1 parent 28e82b1 commit d4bcdd4

31 files changed

+320
-236
lines changed

.azure-pipelines/code-scan-neural-insights.yaml

-52
Original file line numberDiff line numberDiff line change
@@ -57,55 +57,3 @@ stages:
5757
codeScanFileName: "pylint"
5858
uploadPath: "pylint.json"
5959
scanModule: "neural_insights"
60-
61-
- stage: CopyRight
62-
displayName: CopyRight Code Scan
63-
dependsOn: []
64-
jobs:
65-
- job: CopyRight
66-
displayName: CopyRight
67-
steps:
68-
- script: |
69-
rm -fr $(Build.SourcesDirectory) || true
70-
echo y | docker system prune
71-
displayName: "Clean workspace"
72-
73-
- checkout: self
74-
displayName: "Checkout out Repo"
75-
76-
- task: Bash@3
77-
inputs:
78-
targetType: "inline"
79-
script: |
80-
source $(Build.SourcesDirectory)/.azure-pipelines/scripts/change_color.sh
81-
set -e
82-
mkdir -p $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)
83-
RESET="echo -en \\E[0m \\n" # close
84-
85-
supported_extensions=(py, sh, yaml)
86-
git --no-pager diff --name-only $(git show-ref -s remotes/origin/$(System.PullRequest.TargetBranch)) $(Build.SourcesDirectory)/neural_insights > $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/diff.log
87-
files=$(cat $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/diff.log | awk '!a[$0]++')
88-
89-
for file in ${files}
90-
do
91-
if [[ "${supported_extensions[@]}" =~ "${file##*.}" ]]; then
92-
if [ $(grep -E -c "Copyright \\(c\\) ([0-9]{4})(-[0-9]{4})? Intel Corporation" ${file}) = 0 ]; then
93-
echo ${file} >> $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log
94-
$BOLD_YELLOW && echo " ----------------- Current log file output start --------------------------"
95-
cat $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log
96-
$BOLD_YELLOW && echo " ----------------- Current log file output end --------------------------" && $RESET
97-
$BOLD_RED && echo "CopyRight has something wrong! Please click on the artifact button to download and view the error log!" && $RESET; exit 1
98-
fi
99-
else
100-
$LIGHT_PURPLE && echo "Skipping ${file}" && $RESET
101-
fi
102-
done
103-
displayName: "CopyRight Check"
104-
105-
- task: PublishPipelineArtifact@1
106-
condition: failed()
107-
inputs:
108-
targetPath: $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log
109-
artifact: copyright
110-
publishLocation: "pipeline"
111-
displayName: "PublishPipelineArtifact"

.azure-pipelines/code-scan-neural-solution.yaml

-52
Original file line numberDiff line numberDiff line change
@@ -57,55 +57,3 @@ stages:
5757
codeScanFileName: "pylint"
5858
uploadPath: "pylint.json"
5959
scanModule: "neural_solution"
60-
61-
- stage: CopyRight
62-
displayName: CopyRight Code Scan
63-
dependsOn: []
64-
jobs:
65-
- job: CopyRight
66-
displayName: CopyRight
67-
steps:
68-
- script: |
69-
rm -fr $(Build.SourcesDirectory) || true
70-
echo y | docker system prune
71-
displayName: "Clean workspace"
72-
73-
- checkout: self
74-
displayName: "Checkout out Repo"
75-
76-
- task: Bash@3
77-
inputs:
78-
targetType: "inline"
79-
script: |
80-
source $(Build.SourcesDirectory)/.azure-pipelines/scripts/change_color.sh
81-
set -e
82-
mkdir -p $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)
83-
RESET="echo -en \\E[0m \\n" # close
84-
85-
supported_extensions=(py, sh, yaml)
86-
git --no-pager diff --name-only $(git show-ref -s remotes/origin/$(System.PullRequest.TargetBranch)) $(Build.SourcesDirectory)/neural_solution > $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/diff.log
87-
files=$(cat $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/diff.log | awk '!a[$0]++')
88-
89-
for file in ${files}
90-
do
91-
if [[ "${supported_extensions[@]}" =~ "${file##*.}" ]]; then
92-
if [ $(grep -E -c "Copyright \\(c\\) ([0-9]{4})(-[0-9]{4})? Intel Corporation" ${file}) = 0 ]; then
93-
echo ${file} >> $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log
94-
$BOLD_YELLOW && echo " ----------------- Current log file output start --------------------------"
95-
cat $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log
96-
$BOLD_YELLOW && echo " ----------------- Current log file output end --------------------------" && $RESET
97-
$BOLD_RED && echo "CopyRight has something wrong! Please click on the artifact button to download and view the error log!" && $RESET; exit 1
98-
fi
99-
else
100-
$LIGHT_PURPLE && echo "Skipping ${file}" && $RESET
101-
fi
102-
done
103-
displayName: "CopyRight Check"
104-
105-
- task: PublishPipelineArtifact@1
106-
condition: failed()
107-
inputs:
108-
targetPath: $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log
109-
artifact: copyright
110-
publishLocation: "pipeline"
111-
displayName: "PublishPipelineArtifact"

.azure-pipelines/code-scan.yml

-52
Original file line numberDiff line numberDiff line change
@@ -56,55 +56,3 @@ stages:
5656
parameters:
5757
codeScanFileName: "pylint"
5858
uploadPath: "pylint.json"
59-
60-
- stage: CopyRight
61-
displayName: CopyRight Code Scan
62-
dependsOn: []
63-
jobs:
64-
- job: CopyRight
65-
displayName: CopyRight
66-
steps:
67-
- script: |
68-
rm -fr $(Build.SourcesDirectory) || true
69-
echo y | docker system prune
70-
displayName: "Clean workspace"
71-
72-
- checkout: self
73-
displayName: "Checkout out Repo"
74-
75-
- task: Bash@3
76-
inputs:
77-
targetType: "inline"
78-
script: |
79-
source $(Build.SourcesDirectory)/.azure-pipelines/scripts/change_color.sh
80-
set -e
81-
mkdir -p $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)
82-
RESET="echo -en \\E[0m \\n" # close
83-
84-
supported_extensions=(py, sh, yaml)
85-
git --no-pager diff --name-only $(git show-ref -s remotes/origin/$(System.PullRequest.TargetBranch)) $(Build.SourcesDirectory)/neural_compressor > $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/diff.log
86-
files=$(cat $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/diff.log | awk '!a[$0]++')
87-
88-
for file in ${files}
89-
do
90-
if [[ "${supported_extensions[@]}" =~ "${file##*.}" ]]; then
91-
if [ $(grep -E -c "Copyright \\(c\\) ([0-9]{4})(-[0-9]{4})? Intel Corporation" ${file}) = 0 ]; then
92-
echo ${file} >> $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log
93-
$BOLD_YELLOW && echo " ----------------- Current log file output start --------------------------"
94-
cat $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log
95-
$BOLD_YELLOW && echo " ----------------- Current log file output end --------------------------" && $RESET
96-
$BOLD_RED && echo "CopyRight has something wrong! Please click on the artifact button to download and view the error log!" && $RESET; exit 1
97-
fi
98-
else
99-
$LIGHT_PURPLE && echo "Skipping ${file}" && $RESET
100-
fi
101-
done
102-
displayName: "CopyRight Check"
103-
104-
- task: PublishPipelineArtifact@1
105-
condition: failed()
106-
inputs:
107-
targetPath: $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log
108-
artifact: copyright
109-
publishLocation: "pipeline"
110-
displayName: "PublishPipelineArtifact"

.azure-pipelines/scripts/ut/3x/collect_log_3x.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ coverage_compare="/neural-compressor/log_dir/coverage_compare.html"
99
cd /neural-compressor/log_dir
1010

1111
$BOLD_YELLOW && echo "collect coverage for PR branch" && $RESET
12-
cp ut_coverage_3x/.coverage /neural-compressor/
12+
cp ut_3x_coverage/.coverage /neural-compressor/
1313
mkdir -p coverage_PR
1414
cd /neural-compressor
1515
coverage report -m --rcfile=${COVERAGE_RCFILE} | tee ${coverage_log}
@@ -20,18 +20,19 @@ ls -l log_dir/coverage_PR/htmlcov
2020

2121
$BOLD_YELLOW && echo "collect coverage for baseline" && $RESET
2222
cd /neural-compressor
23+
cp -r /neural-compressor/.azure-pipelines .azure-pipelines-pr
2324
git config --global --add safe.directory /neural-compressor
2425
git fetch
2526
git checkout master
2627
rm -rf build dist *egg-info
2728
echo y | pip uninstall neural_compressor_${1}
28-
cd /neural-compressor/.azure-pipelines/scripts && bash install_nc.sh ${1}
29+
cd /neural-compressor/.azure-pipelines-pr/scripts && bash install_nc.sh ${1}
2930

3031
coverage erase
3132
cd /neural-compressor/log_dir
3233
mkdir -p coverage_base
3334
rm -rf /neural-compressor/.coverage || true
34-
cp ut_coverage_3x_baseline/.coverage /neural-compressor
35+
cp ut_3x_baseline_coverage/.coverage /neural-compressor
3536

3637
cd /neural-compressor
3738
coverage report -m --rcfile=${COVERAGE_RCFILE} | tee ${coverage_log_base}
@@ -123,10 +124,10 @@ if [[ ${#fail_items[@]} -ne 0 ]]; then
123124
$BOLD_RED && echo "Unit Test failed with ${item} coverage decrease ${decrease}%" && $RESET
124125
done
125126
$BOLD_RED && echo "compare coverage to give detail info" && $RESET
126-
bash /neural-compressor/.azure-pipelines/scripts/ut/compare_coverage.sh ${coverage_compare} ${coverage_log} ${coverage_log_base} "FAILED" ${coverage_PR_lines_rate} ${coverage_base_lines_rate} ${coverage_PR_branches_rate} ${coverage_base_branches_rate}
127+
bash /neural-compressor/.azure-pipelines-pr/scripts/ut/compare_coverage.sh ${coverage_compare} ${coverage_log} ${coverage_log_base} "FAILED" ${coverage_PR_lines_rate} ${coverage_base_lines_rate} ${coverage_PR_branches_rate} ${coverage_base_branches_rate}
127128
exit 1
128129
else
129130
$BOLD_GREEN && echo "Unit Test success with coverage lines: ${coverage_PR_lines_rate}%, branches: ${coverage_PR_branches_rate}%" && $RESET
130131
$BOLD_GREEN && echo "compare coverage to give detail info" && $RESET
131-
bash /neural-compressor/.azure-pipelines/scripts/ut/compare_coverage.sh ${coverage_compare} ${coverage_log} ${coverage_log_base} "SUCCESS" ${coverage_PR_lines_rate} ${coverage_base_lines_rate} ${coverage_PR_branches_rate} ${coverage_base_branches_rate}
132+
bash /neural-compressor/.azure-pipelines-pr/scripts/ut/compare_coverage.sh ${coverage_compare} ${coverage_log} ${coverage_log_base} "SUCCESS" ${coverage_PR_lines_rate} ${coverage_base_lines_rate} ${coverage_PR_branches_rate} ${coverage_base_branches_rate}
132133
fi

.azure-pipelines/scripts/ut/3x/run_3x_ort.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ mkdir -p ${LOG_DIR}
2121
ut_log_name=${LOG_DIR}/ut_3x_ort.log
2222
pytest --cov="${inc_path}" -vs --disable-warnings --html=report.html --self-contained-html . 2>&1 | tee -a ${ut_log_name}
2323

24-
cp .coverage ${LOG_DIR}/.coverage
2524
cp report.html ${LOG_DIR}/
2625

2726
if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then
@@ -30,4 +29,7 @@ if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS
3029
exit 1
3130
fi
3231

32+
# if ut pass, collect the coverage file into artifacts
33+
cp .coverage ${LOG_DIR}/.coverage
34+
3335
echo "UT finished successfully! "

.azure-pipelines/scripts/ut/3x/run_3x_pt.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ mkdir -p ${LOG_DIR}
2121
ut_log_name=${LOG_DIR}/ut_3x_pt.log
2222
pytest --cov="${inc_path}" -vs --disable-warnings --html=report.html --self-contained-html . 2>&1 | tee -a ${ut_log_name}
2323

24-
cp .coverage ${LOG_DIR}/.coverage
2524
cp report.html ${LOG_DIR}/
2625

2726
if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then
@@ -30,4 +29,7 @@ if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS
3029
exit 1
3130
fi
3231

32+
# if ut pass, collect the coverage file into artifacts
33+
cp .coverage ${LOG_DIR}/.coverage
34+
3335
echo "UT finished successfully! "

.azure-pipelines/scripts/ut/3x/run_3x_tf.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ mkdir -p report
3434
mv *.html report
3535
pytest_html_merger -i ./report -o ./report.html
3636

37-
cp .coverage ${LOG_DIR}/.coverage
3837
cp report.html ${LOG_DIR}/
3938

4039
if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS ==' ${ut_log_name}) != 0 ] || [ $(grep -c ' passed' ${ut_log_name}) == 0 ]; then
@@ -43,4 +42,7 @@ if [ $(grep -c '== FAILURES ==' ${ut_log_name}) != 0 ] || [ $(grep -c '== ERRORS
4342
exit 1
4443
fi
4544

45+
# if ut pass, collect the coverage file into artifacts
46+
cp .coverage ${LOG_DIR}/.coverage
47+
4648
echo "UT finished successfully! "

.azure-pipelines/scripts/ut/collect_log.sh

+8-17
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@ cd /neural-compressor/log_dir
99

1010
$BOLD_YELLOW && echo "collect coverage for PR branch" && $RESET
1111
mkdir -p coverage_PR
12-
cp ut-coverage-adaptor/.coverage.adaptor ./coverage_PR/
13-
cp ut-coverage-api/.coverage.api ./coverage_PR/
14-
cp ut-coverage-tf-pruning/.coverage.tf_pruning ./coverage_PR/
15-
cp ut-coverage-pt-pruning/.coverage.pt_pruning ./coverage_PR/
16-
cp ut-coverage-tfnewapi/.coverage.tfnewapi ./coverage_PR/
17-
cp ut-coverage-others/.coverage.others ./coverage_PR/
18-
cp ut-coverage-itex/.coverage.itex ./coverage_PR/
12+
cp ut_*_coverage/.coverage.* ./coverage_PR/
13+
1914
cd coverage_PR
2015
coverage combine --keep --rcfile=${COVERAGE_RCFILE}
2116
cp .coverage /neural-compressor/.coverage
@@ -26,24 +21,20 @@ coverage xml -o log_dir/coverage_PR/coverage.xml --rcfile=${COVERAGE_RCFILE}
2621
ls -l log_dir/coverage_PR/htmlcov
2722

2823
cd /neural-compressor
24+
cp -r /neural-compressor/.azure-pipelines .azure-pipelines-pr
2925
git config --global --add safe.directory /neural-compressor
3026
git fetch
3127
git checkout master
3228
rm -rf build dist *egg-info
3329
echo y | pip uninstall neural-compressor
34-
cd /neural-compressor/.azure-pipelines/scripts && bash install_nc.sh
30+
cd /neural-compressor/.azure-pipelines-pr/scripts && bash install_nc.sh
3531

3632
$BOLD_YELLOW && echo "collect coverage for baseline" && $RESET
3733
coverage erase
3834
cd /neural-compressor/log_dir
3935
mkdir -p coverage_base
40-
cp ut-coverage-adaptor-base/.coverage.adaptor ./coverage_base/
41-
cp ut-coverage-api-base/.coverage.api ./coverage_base/
42-
cp ut-coverage-tf-pruning-base/.coverage.tf_pruning ./coverage_base/
43-
cp ut-coverage-pt-pruning-base/.coverage.pt_pruning ./coverage_base/
44-
cp ut-coverage-tfnewapi-base/.coverage.tfnewapi ./coverage_base/
45-
cp ut-coverage-others-base/.coverage.others ./coverage_base/
46-
cp ut-coverage-itex-base/.coverage.itex ./coverage_base/
36+
cp ut-base_*_coverage/.coverage.* ./coverage_base/
37+
4738
cd coverage_base
4839
coverage combine --keep --rcfile=${COVERAGE_RCFILE}
4940
cp .coverage /neural-compressor/.coverage
@@ -137,10 +128,10 @@ if [[ ${#fail_items[@]} -ne 0 ]]; then
137128
$BOLD_RED && echo "Unit Test failed with ${item} coverage decrease ${decrease}%" && $RESET
138129
done
139130
$BOLD_RED && echo "compare coverage to give detail info" && $RESET
140-
bash /neural-compressor/.azure-pipelines/scripts/ut/compare_coverage.sh ${coverage_compare} ${coverage_log} ${coverage_log_base} "FAILED" ${coverage_PR_lines_rate} ${coverage_base_lines_rate} ${coverage_PR_branches_rate} ${coverage_base_branches_rate}
131+
bash /neural-compressor/.azure-pipelines-pr/scripts/ut/compare_coverage.sh ${coverage_compare} ${coverage_log} ${coverage_log_base} "FAILED" ${coverage_PR_lines_rate} ${coverage_base_lines_rate} ${coverage_PR_branches_rate} ${coverage_base_branches_rate}
141132
exit 1
142133
else
143134
$BOLD_GREEN && echo "Unit Test success with coverage lines: ${coverage_PR_lines_rate}%, branches: ${coverage_PR_branches_rate}%" && $RESET
144135
$BOLD_GREEN && echo "compare coverage to give detail info" && $RESET
145-
bash /neural-compressor/.azure-pipelines/scripts/ut/compare_coverage.sh ${coverage_compare} ${coverage_log} ${coverage_log_base} "SUCCESS" ${coverage_PR_lines_rate} ${coverage_base_lines_rate} ${coverage_PR_branches_rate} ${coverage_base_branches_rate}
136+
bash /neural-compressor/.azure-pipelines-pr/scripts/ut/compare_coverage.sh ${coverage_compare} ${coverage_log} ${coverage_log_base} "SUCCESS" ${coverage_PR_lines_rate} ${coverage_base_lines_rate} ${coverage_PR_branches_rate} ${coverage_base_branches_rate}
146137
fi

0 commit comments

Comments
 (0)