Merge pull request #707 from Open-CAS/KamilLepek-patch-1

Added header verification script
This commit is contained in:
Robert Baldyga 2022-05-05 11:40:31 +02:00 committed by GitHub
commit 32dbb2d355
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 0 deletions

24
.github/verify_header.sh vendored Normal file
View File

@ -0,0 +1,24 @@
#!/bin/bash
#
# Copyright(c) 2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
YEAR=$(date +"%Y")
REGEX="Copyright\(c\) [0-9]{4}-([0-9]{4}) |Copyright\(c\) ([0-9]{4}) "
while read -r line; do
if [[ "$line" =~ $REGEX ]]; then
echo ${BASH_REMATCH[0]}
if [[ $YEAR == ${BASH_REMATCH[1]} || $YEAR == ${BASH_REMATCH[2]} ]]; then
echo $1 have appropriate license header
exit 0
fi
echo $1 have wrong license header year
exit 1
fi
done < "$1"
echo $1 does not contain appropriate license header
exit 1

34
.github/workflows/pullrequest.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: Licence-date-verification
on:
pull_request:
branches:
- master
env:
EXTENSIONS: "c h cpp py go sh"
jobs:
verify-date:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.1.0
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v18.2
with:
files_ignore: '.github/**'
- name: List all changed files
run: |
for FILE in ${{ steps.changed-files.outputs.all_changed_files }}; do
REGEX=".*\.(.*)"
if [[ "$FILE" =~ $REGEX ]]
then
EXTENSION=${BASH_REMATCH[1]}
EXTENSIONS_LIST=($EXTENSIONS)
if [[ " ${EXTENSIONS_LIST[*]} " =~ " ${EXTENSION} " ]]
then
.github/verify_header.sh $FILE
fi
fi
done