@@ -281,6 +281,14 @@ runs:
281
281
echo "Running yarn lint"
282
282
yarn run lint
283
283
fi
284
+ # Validate licenses of all dependencies are permissive
285
+ echo "Checking licenses of all dependencies"
286
+ npm install -g license-checker
287
+ # A list of allowed software licesnses that are permissive - see https://spdx.org/licenses/ for a list of SPDX identifiers
288
+ # IMPORTANT! If this is updated also update the same variable in the "Run PHP linting" step
289
+ SPDX_ALLOWED_DELIMITED="MIT;MIT-0;ISC;0BSD;BSD-2-Clause;BSD-3-Clause;Apache-2.0;Python-2.0;CC0-1.0;CC-BY-3.0;CC-BY-4.0;Public Domain;Unlicense"
290
+ license-checker --production --unknown --out /dev/null --onlyAllow "$SPDX_ALLOWED_DELIMITED"
291
+ # If we get to this point, everything was successful
284
292
echo "Passed"
285
293
286
294
- name : " Run PHP linting"
@@ -302,6 +310,32 @@ runs:
302
310
echo "Running PHPStan"
303
311
vendor/bin/phpstan analyse
304
312
fi
313
+ # Validate licenses of all dependencies are permissive
314
+ echo "Checking licenses of all dependencies"
315
+ composer global require madewithlove/license-checker
316
+ COMPOSER_GLOBAL_HOME=$(composer -q -n config --global home)
317
+ # A list of allowed software licesnses that are permissive - see https://spdx.org/licenses/ for a list of SPDX identifiers
318
+ # IMPORTANT! If this is updated also update the same variable in the "Run JS tests" step
319
+ SPDX_ALLOWED_DELIMITED="MIT;MIT-0;ISC;0BSD;BSD-2-Clause;BSD-3-Clause;Apache-2.0;Python-2.0;CC0-1.0;CC-BY-3.0;CC-BY-4.0;Public Domain;Unlicense"
320
+ # translate " " to "__" (and back again later) in case any dependencies have a space in them
321
+ # otherwise the bash for loop will split on the space
322
+ SPDX_ALLOWED_LIST=$(echo $SPDX_ALLOWED_DELIMITED | tr " " "__" | tr ";" "\n")
323
+ SPDX_USED_LIST=$($COMPOSER_GLOBAL_HOME/vendor/bin/license-checker --no-dev used)
324
+ for SPDX_USED in $SPDX_USED_LIST; do
325
+ IS_ALLOWED=0
326
+ for SPDX_ALLOWED in $SPDX_ALLOWED_LIST; do
327
+ SPDX_ALLOWED=$(echo $SPDX_ALLOWED | tr "__" " ")
328
+ if [[ $SPDX_USED == $SPDX_ALLOWED ]]; then
329
+ IS_ALLOWED=1
330
+ break
331
+ fi
332
+ done
333
+ if [[ $IS_ALLOWED == 0 ]]; then
334
+ echo "License $SPDX_USED found in composer dependecies is not allowed"
335
+ exit 1
336
+ fi
337
+ done
338
+ # If we get to this point, everything was successful
305
339
echo "Passed"
306
340
307
341
- name : " Run PHP coverage"
0 commit comments