-
Notifications
You must be signed in to change notification settings - Fork 23
50 lines (44 loc) · 1.45 KB
/
license_check.yml
File metadata and controls
50 lines (44 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: License Check
on:
workflow_call: {}
workflow_dispatch: {}
jobs:
license-check:
name: License Check
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check License Headers
shell: bash
run: |
set -euo pipefail
search_dirs=()
for dir in src include bridge cpp-example-collection; do
if [[ -d "$dir" ]]; then
search_dirs+=("$dir")
fi
done
if [[ ${#search_dirs[@]} -eq 0 ]]; then
echo "No source directories found to validate."
exit 1
fi
mapfile -t files < <(find "${search_dirs[@]}" -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) | LC_ALL=C sort)
if [[ ${#files[@]} -eq 0 ]]; then
echo "No source files found to validate."
exit 1
fi
failed=0
for file in "${files[@]}"; do
if ! grep -Eq 'Copyright [0-9]{4}(-[0-9]{4})? LiveKit(, Inc\.)?$' "$file"; then
echo "Missing or unexpected copyright header in $file"
failed=1
fi
if ! grep -Fq 'Licensed under the Apache License, Version 2.0' "$file"; then
echo "Missing Apache 2.0 header in $file"
failed=1
fi
done
exit "$failed"