Skip to content

Commit 88e0a87

Browse files
authored
Merge pull request #220 from per1234/check-license
Sync license check CI workflow with template
2 parents 89a7325 + 2ba6844 commit 88e0a87

File tree

3 files changed

+67
-72
lines changed

3 files changed

+67
-72
lines changed

Diff for: .github/workflows/check-license.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-license.md
2+
name: Check License
3+
4+
env:
5+
EXPECTED_LICENSE_FILENAME: LICENSE.txt
6+
# SPDX identifier: https://spdx.org/licenses/
7+
EXPECTED_LICENSE_TYPE: GPL-3.0
8+
9+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
10+
on:
11+
push:
12+
paths:
13+
- ".github/workflows/check-license.ya?ml"
14+
# See: https://github.com/licensee/licensee/blob/master/docs/what-we-look-at.md#detecting-the-license-file
15+
- "[cC][oO][pP][yY][iI][nN][gG]*"
16+
- "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*"
17+
- "[lL][iI][cC][eE][nN][cCsS][eE]*"
18+
- "[oO][fF][lL]*"
19+
- "[pP][aA][tT][eE][nN][tT][sS]*"
20+
pull_request:
21+
paths:
22+
- ".github/workflows/check-license.ya?ml"
23+
- "[cC][oO][pP][yY][iI][nN][gG]*"
24+
- "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*"
25+
- "[lL][iI][cC][eE][nN][cCsS][eE]*"
26+
- "[oO][fF][lL]*"
27+
- "[pP][aA][tT][eE][nN][tT][sS]*"
28+
workflow_dispatch:
29+
repository_dispatch:
30+
31+
jobs:
32+
check-license:
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v2
38+
39+
- name: Install Ruby
40+
uses: ruby/setup-ruby@v1
41+
with:
42+
ruby-version: ruby # Install latest version
43+
44+
- name: Install licensee
45+
run: gem install licensee
46+
47+
- name: Check license file
48+
run: |
49+
EXIT_STATUS=0
50+
# See: https://github.com/licensee/licensee
51+
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
52+
53+
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
54+
echo "Detected license file: $DETECTED_LICENSE_FILE"
55+
if [ "$DETECTED_LICENSE_FILE" != "\"${EXPECTED_LICENSE_FILENAME}\"" ]; then
56+
echo "::error file=${DETECTED_LICENSE_FILE}::detected license file $DETECTED_LICENSE_FILE doesn't match expected: $EXPECTED_LICENSE_FILENAME"
57+
EXIT_STATUS=1
58+
fi
59+
60+
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
61+
echo "Detected license type: $DETECTED_LICENSE_TYPE"
62+
if [ "$DETECTED_LICENSE_TYPE" != "\"${EXPECTED_LICENSE_TYPE}\"" ]; then
63+
echo "::error file=${DETECTED_LICENSE_FILE}::detected license type $DETECTED_LICENSE_TYPE doesn't match expected \"${EXPECTED_LICENSE_TYPE}\""
64+
EXIT_STATUS=1
65+
fi
66+
67+
exit $EXIT_STATUS

Diff for: .github/workflows/lint-documentation.yml

-43
This file was deleted.

Diff for: Taskfile.yml

-29
Original file line numberDiff line numberDiff line change
@@ -224,35 +224,6 @@ tasks:
224224
- task: markdown:fix
225225
- task: markdown:check-links
226226

227-
docs:lint:
228-
desc: Lint documentation files
229-
cmds:
230-
- task: docs:check-license
231-
232-
docs:check-license:
233-
desc: Check if the license file is correctly formatted
234-
cmds:
235-
- |
236-
EXPECTED_LICENSE_FILE="\"LICENSE.txt\""
237-
EXPECTED_LICENSE_TYPE="\"GPL-3.0\"" # https://spdx.org/licenses/
238-
239-
# See: https://github.com/licensee/licensee
240-
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
241-
242-
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
243-
echo "Detected license file: $DETECTED_LICENSE_FILE"
244-
if [ "$DETECTED_LICENSE_FILE" != "$EXPECTED_LICENSE_FILE" ]; then
245-
echo "ERROR: detected license file doesn't match expected: $EXPECTED_LICENSE_FILE"
246-
exit 1
247-
fi
248-
249-
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
250-
echo "Detected license type: $DETECTED_LICENSE_TYPE"
251-
if [ "$DETECTED_LICENSE_TYPE" != "$EXPECTED_LICENSE_TYPE" ]; then
252-
echo "ERROR: detected license type doesn't match expected $EXPECTED_LICENSE_TYPE"
253-
exit 1
254-
fi
255-
256227
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-shell-task/Taskfile.yml
257228
shell:check:
258229
desc: Check for problems with shell scripts

0 commit comments

Comments
 (0)