diff --git a/.ecrc b/.ecrc index a0ef7686..26e2be60 100644 --- a/.ecrc +++ b/.ecrc @@ -1,5 +1,6 @@ { "Exclude": [ + "^\\.licenses/", "LICENSE.txt", "poetry.lock" ] diff --git a/.github/workflows/check-go-dependencies-task.yml b/.github/workflows/check-go-dependencies-task.yml new file mode 100644 index 00000000..e412486c --- /dev/null +++ b/.github/workflows/check-go-dependencies-task.yml @@ -0,0 +1,109 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md +name: Check Go Dependencies + +env: + # See: https://github.com/actions/setup-go/tree/v2#readme + GO_VERSION: "1.16" + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/check-go-dependencies-task.ya?ml" + - ".licenses/**" + - ".licensed.json" + - ".licensed.ya?ml" + - "Taskfile.ya?ml" + - "**/.gitmodules" + - "**/go.mod" + - "**/go.sum" + pull_request: + paths: + - ".github/workflows/check-go-dependencies-task.ya?ml" + - ".licenses/**" + - ".licensed.json" + - ".licensed.ya?ml" + - "Taskfile.ya?ml" + - "**/.gitmodules" + - "**/go.mod" + - "**/go.sum" + workflow_dispatch: + repository_dispatch: + +jobs: + check-cache: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install licensed + uses: jonabc/setup-licensed@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Install Task + uses: arduino/setup-task@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + + - name: Update dependencies license metadata cache + run: task --silent general:cache-dep-licenses + + - name: Check for outdated cache + id: diff + run: | + git add --intent-to-add . + if ! git diff --color --exit-code; then + echo + echo "::error::Dependency license metadata out of sync. See: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md#metadata-cache" + exit 1 + fi + + # Some might find it convenient to have CI generate the cache rather than setting up for it locally + - name: Upload cache to workflow artifact + if: failure() && steps.diff.outcome == 'failure' + uses: actions/upload-artifact@v2 + with: + if-no-files-found: error + name: dep-licenses-cache + path: .licenses/ + + check-deps: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install licensed + uses: jonabc/setup-licensed@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Install Task + uses: arduino/setup-task@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + + - name: Check for dependencies with unapproved licenses + run: task --silent general:check-dep-licenses diff --git a/.gitignore b/.gitignore index cfe84620..dfd4f5c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__/ /.github/workflows/assets/validate-registry/validate-registry +!/.github/workflows/assets/validate-registry/validate-registry/ /.github/workflows/assets/validate-registry/validate-registry.exe diff --git a/.licensed.yml b/.licensed.yml new file mode 100644 index 00000000..3ea8e0c5 --- /dev/null +++ b/.licensed.yml @@ -0,0 +1,86 @@ +# See: https://github.com/github/licensed/blob/master/docs/configuration.md +sources: + go: true + +apps: + - source_path: .github/workflows/assets/validate-registry/ + +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies/AGPL-3.0/.licensed.yml +allowed: + # The following are based on: https://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses + - gpl-1.0-or-later + - gpl-1.0+ # Deprecated ID for `gpl-1.0-or-later` + - gpl-2.0-or-later + - gpl-2.0+ # Deprecated ID for `gpl-2.0-or-later` + - gpl-3.0-only + - gpl-3.0 # Deprecated ID for `gpl-3.0-only` + - gpl-3.0-or-later + - gpl-3.0+ # Deprecated ID for `gpl-3.0-or-later` + - lgpl-2.0-or-later + - lgpl-2.0+ # Deprecated ID for `lgpl-2.0-or-later` + - lgpl-2.1-only + - lgpl-2.1 # Deprecated ID for `lgpl-2.1-only` + - lgpl-2.1-or-later + - lgpl-2.1+ # Deprecated ID for `lgpl-2.1-or-later` + - lgpl-3.0-only + - lgpl-3.0 # Deprecated ID for `lgpl-3.0-only` + - lgpl-3.0-or-later + - lgpl-3.0+ # Deprecated ID for `lgpl-3.0-or-later` + - agpl-1.0-or-later + - agpl-3.0-only + - agpl-3.0 # Deprecated ID for `agpl-3.0-only` + - agpl-3.0-or-later + - fsfap + - apache-2.0 + - artistic-2.0 + - clartistic + - sleepycat + - bsl-1.0 + - bsd-3-clause + - cecill-2.0 + - bsd-3-clause-clear + # "Cryptix General License" - no SPDX ID (https://github.com/spdx/license-list-XML/issues/456) + - ecos-2.0 + - ecl-2.0 + - efl-2.0 + - eudatagrid + - mit + - bsd-2-clause # Subsumed by `bsd-2-clause-views` + - bsd-2-clause-netbsd # Deprecated ID for `bsd-2-clause` + - bsd-2-clause-views # This is the version linked from https://www.gnu.org/licenses/license-list.html#FreeBSD + - bsd-2-clause-freebsd # Deprecated ID for `bsd-2-clause-views` + - ftl + - hpnd + - imatix + - imlib2 + - ijg + # "Informal license" - this is a general class of license + - intel + - isc + - mpl-2.0 + - ncsa + # "License of Netscape JavaScript" - no SPDX ID + - oldap-2.7 + # "License of Perl 5 and below" - possibly `Artistic-1.0-Perl` ? + - cc0-1.0 + - cc-pddc + - psf-2.0 + - ruby + - sgi-b-2.0 + - smlnj + - standardml-nj # Deprecated ID for `smlnj` + - unicode-dfs-2015 + - upl-1.0 + - unlicense + - vim + - w3c + - wtfpl + - lgpl-2.0-or-later with wxwindows-exception-3.1 + - wxwindows # Deprecated ID for `lgpl-2.0-or-later with wxwindows-exception-3.1` + - x11 + - xfree86-1.1 + - zlib + - zpl-2.0 + - zpl-2.1 + # The following are based on individual license text + - eupl-1.2 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..b32a2113 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +/.licenses/ diff --git a/README.md b/README.md index 42c6a9b3..8e09fc52 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ [![Check Workflows status](https://github.com/arduino/library-registry/actions/workflows/check-workflows-task.yml/badge.svg)](https://github.com/arduino/library-registry/actions/workflows/check-workflows-task.yml) [![Check YAML status](https://github.com/arduino/library-registry/actions/workflows/check-yaml-task.yml/badge.svg)](https://github.com/arduino/library-registry/actions/workflows/check-yaml-task.yml) [![Check License status](https://github.com/arduino/library-registry/actions/workflows/check-license.yml/badge.svg)](https://github.com/arduino/library-registry/actions/workflows/check-license.yml) +[![Check Go Dependencies status](https://github.com/arduino/library-registry/actions/workflows/check-go-dependencies-task.yml/badge.svg)](https://github.com/arduino/library-registry/actions/workflows/check-go-dependencies-task.yml) This branch contains the generated source file for the Arduino Library Manager index. If you want to add a library to the Arduino Library Manager index, please follow these instructions: diff --git a/Taskfile.yml b/Taskfile.yml index 9ad5a540..40db2797 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -35,6 +35,30 @@ tasks: -s "{{.WORKFLOW_SCHEMA_PATH}}" \ -d "{{.WORKFLOWS_DATA_PATH}}" + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml + general:cache-dep-licenses: + desc: Cache dependency license metadata + cmds: + - | + if ! which licensed &>/dev/null; then + if [[ "{{OS}}" == "windows" ]]; then + echo "Licensed does not have Windows support." + echo "Please use Linux/macOS or download the dependencies cache from the GitHub Actions workflow artifact." + else + echo "licensed not found or not in PATH. Please install: https://github.com/github/licensed#as-an-executable" + fi + exit 1 + fi + - licensed cache + + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml + general:check-dep-licenses: + desc: Check for unapproved dependency licenses + deps: + - task: general:cache-dep-licenses + cmds: + - licensed status + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-general-formatting-task/Taskfile.yml general:check-formatting: desc: Check basic formatting style of all files