Skip to content

Commit f9c2f0e

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 9f6c09f commit f9c2f0e

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
@@ -228,35 +228,6 @@ tasks:
228228
- task: markdown:fix
229229
- task: markdown:check-links
230230

231-
docs:lint:
232-
desc: Lint documentation files
233-
cmds:
234-
- task: docs:check-license
235-
236-
docs:check-license:
237-
desc: Check if the license file is correctly formatted
238-
cmds:
239-
- |
240-
EXPECTED_LICENSE_FILE="\"LICENSE.txt\""
241-
EXPECTED_LICENSE_TYPE="\"GPL-3.0\"" # https://spdx.org/licenses/
242-
243-
# See: https://github.com/licensee/licensee
244-
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
245-
246-
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
247-
echo "Detected license file: $DETECTED_LICENSE_FILE"
248-
if [ "$DETECTED_LICENSE_FILE" != "$EXPECTED_LICENSE_FILE" ]; then
249-
echo "ERROR: detected license file doesn't match expected: $EXPECTED_LICENSE_FILE"
250-
exit 1
251-
fi
252-
253-
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
254-
echo "Detected license type: $DETECTED_LICENSE_TYPE"
255-
if [ "$DETECTED_LICENSE_TYPE" != "$EXPECTED_LICENSE_TYPE" ]; then
256-
echo "ERROR: detected license type doesn't match expected $EXPECTED_LICENSE_TYPE"
257-
exit 1
258-
fi
259-
260231
docs:check-formatting:
261232
desc: Check formatting of documentation files
262233
cmds:

0 commit comments

Comments
 (0)