diff --git a/.github/steps/1-preparing.md b/.github/steps/1-preparing.md index 6c55e2a..3f7fe3d 100644 --- a/.github/steps/1-preparing.md +++ b/.github/steps/1-preparing.md @@ -6,7 +6,7 @@ In this exercise, you will be using different GitHub Copilot features to work on screenshot of Mergington High School WebApp -### What is GitHub Copilot? +### 📖 Theory: Getting to know GitHub Copilot copilot logo @@ -14,19 +14,22 @@ GitHub Copilot is an AI coding assistant that helps you write code faster and wi GitHub Copilot has been proven to increase developer productivity and accelerate the pace of software development. For more information, see [Research: quantifying GitHub Copilot’s impact on developer productivity and happiness in the GitHub blog.](https://github.blog/news-insights/research/research-quantifying-github-copilots-impact-on-developer-productivity-and-happiness/) -Your most common interactions will likely be: +As you work in your IDE, you'll most often interact with GitHub Copilot in the following ways: -- **Inline suggestions**: As you type, Copilot uses the nearby context to suggest code directly in your editor. This will be a familiar interaction if you have used code completion tools like [Intellisense](https://code.visualstudio.com/docs/editor/intellisense), except that the completions may be entire functions. -- **Copilot - Ask Mode**: A dedicated chat panel that lets you ask coding related questions. This will feel familiar if you have used online AI assistant chats. The big difference however, is that your project files will provide automatic context to provide tailored responses. -- **Copilot - Edit Mode**: Similar to Ask mode, but less conversational. Copilot will make changes to your selected files to implement your request. -- **Copilot - Agent Mode**: Copilot will run iteratively until it achieves your request. It will select context, make code changes, run terminal commands, run tools, and most importantly review its work to make adjustments. +| Interaction Mode | 📝 Description | 🎯 Best For | +| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| **⚡ Inline suggestions** | AI-powered code suggestions that appear as you type, offering context-aware completions from single lines to entire functions. | Completion of the current line, sometimes a whole new block of code | +| **💬 Ask Mode** | Optimized for answering questions about your codebase, coding, and general technology concepts. | Understanding how code works, brainstorming ideas, asking questions | +| **✏️ Edit Mode** | Optimized for making code edits across multiple files in your project. VS Code directly applies the code changes in the editor for in-place review. | Coding tasks when you have a good understanding of the changes you want to make and which files you want to edit | +| **🤖 Agent Mode** | Optimized for making autonomous edits across multiple files in your project. | Coding tasks when you have a less well-defined task that might also require running terminal commands and tools | +| **💭 Inline Chat** | Interactive chat scoped to your current file or selection. Ask questions about specific code blocks. | Code explanations, debugging specific functions, targeted improvements | -> [!TIP] -> You can learn more about current and upcoming features in the [GitHub Copilot Features](https://docs.github.com/en/copilot/about-github-copilot/github-copilot-features) documentation. You can also select different [models](https://docs.github.com/en/github-models) and make your own [extensions](https://github.com/features/copilot/extensions), but that's for a different lesson! +As you work, you'll find GitHub Copilot can help out in several places across the `github.com` website and in your favorite coding environments such as VS Code, Jet Brains, and Xcode! -### How can I use GitHub Copilot? +For today's coding though, we will practice with VS Code in a pre-configured development environment known as a [GitHub Codespace](https://github.com/features/codespaces). -As you work, you'll find GitHub Copilot can help out in several places across the website and in your favorite coding environments such as VS Code, Jet Brains, and Xcode! For today's coding though, we will practice with VS Code in a pre-configured development environment known as [Codespace](https://github.com/features/codespaces). +> [!TIP] +> You can learn more about current and upcoming features in the [GitHub Copilot Features](https://docs.github.com/en/copilot/about-github-copilot/github-copilot-features) documentation. ### :keyboard: Activity: Get a project intro from Copilot Chat @@ -49,13 +52,17 @@ Let's start up our development environment, use copilot to learn a bit about the python extension for VS Code -1. At the top of VS Code, locate and click the **Copilot icon** to open a Copilot Chat panel. +1. At the top of VS Code, locate and click the **Toggle Chat icon** to open a Copilot Chat side panel. + + image + + > 🪧 **Note:** If this is your first time using GitHub Copilot, you will need to accept the usage terms to continue. - image +1. Make sure you are in **Ask Mode** for our first interaction -1. If this is your first time using GitHub Copilot, you will need to accept the usage terms to continue. -1. Enter the below prompt to ask Copilot to introduce you to the project. Use Copilot **Ask Mode** for this prompt. + screenshot showing Ask Mode selection in Copilot Chat +1. Enter the below prompt to ask Copilot to introduce you to the project. > ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot) > @@ -64,11 +71,13 @@ Let's start up our development environment, use copilot to learn a bit about the > What should I do to run it? > ``` - > **Note**: It is not necessary to follow Copilot's recommended instructions. We have already prepared the environment for you. + > 🪧 **Note:** It is not necessary to follow Copilot's recommended instructions. We have already prepared the environment for you.
What is @workspace? - Nice job noticing the details, but let's just use it for now. 🤓 We promise to explain in the next step. + + Great question! This is a specialized [chat participant](https://docs.github.com/en/copilot/using-github-copilot/copilot-chat/github-copilot-chat-cheat-sheet?tool=vscode#chat-participants) that will explore the project repository and try to include relevant additional context. +
1. Now that we know a bit more about the project, let's actually try running it! In the left sidebar, select the `Run and Debug` tab and then press the **Start Debugging** icon. @@ -85,11 +94,9 @@ Let's start up our development environment, use copilot to learn a bit about the Great work! Now that we are familiar with the app and we know it works, let's ask copilot for help starting a branch so we can do some customizing. -1. If not already there, return to VS Code. - -1. In the bottom panel, select the **Terminal** tab. On the right side, click the plus `+` sign to create a new terminal window. +1. In VS Code's bottom panel, select the **Terminal** tab and on the right side click the plus `+` sign to create a new terminal window. - > **Note:** This will avoid stopping the existing debug session that is hosting our web application service. + > 🪧 **Note:** This will avoid stopping the existing debug session that is hosting our web application service. 1. Within the new terminal window use the keyboard shortcut `Ctrl + I` (windows) or `Cmd + I` (mac) to bring up **Copilot's Terminal Inline Chat**. @@ -101,7 +108,7 @@ Great work! Now that we are familiar with the app and we know it works, let's as > Hey copilot, how can I create and publish a new Git branch called "accelerate-with-copilot"? > ``` - > **Tip:** If Copilot doesn't give you quite what you want, you can always continue explaining what you need. Copilot will remember the conversation history for follow-up responses. + > 💡 **Tip:** If Copilot doesn't give you quite what you want, you can always continue explaining what you need. Copilot will remember the conversation history for follow-up responses. 1. Press the `Run` button to let Copilot insert the terminal command for us. No need to copy and paste! diff --git a/.github/steps/2-first-introduction.md b/.github/steps/2-first-introduction.md index 9914261..85ac686 100644 --- a/.github/steps/2-first-introduction.md +++ b/.github/steps/2-first-introduction.md @@ -2,13 +2,14 @@ In the previous step, GitHub Copilot was able to help us onboard to the project. That alone is a huge time saver, but now let's get some work done! -We recently learned there is a bug where students are registering for the same activities twice. That simply isn't acceptable, so let's get it fixed! +:bug: **THERE IS A BUG ON THE WEBSITE** :bug: -Unfortunately, we were given little information to solve this problem. So, let's enlist Copilot to help find the problem area and get a potential solution made. +We’ve discovered that something’s off in the signup flow. +Students can currently register for the same activity **more than once**! Let’s see how far Copilot can take us in uncovering the cause and shaping a clean fix. -But before we do that, let's learn a bit more about Copilot! 🧑‍🚀 +Before we dive in, a quick primer on how Copilot works. 🧑‍🚀 -### How does Copilot work? +### 📖 Theory: How Copilot works In short, you can think of Copilot like a very specialized coworker. To be effective with them, you need to provide them background (context) and clear direction (prompts). Additionally, different people are better at different things because of their unique experiences (models). @@ -32,13 +33,6 @@ In short, you can think of Copilot like a very specialized coworker. To be effec > Where could this bug be coming from? > ``` -
- What is @workspace? - - Great question! This is a specialized [chat participant](https://docs.github.com/en/copilot/using-github-copilot/copilot-chat/github-copilot-chat-cheat-sheet?tool=vscode#chat-participants) that will explore the project repository and try to include relevant additional context. - -
- 1. Now that we know the issue is in the `src/app.py` file and the `signup_for_activity` method, let's follow Copilot's recommendation and go fix it (semi-manually). We'll start with a comment and let Copilot finish the correction. 1. In VS Code, select the file **Explorer tab** to show the project files and open the `src/app.py` file. @@ -55,8 +49,6 @@ In short, you can think of Copilot like a very specialized coworker. To be effec 1. Press `Tab` to accept Copilot's suggestion and convert the shadow text to code. - > **Tip:** If you would like to see other suggestions, instead of pressing `Tab`, hover over the shadow text suggestion and a toolbar will appear. Use the arrows to select other suggestions or the three dots `...` and `Open Completions Panel` option to show all suggestions in a dedicated panel. -
Example Results
@@ -88,15 +80,13 @@ In short, you can think of Copilot like a very specialized coworker. To be effec In new project developments, it's often helpful to have some realistic looking fake data for testing. Copilot is excellent at this task, so let's add some more sample activities and introduce another way to interact with Copilot using **Inline Chat** -**Inline Chat** and the **Copilot Chat** panel are very similar tools, but with slightly different automatic context. As such, while Copilot Chat is good at explaining about the project, inline chat might feel more natural for asking about a particular line or function. - -1. If not already open, open the `src/app.py` file. +**Inline Chat** and the **Copilot Chat** panel are similar, but differ in scope: Copilot Chat handles broader, multi-file or exploratory questions; Inline Chat is faster when you want targeted help on the exact line or block in front of you. -1. Near the top (about line 23), find the `activities` variable, where our example extracurricular activities are configured. +1. Near the top of the `src/app.py` file (about line 23), find the `activities` variable, where our example extracurricular activities are configured. 1. Click on any of the related lines and bring up Copilot inline chat by using the keyboard command `Ctrl + I` (windows) or `Cmd + I` (mac). - > **Tip:** Another way to bring up Copilot inline chat is: `right click` on any of the selected lines -> `Copilot` -> `Editor Inline Chat`. + > 💡 **Tip:** Another way to bring up Copilot inline chat is: `right click` on any of the selected lines -> `Copilot` -> `Editor Inline Chat`. 1. Enter the following prompt text and press enter or the **Send and Dispatch** button. @@ -182,7 +172,7 @@ Nice work fixing that bug and expanding the example activities! Now let's get ou 1. In the left sidebar, select the `Source Control` tab. - > **Tip:** Opening a file from the source control area will show the differences to the original rather than simply opening it. + > 💡 **Tip:** Opening a file from the source control area will show the differences to the original rather than simply opening it. 1. Find the `app.py` file and press the `+` sign to collect your changes together in the staging area. @@ -192,7 +182,7 @@ Nice work fixing that bug and expanding the example activities! Now let's get ou - Typically, you would write a short description of the changes here, but now we have Copilot to help out! -1. To the right of the **Message** text box, find and click the **Generate Commit Message with Copilot** button (sparkles icon). +1. To the right of the **Message** text box, find and click the **Generate Commit Message** button (sparkles icon). 1. Press the **Commit** button and **Sync Changes** button to push your changes to GitHub. diff --git a/.github/steps/3-copilot-edits.md b/.github/steps/3-copilot-edits.md index 5a23d52..d39e0cf 100644 --- a/.github/steps/3-copilot-edits.md +++ b/.github/steps/3-copilot-edits.md @@ -1,27 +1,39 @@ -## Step 3: Getting work done even _faster_ with Copilot Edits +## Step 3: Getting work done even _faster_ with Copilot Edit Mode -In our previous steps, we used features of Copilot that require more hands-on guidance and they produced mostly localized results. Now, we will explore Copilot Edits, a feature that allows working more holistically on our repo. +In our previous steps, we used features of Copilot that require more hands-on guidance and they produced mostly localized results. Now, we will explore Copilot **Edit Mode**, a feature that allows working more holistically on our repo. -[Copilot - Edit Mode](https://code.visualstudio.com/docs/copilot/copilot-edits) is an AI-powered code editing session to make changes across **multiple files** using **natural language**, and applies the edits directly in the editor, where you can review them in-place, with the full context of the surrounding code. +### 📖 Theory: Copilot Edit Mode -#### Key features +Copilot **Edit Mode** and **Agent Mode** both let you apply **natural‑language** driven changes across **multiple files**, however there are some differences between them. -- **Multi-file Editing**: Copilot Edits can make changes across multiple files in your workspace. -- **Iterative Workflow**: Designed for fast iteration, allowing you to review, accept, or discard AI-generated code. -- **In-place Edits**: Shows generated code directly in your editor, providing a code review-like flow. -- **Working Set**: Allows you to define which files the edits should be applied to. +In this step we will focus on **Edit Mode** and explore **Agent Mode** in the next step. -#### How it works +Edit Mode is best used for **well defined** tasks where you **know the scope** of the needed changes. -1. **Set Context**: Select files to be in the working set. -1. **Provide Instructions**: Use natural language to describe the required changes. +#### How Edit Mode works + +```mermaid +flowchart LR + A[Select Context Files] --> B[Prompt Copilot] + B --> C[Proposed Changes] + C --> D{Review Change} + D --> E[Accept] + D --> F[Discard] + D -->|Refine Prompt| B + +``` + +1. **Set Context**: Select files that Copilot should consider in it's changes +1. **Prompt Copilot**: Use natural language to describe the required changes. 1. **Review Changes**: See proposed changes in-place in your code. 1. **Accept or Discard**: Review each suggested edit and choose which to keep. 1. **Iterate**: If needed, provide follow-up instructions to refine the changes. ### :keyboard: Activity: Use Copilot to add a new feature! :rocket: -1. If the Copilot Chat panel is not visible, please reopen it. +Our website lists activities, but it's keeping the guest list secret 🤫 + +Let's use Copilot to change the website to display signed up students under each activity! 1. At the bottom of Copilot Chat window, use the dropdown to switch to **Edit** mode. @@ -33,7 +45,9 @@ In our previous steps, we used features of Copilot that require more hands-on gu - `src/static/index.html` - `src/static/styles.css` - > **Tip:** You can also use the **Add Context...** button to provide other sources of context items, like a GitHub issue, the entire codebase, or the results of a terminal window. + image showing files added to context + + > 💡 **Tip:** You can also use the **Add Context...** button to provide other sources of context items, like a GitHub issue, the entire codebase, or the results of a terminal window. 1. Ask Copilot to update our project to display the current participants of activities. Wait a moment for the edit suggestions to arrive and be applied. @@ -52,20 +66,12 @@ In our previous steps, we used features of Copilot that require more hands-on gu edit navigation panel -
- Need help? 🤷
- - Remember, to add the relevant files to the working set. - - ![screenshot of working set](https://github.com/user-attachments/assets/d3eadc8e-583e-4a28-9e82-be128eab843b) - -
1. Before we simply accept the changes, please check our website again and verify everything is updated as expected. Here is an example of an updated activity card. You may need to restart the app or refresh the page. Activity card with participant info - > **Note:** Your activity card may look different. Copilot won't always produce the same results. + > 🪧 **Note:** Your activity card may look different. Copilot won't always produce the same results.
Need help? 🤷
@@ -79,17 +85,12 @@ In our previous steps, we used features of Copilot that require more hands-on gu 1. Now that we have confirmed our changes are good, use the panel to cycle through each suggested edit and press **Keep** to apply the change. - > **Tip:** You can accept the changes directly, modify them, or provide additional instruction to refine them using the chat interface. + > 💡 **Tip:** You can accept the changes directly, modify them, or provide additional instruction to refine them using the chat interface. 1. With our new feature complete, please **commit** and **push** the changes to GitHub. -1. Wait a moment for Mona to check your work, provide feedback, and share the final lesson. Almost done! - -1. (optional) If you would like an ungraded bonus step to briefly introduce Agent mode, **add an issue comment** asking **@professortocat** about Copilot Agent mode. 🚀 +1. Wait a moment for Mona to check your work, provide feedback, and share the next lesson. - ```txt - Hey @professortocat, Agent mode sounds pretty cool. Can you please tell me more about it? - ```
Having trouble? 🤷
diff --git a/.github/steps/3b-copilot-agent-mode.md b/.github/steps/3b-copilot-agent-mode.md deleted file mode 100644 index 0f837b6..0000000 --- a/.github/steps/3b-copilot-agent-mode.md +++ /dev/null @@ -1,88 +0,0 @@ -### :keyboard: Bonus Activity - GitHub Copilot Agent Mode - -> [!NOTE] -> This activity is optional and not graded. - -### What is "Agent" Mode? - -**Agent** mode enhances Copilot by automatically providing it feedback, typically the types of feedback you would provide after reviewing Copilot's suggested edits. - -**Agent** mode gives Copilot a feedback loop, enabling it to inspect its own results for issues, bugs, inconsistency, etc. in the code and even the terminal! This allows it to automatically revise its work in many situations. Similarly this means **Agent** mode can -typically handle more complex and multi-step tasks. - -That's just a brief intro and there is much more to learn, but that's for a dedicated future exercise. (hint) - -Now, let's give **Agent** mode a try! 👩‍🚀 - -### :keyboard: Activity: Use Agent mode to add functional "unregister" buttons - -Let's experiment with some more open-ended requests that will add more functionality to our web application. Remember, AI assistants often produce different results, even if the same prompt is provided. If you don't get the desired results, you can try other models or provided followup feedback to refine the results. - -1. Open the **Copilot** chat panel and use the dropdown menu to switch to **Agent** mode. - - image - -1. Time for our test! Let's ask Copilot to add functionality for removing participants. - - > ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot) - > - > ```prompt - > #codebase Please add a delete icon next to each participant and hide the bullet points. - > When clicked, it will unregister that participant from the activity. - > ``` - - - If you try this prompt in **Edit** mode, you will probably find that the changes to the frontend and backend were made in a theoretical way. Although no syntax or runtime errors occurred, the changes were not compatible and didn't achieve the goal. - - In **Agent** mode, Copilot reviewed its own work and refined it to ensure all changes were error free and coordinated together. - -1. When Copilot is finished, restart the debugger and inspect the results. If you like the results, press the **Keep** button. If not, try providing Copilot some feedback to refined the results. - -1. Ask Copilot to fix a registration bug. - - > ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot) - > - > ```prompt - > #codebase I've noticed there seems to be a bug. - > When a participant is registered, the page must be refreshed to see the change on the activity. - > ``` - - - If you try this prompt in **Edit** mode, it may or may not work. - -1. When Copilot is finished, inspect the results. If you like the results, press the **Keep** button. If not, try providing Copilot some feedback. - -### :keyboard: Activity: Use Agent mode to change the database! 🧑‍🚀 - -Just for fun, let's try something even more difficult and open-ended to see what happens! - -> [!TIP] -> In our experiments, we got working results most of the time, but not every time. -> You might try other models or pausing to provide Copilot feedback. - -1. (optional) If it is available for you, you might try another model such as `Claude 3.5 Sonnet`. - - image - -1. Ask Copilot to install a local database service. - - > ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot) - > - > ```prompt - > Please install a local mongodb server for development reasons. - > Afterward, run a command that lists the collections to verify the service is active and working. - > Do not modify our program yet. - > ``` - - - We purposely made the default development environment not ready for installing a local MongoDB server. - - You will see Copilot make mistakes, analyze the error messages, and ask to run various extra commands to make the environment suitable. Nice! - -1. Ask Copilot to change our app to use the database service. 🤯 - - > ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot) - > - > ```prompt - > #codebase I don't like that we are storing the data in memory. - > Let's switch to using mongodb. - > For now use the local development instance. - > Please pre-populate the database with the existing hardcoded json activities, keeping the activity name as the key. - > ``` - -1. That's your preview for now. We hope it was fun and please check back soon on the [Skills page](https://skills.github.com) for a dedicated exercise to explore even more of Agent Mode! 🧑‍🚀 🚀 diff --git a/.github/steps/4-copilot-agent-mode.md b/.github/steps/4-copilot-agent-mode.md new file mode 100644 index 0000000..84f9128 --- /dev/null +++ b/.github/steps/4-copilot-agent-mode.md @@ -0,0 +1,95 @@ +## Step 4: Engage Hyperdrive - Copilot Agent Mode 🚀 + +### 📖 Theory: What is Copilot Agent Mode? + +Copilot [agent mode](https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode) is the next evolution in AI-assisted coding. Acting as an autonomous peer programmer, it performs multi-step coding tasks at your command. + +Copilot Agent Mode responds to compile and lint errors, monitors terminal and test output, and auto-corrects in a loop until the task is completed. + +#### Edit Mode vs Agent Mode (at a glance) + +| Aspect | ✏️ Edit Mode | 👩‍🚀 Agent Mode | +| -------------- | --------------------------------- | -------------------------------------------------------------------------------- | +| Context scope | Only the files you explicitly add | May read/add additional files & surfaces as needed | +| Self‑review | Minimal (you drive iteration) | Built‑in feedback & retry loop on errors/failures | +| Change scope | Highly scoped & surgical | Broader; may touch related layers for consistency | +| When to choose | You know exactly what to change | Goal is broader or uncertain; requires exploration | +| Tool calling | None (you run commands manually) | Can invoke tools (read/edit files, run commands, inspect terminal & test output) | + +#### 🧰 Agent Mode Tools + +Agent mode uses tools to accomplish specialized tasks while processing a user request. Examples of such tasks are: + +- Finding relevant files to complete your prompt +- Fetching contents of a webpage +- Running tests or terminal commands + +> [!TIP] +> While VS Code provides many built‑in tools, you can also provide Agent Mode more domain‑specific powers through **MCP tools**. +> +> Read more on [MCP servers](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) and [GitHub MCP Server](https://github.com/github/github-mcp-server) + +Now, let's give **Agent Mode** a try! 👩‍🚀 + +### :keyboard: Activity: Use Agent mode to add functional "unregister" buttons + +Let's experiment with some more open-ended requests that will add more functionality to our web application. + +If you don't get the desired results, you can try other models or provided followup feedback to refine the results. + +1. Open the **Copilot** chat panel and use the dropdown menu to switch to **Agent** mode. + + agent mode + +1. Click on the **Tools** icon and explore all Tools currently available to Copilot Agent Mode. + + tools icon + + +1. Time for our test! Let's ask Copilot to add functionality for removing participants. + + > ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot) + > + > ```prompt + > #codebase Please add a delete icon next to each participant and hide the bullet points. + > When clicked, it will unregister that participant from the activity. + > ``` + + The `#codebase` tool is used by Copilot to find relevant files, code chunks that are relevant to the task at hand. + + > 🪧 **Note:** In this lab we explicitly include the `#codebase` tool to get the most repeatable results. + > Feel free to try the prompt **without** `#codebase` and observe whether Agent Mode decides to gather broader project context on its own. + +1. When Copilot is finished, restart the debugger and inspect the results. If you like the results, press the **Keep** button. If not, try providing Copilot some feedback to refined the results. + +1. Ask Copilot to fix a registration bug. + + > ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot) + > + > ```prompt + > I've noticed there seems to be a bug. + > When a participant is registered, the page must be refreshed to see the change on the activity. + > ``` + +1. When Copilot is finished, inspect the results. If you like the results, press the **Keep** button. If not, try providing Copilot some feedback. + +### :keyboard: Activity: Use Agent mode to get test coverage 🧑‍🚀 + +Your backend is now feature‑rich—but still has zero test coverage. Use Copilot **Agent Mode** to add test dependencies, scaffold starter tests and run them. + +1. Ask Copilot in **Agent mode** to set up and run tests for your backend. + + > ![Static Badge](https://img.shields.io/badge/-Prompt-placeholder?style=social&logo=github%20copilot) + > + > ```prompt + > Add fastapi tests using pytest in a new tests directory and run them. + > Make sure to add any new dependencies to requirements.txt + > ``` + +1. As Copilot works on your prompt, different tools might need your approval. + + **🎯 Goal: Get all tests passing (green) — aim for a clean run! ✅** + + > 🪧 **Note:** Copilot may one-shot this with the initial prompt or need more guidance from you. + +1. Once the tests are passing - **commit** and **push** all changes to your `accelerate-with-copilot` branch to progress to the last step! Almost done! diff --git a/.github/steps/4-copilot-on-github.md b/.github/steps/5-copilot-on-github.md similarity index 62% rename from .github/steps/4-copilot-on-github.md rename to .github/steps/5-copilot-on-github.md index 7c6a772..146c9c2 100644 --- a/.github/steps/4-copilot-on-github.md +++ b/.github/steps/5-copilot-on-github.md @@ -1,43 +1,42 @@ -## Step 4: Using GitHub Copilot within a pull request +## Step 5: Using GitHub Copilot within a pull request Congratulations! You are finished with coding for this exercise (and VS Code). 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! +### 📖 Theory: GitHub Copilot for pull requests + #### Copilot pull request summaries 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 documented well. Fortunately, Copilot can consider all changes in the pull request and provide the important highlights, and with references too! -> [!NOTE] -> This feature is not available in **GitHub Copilot Free**. [[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 code 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 are fixed by simple adjustments, but please remember to use it responsibly. > [!NOTE] -> This feature is not available in **GitHub Copilot Free**. [[docs]](https://docs.github.com/en/copilot/using-github-copilot/code-review/using-copilot-code-review) +> These features are only available on paid plans of **GitHub Copilot**. [[docs]](https://docs.github.com/en/copilot/get-started/plans) ### :keyboard: Activity: Summarize and review a PR with Copilot -Both **Copilot pull request summaries** and **Copilot code review** have limited access, so this activity is mostly optional. If you have access, go ahead and try them though! If not, you can skip the optional steps. +Both **Copilot pull request summaries** and **Copilot code review** have limited access, so this activity is mostly optional. If you don't have access, skip the optional steps of this activity. 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: +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` + - **title:** `Improve student activity registration system` -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. (Optional) In the PR description toolbar click the **Copilot** icon and **Summary** action. After a moment, Copilot will add a description based on your changes. :memo: - Copilot summarize button + 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! Copilot review button - > **Tip:** Notice a log entry that Copilot was requested for a review. + > 💡 **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: -1. Wait a moment for Mona to check your work, provide feedback, and post a final review of this lesson! +1. Wait a moment for Mona to check your work, provide feedback, and post a final review of this exercise! diff --git a/.github/steps/x-review.md b/.github/steps/x-review.md index 96e5dbf..7e1bc55 100644 --- a/.github/steps/x-review.md +++ b/.github/steps/x-review.md @@ -4,14 +4,17 @@ _Congratulations, you've completed this exercise and learned a lot about GitHub celebrate -Here's a recap of your accomplishments: +Here's a recap of the GitHub Copilot features you learned: -- Set up your GitHub Codespace and environment. -- Learned how to use Copilot inline suggestions, Chat, and Edits. -- Used Copilot to generate commit messages and pull request summaries. -- Learned how to request Copilot to review your code. +- **Ask Mode**: Used @workspace to explore and understand your codebase +- **Inline suggestions**: Completed code with Tab acceptance +- **Inline Chat**: Generated code and data with Ctrl/Cmd + I +- **Edit Mode**: Made multi-file changes with targeted prompts +- **Agent Mode**: Built features and tests autonomously +- **GitHub integration**: Generated commit messages, PR summaries, and code reviews ### What's next? + - Check out the other [GitHub Skills exercises](https://learn.github.com/skills). - Learn how to [Integrate MCP with Copilot](https://github.com/skills/integrate-mcp-with-copilot) to give Copilot extra capabilities! - Tailor Copilot to your project needs in [Customize your GitHub Copilot Experience](https://github.com/skills/customize-your-github-copilot-experience) diff --git a/.github/workflows/0-start-exercise.yml b/.github/workflows/0-start-exercise.yml index 009158d..a977089 100644 --- a/.github/workflows/0-start-exercise.yml +++ b/.github/workflows/0-start-exercise.yml @@ -33,10 +33,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Get response templates - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: skills/exercise-toolkit path: exercise-toolkit diff --git a/.github/workflows/1-preparing.yml b/.github/workflows/1-preparing.yml index 1d4d9ee..dd57c15 100644 --- a/.github/workflows/1-preparing.yml +++ b/.github/workflows/1-preparing.yml @@ -1,9 +1,10 @@ -name: Step 1 # Preparing to make your extension +name: Step 1 on: push: - branches: - - "accelerate-with-copilot" + # Trigger on pushes to any branch except the protected `main` branch + branches-ignore: + - main permissions: contents: read @@ -18,9 +19,79 @@ jobs: name: Find Exercise Issue uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.0 + check_step_work: + name: Check step work + runs-on: ubuntu-latest + needs: [find_exercise] + env: + ISSUE_REPOSITORY: ${{ github.repository }} + ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }} + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Get response templates + uses: actions/checkout@v5 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.7.0 + + - name: Find last comment + id: find-last-comment + uses: peter-evans/find-comment@v3 + with: + repository: ${{ env.ISSUE_REPOSITORY }} + issue-number: ${{ env.ISSUE_NUMBER }} + direction: last + + - name: Update comment - checking work + uses: GrantBirki/comment@v2.1.1 + with: + repository: ${{ env.ISSUE_REPOSITORY }} + issue-number: ${{ env.ISSUE_NUMBER }} + comment-id: ${{ steps.find-last-comment.outputs.comment-id }} + file: exercise-toolkit/markdown-templates/step-feedback/checking-work.md + edit-mode: replace + + # START: Check practical exercise + + - name: Check branch name is correct + id: check-branch + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + # Check the branch ref directly + text: ${{ github.ref }} + keyphrase: accelerate-with-copilot + case-sensitive: true + minimum-occurrences: 1 + maximum-occurrences: 1 + + - name: Update comment - step results + uses: GrantBirki/comment@v2.1.1 + with: + repository: ${{ env.ISSUE_REPOSITORY }} + issue-number: ${{ env.ISSUE_NUMBER }} + comment-id: ${{ steps.find-last-comment.outputs.comment-id }} + edit-mode: replace + file: exercise-toolkit/markdown-templates/step-feedback/step-results-table.md + vars: | + step_number: 1 + results_table: + - description: "Checked that branch name is accelerate-with-copilot" + passed: ${{ steps.check-branch.outcome == 'success' }} + + # END: Check practical exercise + + - name: Fail job if check failed + if: ${{ steps.check-branch.outcome != 'success' }} + run: exit 1 + post_next_step_content: name: Post next step content - needs: [find_exercise] + needs: [find_exercise, check_step_work] runs-on: ubuntu-latest env: ISSUE_REPOSITORY: ${{ github.repository }} @@ -28,10 +99,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Get response templates - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: skills/exercise-toolkit path: exercise-toolkit diff --git a/.github/workflows/2-first-introduction.yml b/.github/workflows/2-first-introduction.yml index d00e25e..5335f6d 100644 --- a/.github/workflows/2-first-introduction.yml +++ b/.github/workflows/2-first-introduction.yml @@ -1,5 +1,4 @@ -name: Step 2 # Copilot chat - +name: Step 2 on: push: branches: @@ -30,10 +29,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Get response templates - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: skills/exercise-toolkit path: exercise-toolkit @@ -47,7 +46,6 @@ jobs: issue-number: ${{ env.ISSUE_NUMBER }} direction: last - - name: Update comment - checking work uses: GrantBirki/comment@v2.1.1 with: @@ -87,7 +85,6 @@ jobs: if: contains(steps.*.outcome, 'failure') run: exit 1 - post_next_step_content: name: Post next step content needs: [find_exercise, check_step_work] @@ -98,10 +95,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Get response templates - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: skills/exercise-toolkit path: exercise-toolkit @@ -116,7 +113,6 @@ jobs: vars: | next_step_number: 3 - - name: Create comment - add step content uses: GrantBirki/comment@v2.1.1 with: diff --git a/.github/workflows/3-copilot-edits.yml b/.github/workflows/3-copilot-edits.yml index 5201906..1686627 100644 --- a/.github/workflows/3-copilot-edits.yml +++ b/.github/workflows/3-copilot-edits.yml @@ -1,4 +1,4 @@ -name: Step 3 # Copilot edits +name: Step 3 on: push: @@ -13,7 +13,7 @@ permissions: issues: write env: - STEP_4_FILE: ".github/steps/4-copilot-on-github.md" + STEP_4_FILE: ".github/steps/4-copilot-agent-mode.md" jobs: find_exercise: @@ -30,10 +30,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Get response templates - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: skills/exercise-toolkit path: exercise-toolkit @@ -106,10 +106,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Get response templates - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: skills/exercise-toolkit path: exercise-toolkit diff --git a/.github/workflows/3b-copilot-agent-mode.yml b/.github/workflows/3b-copilot-agent-mode.yml deleted file mode 100644 index f531107..0000000 --- a/.github/workflows/3b-copilot-agent-mode.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Step 3b # Copilot Agent Mode - -on: - issue_comment: - types: [created] - -permissions: - contents: read - actions: write - issues: write - -env: - # Keywords required in the issue comment to allow this workflow to run - STEP_3B_FILE: ".github/steps/3b-copilot-agent-mode.md" - -jobs: - check_keywords: - name: Check issue comment text for required keyword - runs-on: ubuntu-latest - steps: - - name: Check for professortocat reference - id: check_professortocat - uses: skills/action-keyphrase-checker@v1 - with: - text: ${{ github.event.comment.body }} - keyphrase: "professortocat" - case-sensitive: false - minimum-occurrences: 1 - - name: Check for alert reference - id: check_alert - uses: skills/action-keyphrase-checker@v1 - with: - text: ${{ github.event.comment.body }} - keyphrase: "agent" - case-sensitive: false - minimum-occurrences: 1 - - find_exercise: - name: Find Exercise Issue - uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.0 - - post_next_step_content: - name: Post next step content - needs: [find_exercise, check_keywords] - runs-on: ubuntu-latest - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Create comment - add step content - uses: GrantBirki/comment@v2.1.1 - with: - repository: ${{ env.ISSUE_REPOSITORY }} - issue-number: ${{ env.ISSUE_NUMBER }} - file: ${{ env.STEP_3B_FILE }} - - - name: Disable current workflow - run: | - gh workflow disable "${{github.workflow}}" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/4-copilot-agent-mode.yml b/.github/workflows/4-copilot-agent-mode.yml new file mode 100644 index 0000000..dd11dee --- /dev/null +++ b/.github/workflows/4-copilot-agent-mode.yml @@ -0,0 +1,148 @@ +name: Step 4 + +on: + push: + branches: + - "accelerate-with-copilot" + +permissions: + contents: read + actions: write + issues: write + +env: + STEP_5_FILE: ".github/steps/5-copilot-on-github.md" + +jobs: + find_exercise: + name: Find Exercise Issue + uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.0 + + check_step_work: + name: Check step work + runs-on: ubuntu-latest + needs: [find_exercise] + env: + ISSUE_REPOSITORY: ${{ github.repository }} + ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }} + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Get response templates + uses: actions/checkout@v5 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.7.0 + + - name: Find last comment + id: find-last-comment + uses: peter-evans/find-comment@v3 + with: + repository: ${{ env.ISSUE_REPOSITORY }} + issue-number: ${{ env.ISSUE_NUMBER }} + direction: last + + - name: Update comment - checking work + uses: GrantBirki/comment@v2.1.1 + with: + repository: ${{ env.ISSUE_REPOSITORY }} + issue-number: ${{ env.ISSUE_NUMBER }} + comment-id: ${{ steps.find-last-comment.outputs.comment-id }} + file: exercise-toolkit/markdown-templates/step-feedback/checking-work.md + edit-mode: replace + + # START: Check practical exercise + + - name: Check for pytest keyphrase in requirements.txt + id: check-for-pytest + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: requirements.txt + keyphrase: pytest + + - name: Check if tests directory exists + id: check-tests-dir + continue-on-error: true + run: | + if find . -name "tests" -type d | grep -q .; then + echo "Tests directory found" + exit 0 + else + echo "Tests directory not found" + exit 1 + fi + + - name: Update comment - step results + uses: GrantBirki/comment@v2.1.1 + with: + repository: ${{ env.ISSUE_REPOSITORY }} + issue-number: ${{ env.ISSUE_NUMBER }} + comment-id: ${{ steps.find-last-comment.outputs.comment-id }} + edit-mode: replace + file: exercise-toolkit/markdown-templates/step-feedback/step-results-table.md + vars: | + step_number: 4 + results_table: + - description: "Checked for pytest in requirements.txt" + passed: ${{ steps.check-for-pytest.outcome == 'success' }} + - description: "Checked if tests are added in a separate directory" + passed: ${{ steps.check-tests-dir.outcome == 'success' }} + + # END: Check practical exercise + + - name: Fail job if not all checks passed + if: contains(steps.*.outcome, 'failure') + run: exit 1 + + post_next_step_content: + name: Post next step content + needs: [find_exercise, check_step_work] + runs-on: ubuntu-latest + env: + ISSUE_REPOSITORY: ${{ github.repository }} + ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }} + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Get response templates + uses: actions/checkout@v5 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.7.0 + + - name: Create comment - step finished + uses: GrantBirki/comment@v2.1.1 + with: + repository: ${{ env.ISSUE_REPOSITORY }} + issue-number: ${{ env.ISSUE_NUMBER }} + file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md + vars: | + next_step_number: 5 + + - name: Create comment - add step content + uses: GrantBirki/comment@v2.1.1 + with: + repository: ${{ env.ISSUE_REPOSITORY }} + issue-number: ${{ env.ISSUE_NUMBER }} + file: ${{ env.STEP_5_FILE }} + + - name: Create comment - watching for progress + uses: GrantBirki/comment@v2.1.1 + with: + repository: ${{ env.ISSUE_REPOSITORY }} + issue-number: ${{ env.ISSUE_NUMBER }} + file: exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md + + - name: Disable current workflow and enable next one + run: | + gh workflow disable "${{github.workflow}}" + gh workflow enable "Step 5" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/4-copilot-on-github.yml b/.github/workflows/5-copilot-on-github.yml similarity index 93% rename from .github/workflows/4-copilot-on-github.yml rename to .github/workflows/5-copilot-on-github.yml index 1ab47a0..84b546f 100644 --- a/.github/workflows/4-copilot-on-github.yml +++ b/.github/workflows/5-copilot-on-github.yml @@ -1,4 +1,4 @@ -name: Step 4 # Copilot on GitHub +name: Step 5 on: pull_request: @@ -30,10 +30,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Get response templates - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: skills/exercise-toolkit path: exercise-toolkit @@ -61,7 +61,7 @@ jobs: finish_exercise: name: Finish Exercise needs: [find_exercise, post_review_content] - uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.7.0 + uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.7.1 with: issue-url: ${{ needs.find_exercise.outputs.issue-url }} exercise-title: "Getting Started with GitHub Copilot" diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..a635c5c --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +pythonpath = .