Skip to content

Add style checks #6571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ The MIT License (MIT)

Copyright (c) Microsoft Corporation
All rights reserved.
Copyright (c) 2021 ChakraCore Project Contributors
Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
24 changes: 24 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
#-------------------------------------------------------------------------------------------------------
# Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
#-------------------------------------------------------------------------------------------------------

trigger:
- master
- release/*

jobs:
- job: Style
timeoutInMinutes: 10

pool:
vmImage: 'ubuntu-latest'

steps:
- script: jenkins/check_copyright.sh
displayName: "Copyright Check"

- script: jenkins/check_ascii.sh
displayName: "Ascii Check"

- script: jenkins/check_eol.sh
displayName: "EOL Check"

- script: jenkins/check_tabs.sh
displayName: "Tab Check"

- job: CMake
timeoutInMinutes: 120
strategy:
Expand Down
3 changes: 2 additions & 1 deletion jenkins/check_ascii.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#-------------------------------------------------------------------------------------------------------
# Copyright (C) Microsoft. All rights reserved.
# Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
#-------------------------------------------------------------------------------------------------------

Expand All @@ -20,7 +21,7 @@ if [ -e $ERRFILE ]; then # if error file exists then there were errors
>&2 echo "--------------" # leading >&2 means echo to stderr
>&2 echo "--- ERRORS ---"
cat $ERRFILE 1>&2 # send output to stderr so it can be redirected as error if desired
exit 1 # tell the caller there was an error (so Jenkins will fail the CI task)
exit 1 # tell the caller there was an error (so the CI task will fail)
else
echo "--- NO PROBLEMS DETECTED ---"
fi
4 changes: 3 additions & 1 deletion jenkins/check_copyright.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#-------------------------------------------------------------------------------------------------------
# Copyright (C) Microsoft. All rights reserved.
# Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
#-------------------------------------------------------------------------------------------------------

Expand All @@ -13,6 +14,7 @@
copyright_lines = [
r'-------------------------------------------------------------------------------------------------------',
r' Copyright \(C\) Microsoft( Corporation and contributors)?\. All rights reserved\.',
r' Copyright \(c\) 2021 ChakraCore Project Contributors\. All rights reserved\.',
r' Licensed under the MIT license\. See LICENSE\.txt file in the project root for full license information\.',
r'.*' # the above should always be followed by at least one other line, so make sure that line is present
]
Expand All @@ -33,7 +35,7 @@

def report_incorrect(file_name, pairs):
# found a problem so report the problem to the caller and exit
print(file_name, "... does not contain a correct Microsoft copyright notice.\n")
print(file_name, "... does not contain a correct copyright notice.\n")
# print the relevant lines to help the reader find the problem
for (_, line) in pairs:
print(" ", line, end="")
Expand Down
6 changes: 4 additions & 2 deletions jenkins/check_copyright.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#-------------------------------------------------------------------------------------------------------
# Copyright (C) Microsoft. All rights reserved.
# Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
#-------------------------------------------------------------------------------------------------------

Expand All @@ -18,9 +19,10 @@ rm -f $ERRFILE
rm -f $ERRFILETEMP

echo "Check Copyright > Begin Checking..."
git diff --name-only `git merge-base origin/$ghprbTargetBranch HEAD` HEAD |
git diff --name-only `git merge-base origin/master HEAD` HEAD |
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This instruction didn't work - edited to fix (by bringing in line with the logic in the other check scripts

grep -v -E '\.git.*' |
grep -v -E '\.xml$' |
grep -v -E '\.yml$' |
grep -v -E '\.props$' |
grep -v -E '\.md$' |
grep -v -E '\.txt$' |
Expand Down Expand Up @@ -59,7 +61,7 @@ if [ -e $ERRFILE ]; then # if error file exists then there were errors
>&2 echo "--- ERRORS ---"
cat $ERRFILE 1>&2 # send output to stderr so it can be redirected as error if desired
>&2 echo "--------------"
exit 1 # tell the caller there was an error (so Jenkins will fail the CI task)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to keep make it more future-proof, you can remove the name of the CI system we are using. I don't think it is critical, we can keep Azure here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might still need exit 1, otherwise Azure may not pick the failure up.

exit 1 # tell the caller there was an error (so the CI task will fail)
else
echo "--- NO PROBLEMS DETECTED ---"
fi
3 changes: 2 additions & 1 deletion jenkins/check_eol.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#-------------------------------------------------------------------------------------------------------
# Copyright (C) Microsoft. All rights reserved.
# Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
#-------------------------------------------------------------------------------------------------------

Expand All @@ -21,7 +22,7 @@ if [ -e $ERRFILE ]; then # if error file exists then there were errors
>&2 echo "--------------" # leading >&2 means echo to stderr
>&2 echo "--- ERRORS ---"
cat $ERRFILE 1>&2 # send output to stderr so it can be redirected as error if desired
exit 1 # tell the caller there was an error (so Jenkins will fail the CI task)
exit 1 # tell the caller there was an error (so the CI task will fail)
else
echo "--- NO PROBLEMS DETECTED ---"
fi
3 changes: 2 additions & 1 deletion jenkins/check_tabs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#-------------------------------------------------------------------------------------------------------
# Copyright (C) Microsoft. All rights reserved.
# Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
#-------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -36,7 +37,7 @@ if [ -s $ERRFILE ]; then # if file exists and is non-empty then there were error
>&2 echo "--- ERRORS ---"
>&2 echo ""

cat $ERRFILE 1>&2 # send output to stderr so it can be redirected as error if desired
cat $ERRFILE 1>&2 # tell the caller there was an error (so the CI task will fail)

exit 1
else
Expand Down
Loading