-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add code scan CI for neural insights (#996)
Signed-off-by: chensuyue <[email protected]> Co-authored-by: bmyrcha <[email protected]>
- Loading branch information
Showing
15 changed files
with
190 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
trigger: none | ||
|
||
pr: | ||
autoCancel: true | ||
drafts: false | ||
branches: | ||
include: | ||
- master | ||
paths: | ||
include: | ||
- neural_insights | ||
- setup.py | ||
- .azure-pipelines/code-scan-neural-insights.yml | ||
- .azure-pipelines/scripts/codeScan | ||
|
||
pool: | ||
vmImage: "ubuntu-latest" | ||
|
||
variables: | ||
CODE_SCAN_LOG_PATH: ".azure-pipelines/scripts/codeScan/scanLog" | ||
|
||
stages: | ||
- stage: DocStyleCodeScan | ||
displayName: DocStyle Code Scan | ||
dependsOn: [] | ||
jobs: | ||
- job: DocStyle | ||
displayName: DocStyle | ||
steps: | ||
- template: template/code-scan-template.yml | ||
parameters: | ||
codeScanFileName: "pydocstyle" | ||
uploadPath: "pydocstyle.log" | ||
scanModule: "neural_insights" | ||
|
||
- stage: BanditCodeScan | ||
displayName: Bandit Code Scan | ||
dependsOn: [] | ||
jobs: | ||
- job: Bandit | ||
displayName: Bandit | ||
steps: | ||
- template: template/code-scan-template.yml | ||
parameters: | ||
codeScanFileName: "bandit" | ||
uploadPath: "bandit.log" | ||
scanModule: "neural_insights" | ||
|
||
- stage: PylintCodeScan | ||
displayName: Pylint Code Scan | ||
dependsOn: [] | ||
jobs: | ||
- job: Pylint | ||
displayName: Pylint | ||
steps: | ||
- template: template/code-scan-template.yml | ||
parameters: | ||
codeScanFileName: "pylint" | ||
uploadPath: "pylint.json" | ||
scanModule: "neural_insights" | ||
|
||
- stage: CopyRight | ||
displayName: CopyRight Code Scan | ||
dependsOn: [] | ||
jobs: | ||
- job: CopyRight | ||
displayName: CopyRight | ||
steps: | ||
- script: | | ||
rm -fr $(Build.SourcesDirectory) || true | ||
echo y | docker system prune | ||
displayName: "Clean workspace" | ||
- checkout: self | ||
displayName: "Checkout out Repo" | ||
|
||
- task: Bash@3 | ||
inputs: | ||
targetType: "inline" | ||
script: | | ||
source $(Build.SourcesDirectory)/.azure-pipelines/scripts/change_color.sh | ||
set -e | ||
mkdir -p $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH) | ||
RESET="echo -en \\E[0m \\n" # close | ||
supported_extensions=(py, sh, yaml) | ||
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 | ||
files=$(cat $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/diff.log | awk '!a[$0]++') | ||
for file in ${files} | ||
do | ||
if [[ "${supported_extensions[@]}" =~ "${file##*.}" ]]; then | ||
if [ $(grep -E -c "Copyright \\(c\\) ([0-9]{4})(-[0-9]{4})? Intel Corporation" ${file}) = 0 ]; then | ||
echo ${file} >> $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log | ||
$BOLD_YELLOW && echo " ----------------- Current log file output start --------------------------" | ||
cat $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log | ||
$BOLD_YELLOW && echo " ----------------- Current log file output end --------------------------" && $RESET | ||
$BOLD_RED && echo "CopyRight has something wrong! Please click on the artifact button to download and view the error log!" && $RESET; exit 1 | ||
fi | ||
else | ||
$LIGHT_PURPLE && echo "Skipping ${file}" && $RESET | ||
fi | ||
done | ||
displayName: "CopyRight Check" | ||
|
||
- task: PublishPipelineArtifact@1 | ||
condition: failed() | ||
inputs: | ||
targetPath: $(Build.SourcesDirectory)/$(CODE_SCAN_LOG_PATH)/copyright_issue_summary.log | ||
artifact: copyright | ||
publishLocation: "pipeline" | ||
displayName: "PublishPipelineArtifact" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
.azure-pipelines/scripts/codeScan/pydocstyle/scan_path_neural_insights.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/neural-compressor/neural_insights/components | ||
/neural-compressor/neural_insights/utils | ||
/neural-compressor/neural_insights/web | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.