This repository has been archived by the owner on Aug 30, 2024. It is now read-only.
Refact convert scripts #208
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
name: Copyright Check | |
on: | |
pull_request: | |
branches: [main] | |
paths: | |
- neural_speed/** | |
- setup.py | |
- .github/workflows/format_scan.yml | |
workflow_dispatch: | |
# If there is a new commit, the previous jobs will be canceled | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
CODE_SCAN_LOG_PATH: "${{ github.workspace }}/log" | |
CONTAINER_NAME: "codeScan" | |
jobs: | |
format-scan: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
job_name: ["copyright"] | |
fail-fast: false | |
steps: | |
- name: Checkout out Repo | |
uses: actions/checkout@v3 | |
- name: CopyRight check | |
run: | | |
source ${{ github.workspace }}/.github/workflows/scripts/change_color.sh | |
set -e | |
mkdir -p ${{ env.CODE_SCAN_LOG_PATH }} | |
supported_extensions=(py, sh, yaml) | |
git fetch | |
git --no-pager diff --name-only remotes/origin/${{ github.base_ref }} ${{ github.workspace }}/neural_speed> ${{ env.CODE_SCAN_LOG_PATH }}/diff.log | |
files=$(cat ${{ env.CODE_SCAN_LOG_PATH }}/diff.log | awk '!a[$0]++') | |
$LIGHT_PURPLE && echo " ----------------- checking ... --------------------------" && $RESET | |
if [[ -f ${{ env.CODE_SCAN_LOG_PATH }}/copyright_issue_summary.log ]]; then | |
rm -f ${{ env.CODE_SCAN_LOG_PATH }}/copyright_issue_summary.log | |
fi | |
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} >> ${{ env.CODE_SCAN_LOG_PATH }}/copyright_issue_summary.log | |
$BOLD_YELLOW && echo " ----------------- Current log file output start --------------------------" | |
cat ${{ env.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 | |
fi | |
else | |
$LIGHT_PURPLE && echo "Skipping ${file}" && $RESET | |
fi | |
done | |
if [[ -f ${{ env.CODE_SCAN_LOG_PATH }}/copyright_issue_summary.log ]]; then | |
$BOLD_YELLOW && echo " ----------------- Current log file output start --------------------------" | |
cat ${{ env.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 | |
- name: Publish pipeline artifact | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.job_name }} | |
path: ${{ env.CODE_SCAN_LOG_PATH }}.* |