2022-12-20 19:00:34 +00:00
|
|
|
name: "🧐 Checking IR Files"
|
|
|
|
|
|
|
|
on:
|
2023-12-13 14:05:50 +00:00
|
|
|
pull_request:
|
2024-10-27 00:19:27 +00:00
|
|
|
paths:
|
|
|
|
- '**/*.ir'
|
2022-12-20 19:00:34 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
lint:
|
|
|
|
name: "🐛 Looking for issues"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-10-27 00:19:27 +00:00
|
|
|
- uses: actions/checkout@v4
|
2022-12-20 19:00:34 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Clean Script Directory
|
|
|
|
run: rm -rf fff-ir-lint
|
2024-10-27 00:19:27 +00:00
|
|
|
|
|
|
|
- uses: actions/checkout@v4
|
2022-12-20 19:00:34 +00:00
|
|
|
with:
|
|
|
|
repository: 'darmiel/fff-ir-lint'
|
|
|
|
path: fff-ir-lint
|
|
|
|
|
2024-10-27 00:19:27 +00:00
|
|
|
- name: Get changed files
|
2022-12-20 19:00:34 +00:00
|
|
|
id: changed-files
|
2024-10-27 00:19:27 +00:00
|
|
|
uses: tj-actions/changed-files@v45
|
2022-12-20 19:00:34 +00:00
|
|
|
with:
|
|
|
|
files: "**/*.ir"
|
2024-10-27 00:19:27 +00:00
|
|
|
json: true
|
|
|
|
write_output_files: true
|
2022-12-20 19:00:34 +00:00
|
|
|
sha: ${{ github.event.pull_request.head.sha }}
|
|
|
|
|
2024-10-27 00:19:27 +00:00
|
|
|
- name: Verify the contents of the .github/outputs/added_files.json file
|
|
|
|
run: cat .github/outputs/added_files.json
|
|
|
|
|
|
|
|
- uses: actions/setup-python@v5
|
2022-12-20 19:00:34 +00:00
|
|
|
with:
|
2024-10-27 00:19:27 +00:00
|
|
|
python-version: '3.10'
|
2022-12-20 19:00:34 +00:00
|
|
|
|
2024-10-27 00:19:27 +00:00
|
|
|
- name: Run Linter
|
|
|
|
id: run-linter
|
2022-12-20 19:00:34 +00:00
|
|
|
continue-on-error: true
|
2024-10-27 00:19:27 +00:00
|
|
|
run: LINTER_CONFIG=.fff-ir-lint.json python fff-ir-lint/main.py github2 json:.github/outputs/added_files.json > .github/outputs/linter_output.txt
|
|
|
|
|
|
|
|
- name: Verify the contents of the .github/outputs/linter_output.txt file
|
|
|
|
run: cat .github/outputs/linter_output.txt
|
|
|
|
|
|
|
|
- name: Find Comment from Linter
|
|
|
|
uses: peter-evans/find-comment@v3
|
|
|
|
if: ${{ github.event.pull_request.head.repo.full_name == 'Lucaslhm/Flipper-IRDB' }} # does not work in forks
|
|
|
|
id: fc
|
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
comment-author: 'github-actions[bot]'
|
|
|
|
body-includes: '<!-- [lint] -->'
|
|
|
|
|
|
|
|
- name: Create or update comment if linter found no errors
|
|
|
|
uses: peter-evans/create-or-update-comment@v4
|
|
|
|
if: ${{ steps.run-linter.outcome == 'success' && github.event.pull_request.head.repo.full_name == 'Lucaslhm/Flipper-IRDB' }} # does not work in forks
|
2022-12-20 19:00:34 +00:00
|
|
|
with:
|
2024-10-27 00:19:27 +00:00
|
|
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
body: |
|
|
|
|
<!-- [lint] -->
|
|
|
|
Thank you for your contribution! ❤️
|
2022-12-20 19:00:34 +00:00
|
|
|
|
2024-10-27 00:19:27 +00:00
|
|
|
**The linter found no issues. 🎉**
|
|
|
|
edit-mode: replace
|
|
|
|
|
|
|
|
- name: Create comment body if linter found errors
|
|
|
|
if: ${{ steps.run-linter.outcome != 'success' }}
|
|
|
|
run: |
|
|
|
|
cat <<EOF > .github/outputs/comment_body.txt
|
|
|
|
<!-- [lint] -->
|
|
|
|
Thank you for your contribution! ❤️
|
|
|
|
|
|
|
|
We use an automated linter to ensure consistency. During the review of the \`.ir\` files in your pull request, it found the following issue(s):
|
|
|
|
|
|
|
|
<details>
|
|
|
|
<summary><strong>🐛 Linter Result</strong> <i>(Click to open)</i></summary>
|
|
|
|
|
|
|
|
$(cat .github/outputs/linter_output.txt)
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
Please address these issues and update your pull request. Once the problems are resolved, the linter will re-check your changes.
|
|
|
|
EOF
|
|
|
|
|
|
|
|
- name: Create or update comment if linter found errors
|
|
|
|
uses: peter-evans/create-or-update-comment@v4
|
|
|
|
if: ${{ steps.run-linter.outcome != 'success' && github.event.pull_request.head.repo.full_name == 'Lucaslhm/Flipper-IRDB' }} # does not work in forks
|
|
|
|
with:
|
|
|
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
body-path: .github/outputs/comment_body.txt
|
|
|
|
edit-mode: replace
|
2022-12-20 19:00:34 +00:00
|
|
|
|
2024-10-27 00:19:27 +00:00
|
|
|
- name: Fail Pipeline if Linter Found Issues
|
|
|
|
if: ${{ steps.run-linter.outcome == 'failure' }}
|
2023-02-25 17:11:37 +00:00
|
|
|
run: exit 1
|