2020-06-20 23:19:56 +02:00
|
|
|
name: PR Lint keyboards
|
|
|
|
|
2022-12-23 00:41:16 +01:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2020-06-20 23:19:56 +02:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
paths:
|
|
|
|
- 'keyboards/**'
|
|
|
|
|
|
|
|
jobs:
|
2020-11-07 18:56:08 +01:00
|
|
|
lint:
|
2020-06-20 23:19:56 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
2023-03-17 02:32:09 +01:00
|
|
|
container: ghcr.io/qmk/qmk_cli
|
2020-06-20 23:19:56 +02:00
|
|
|
|
|
|
|
steps:
|
2023-02-28 21:27:11 +01:00
|
|
|
- name: Disable safe.directory check
|
|
|
|
run : git config --global --add safe.directory '*'
|
|
|
|
|
2023-09-05 19:50:04 +02:00
|
|
|
- uses: actions/checkout@v4
|
2020-06-20 23:19:56 +02:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2022-06-09 22:02:16 +02:00
|
|
|
- name: Install dependencies
|
|
|
|
run: pip3 install -r requirements-dev.txt
|
|
|
|
|
2022-11-28 21:04:04 +01:00
|
|
|
- name: Get changed files
|
2020-08-17 11:12:45 +02:00
|
|
|
id: file_changes
|
2024-03-27 21:55:32 +01:00
|
|
|
uses: tj-actions/changed-files@v44
|
2024-03-05 17:59:09 +01:00
|
|
|
with:
|
|
|
|
use_rest_api: true
|
2020-08-17 11:12:45 +02:00
|
|
|
|
2020-06-20 23:19:56 +02:00
|
|
|
- name: Print info
|
|
|
|
run: |
|
|
|
|
git rev-parse --short HEAD
|
|
|
|
echo ${{ github.event.pull_request.base.sha }}
|
2022-11-28 21:04:04 +01:00
|
|
|
echo '${{ steps.file_changes.outputs.all_changed_files}}'
|
2020-06-20 23:19:56 +02:00
|
|
|
|
2020-11-07 18:56:08 +01:00
|
|
|
- name: Run qmk lint
|
2023-06-24 01:22:14 +02:00
|
|
|
if: always()
|
2020-06-20 23:19:56 +02:00
|
|
|
shell: 'bash {0}'
|
|
|
|
run: |
|
2022-11-28 21:04:04 +01:00
|
|
|
QMK_CHANGES=$(echo -e '${{ steps.file_changes.outputs.all_changed_files}}' | sed 's/ /\n/g')
|
2020-06-20 23:19:56 +02:00
|
|
|
QMK_KEYBOARDS=$(qmk list-keyboards)
|
|
|
|
|
|
|
|
exit_code=0
|
2023-01-22 04:15:10 +01:00
|
|
|
|
2020-06-20 23:19:56 +02: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 20:36:47 +01:00
|
|
|
qmk lint --keyboard ${KB} && qmk info -l --keyboard ${KB}
|
2020-11-10 16:21:59 +01:00
|
|
|
exit_code=$(($exit_code + $?))
|
2020-06-20 23:19:56 +02:00
|
|
|
fi
|
|
|
|
done
|
2023-01-22 04:15:10 +01:00
|
|
|
|
|
|
|
qmk format-text ${{ steps.file_changes.outputs.all_changed_files}} || true
|
|
|
|
for file in ${{ steps.file_changes.outputs.all_changed_files}}; do
|
2024-03-05 17:59:09 +01:00
|
|
|
if [[ -f $file ]]; then
|
|
|
|
if ! git diff --quiet $file; then
|
|
|
|
echo "File '${file}' Requires Formatting"
|
|
|
|
echo "::error file=${file}::Requires Formatting"
|
|
|
|
exit_code=$(($exit_code + 1))
|
|
|
|
fi
|
2023-01-22 04:15:10 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2020-11-10 16:21:59 +01:00
|
|
|
if [[ $exit_code -gt 255 ]]; then
|
|
|
|
exit 255
|
|
|
|
fi
|
2020-06-20 23:19:56 +02:00
|
|
|
exit $exit_code
|
2023-06-24 01:22:14 +02:00
|
|
|
|
2023-10-06 01:34:23 +02:00
|
|
|
- name: Verify keyboard aliases
|
2023-06-24 01:22:14 +02:00
|
|
|
if: always()
|
|
|
|
shell: 'bash {0}'
|
|
|
|
run: |
|
|
|
|
git reset --hard
|
|
|
|
git clean -xfd
|
2023-10-06 01:34:23 +02:00
|
|
|
qmk ci-validate-aliases
|