|
| 1 | +# Copyright 2010 New Relic, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +--- |
| 15 | +name: Check License Headers |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + branches: |
| 20 | + - main |
| 21 | + tags-ignore: |
| 22 | + - "**" |
| 23 | + pull_request: |
| 24 | + |
| 25 | +concurrency: |
| 26 | + group: ${{ github.ref || github.run_id }}-${{ github.workflow }} |
| 27 | + cancel-in-progress: true |
| 28 | + |
| 29 | +jobs: |
| 30 | + # Tests |
| 31 | + addlicense: |
| 32 | + runs-on: ubuntu-22.04 |
| 33 | + container: |
| 34 | + image: ghcr.io/newrelic/newrelic-python-agent-ci:latest |
| 35 | + timeout-minutes: 30 |
| 36 | + permissions: |
| 37 | + contents: read |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1 |
| 40 | + |
| 41 | + - name: Fetch git tags |
| 42 | + run: | |
| 43 | + git config --global --add safe.directory "$GITHUB_WORKSPACE" |
| 44 | + git fetch --tags origin |
| 45 | +
|
| 46 | + - name: Check License Headers |
| 47 | + shell: bash |
| 48 | + run: | |
| 49 | + # shellcheck disable=SC2046 |
| 50 | + if addlicense -f ./.github/LICENSE_HEADER -check -ignore "newrelic/packages/**/*" $(git ls-tree -r HEAD --name-only) >output.log; then |
| 51 | + echo "All files have the correct license header." |
| 52 | + else |
| 53 | + echo "License header missing from the following files:" |
| 54 | + sed s'/^/ - /' <output.log |
| 55 | +
|
| 56 | + # shellcheck disable=SC2016 |
| 57 | + echo ' |
| 58 | + To automatically add the license header to files that are missing it: |
| 59 | + Download the addlicense binary for your architecture and add it to your $PATH |
| 60 | + https://github.com/google/addlicense/releases |
| 61 | +
|
| 62 | + Then run the following command from the repository root directory: |
| 63 | + addlicense -f ./.github/LICENSE_HEADER -ignore "newrelic/packages/**/*" $(git ls-tree -r HEAD --name-only)' \ |
| 64 | + | sed 's/^ *//' |
| 65 | + exit 1 |
| 66 | + fi |
0 commit comments