forked from taiyme/misskey
-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (105 loc) · 3.08 KB
/
check-spdx-license-id.yaml
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Check SPDX-License-Identifier
on:
push:
branches:
- stream
paths:
- .github/workflows/check-spdx-license-id.yaml
- cypress/e2e/**/*
- packages/**/*
- scripts/**/*
pull_request_target:
branches:
- stream
paths:
- cypress/e2e/**/*
- packages/**/*
- scripts/**/*
permissions:
contents: read
jobs:
pre-checkout:
name: Pre checkout
uses: ./.github/workflows/pre-checkout.yaml
check-spdx-license-id:
name: Check SPDX-License-Identifier
runs-on: ubuntu-22.04
needs:
- pre-checkout
steps:
- name: Checkout
uses: actions/[email protected]
with:
persist-credentials: false
ref: ${{ needs.pre-checkout.outputs.sha }}
fetch-depth: 1
- name: Check SPDX-License-Identifier
run: |
counter=0
search() {
local directory="$1"
if [[ ! -d "$directory" ]]; then
return 0
fi
find "$directory" -type f \
\( \
-name '*.html' -or \
-name '*.scss' -or \
-name '*.css' -or \
-name '*.vue' \
\) -or \
\( \
\( \
-name '*.ts' -or \
-name '*.js' -or \
-name '*.mjs' -or \
-name '*.cjs' \
\) -and \( \
-not -name '*.config.*' \
\) \
\)
}
check() {
local file="$1"
if ! (
grep -q 'SPDX-FileCopyrightText: ' "$file" &&
grep -q 'SPDX-License-Identifier: ' "$file"
); then
echo "::error file=${file},line=0::Missing SPDX-License-Identifier"
((counter++))
fi
}
directories=(
'cypress/e2e'
'packages/backend/migration'
'packages/backend/src'
'packages/backend/test'
'packages/backend/test-federation'
'packages/backend/test-server'
'packages/frontend/.storybook'
'packages/frontend/@types'
'packages/frontend/lib'
'packages/frontend/public'
'packages/frontend/src'
'packages/frontend/test'
'packages/frontend-embed/@types'
'packages/frontend-embed/src'
'packages/frontend-shared/@types'
'packages/frontend-shared/js'
'packages/misskey-bubble-game/src'
'packages/misskey-reversi/src'
'packages/sw/src'
'scripts'
)
for directory in "${directories[@]}"; do
for file in $(search "$directory"); do
check "$file"
done
done
if [ "$counter" -gt 0 ]; then
echo "::error::SPDX-License-Identifier is missing in ${counter} file(s)."
exit 1
else
echo '::notice::SPDX-License-Identifier is certainly described in all target file(s)!'
exit 0
fi