From 29a0562b405958a23137414cb776ceb60ab0afbb Mon Sep 17 00:00:00 2001 From: Nathan Coleman Date: Wed, 16 Aug 2023 12:58:07 -0400 Subject: [PATCH 1/3] Add license-checker action that fails when any backported file contains BUSL header --- .github/scripts/license_checker.sh | 16 ++++++++++++++++ .github/workflows/license-checker.yml | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 .github/scripts/license_checker.sh create mode 100644 .github/workflows/license-checker.yml diff --git a/.github/scripts/license_checker.sh b/.github/scripts/license_checker.sh new file mode 100755 index 000000000000..909e8c6a4772 --- /dev/null +++ b/.github/scripts/license_checker.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: BUSL-1.1 + + +busl_files=$(grep -r 'SPDX-License-Identifier: BUSL' --exclude=./.github/scripts/license_checker.sh .) + +# If we do not find a file in .changelog/, we fail the check +if [ -n "$busl_files" ]; then + echo "Found BUSL occurrences in the PR branch!" + echo -e $busl_files + exit 1 +else + echo "Did not find any occurrences of BUSL in the PR branch" + exit 0 +fi diff --git a/.github/workflows/license-checker.yml b/.github/workflows/license-checker.yml new file mode 100644 index 000000000000..13a2135804e3 --- /dev/null +++ b/.github/workflows/license-checker.yml @@ -0,0 +1,27 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +# This workflow checks that the BUSL license is not mentioned anywhere in +# a PR targeting a release that should maintain the MPL-2.0 license. +name: License Checker + +on: + pull_request: + types: [opened] + branches: + - release/1.14.* + - release/1.15.* + - release/1.16.* + +jobs: + # checks that the diff does not contain any reference to + # the BUSL license and thus retains the MPL-2.0 license + license-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 # by default the checkout action doesn't checkout all branches + - name: Check for BUSL text in diff + run: ./.github/scripts/license_checker.sh From 8e083db58900acdffaf929f72b49fde73f1f7d4c Mon Sep 17 00:00:00 2001 From: Nathan Coleman Date: Wed, 16 Aug 2023 13:52:21 -0400 Subject: [PATCH 2/3] Quote echoed variable to retain line breaks --- .github/scripts/license_checker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/license_checker.sh b/.github/scripts/license_checker.sh index 909e8c6a4772..b5e481e61533 100755 --- a/.github/scripts/license_checker.sh +++ b/.github/scripts/license_checker.sh @@ -8,7 +8,7 @@ busl_files=$(grep -r 'SPDX-License-Identifier: BUSL' --exclude=./.github/scripts # If we do not find a file in .changelog/, we fail the check if [ -n "$busl_files" ]; then echo "Found BUSL occurrences in the PR branch!" - echo -e $busl_files + echo -n "$busl_files" exit 1 else echo "Did not find any occurrences of BUSL in the PR branch" From afc0ca98662a28393ff1fd45d7c2fd19c8a7e799 Mon Sep 17 00:00:00 2001 From: Nathan Coleman Date: Wed, 16 Aug 2023 13:53:31 -0400 Subject: [PATCH 3/3] Add ticket to reference for more details --- .github/scripts/license_checker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/license_checker.sh b/.github/scripts/license_checker.sh index b5e481e61533..fb1ac4194d72 100755 --- a/.github/scripts/license_checker.sh +++ b/.github/scripts/license_checker.sh @@ -7,7 +7,7 @@ busl_files=$(grep -r 'SPDX-License-Identifier: BUSL' --exclude=./.github/scripts # If we do not find a file in .changelog/, we fail the check if [ -n "$busl_files" ]; then - echo "Found BUSL occurrences in the PR branch!" + echo "Found BUSL occurrences in the PR branch! (See NET-5258 for details)" echo -n "$busl_files" exit 1 else