Skip to content

Commit 02d14d0

Browse files
License Header Linter (#1357)
* Install addlicense to CI image * Fix related ARCH based ODBC driver bug * Add check license header job to GHA * Add missing license headers * Fix linter issues * Fix issue in x86/arm selection * Add explicit permissions to CI job --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 4134c5e commit 02d14d0

File tree

15 files changed

+263
-3
lines changed

15 files changed

+263
-3
lines changed

.devcontainer/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
# To target other architectures, change the --platform directive in the Dockerfile.
216
ARG IMAGE_TAG=latest
317
FROM ghcr.io/newrelic/newrelic-python-agent-ci:${IMAGE_TAG}

.github/LICENSE_HEADER

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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.

.github/containers/Dockerfile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515

1616
FROM ubuntu:20.04
17+
ARG TARGETPLATFORM
1718

1819
# Install OS packages
1920
RUN export DEBIAN_FRONTEND=noninteractive && \
@@ -61,6 +62,17 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
6162
zsh && \
6263
rm -rf /var/lib/apt/lists/*
6364

65+
# Install addlicense binary
66+
ARG ADDLICENSE_VERSION=1.1.1
67+
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then export ARCH="x86_64"; else export ARCH="arm64"; fi && \
68+
mkdir -p /tmp/addlicense && \
69+
wget https://github.com/google/addlicense/releases/download/v${ADDLICENSE_VERSION}/addlicense_${ADDLICENSE_VERSION}_Linux_${ARCH}.tar.gz \
70+
-O /tmp/addlicense/addlicense.tar.gz && \
71+
tar -xzvf /tmp/addlicense/addlicense.tar.gz -C /tmp/addlicense && \
72+
mv /tmp/addlicense/addlicense /usr/local/bin/addlicense && \
73+
rm -rf /tmp/addlicense && \
74+
chmod +x /usr/local/bin/addlicense
75+
6476
# Build librdkafka from source
6577
ARG LIBRDKAFKA_VERSION=2.1.1
6678
RUN cd /tmp && \
@@ -74,9 +86,10 @@ RUN cd /tmp && \
7486
rm -rf ./librdkafka-${LIBRDKAFKA_VERSION}
7587

7688
# Setup ODBC config
77-
RUN sed -i 's|Driver=psqlodbca.so|Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so|g' /etc/odbcinst.ini && \
78-
sed -i 's|Driver=psqlodbcw.so|Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so|g' /etc/odbcinst.ini && \
79-
sed -i 's|Setup=libodbcpsqlS.so|Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so|g' /etc/odbcinst.ini
89+
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then export ARCH="x86_64"; else export ARCH="aarch64"; fi && \
90+
sed -i 's|Driver=psqlodbca.so|Driver=/usr/lib/${ARCH}-linux-gnu/odbc/psqlodbca.so|g' /etc/odbcinst.ini && \
91+
sed -i 's|Driver=psqlodbcw.so|Driver=/usr/lib/${ARCH}-linux-gnu/odbc/psqlodbcw.so|g' /etc/odbcinst.ini && \
92+
sed -i 's|Setup=libodbcpsqlS.so|Setup=/usr/lib/${ARCH}-linux-gnu/odbc/libodbcpsqlS.so|g' /etc/odbcinst.ini
8093

8194
# Set the locale
8295
RUN locale-gen --no-purge en_US.UTF-8

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
---
216
version: 2
317
updates:

.github/mergify.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
# For condition grammar see: https://docs.mergify.com/conditions/#grammar
216

317
pull_request_rules:

.github/workflows/addlicense.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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

.github/workflows/mega-linter.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
---
216
# MegaLinter GitHub Action configuration file
317
# More info at https://megalinter.io

.mega-linter.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
# Configuration file for Mega-Linter
216
# See all available variables at https://oxsecurity.github.io/megalinter/configuration/ and in linters documentation
317

codecov.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
ignore:
216
- "newreilc/hooks/component_sentry.py"
317
- "newrelic/admin/*"

newrelic/core/infinite_tracing.proto

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
// Generate pb2 files using the following command:
216
// python -m grpc_tools.protoc --proto_path=newrelic/core --python_out=newrelic/core newrelic/core/infinite_tracing.proto
317

0 commit comments

Comments
 (0)