From 8b7c3fdc13f0c0b597db21d397b5540d6a37d9ed Mon Sep 17 00:00:00 2001 From: "Christopher W. Blake" Date: Mon, 10 Mar 2025 21:43:37 +0000 Subject: [PATCH 1/6] Describe copilot PR summaries and review. Indicate that the activity is optional. --- .github/steps/4-copilot-on-github.md | 47 +++++++++++++++++++++------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/.github/steps/4-copilot-on-github.md b/.github/steps/4-copilot-on-github.md index e800c9a..8874af1 100644 --- a/.github/steps/4-copilot-on-github.md +++ b/.github/steps/4-copilot-on-github.md @@ -1,32 +1,55 @@ ## Step 4: Using GitHub Copilot within a pull request -Congratulations! You are finished with coding for this exercise :tada: +Congratulations! You are finished with coding for this exercise. Now it's time to merge our work. :tada: To wrap up, let's learn about two limited-access Copilot features that can speed up our pull requests! -Now, let's see how Copilot can help us finish up with during our pull request. +#### Copilot Pull Request Summaries -### :keyboard: Activity: Summarize and review with Copilot :robot: +Typically, you would review your notes and commit messages then summarize them for your pull request description. This may take some time, especially if commit messages are inconsistent or code is not not documented well. Fortunately, Copilot can consider all changes in the pull request and provide the important highlights, and with references too! -1. In a web browser, navigate to your exercise repository. +Here is what that process looks like: -1. At the top, select the **Pull Requests** tab and create a new pull request. Stop when you reach a form to enter a title and description. + + +> [!NOTE] +> This is a unavailable with the **Copilot Free** tier. [[docs]](https://docs.github.com/en/enterprise-cloud@latest/copilot/using-github-copilot/using-github-copilot-for-pull-requests/creating-a-pull-request-summary-with-github-copilot) + +#### Copilot Review + +More eyes on our work is always useful so let's ask Copilot to do a first pass before we do a normal peer review process. Copilot is great at catching common mistakes that can are fixed by simple adjustment, but please remember to use it responsibily. + +Here is what that process looks like: + + + +> [!IMPORTANT] +> This is in **Public Preview** for organizations. [[docs]](https://docs.github.com/en/copilot/using-github-copilot/code-review/using-copilot-code-review) + +### :keyboard: Activity: Summarize and review a PR with Copilot + +Both **pull request summaries** and **copilot review** have limited access, so this activity is mostly optional. If you have access, Mona will gladly check your work though! If not, you can skip the optional steps. + +1. In a web browser, open another tab and navigate to your exercise repository. + +1. You might notice a **notification banner** suggesting to create a new pull request. Click that or use the **Pull Requests** tab at the top to create a new pull request. Please use the following details: - **base:** `main` - **compare:** `accelerate-with-copilot` - **title:** `Add registration validation and more activities` -1. **Use Copilot to add a description** - In the **Add a description** toolbar, click the **Copilot actions** icon and **Summary** action to describe your changes. :memo: +1. (Optional) In the **Add a description** area, enter edit mode if needed, then click the **Copilot actions** icon and **Summary** action. After a moment, Copilot will add a description. :memo: -1. **Ask Copilot to review your changes** - In the right side information panel at the top, locate the **Reviewers** section and click the **Request** button next to a **Copilot icon**. + Copilot -1. Below the pull request description, press the green **Create pull request** one more time. +1. (Optional) In the right side information panel at the top, locate the **Reviewers** section and click the **Request** button next to a **Copilot icon**. Wait a moment for Copilot to add a review comment to your pull request! -1. Wait a moment for Copilot to add a review comment to your pull request! + > **Tip:** Notice a log entry was added to indicate a Copilot review was requested. - - Notice the log entry indicating a Copilot review was requested. + Copilot + Copilot -1. Wait a moment for Mona to check your work, provide feedback, and post a final review of this lesson! +1. At the bottom, press the **Merge pull request** button. Nice work! You are all done! :tada: -1. At the bottom, press the green **Merge pull request** button. Nice work! You are all done! :tada: +1. Wait a moment for Mona to check your work, provide feedback, and post a final review of this lesson!
Having trouble? 🤷
From dc294771b11d56db406436ac35b2c139e6362e9f Mon Sep 17 00:00:00 2001 From: "Christopher W. Blake" Date: Mon, 10 Mar 2025 21:54:02 +0000 Subject: [PATCH 2/6] Update some pictures in Step 4 --- .github/steps/4-copilot-on-github.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/steps/4-copilot-on-github.md b/.github/steps/4-copilot-on-github.md index 8874af1..48261b3 100644 --- a/.github/steps/4-copilot-on-github.md +++ b/.github/steps/4-copilot-on-github.md @@ -6,10 +6,6 @@ Congratulations! You are finished with coding for this exercise. Now it's time t Typically, you would review your notes and commit messages then summarize them for your pull request description. This may take some time, especially if commit messages are inconsistent or code is not not documented well. Fortunately, Copilot can consider all changes in the pull request and provide the important highlights, and with references too! -Here is what that process looks like: - - - > [!NOTE] > This is a unavailable with the **Copilot Free** tier. [[docs]](https://docs.github.com/en/enterprise-cloud@latest/copilot/using-github-copilot/using-github-copilot-for-pull-requests/creating-a-pull-request-summary-with-github-copilot) @@ -17,10 +13,6 @@ Here is what that process looks like: More eyes on our work is always useful so let's ask Copilot to do a first pass before we do a normal peer review process. Copilot is great at catching common mistakes that can are fixed by simple adjustment, but please remember to use it responsibily. -Here is what that process looks like: - - - > [!IMPORTANT] > This is in **Public Preview** for organizations. [[docs]](https://docs.github.com/en/copilot/using-github-copilot/code-review/using-copilot-code-review) @@ -38,14 +30,14 @@ Both **pull request summaries** and **copilot review** have limited access, so t 1. (Optional) In the **Add a description** area, enter edit mode if needed, then click the **Copilot actions** icon and **Summary** action. After a moment, Copilot will add a description. :memo: - Copilot + Copilot summarize button 1. (Optional) In the right side information panel at the top, locate the **Reviewers** section and click the **Request** button next to a **Copilot icon**. Wait a moment for Copilot to add a review comment to your pull request! - > **Tip:** Notice a log entry was added to indicate a Copilot review was requested. + Copilot review button + - Copilot - Copilot + > **Tip:** Notice a log entry that Copilot was requested for a review. 1. At the bottom, press the **Merge pull request** button. Nice work! You are all done! :tada: From 16ff271f5af9e07929943985fd95dc0bac019828 Mon Sep 17 00:00:00 2001 From: "Christopher W. Blake" Date: Mon, 10 Mar 2025 22:03:06 +0000 Subject: [PATCH 3/6] Separate step 4 grading workflow into 2 files. --- .github/workflows/3-copilot-edits.yml | 3 +- .github/workflows/4a-copilot-on-github.yml | 171 ++++++++++++++++++ ...on-github.yml => 4b-copilot-on-github.yml} | 139 ++------------ 3 files changed, 188 insertions(+), 125 deletions(-) create mode 100644 .github/workflows/4a-copilot-on-github.yml rename .github/workflows/{4-copilot-on-github.yml => 4b-copilot-on-github.yml} (54%) diff --git a/.github/workflows/3-copilot-edits.yml b/.github/workflows/3-copilot-edits.yml index e0d4dc0..5034ee5 100644 --- a/.github/workflows/3-copilot-edits.yml +++ b/.github/workflows/3-copilot-edits.yml @@ -204,6 +204,7 @@ jobs: - name: Disable current workflow and enable next one run: | gh workflow disable "Step 3" - gh workflow enable "Step 4" + gh workflow enable "Step 4a" + gh workflow enable "Step 4b" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/4a-copilot-on-github.yml b/.github/workflows/4a-copilot-on-github.yml new file mode 100644 index 0000000..ecfdc1d --- /dev/null +++ b/.github/workflows/4a-copilot-on-github.yml @@ -0,0 +1,171 @@ +name: Step 4a # Copilot on GitHub + +on: + pull_request: + branches: + - main + types: + - closed + +permissions: + contents: write + actions: write + issues: write + +env: + REVIEW_FILE: ".github/steps/x-review.md" + +jobs: + find_exercise: + if: | + !github.event.repository.is_template + name: Find exercise by issue title + runs-on: ubuntu-latest + + outputs: + issue-url: ${{ steps.get-issue-url.outputs.ISSUE_URL }} + + steps: + - id: get-issue-url + run: | + # Get the issue url from the event or search for it. + if [ -n "${{ github.event.issue }}" ]; then + issue_url="${{ github.event.issue.html_url }}" + else + issue_url=$(gh issue list --repo $REPO --search "in:title Exercise:" --json url,title --jq '.[].url') + fi + + # Save to output + echo "ISSUE_URL=$issue_url" >> $GITHUB_OUTPUT + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + + check_step_work: + name: Check step work + runs-on: ubuntu-latest + needs: [find_exercise] + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/response-templates + path: skills-response-templates + + # START: Check practical exercise + + # Nothing to check. Merging the pull request is enough. + + # END: Check practical exercise + + - name: Create comment - step finished - final review next + run: | + gh issue comment "$ISSUE_URL" \ + --body-file skills-response-templates/step-feedback/lesson-review.md + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + post_review_content: + name: Post review content + needs: [find_exercise, check_step_work] + runs-on: ubuntu-latest + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/response-templates + path: skills-response-templates + + - name: Create comment - add step content + run: | + gh issue comment "$ISSUE_URL" \ + --body-file "$REVIEW_FILE" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + finish_exercise: + name: Finish exercise + needs: [find_exercise, post_review_content] + runs-on: ubuntu-latest + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: main + + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/response-templates + path: skills-response-templates + + - name: Configure Git user + run: | + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + + - name: Build message - congratulations + id: build-message-congratulations + uses: skills/action-text-variables@v1 + with: + template-file: skills-response-templates/readme/congratulations.md + template-vars: | + login=${{ github.actor }} + + - name: Update README - congratulations + run: | + # Add "Congratulations" to the start of the README + orig_readme=$(cat README.md) + new_readme="${{ steps.build-message-congratulations.outputs.updated-text }} $orig_readme" + + # Update file and push + echo "$new_readme" > README.md + git add README.md + git commit --message="Congratulations!🎉" + git push + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build message - exercise finished + id: build-finish-message + uses: skills/action-text-variables@v1 + with: + template-file: skills-response-templates/step-feedback/lesson-finished.md + template-vars: | + login=${{ github.actor }} + repo_full_name=${{ github.repository }} + + - name: Create comment - exercise finished + run: | + gh issue comment "$ISSUE_URL" \ + --body "$ISSUE_BODY" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_BODY: ${{ steps.build-finish-message.outputs.updated-text }} + + - name: Close issue + run: gh issue close "$ISSUE_URL" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Disable current workflow + run: | + gh workflow disable "Step 4a" + gh workflow disable "Step 4b" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/4-copilot-on-github.yml b/.github/workflows/4b-copilot-on-github.yml similarity index 54% rename from .github/workflows/4-copilot-on-github.yml rename to .github/workflows/4b-copilot-on-github.yml index 3d72910..fd55a3c 100644 --- a/.github/workflows/4-copilot-on-github.yml +++ b/.github/workflows/4b-copilot-on-github.yml @@ -1,11 +1,17 @@ -name: Step 4 # Copilot on GitHub +name: Step 4b # Copilot on GitHub on: - pull_request: - branches: - - main - types: [edited] - pull_request_review: + # Trigger if PR Description is edited + # pull_request: + # branches: + # - main + # types: + # - edited + + # Trigger if Copilot adds a review comment + pull_request_review_comment: + types: + - created permissions: contents: write @@ -14,9 +20,6 @@ permissions: pull-requests: read repository-projects: read -env: - REVIEW_FILE: ".github/steps/x-review.md" - jobs: find_exercise: if: | @@ -60,16 +63,9 @@ jobs: repository: skills/response-templates path: skills-response-templates - - name: Update comment - checking work - run: | - gh issue comment "$ISSUE_URL" \ - --body-file skills-response-templates/step-feedback/checking-work.md \ - --edit-last - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # START: Check practical exercise - - name: Check participant info on activity cards + + - name: Check for pr description and copilot review id: check-user-work run: | # Checks to perform @@ -143,8 +139,7 @@ jobs: - name: Create comment - step results run: | gh issue comment "$ISSUE_URL" \ - --body "$COMMENT_BODY" \ - --edit-last + --body "$COMMENT_BODY" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMMENT_BODY: ${{ steps.build-message-step-results.outputs.updated-text }} @@ -154,107 +149,3 @@ jobs: run: exit 1 # END: Check practical exercise - - - name: Update comment - step finished - final review next - run: | - gh issue comment "$ISSUE_URL" \ - --body-file skills-response-templates/step-feedback/lesson-review.md - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - post_review_content: - name: Post review content - needs: [find_exercise, check_step_work] - runs-on: ubuntu-latest - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Get response templates - uses: actions/checkout@v4 - with: - repository: skills/response-templates - path: skills-response-templates - - - name: Create comment - add step content - run: | - gh issue comment "$ISSUE_URL" \ - --body-file "$REVIEW_FILE" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - finish_exercise: - name: Finish exercise - needs: [find_exercise, post_review_content] - runs-on: ubuntu-latest - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: main - - - name: Get response templates - uses: actions/checkout@v4 - with: - repository: skills/response-templates - path: skills-response-templates - - - name: Configure Git user - run: | - git config user.name github-actions[bot] - git config user.email github-actions[bot]@users.noreply.github.com - - - name: Build message - congratulations - id: build-message-congratulations - uses: skills/action-text-variables@v1 - with: - template-file: skills-response-templates/readme/congratulations.md - template-vars: | - login=${{ github.actor }} - - - name: Update README - congratulations - run: | - # Add "Congratulations" to the start of the README - orig_readme=$(cat README.md) - new_readme="${{ steps.build-message-congratulations.outputs.updated-text }} $orig_readme" - - # Update file and push - echo "$new_readme" > README.md - git add README.md - git commit --message="Congratulations!🎉" - git push - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Build message - exercise finished - id: build-finish-message - uses: skills/action-text-variables@v1 - with: - template-file: skills-response-templates/step-feedback/lesson-finished.md - template-vars: | - login=${{ github.actor }} - repo_full_name=${{ github.repository }} - - - name: Create comment - exercise finished - run: | - gh issue comment "$ISSUE_URL" \ - --body "$ISSUE_BODY" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ISSUE_BODY: ${{ steps.build-finish-message.outputs.updated-text }} - - - name: Close issue - run: gh issue close "$ISSUE_URL" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Disable current workflow - run: gh workflow disable "${{github.workflow}}" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From c8280fcc2bbef936f400b94ad5f0a6d3dea6ac48 Mon Sep 17 00:00:00 2001 From: "Christopher W. Blake" Date: Mon, 10 Mar 2025 22:17:29 +0000 Subject: [PATCH 4/6] fix: 4b workflow not triggering when copilot submits review --- .github/workflows/4b-copilot-on-github.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/4b-copilot-on-github.yml b/.github/workflows/4b-copilot-on-github.yml index fd55a3c..38cc2dd 100644 --- a/.github/workflows/4b-copilot-on-github.yml +++ b/.github/workflows/4b-copilot-on-github.yml @@ -9,9 +9,7 @@ on: # - edited # Trigger if Copilot adds a review comment - pull_request_review_comment: - types: - - created + pull_request_review: permissions: contents: write From 710ca866fec20fbaf9c5906bdb1271d0c8db03ef Mon Sep 17 00:00:00 2001 From: "Christopher W. Blake" Date: Mon, 10 Mar 2025 22:21:55 +0000 Subject: [PATCH 5/6] Remove help since tasks are optional. --- .github/steps/4-copilot-on-github.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/steps/4-copilot-on-github.md b/.github/steps/4-copilot-on-github.md index 48261b3..ea3af38 100644 --- a/.github/steps/4-copilot-on-github.md +++ b/.github/steps/4-copilot-on-github.md @@ -42,13 +42,3 @@ Both **pull request summaries** and **copilot review** have limited access, so t 1. At the bottom, press the **Merge pull request** button. Nice work! You are all done! :tada: 1. Wait a moment for Mona to check your work, provide feedback, and post a final review of this lesson! - -
-Having trouble? 🤷
- -If you don't get feedback, here are some things to check: - -- Make sure Copilot generated a description. -- Make sure Copilot was requested to provide a review. - -
From f1fbf1deedccbec3a67fe93b1e3654fb35d8759a Mon Sep 17 00:00:00 2001 From: "Christopher W. Blake" Date: Mon, 10 Mar 2025 22:22:18 +0000 Subject: [PATCH 6/6] Remove hidden image --- .github/steps/4-copilot-on-github.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/steps/4-copilot-on-github.md b/.github/steps/4-copilot-on-github.md index ea3af38..26f35f6 100644 --- a/.github/steps/4-copilot-on-github.md +++ b/.github/steps/4-copilot-on-github.md @@ -35,7 +35,6 @@ Both **pull request summaries** and **copilot review** have limited access, so t 1. (Optional) In the right side information panel at the top, locate the **Reviewers** section and click the **Request** button next to a **Copilot icon**. Wait a moment for Copilot to add a review comment to your pull request! Copilot review button - > **Tip:** Notice a log entry that Copilot was requested for a review.