File tree Expand file tree Collapse file tree 5 files changed +40
-0
lines changed
Expand file tree Collapse file tree 5 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 7272 working-directory : gateway-contracts
7373 run : make check-mocks
7474
75+ - name : Check SPDX license headers
76+ working-directory : gateway-contracts
77+ run : make check-spdx-headers
78+
7579 - name : Check licenses compliance
7680 working-directory : gateway-contracts
7781 run : make check-licenses
Original file line number Diff line number Diff line change 6868 - name : Check contract selectors are up-to-date
6969 working-directory : host-contracts
7070 run : make check-selectors
71+
72+ - name : Check SPDX license headers
73+ working-directory : host-contracts
74+ run : make check-spdx-headers
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # Check that all Solidity contracts use the expected SPDX license identifier.
3+
4+ set -euo pipefail
5+
6+ EXPECTED_LICENSE=" BSD-3-Clause-Clear"
7+ CONTRACTS_DIR=" ${1:- contracts} "
8+ EXIT_CODE=0
9+
10+ while IFS= read -r -d ' ' file; do
11+ first_line=$( head -n 1 " $file " )
12+ if [[ " $first_line " != " // SPDX-License-Identifier: ${EXPECTED_LICENSE} " ]]; then
13+ echo " ERROR: Wrong or missing license in $file "
14+ echo " Found: $first_line "
15+ echo " Expected: // SPDX-License-Identifier: ${EXPECTED_LICENSE} "
16+ EXIT_CODE=1
17+ fi
18+ done < <( find " $CONTRACTS_DIR " -name ' *.sol' -print0)
19+
20+ if [ " $EXIT_CODE " -eq 0 ]; then
21+ echo " All Solidity files use SPDX-License-Identifier: ${EXPECTED_LICENSE} "
22+ fi
23+
24+ exit " $EXIT_CODE "
Original file line number Diff line number Diff line change @@ -106,6 +106,10 @@ deploy-setup-contracts:
106106ensure-addresses :
107107 ENV_PATH=$(ENV_PATH ) npx ts-node scripts/ensure_proxy_addresses.ts
108108
109+ # Make sure all Solidity contracts use the expected SPDX license identifier (BSD-3-Clause-Clear)
110+ check-spdx-headers :
111+ bash ../ci/check_spdx_licenses.sh contracts
112+
109113# Make sure we only use allowed licenses for dependencies
110114# Full list of SPDX identifiers can be found here: https://spdx.org/licenses/
111115# The following packages are exceptionally excluded from the check:
Original file line number Diff line number Diff line change @@ -60,5 +60,9 @@ lint-bindings:
6060# Update auto-generated files for conformance checks
6161update-conformance : update-bindings update-selectors
6262
63+ # Make sure all Solidity contracts use the expected SPDX license identifier (BSD-3-Clause-Clear)
64+ check-spdx-headers :
65+ bash ../ci/check_spdx_licenses.sh contracts
66+
6367# Conform to pre-commit checks
6468conformance : prettier update-conformance
You can’t perform that action at this time.
0 commit comments