1
0
mirror of https://github.com/arduino/library-registry.git synced 2025-07-29 14:01:15 +03:00

Simplify license check CI system

Now that the parser tool is moved out of the repository, it makes less sense to use the taskfile-based approach for the
CI infrastructure. In order to make the repository more contributor-friendly, the license checking system is now
confined to a single workflow file.
This commit is contained in:
per1234
2021-03-24 09:31:32 -07:00
parent d38ccc82a0
commit 3a5826a784
2 changed files with 32 additions and 43 deletions

View File

@ -1,22 +1,28 @@
name: Check license name: Check license
env:
EXPECTED_LICENSE_FILENAME: LICENSE.txt
# SPDX identifier: https://spdx.org/licenses/
EXPECTED_LICENSE_TYPE: GPL-3.0
on: on:
push: push:
paths: paths:
- ".github/workflows/check-license.yml" - ".github/workflows/check-license.yml"
- "Taskfile.yml"
# Recognized license files. See: https://github.com/licensee/licensee/blob/master/docs/what-we-look-at.md#detecting-the-license-file # Recognized license files. See: https://github.com/licensee/licensee/blob/master/docs/what-we-look-at.md#detecting-the-license-file
- "COPYING*" - "[cC][oO][pP][yY][iI][nN][gG]*"
- "LICENCE*" - "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*"
- "LICENSE*" - "[lL][iI][cC][eE][nN][cCsS][eE]*"
- "[oO][fF][lL]*"
- "[pP][aA][tT][eE][nN][tT][sS]*"
pull_request: pull_request:
paths: paths:
- ".github/workflows/check-license.yml" - ".github/workflows/check-license.yml"
- "Taskfile.yml" - "[cC][oO][pP][yY][iI][nN][gG]*"
# Recognized license files. See: https://github.com/licensee/licensee/blob/master/docs/what-we-look-at.md#detecting-the-license-file - "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*"
- "COPYING*" - "[lL][iI][cC][eE][nN][cCsS][eE]*"
- "LICENCE*" - "[oO][fF][lL]*"
- "LICENSE*" - "[pP][aA][tT][eE][nN][tT][sS]*"
jobs: jobs:
check: check:
@ -26,12 +32,6 @@ jobs:
- name: Checkout local repository - name: Checkout local repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Install Taskfile
uses: arduino/actions/setup-taskfile@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1
with: with:
ruby-version: ruby # Install latest version ruby-version: ruby # Install latest version
@ -41,4 +41,20 @@ jobs:
# See: https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/licensing-a-repository # See: https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/licensing-a-repository
- name: Check license file - name: Check license file
run: task --silent docs:check-license run: |
# See: https://github.com/licensee/licensee
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
echo "Detected license file: $DETECTED_LICENSE_FILE"
if [ "$DETECTED_LICENSE_FILE" != "\"$EXPECTED_LICENSE_FILENAME\"" ]; then
echo "ERROR: detected license file doesn't match expected: $EXPECTED_LICENSE_FILENAME"
exit 1
fi
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
echo "Detected license type: $DETECTED_LICENSE_TYPE"
if [ "$DETECTED_LICENSE_TYPE" != "\"$EXPECTED_LICENSE_TYPE\"" ]; then
echo "ERROR: detected license type doesn't match expected $EXPECTED_LICENSE_TYPE"
exit 1
fi

View File

@ -1,27 +0,0 @@
version: "3"
tasks:
docs:check-license:
desc: Check if the license file is correctly formatted
cmds:
- |
EXPECTED_LICENSE_FILE="\"LICENSE.txt\""
EXPECTED_LICENSE_TYPE="\"GPL-3.0\"" # https://spdx.org/licenses/
# See: https://github.com/licensee/licensee
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
echo "Detected license file: $DETECTED_LICENSE_FILE"
if [ "$DETECTED_LICENSE_FILE" != "$EXPECTED_LICENSE_FILE" ]; then
echo "ERROR: detected license file doesn't match expected: $EXPECTED_LICENSE_FILE"
exit 1
fi
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
echo "Detected license type: $DETECTED_LICENSE_TYPE"
if [ "$DETECTED_LICENSE_TYPE" != "$EXPECTED_LICENSE_TYPE" ]; then
echo "ERROR: detected license type doesn't match expected $EXPECTED_LICENSE_TYPE"
exit 1
fi