2020-06-20 14:19:56 -07:00
|
|
|
name: PR Lint keyboards
|
|
|
|
|
lotus: Try to fix gh actions
Current error:
```
1s
Run trilom/file-changes-action@v1.2.4
/usr/bin/docker exec e94fda2c6b79f2a3fda6ad3973fb2452092507da89442d782b39afc8b41f24a4 sh -c "cat /etc/*release | grep ^ID"
Warning: Received event from pull_request, but also received a before(50eff5af7dc04b0a4875f13f14be50f1e279774c) or after(8bd0db74a78f63e77553e5800add3fad45783a1e) value.
I am assuming you want to use a Push event but forgot something, so I'm giving you a message.
Error: undefined
Exception: {
"error": "403/Unknown Error:HttpError",
"from": "undefined/Error",
"message": "There was an error getting change files for repo:qmk_firmware owner:FrameworkComputer pr:1",
"payload": "Resource not accessible by integration"
}
(node:128) UnhandledPromiseRejectionWarning: Error: {"error":"403/Unknown Error:HttpError","from":"undefined/Error","message":"There was an error getting change files for repo:qmk_firmware owner:FrameworkComputer pr:1","payload":"Resource not accessible by integration"}
at run (/__w/_actions/trilom/file-changes-action/v1.2.4/dist/index.js:1:19989)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:128) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:128) [DEP0018] DeprecationWarning: Unhandled promise rejections
are deprecated. In the future, promise rejections that are not handled
will terminate the Node.js process with a non-zero exit code.
```
Signed-off-by: Daniel Schaefer <dhs@frame.work>
2023-02-01 23:04:56 -08:00
|
|
|
#permissions:
|
|
|
|
# contents: read
|
2022-12-22 15:41:16 -08:00
|
|
|
|
2020-06-20 14:19:56 -07:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
paths:
|
|
|
|
- 'keyboards/**'
|
|
|
|
|
|
|
|
jobs:
|
2020-11-07 09:56:08 -08:00
|
|
|
lint:
|
2020-06-20 14:19:56 -07:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
2023-03-16 18:32:09 -07:00
|
|
|
container: ghcr.io/qmk/qmk_cli
|
2020-06-20 14:19:56 -07:00
|
|
|
|
|
|
|
steps:
|
2023-02-28 12:27:11 -08:00
|
|
|
- name: Disable safe.directory check
|
|
|
|
run : git config --global --add safe.directory '*'
|
|
|
|
|
2022-06-28 23:44:54 -07:00
|
|
|
- uses: actions/checkout@v3
|
2020-06-20 14:19:56 -07:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2022-06-09 13:02:16 -07:00
|
|
|
- name: Install dependencies
|
|
|
|
run: pip3 install -r requirements-dev.txt
|
|
|
|
|
2022-11-28 12:04:04 -08:00
|
|
|
- name: Get changed files
|
2020-08-17 02:12:45 -07:00
|
|
|
id: file_changes
|
2023-06-23 13:53:24 -07:00
|
|
|
uses: tj-actions/changed-files@v37
|
2020-08-17 02:12:45 -07:00
|
|
|
|
2020-06-20 14:19:56 -07:00
|
|
|
- name: Print info
|
|
|
|
run: |
|
|
|
|
git rev-parse --short HEAD
|
|
|
|
echo ${{ github.event.pull_request.base.sha }}
|
2022-11-28 12:04:04 -08:00
|
|
|
echo '${{ steps.file_changes.outputs.all_changed_files}}'
|
2020-06-20 14:19:56 -07:00
|
|
|
|
2020-11-07 09:56:08 -08:00
|
|
|
- name: Run qmk lint
|
2023-06-23 16:22:14 -07:00
|
|
|
if: always()
|
2020-06-20 14:19:56 -07:00
|
|
|
shell: 'bash {0}'
|
|
|
|
run: |
|
2022-11-28 12:04:04 -08:00
|
|
|
QMK_CHANGES=$(echo -e '${{ steps.file_changes.outputs.all_changed_files}}' | sed 's/ /\n/g')
|
2020-06-20 14:19:56 -07:00
|
|
|
QMK_KEYBOARDS=$(qmk list-keyboards)
|
|
|
|
|
|
|
|
exit_code=0
|
2023-01-21 19:15:10 -08:00
|
|
|
|
2020-06-20 14:19:56 -07:00
|
|
|
for KB in $QMK_KEYBOARDS; do
|
|
|
|
KEYBOARD_CHANGES=$(echo "$QMK_CHANGES" | grep -E '^(keyboards/'${KB}'/)')
|
|
|
|
if [[ -z "$KEYBOARD_CHANGES" ]]; then
|
|
|
|
# skip as no changes for this keyboard
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
KEYMAP_ONLY=$(echo "$KEYBOARD_CHANGES" | grep -cv /keymaps/)
|
|
|
|
if [[ $KEYMAP_ONLY -gt 0 ]]; then
|
|
|
|
echo "linting ${KB}"
|
|
|
|
|
2020-11-07 11:36:47 -08:00
|
|
|
qmk lint --keyboard ${KB} && qmk info -l --keyboard ${KB}
|
2020-11-10 07:21:59 -08:00
|
|
|
exit_code=$(($exit_code + $?))
|
2020-06-20 14:19:56 -07:00
|
|
|
fi
|
|
|
|
done
|
2023-01-21 19:15:10 -08:00
|
|
|
|
|
|
|
qmk format-text ${{ steps.file_changes.outputs.all_changed_files}} || true
|
|
|
|
for file in ${{ steps.file_changes.outputs.all_changed_files}}; do
|
|
|
|
if ! git diff --quiet $file; then
|
|
|
|
echo "File '${file}' Requires Formatting"
|
|
|
|
echo "::error file=${file}::Requires Formatting"
|
|
|
|
exit_code=$(($exit_code + 1))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2020-11-10 07:21:59 -08:00
|
|
|
if [[ $exit_code -gt 255 ]]; then
|
|
|
|
exit 255
|
|
|
|
fi
|
2020-06-20 14:19:56 -07:00
|
|
|
exit $exit_code
|
2023-06-23 16:22:14 -07:00
|
|
|
|
|
|
|
- name: Verify at most one added keyboard
|
|
|
|
if: always()
|
|
|
|
shell: 'bash {0}'
|
|
|
|
run: |
|
|
|
|
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 "$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
|
|
|
|
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
|