Skip to content

Commit 735768c

Browse files
committed
Don't use Task for license check
Task provides a convenient way to run common development processes locally with a single command. But I don't think the need to check the license file is common, nor something anyone would bother running. Instead, it's something that can be added to the repository and forgotten until the day comes that someone mucks around with the license file. That person likely would not have been aware of the existence of the task.
1 parent 8209fd5 commit 735768c

File tree

2 files changed

+22
-38
lines changed

2 files changed

+22
-38
lines changed

.github/workflows/check-license.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
name: Check License
22

3+
env:
4+
EXPECTED_LICENSE_FILENAME: LICENSE.txt
5+
# SPDX identifier: https://spdx.org/licenses/
6+
EXPECTED_LICENSE_TYPE: GPL-3.0
7+
38
on:
49
push:
510
paths:
611
- ".github/workflows/check-license.ya?ml"
7-
- "Taskfile.yml"
812
# Recognized license files. See: https://github.com/licensee/licensee/blob/master/docs/what-we-look-at.md#detecting-the-license-file
913
- "COPYING*"
1014
- "LICENCE*"
1115
- "LICENSE*"
1216
pull_request:
1317
paths:
1418
- ".github/workflows/check-license.ya?ml"
15-
- "Taskfile.yml"
1619
- "COPYING*"
1720
- "LICENCE*"
1821
- "LICENSE*"
@@ -25,12 +28,6 @@ jobs:
2528
- name: Checkout local repository
2629
uses: actions/checkout@v2
2730

28-
- name: Install Taskfile
29-
uses: arduino/setup-task@v1
30-
with:
31-
repo-token: ${{ secrets.GITHUB_TOKEN }}
32-
version: 3.x
33-
3431
- uses: ruby/setup-ruby@v1
3532
with:
3633
ruby-version: ruby # Install latest version
@@ -40,4 +37,20 @@ jobs:
4037

4138
# See: https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/licensing-a-repository
4239
- name: Check license file
43-
run: task --silent docs:check-license
40+
run: |
41+
# See: https://github.com/licensee/licensee
42+
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
43+
44+
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
45+
echo "Detected license file: $DETECTED_LICENSE_FILE"
46+
if [ "$DETECTED_LICENSE_FILE" != "\"${EXPECTED_LICENSE_FILENAME}\"" ]; then
47+
echo "ERROR: detected license file doesn't match expected: $EXPECTED_LICENSE_FILENAME"
48+
exit 1
49+
fi
50+
51+
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
52+
echo "Detected license type: $DETECTED_LICENSE_TYPE"
53+
if [ "$DETECTED_LICENSE_TYPE" != "\"${EXPECTED_LICENSE_TYPE}\"" ]; then
54+
echo "ERROR: detected license type doesn't match expected $EXPECTED_LICENSE_TYPE"
55+
exit 1
56+
fi

Taskfile.yml

Lines changed: 0 additions & 29 deletions
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)