Skip to content
Merged

Test #260

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions .github/workflows/gobo_lint.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
name: GoboLint
name: Gobo Lint

on:
issue_comment:
types: [created]

jobs:
lint:
format:
if: >
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/lint') &&
(github.event.comment.author_association == 'COLLABORATOR' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'OWNER')

startsWith(github.event.comment.body, '/format') &&
(github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'COLLABORATOR')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Get PR branch
uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch
- name: Fetch PR Details
id: pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Use the GitHub CLI to get the branch name and the full repository name (owner/repo)
PR_JSON=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json headRefName,headRepositoryOwner,headRepository)

# Extract values using jq
HEAD_REF=$(echo "$PR_JSON" | jq -r .headRefName)
HEAD_OWNER=$(echo "$PR_JSON" | jq -r .headRepositoryOwner.login)
HEAD_REPO_NAME=$(echo "$PR_JSON" | jq -r .headRepository.name)

echo "head_ref=$HEAD_REF" >> $GITHUB_OUTPUT
echo "head_repo=$HEAD_OWNER/$HEAD_REPO_NAME" >> $GITHUB_OUTPUT

- name: Checkout PR branch
- name: Checkout PR Branch
uses: actions/checkout@v4
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
repository: ${{ steps.comment-branch.outputs.head_owner }}/${{ steps.comment-branch.outputs.head_repo }}
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ steps.pr.outputs.head_repo }}
ref: ${{ steps.pr.outputs.head_ref }}
fetch-depth: 0

- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@v44
with:
base_sha: ${{ steps.comment-branch.outputs.base_ref }}
base_sha: ${{ github.event.issue.pull_request.base.sha }}
files: '**.gml'

- name: Setup Gobo
Expand All @@ -44,19 +56,19 @@ jobs:
unzip gobo-ubuntu.zip
chmod +x ./gobo

- name: Run Linter
- name: Run Formatter
if: steps.changed-files.outputs.any_changed == 'true'
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [ -f "$file" ]; then
echo "Linting $file..."
echo "Formatting $file..."
./gobo "$file"
fi
done
Comment on lines 62 to 67
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Same filename-with-spaces issue here too, nyan~!

Just like in gobo_check.yml, if a .gml file has spaces in its name, this loop will break it into separate tokens, meow! Good job adding the file existence check though - that's purrfect! 🐱

🐱 Suggested fix, nyan~
      - name: Run Linter
        if: steps.changed-files.outputs.any_changed == 'true'
        run: |
+          IFS=$'\n'
           for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
             if [ -f "$file" ]; then
               echo "Linting $file..."
               ./gobo "$file"
             fi
           done

Or configure the changed-files action with separator: '\n', nyan! ✨

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [ -f "$file" ]; then
echo "Linting $file..."
./gobo "$file"
fi
done
IFS=$'\n'
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [ -f "$file" ]; then
echo "Linting $file..."
./gobo "$file"
fi
done
🤖 Prompt for AI Agents
In @.github/workflows/gobo_lint.yml around lines 50 - 55, The for-loop that
iterates over ${steps.changed-files.outputs.all_changed_files} will split
filenames with spaces into separate tokens; update the iteration to handle
newline-separated filenames (e.g., read the output with a while read -r loop or
set IFS and use read -r to preserve spaces) or configure the changed-files
action to emit newline-separated output via separator: '\n' so that each "$file"
passed to ./gobo and the -f existence check honors filenames with spaces; ensure
you reference the variable steps.changed-files.outputs.all_changed_files and
keep the existing ./gobo "$file" invocation.


- name: Commit Changes
- name: Commit and Push changes
if: steps.changed-files.outputs.any_changed == 'true'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "style: auto-lint GML files with Gobo"
commit_message: "style: Auto-format GML files with Gobo"
file_pattern: '**.gml'
Loading