From 12c0950555fca01ab8f69ef1a401e419e7568ad0 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Thu, 15 Jun 2023 08:08:45 +1000 Subject: [PATCH 1/2] Verify max one keyboard addition during CI. - Lists the added/removed keyboards in the CI run output. - Checks the before and after counts of the number of keyboards in the repository, ensuring that a maximum increase of 1 is present in the PR. --- .github/workflows/lint.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2b77e29a2838..af8ae1b664ca 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -36,6 +36,7 @@ jobs: echo '${{ steps.file_changes.outputs.all_changed_files}}' - name: Run qmk lint + if: always() shell: 'bash {0}' run: | QMK_CHANGES=$(echo -e '${{ steps.file_changes.outputs.all_changed_files}}' | sed 's/ /\n/g') @@ -72,3 +73,30 @@ jobs: exit 255 fi exit $exit_code + + - name: Verify at most one added keyboard + if: always() + shell: 'bash {0}' + run: | + git reset --hard ${{ github.head_ref }} + git clean -xfd + + # Get the keyboard list and count for the target branch + git checkout -f ${{ github.base_ref }} + QMK_KEYBOARDS_BASE=$(qmk list-keyboards) + QMK_KEYBOARDS_BASE_COUNT=$(qmk list-keyboards | wc -l) + + # Get the keyboard list and count for the PR + git checkout -f ${{ github.head_ref }} + QMK_KEYBOARDS_PR=$(qmk list-keyboards) + QMK_KEYBOARDS_PR_COUNT=$(qmk list-keyboards | wc -l) + + echo "::group::Keyboards changes in this PR" + diff -d -U 0 <(echo $left_side) <(echo $right_side) | grep -vE '^(---|\+\+\+|@@)' | sed -e 's@^-@Removed: @g' -e 's@^+@ Added: @g' + echo "::endgroup::" + + if [[ $QMK_KEYBOARDS_PR_COUNT -gt $(($QMK_KEYBOARDS_BASE_COUNT + 1)) ]]; then + echo "More than one keyboard added in this PR -- see the PR Checklist." + echo "::error::More than one keyboard added in this PR -- see the PR Checklist." + exit 1 + fi From dc08ba3115b4b64ff29aaa57520c00605d466351 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Thu, 15 Jun 2023 09:53:23 +1000 Subject: [PATCH 2/2] Fixes --- .github/workflows/lint.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index af8ae1b664ca..393a57a66ac0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -78,21 +78,23 @@ jobs: if: always() shell: 'bash {0}' run: | - git reset --hard ${{ github.head_ref }} + git reset --hard git clean -xfd # Get the keyboard list and count for the target branch git checkout -f ${{ github.base_ref }} + git pull --ff-only QMK_KEYBOARDS_BASE=$(qmk list-keyboards) QMK_KEYBOARDS_BASE_COUNT=$(qmk list-keyboards | wc -l) # Get the keyboard list and count for the PR git checkout -f ${{ github.head_ref }} + git merge --no-commit --squash ${{ github.base_ref }} QMK_KEYBOARDS_PR=$(qmk list-keyboards) QMK_KEYBOARDS_PR_COUNT=$(qmk list-keyboards | wc -l) echo "::group::Keyboards changes in this PR" - diff -d -U 0 <(echo $left_side) <(echo $right_side) | grep -vE '^(---|\+\+\+|@@)' | sed -e 's@^-@Removed: @g' -e 's@^+@ Added: @g' + diff -d -U 0 <(echo "$QMK_KEYBOARDS_BASE") <(echo "$QMK_KEYBOARDS_PR") | grep -vE '^(---|\+\+\+|@@)' | sed -e 's@^-@Removed: @g' -e 's@^+@ Added: @g' echo "::endgroup::" if [[ $QMK_KEYBOARDS_PR_COUNT -gt $(($QMK_KEYBOARDS_BASE_COUNT + 1)) ]]; then