Flipper-IRDB/.github/workflows/pr-lint-check.yaml
2024-10-30 23:09:17 +01:00

94 lines
2.9 KiB
YAML

name: Lint Check Pull Request
on:
pull_request:
paths:
- '**/*.ir'
jobs:
lint:
name: "🐛 Looking for issues"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clean Script Directory
run: rm -rf fff-ir-lint
- uses: actions/checkout@v4
with:
repository: 'darmiel/fff-ir-lint'
path: fff-ir-lint
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: "**/*.ir"
json: true
safe_output: false
write_output_files: true
- name: Verify the contents of the .github/outputs/all_changed_files.json file
run: cat .github/outputs/all_changed_files.json
- name: list files
run: ls -larth .github/outputs
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Run Linter
id: run-linter
continue-on-error: true
run: LINTER_CONFIG=.fff-ir-lint.json python fff-ir-lint/main.py github2 json:.github/outputs/all_changed_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: Save PR number
run: |
rm -rf pr/ || true
mkdir -p pr/
echo ${{ github.event.number }} > ./pr/NR
- name: Create comment body if linter found no errors
if: ${{ steps.run-linter.outcome == 'success' }}
run: |
cat <<EOF > ./pr/comment_body.txt
<!-- [lint] -->
Thank you for your contribution! ❤️
**The linter found no issues. 🎉**
EOF
- name: Create comment body if linter found errors
if: ${{ steps.run-linter.outcome != 'success' }}
run: |
cat <<EOF > ./pr/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: Save comment body
uses: actions/upload-artifact@v4
with:
name: pr
path: pr/
- name: Fail Pipeline if Linter Found Issues
if: ${{ steps.run-linter.outcome == 'failure' }}
run: exit 1