From d6ac2cc6328ab5d6c6d4b1a1dc16252f92299002 Mon Sep 17 00:00:00 2001 From: mmcky Date: Mon, 8 Sep 2025 11:02:35 +1000 Subject: [PATCH 1/2] TST: setup workflow for issue comments --- .github/workflows/style-guide.yml | 70 +++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/style-guide.yml diff --git a/.github/workflows/style-guide.yml b/.github/workflows/style-guide.yml new file mode 100644 index 00000000..757b16d7 --- /dev/null +++ b/.github/workflows/style-guide.yml @@ -0,0 +1,70 @@ +name: QuantEcon Style Guide Check + +on: + issue_comment: + types: [created] + +jobs: + style-check: + if: contains(github.event.comment.body, '@qe-style-check') + runs-on: ubuntu-latest + name: Process style guide check request + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.issue.pull_request && github.event.pull_request.head.ref || github.sha }} + + - name: Check if user has permissions + id: check-permissions + uses: actions/github-script@v7 + with: + script: | + const { data: permissions } = await github.rest.repos.getCollaboratorPermissionLevel({ + owner: context.repo.owner, + repo: context.repo.repo, + username: context.payload.comment.user.login + }); + + const hasPermissions = ['write', 'admin', 'maintain'].includes(permissions.permission); + + if (!hasPermissions) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: '⚠️ Sorry, only collaborators with write access can trigger style guide checks.' + }); + core.setFailed('User does not have sufficient permissions'); + return; + } + + core.setOutput('has-permissions', 'true'); + + - name: React to comment + if: steps.check-permissions.outputs.has-permissions == 'true' + uses: actions/github-script@v7 + with: + script: | + await github.rest.reactions.createForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: context.payload.comment.id, + content: 'eyes' + }); + + - name: Run style guide check + if: steps.check-permissions.outputs.has-permissions == 'true' + id: style-check + uses: QuantEcon/meta/.github/actions/qe-style-guide@main + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + style-guide: '.github/copilot-qe-style-guide.md' + docs: 'lectures/' # Adjust this to your content directory + extensions: 'md' # Adjust file extensions as needed + openai-api-key: ${{ secrets.OPENAI_API_KEY }} + model: 'gpt-4' + max-suggestions: '20' + confidence-threshold: '0.8' \ No newline at end of file From 42aab8c7fd5a6edd0dd2df12271ba5c80fcd1b23 Mon Sep 17 00:00:00 2001 From: mmcky Date: Mon, 8 Sep 2025 11:04:22 +1000 Subject: [PATCH 2/2] update to load action from branch --- .github/workflows/style-guide.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/style-guide.yml b/.github/workflows/style-guide.yml index 757b16d7..f809a66f 100644 --- a/.github/workflows/style-guide.yml +++ b/.github/workflows/style-guide.yml @@ -58,7 +58,7 @@ jobs: - name: Run style guide check if: steps.check-permissions.outputs.has-permissions == 'true' id: style-check - uses: QuantEcon/meta/.github/actions/qe-style-guide@main + uses: QuantEcon/meta/.github/actions/qe-style-guide@copilot/fix-228 with: github-token: ${{ secrets.GITHUB_TOKEN }} style-guide: '.github/copilot-qe-style-guide.md'