Skip to content

Commit 69bab9b

Browse files
authored
Add check for copyright headers (#325)
* Make copyright headers consistent This is to prepare the code for introducing copyright header checking. One file, PWGDQ/Tasks/filterPPTiny.cxx, had CR-LF line endings, which would confuse the checker. It was converted to LF line endings to match the rest of O2Physics. * Add check for copyright headers It runs in parallel with the clang-format check, and makes sure the copyright notice of any changed .cxx or .h files is OK.
1 parent 037ae25 commit 69bab9b

18 files changed

Lines changed: 489 additions & 426 deletions

.github/workflows/code-formatting.yml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
name: Check PR with clang-format
1+
name: PR formatting
22

33
on: [pull_request_target]
44

55
jobs:
66
clang-format:
7+
name: clang-format
78
# We need at least 20.04 to install clang-format-11.
89
runs-on: ubuntu-20.04
910

@@ -99,3 +100,53 @@ jobs:
99100
true) echo 'PR clean' ; exit 0 ;;
100101
false) echo 'PR not clean' ; exit 1 ;;
101102
esac
103+
104+
copyright:
105+
name: copyright headers
106+
runs-on: ubuntu-latest
107+
108+
steps:
109+
- uses: actions/checkout@v2
110+
with:
111+
ref: ${{ github.event.pull_request.head.sha }}
112+
persist-credentials: false
113+
# We need the history of the dev branch all the way back to where the PR
114+
# diverged. We're fetching everything here, as we don't know how many
115+
# commits back that point is.
116+
fetch-depth: 0
117+
118+
- name: Check copyright headers
119+
env:
120+
# The expected copyright notice.
121+
COPYRIGHT: |
122+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
123+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
124+
// All rights not expressly granted are reserved.
125+
//
126+
// This software is distributed under the terms of the GNU General Public
127+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
128+
//
129+
// In applying this license CERN does not waive the privileges and immunities
130+
// granted to it by virtue of its status as an Intergovernmental Organization
131+
// or submit itself to any jurisdiction.
132+
run: |
133+
# Run copyright notice check
134+
copyright_lines=$(echo "$COPYRIGHT" | wc -l)
135+
base_commit=$(git merge-base HEAD ${{ github.event.pull_request.base.sha }})
136+
have_err=
137+
git diff --diff-filter d --name-only "$base_commit" -- '*.cxx' '*.h' | while read -r file; do
138+
if [ "$(head -n "$copyright_lines" "$file")" != "$COPYRIGHT" ]; then
139+
echo "::error::$file: missing or malformed copyright notice" >&2
140+
have_err=1
141+
fi
142+
done
143+
144+
# Tell user what to do in case of copyright notice error
145+
if [ -n "$have_err" ]; then
146+
cat << EOF >&2
147+
::error::The files listed above are missing the correct copyright notice.
148+
::error::Make sure all your source files begin with the following exact lines:
149+
$COPYRIGHT
150+
EOF
151+
exit 1
152+
fi

Common/Tasks/ft0Qa.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
32
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
43
// All rights not expressly granted are reserved.

DPG/TableProducer/pidMLProducer.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright CERN and copyright holders of ALICE O2. This software is
2-
// distributed under the terms of the GNU General Public License v3 (GPL
3-
// Version 3), copied verbatim in the file "COPYING".
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
44
//
5-
// See http://alice-o2.web.cern.ch/license for full licensing information.
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
67
//
78
// In applying this license CERN does not waive the privileges and immunities
89
// granted to it by virtue of its status as an Intergovernmental Organization

EventFiltering/PWGHF/HFFilter.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright CERN and copyright holders of ALICE O2. This software is
2-
// distributed under the terms of the GNU General Public License v3 (GPL
3-
// Version 3), copied verbatim in the file "COPYING".
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
44
//
5-
// See http://alice-o2.web.cern.ch/license for full licensing information.
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
67
//
78
// In applying this license CERN does not waive the privileges and immunities
89
// granted to it by virtue of its status as an Intergovernmental Organization

EventFiltering/PWGJE/jetFilter.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
32
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
43
// All rights not expressly granted are reserved.

EventFiltering/PWGLF/strangenessFilter.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright CERN and copyright holders of ALICE O2. This software is
2-
// distributed under the terms of the GNU General Public License v3 (GPL
3-
// Version 3), copied verbatim in the file "COPYING".
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
44
//
5-
// See http://alice-o2.web.cern.ch/license for full licensing information.
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
67
//
78
// In applying this license CERN does not waive the privileges and immunities
89
// granted to it by virtue of its status as an Intergovernmental Organization

EventFiltering/PWGMM/multFilter.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
32
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
43
// All rights not expressly granted are reserved.
@@ -9,11 +8,13 @@
98
// In applying this license CERN does not waive the privileges and immunities
109
// granted to it by virtue of its status as an Intergovernmental Organization
1110
// or submit itself to any jurisdiction.
12-
// O2 includes
11+
//
1312
// \file multFilter.cxx
1413
// \brief task for selection of high multiplicity events
1514
//
1615
// \author Antonio Ortiz <antonio.ortiz.velasquez@cern.ch>, ICN-UNAM
16+
//
17+
// O2 includes
1718

1819
#include "ReconstructionDataFormats/Track.h"
1920
#include "Framework/runDataProcessing.h"

PWGCF/FemtoDream/FemtoDreamDetaDphiStar.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright CERN and copyright holders of ALICE O2. This software is
2-
// distributed under the terms of the GNU General Public License v3 (GPL
3-
// Version 3), copied verbatim in the file "COPYING".
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
44
//
5-
// See http://alice-o2.web.cern.ch/license for full licensing information.
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
67
//
78
// In applying this license CERN does not waive the privileges and immunities
89
// granted to it by virtue of its status as an Intergovernmental Organization

0 commit comments

Comments
 (0)