|
1 | | -name: Check PR with clang-format |
| 1 | +name: PR formatting |
2 | 2 |
|
3 | 3 | on: [pull_request_target] |
4 | 4 |
|
5 | 5 | jobs: |
6 | 6 | clang-format: |
| 7 | + name: clang-format |
7 | 8 | # We need at least 20.04 to install clang-format-11. |
8 | 9 | runs-on: ubuntu-20.04 |
9 | 10 |
|
@@ -99,3 +100,49 @@ jobs: |
99 | 100 | true) echo 'PR clean' ; exit 0 ;; |
100 | 101 | false) echo 'PR not clean' ; exit 1 ;; |
101 | 102 | 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 | + |
| 114 | + - name: Check copyright headers |
| 115 | + env: |
| 116 | + # The expected copyright notice. |
| 117 | + COPYRIGHT: | |
| 118 | + // Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 119 | + // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 120 | + // All rights not expressly granted are reserved. |
| 121 | + // |
| 122 | + // This software is distributed under the terms of the GNU General Public |
| 123 | + // License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 124 | + // |
| 125 | + // In applying this license CERN does not waive the privileges and immunities |
| 126 | + // granted to it by virtue of its status as an Intergovernmental Organization |
| 127 | + // or submit itself to any jurisdiction. |
| 128 | + run: | |
| 129 | + # Run copyright notice check |
| 130 | + copyright_lines=$(echo "$COPYRIGHT" | wc -l) |
| 131 | + base_commit=$(git merge-base HEAD ${{ github.event.pull_request.base.sha }}) |
| 132 | + have_err= |
| 133 | + git diff --diff-filter d --name-only "$base_commit" -- '*.cxx' '*.h' | while read -r file; do |
| 134 | + if [ "$(head -n "$copyright_lines" "$file")" != "$COPYRIGHT" ]; then |
| 135 | + echo "::error::$file: missing or malformed copyright notice" >&2 |
| 136 | + have_err=1 |
| 137 | + fi |
| 138 | + done |
| 139 | +
|
| 140 | + # Tell user what to do in case of copyright notice error |
| 141 | + if [ -n "$have_err" ]; then |
| 142 | + cat << EOF >&2 |
| 143 | + ::error::The files listed above are missing the correct copyright notice. |
| 144 | + ::error::Make sure all your source files begin with the following exact lines: |
| 145 | + $COPYRIGHT |
| 146 | + EOF |
| 147 | + exit 1 |
| 148 | + fi |
0 commit comments