2021-05-11 02:18:44 +08:00
|
|
|
name: PR Lint Format
|
2020-12-11 01:01:51 +08:00
|
|
|
|
2022-12-23 07:41:16 +08:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2020-12-11 01:01:51 +08:00
|
|
|
on:
|
2021-05-11 02:18:44 +08:00
|
|
|
pull_request:
|
|
|
|
paths:
|
|
|
|
- 'drivers/**'
|
|
|
|
- 'lib/arm_atsam/**'
|
|
|
|
- 'lib/lib8tion/**'
|
|
|
|
- 'lib/python/**'
|
|
|
|
- 'platforms/**'
|
|
|
|
- 'quantum/**'
|
|
|
|
- 'tests/**'
|
|
|
|
- 'tmk_core/**'
|
2020-12-11 01:01:51 +08:00
|
|
|
|
|
|
|
jobs:
|
2021-05-11 02:18:44 +08:00
|
|
|
lint:
|
2020-12-11 01:01:51 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
2023-03-17 09:32:09 +08:00
|
|
|
container: ghcr.io/qmk/qmk_cli
|
2020-12-11 01:01:51 +08:00
|
|
|
|
|
|
|
steps:
|
2023-03-01 04:27:11 +08:00
|
|
|
- name: Disable safe.directory check
|
|
|
|
run : git config --global --add safe.directory '*'
|
|
|
|
|
2023-09-06 01:50:04 +08:00
|
|
|
- uses: actions/checkout@v4
|
2020-12-17 07:00:02 +08:00
|
|
|
with:
|
2021-05-11 02:18:44 +08:00
|
|
|
fetch-depth: 0
|
2020-12-11 01:01:51 +08:00
|
|
|
|
2022-02-23 02:24:18 +08:00
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
pip3 install -r requirements-dev.txt
|
|
|
|
|
2022-11-29 04:04:04 +08:00
|
|
|
- name: Get changed files
|
2021-05-11 02:18:44 +08:00
|
|
|
id: file_changes
|
2024-08-22 05:56:22 +08:00
|
|
|
uses: tj-actions/changed-files@v45
|
2024-03-06 00:59:09 +08:00
|
|
|
with:
|
|
|
|
use_rest_api: true
|
2020-12-11 01:01:51 +08:00
|
|
|
|
2021-11-15 07:06:22 +08:00
|
|
|
- name: Run qmk formatters
|
2021-05-11 02:18:44 +08:00
|
|
|
shell: 'bash {0}'
|
2021-02-06 20:55:50 +08:00
|
|
|
run: |
|
2022-11-29 04:04:04 +08:00
|
|
|
echo '${{ steps.file_changes.outputs.added_files}}' '${{ steps.file_changes.outputs.modified_files}}' > ~/files_changed.txt
|
2021-11-23 09:40:53 +08:00
|
|
|
qmk format-c --core-only $(< ~/files_changed.txt) || true
|
|
|
|
qmk format-python $(< ~/files_changed.txt) || true
|
|
|
|
qmk format-text $(< ~/files_changed.txt) || true
|
2021-02-06 20:55:50 +08:00
|
|
|
|
2021-11-15 07:06:22 +08:00
|
|
|
- name: Fail when formatting required
|
|
|
|
run: |
|
2021-11-21 06:45:12 +08:00
|
|
|
git diff
|
2021-11-15 07:06:22 +08:00
|
|
|
for file in $(git diff --name-only); do
|
2021-11-21 06:45:12 +08:00
|
|
|
echo "File '${file}' Requires Formatting"
|
|
|
|
echo "::error file=${file}::Requires Formatting"
|
2021-11-15 07:06:22 +08:00
|
|
|
done
|
|
|
|
test -z "$(git diff --name-only)"
|