Skip to content

Commit 1d1f4f2

Browse files
committed
Merge branch 'issue_1214-spdx-enforce'
2 parents 37faf7c + c12b813 commit 1d1f4f2

File tree

21 files changed

+71
-10
lines changed

21 files changed

+71
-10
lines changed

.github/scripts/store_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
MAX_ARTIFACTS = 100
1818

1919
# behave differently outside of github actions, for testing
20-
in_gh = (os.getenv("IN_GITHUB_WORKFLOW") == "1")
20+
in_gh = (os.getenv("GITHUB_ACTIONS") == "true")
2121

2222
benchmarking_dir = os.path.join("metrics", "benchmarking")
2323
artifacts_dir = os.path.join(benchmarking_dir, "artifacts")

.github/workflows/benchmark.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ jobs:
9898
run: |
9999
python ./.github/scripts/store_benchmark.py
100100
working-directory: src
101-
env:
102-
IN_GITHUB_WORKFLOW: 1
103101

104102
- name: Setup git config
105103
run: |

.github/workflows/copyright.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: copyright
2+
on:
3+
pull_request:
4+
paths:
5+
- 'src/**'
6+
- '!**.md'
7+
push:
8+
paths:
9+
- 'src/**'
10+
- '!**.md'
11+
12+
jobs:
13+
main:
14+
name: Enforce copyright notices
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: 2.7
25+
26+
- name: Run copyright checker
27+
run: |
28+
bash ./src/build_utils/license/apply_copyright
29+
if [[ "$(git status | grep modified)" != "" ]]; then
30+
echo "Some sourcefiles are missing copyright notice!" 1>&2
31+
echo "Run ./src/build_utils/license/apply_copyright to apply." 1>&2
32+
exit 1
33+
fi

src/build_utils/license/change_copyright

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from __future__ import print_function
66
import argparse
77
import sys
8+
import os
89

910

1011
new_copyright = (
@@ -16,17 +17,26 @@ lines = []
1617
NO_COPYRIGHT = "NO_COPYRIGHT"
1718
OTHER_COPYRIGHT = "OTHER_COPYRIGHT"
1819

20+
# just removes some verbosity in workflow so user can more easily see problems
21+
IN_WORKFLOW = (os.getenv("GITHUB_ACTIONS") == "true")
22+
1923

2024
def find_existing_copyright():
25+
i_comment_start = None
2126
i_start = None
2227

2328
for i, line in enumerate(lines):
24-
if line.startswith('#') and "Copyright" in line:
25-
if "Allan" in line or "Rez" in line:
26-
i_start = i
27-
break
28-
else:
29-
return OTHER_COPYRIGHT
29+
if line.startswith('#'):
30+
if i_comment_start is None:
31+
i_comment_start = i
32+
33+
if "Copyright" in line:
34+
if "Rez" in line:
35+
i_start = i_comment_start
36+
else:
37+
return OTHER_COPYRIGHT
38+
else:
39+
i_comment_start = None
3040

3141
if i_start is None:
3242
return NO_COPYRIGHT
@@ -59,7 +69,8 @@ if __name__ == "__main__":
5969
result = find_existing_copyright()
6070

6171
if result == OTHER_COPYRIGHT:
62-
print("Other copyright, skipping %s" % opts.FILE, file=sys.stderr)
72+
if not IN_WORKFLOW:
73+
print("Other copyright, skipping %s" % opts.FILE, file=sys.stderr)
6374
sys.exit(1)
6475

6576
# strip existing copyright
@@ -90,6 +101,9 @@ if __name__ == "__main__":
90101

91102
if not opts.overwrite_file:
92103
print(new_txt)
104+
elif new_txt == txt:
105+
if not IN_WORKFLOW:
106+
print("(file contents unchanged)")
93107
else:
94108
with open(opts.FILE, 'w') as f:
95109
f.write(new_txt)

src/rez/bind/PyQt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright Contributors to the Rez Project
33

4+
45
"""
56
Binds the python PyQt module as a rez package.
67
"""

src/rez/bind/PySide.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright Contributors to the Rez Project
33

4+
45
"""
56
Binds the python PySide module as a rez package.
67
"""

src/rez/bind/_pymodule.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright Contributors to the Rez Project
33

4+
45
"""
56
Binds a python module to rez.
67

src/rez/bind/_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright Contributors to the Rez Project
33

4+
45
"""
56
Utility functions for bind modules.
67
"""

src/rez/bind/arch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright Contributors to the Rez Project
33

4+
45
"""
56
Creates the system architecture package.
67
"""

0 commit comments

Comments
 (0)