From 0a8c5b0f55193854ac771e71b4b9a0fdd18e6d32 Mon Sep 17 00:00:00 2001 From: Jeff Bishop Date: Mon, 4 May 2026 12:01:34 -0700 Subject: [PATCH] fix: update-or-create comments, failure fallback, concurrency for Challenge 16 --- .github/workflows/autograder-capstone.yml | 67 ++++++++++++++++++++++- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/.github/workflows/autograder-capstone.yml b/.github/workflows/autograder-capstone.yml index 5a504bd..c77e8be 100644 --- a/.github/workflows/autograder-capstone.yml +++ b/.github/workflows/autograder-capstone.yml @@ -14,6 +14,10 @@ permissions: contents: read pull-requests: write +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + jobs: validate-agent: name: Verify Agent File @@ -103,13 +107,70 @@ jobs: 'Excellent capstone work!' ].join('\n'); } + const MARKER = '## Challenge 16:'; try { - await github.rest.issues.createComment({ + const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, - issue_number: context.issue.number, - body + issue_number: context.issue.number }); + const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(MARKER)); + if (existing) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body + }); + } } catch (error) { console.error('Could not post Challenge 16 result:', error.message); } + + - name: Post workflow error notice + if: failure() + uses: actions/github-script@v7 + with: + script: | + const MARKER = '## Challenge 16:'; + const body = [ + '## Challenge 16: Check could not complete', + '', + 'The automated agent file check ran into an unexpected error. Your work is not affected.', + 'Keep going and ask your facilitator, or mention @facilitator in a comment.', + '', + '---', + '*Automated message from Learning Room Bot.*' + ].join('\n'); + try { + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(MARKER)); + if (existing) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body + }); + } + } catch (err) { + console.error('Could not post error notice:', err.message); + }