Skip to content

Commit 35510f5

Browse files
gkdncopybara-github
authored andcommitted
Make license_check executable as a script instead of Bazel action.
The tool is still broken since there are logical errors but this is a step towards making it executable. When it is fixed, the idea is to run it directly instead of bazel which removes a lot of complexity around it. PiperOrigin-RevId: 703658810
1 parent e6519e5 commit 35510f5

File tree

4 files changed

+10
-46
lines changed

4 files changed

+10
-46
lines changed

BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ package(licenses = ["notice"])
2626

2727
exports_files([
2828
"LICENSE",
29-
"THIRD_PARTY_NOTICES",
30-
"maven_artifacts.bzl",
3129
])
3230

3331
filegroup(

license_check/BUILD.bazel

Lines changed: 0 additions & 25 deletions
This file was deleted.

license_check/third_party_license_test.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,6 @@ def main():
131131
description='Checks if the third party licenses are up to date',
132132
epilog='',
133133
)
134-
135-
parser.add_argument(
136-
'maven_artifacts_file',
137-
help='path to the bzl file with the list of maven artifacts.',
138-
)
139-
parser.add_argument(
140-
'third_party_notices_file', help='path to the THIRD_PARTY_NOTICES file.'
141-
)
142134
parser.add_argument(
143135
'-u',
144136
'--update',
@@ -147,8 +139,11 @@ def main():
147139
)
148140
args = parser.parse_args()
149141

142+
maven_artifacts_file = 'maven_artifacts.bzl'
143+
third_party_notices_file = 'THIRD_PARTY_NOTICES'
144+
150145
# Read maven_artifacts.bzl
151-
bzl_file_contents = open(args.maven_artifacts_file).read()
146+
bzl_file_contents = open(maven_artifacts_file).read()
152147

153148
# Work around a python3 bug with exec and local variables
154149
ldict = {}
@@ -161,7 +156,7 @@ def main():
161156
print(
162157
'artifact list length and pom/gradle file list length is not equal. ',
163158
'Please check the file :',
164-
args.maven_artifacts_file,
159+
maven_artifacts_file,
165160
)
166161
sys.exit(1)
167162

@@ -220,22 +215,18 @@ def main():
220215

221216
# Compare or Write out THIRD_PARTY_NOTICES file
222217
if args.update:
223-
fh = open(args.third_party_notices_file, 'w')
218+
fh = open(third_party_notices_file, 'w')
224219
fh.write(third_party_notices_content)
225220
fh.close()
226221
sys.exit()
227222

228223
else:
229-
old_third_party_notices_content = open(args.third_party_notices_file).read()
224+
old_third_party_notices_content = open(third_party_notices_file).read()
230225
if old_third_party_notices_content == third_party_notices_content:
231226
sys.exit()
232227
else:
233228
print('Changes detected in THIRD_PARTY_NOTICES file!')
234-
print('Please run the following command to update the license file: \n')
235-
print(' python3 \\')
236-
print(' third_party/third_party_license_test.py \\')
237-
print(' third_party/maven_artifacts.bzl \\')
238-
print(' third_party/THIRD_PARTY_NOTICES --update')
229+
print('Please run with --update flagto update the license file.')
239230
sys.exit(1)
240231

241232

license_check/third_party_license_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
set -e
44

5-
ROOT_DIR=${TEST_SRCDIR}/com_google_javascript_jscomp/third_party/
5+
python3 -m pip install requests
66

7-
python3 ${ROOT_DIR}/third_party_license_test.py ${ROOT_DIR}/maven_artifacts.bzl ${ROOT_DIR}/THIRD_PARTY_NOTICES "${@:2}"
7+
python3 license_check/third_party_license_test.py ${@}

0 commit comments

Comments
 (0)