Skip to content

Commit decf271

Browse files
authored
Merge pull request #190 from github-samples/copilot/sub-pr-179
Merge main, resolve conflicts, and fix content path references
2 parents 314144e + b56c68a commit decf271

41 files changed

Lines changed: 1880 additions & 245 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dev/Dockerfile.sandbox

Lines changed: 0 additions & 19 deletions
This file was deleted.

.dev/sandbox.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

.dev/start-copilot-sandbox.sh

Lines changed: 0 additions & 72 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ app/client/test-results/
4444
app/client/playwright-report/
4545

4646
# e2e test database
47-
app/server/e2e_test_dogshelter.db
47+
app/server/e2e_test_dogshelter.db
48+
49+
# azure
50+
.azure

PLAN.md

Lines changed: 0 additions & 95 deletions
This file was deleted.

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Pets workshop
22

3-
This repository contains the project for two guided workshops to explore various GitHub features. The project is a website for a fictional dog shelter, with a [Flask](https://flask.palletsprojects.com/en/stable/) backend using [SQLAlchemy](https://www.sqlalchemy.org/) and an [Astro](https://astro.build/) frontend using [Tailwind CSS](https://tailwindcss.com/).
3+
This repository contains the project for three guided workshops to explore various GitHub features. The project is a website for a fictional dog shelter, with a [Flask](https://flask.palletsprojects.com/en/stable/) backend using [SQLAlchemy](https://www.sqlalchemy.org/) and an [Astro](https://astro.build/) frontend using [Tailwind CSS](https://tailwindcss.com/).
4+
5+
The available workshops are:
6+
7+
- **[One hour](./content/1-hour/README.md)** — focused on GitHub Copilot
8+
- **[Full-day](./content/full-day/README.md)** — a full day-in-the-life of a developer using GitHub for their DevOps processes
9+
- **[GitHub Actions](./content/github-actions/README.md)** — CI/CD pipelines from running tests to deploying to Azure
410

511
## Getting started
612

app/server/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ def get_dog(id: int) -> tuple[Response, int] | Response:
8080
## HERE
8181

8282
if __name__ == '__main__':
83-
app.run(debug=True, port=5100) # Port 5100 to avoid macOS conflicts
83+
app.run(debug=True, port=5100) # Port 5100 to avoid macOS conflicts

app/server/utils/seed_database.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def create_app():
1919
# Get the server directory path (one level up from utils)
2020
server_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2121

22-
app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{os.path.join(server_dir, "dogshelter.db")}'
22+
db_path = os.environ.get('DATABASE_PATH', os.path.join(server_dir, 'dogshelter.db'))
23+
app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{db_path}'
2324
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
2425

2526
# Initialize the database with the app

content/1-hour/0-setup.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ Let's create the repository you'll use for your workshop.
1717
1. Navigate to [the repository root](/)
1818
2. Select **Use this template** > **Create a new repository**
1919

20-
![Screenshot of Use this template dropdown](images/0-setup-template.png)
20+
![Screenshot of Use this template dropdown](../shared-images/setup-use-template.png)
2121

2222
3. Under **Owner**, select the name of your GitHub handle, or the owner specified by your workshop leader.
2323
4. Under **Repository**, set the name to **pets-workshop**, or the name specified by your workshop leader.
2424
5. Ensure **Public** is selected for the visibility, or the value indicated by your workshop leader.
2525
6. Select **Create repository from template**.
2626

27-
![Screenshot of configured template creation dialog](images/0-setup-configure.png)
27+
![Screenshot of configured template creation dialog](../shared-images/setup-configure-repo.png)
2828

2929
In a few moments a new repository will be created from the template for this workshop!
3030

3131
## Clone the repository and start the app
3232

3333
With the repository created, it's now time to clone the repository locally. We'll do this from a shell capable of running BASH commands.
3434

35-
1. Copy the URL for the repository you just created in the prior set.
35+
1. Copy the URL for the repository you just created in the prior step.
3636
2. Open your terminal or command shell.
3737
3. Run the following command to clone the repository locally (changing directories to a parent directory as appropriate):
3838

@@ -51,19 +51,19 @@ With the repository created, it's now time to clone the repository locally. We'l
5151
- macOS / Linux:
5252

5353
```sh
54-
./scripts/start-app.sh
54+
./app/scripts/start-app.sh
5555
```
5656

5757
- Windows (PowerShell):
5858

5959
```powershell
60-
./scripts/start-app.ps1
60+
./app/scripts/start-app.ps1
6161
```
6262

6363
If you encounter execution policy warnings on Windows, run PowerShell as an administrator or execute the script with an explicit bypass, for example:
6464

6565
```powershell
66-
powershell -ExecutionPolicy Bypass -File .\scripts\start-app.ps1
66+
powershell -ExecutionPolicy Bypass -File .\app\scripts\start-app.ps1
6767
```
6868

6969
The startup script will start two applications:

content/1-hour/1-add-endpoint.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ With code completions, GitHub Copilot provides suggestions in your code editor w
1010

1111
It's standard to work in phases when adding functionality to an application. Given that we know we want to allow users to filter the list of dogs based on breed, we'll need to add an endpoint to provide a list of all breeds. Later we'll add the rest of the functionality, but let's focus on this part for now.
1212

13-
The application uses a Flask app with SQLAlchemy as the backend API (in the [/server][server-code] folder), and an Astro app as the frontend (in the [/client][client-code] folder). You will explore more of the project later; this exercise will focus solely on the Flask application.
13+
The application uses a Flask app with SQLAlchemy as the backend API (in the [app/server][server-code] folder), and an Astro app as the frontend (in the [app/client][client-code] folder). You will explore more of the project later; this exercise will focus solely on the Flask application.
1414

1515
> [!NOTE]
16-
> As you begin making changes to the application, there is always a chance a breaking change could be created. If the page stops working, check the terminal window you used previously to start the application for any error messages. You can stop the app by using <kbd>Ctl</kbd>+<kbd>C</kbd>, and restart it by running the script appropriate for your operating system: `./scripts/start-app.sh` (macOS / Linux) or `./scripts/start-app.ps1` (Windows PowerShell).
16+
> As you begin making changes to the application, there is always a chance a breaking change could be created. If the page stops working, check the terminal window you used previously to start the application for any error messages. You can stop the app by using <kbd>Ctrl</kbd>+<kbd>C</kbd>, and restart it by running the script appropriate for your operating system: `./app/scripts/start-app.sh` (macOS / Linux) or `./app/scripts/start-app.ps1` (Windows PowerShell).
1717
1818
## Flask routes
1919

@@ -34,7 +34,7 @@ Let's build our new route in our Flask backend with the help of code completion.
3434
3535
1. Return to your IDE with the project open.
3636
2. Open **app/server/app.py**.
37-
3. Locate the comment which reads `## HERE`, which should be at line 69.
37+
3. Locate the comment which reads `## HERE`, which should be at line 80.
3838
4. Delete the comment to ensure there isn't any confusion for Copilot, and leave your cursor there.
3939
5. Begin adding the code to create the route to return all breeds from an endpoint of **api/breeds** by typing the following:
4040

@@ -68,7 +68,7 @@ Let's build our new route in our Flask backend with the help of code completion.
6868
> [!IMPORTANT]
6969
> Because LLMs are probabilistic, not deterministic, the exact code generated can vary. The above is a representative example. If your code is different, that's just fine as long as it works!
7070

71-
8. Add a comment to the newly created function. To do this, place your cursor inside the function (anywhere between the lines `def get_breeds...` and `return jsonify...`). Then, press <kbd>Ctl</kbd>+<kbd>I</kbd> (or <kbd>cmd</kbd>+<kbd>I</kbd> on a Mac) to open the editor inline chat. In the input box, type `/doc`. (You can optionally provide additional details, but it's not required). This will prompt GitHub Copilot to generate a documentation comment for the function. The suggested comment will appear inline in the code (highlighted in green). Click **Accept** to apply the comment to your code, or click **Close** to discard the suggestion. You just used a slash command, a shortcut to streamline a task, these commands eliminate the need for verbose prompts.
71+
8. Add a comment to the newly created function. To do this, place your cursor inside the function (anywhere between the lines `def get_breeds...` and `return jsonify...`). Then, press <kbd>Ctrl</kbd>+<kbd>I</kbd> (or <kbd>cmd</kbd>+<kbd>I</kbd> on a Mac) to open the editor inline chat. In the input box, type `/doc`. (You can optionally provide additional details, but it's not required). This will prompt GitHub Copilot to generate a documentation comment for the function. The suggested comment will appear inline in the code (highlighted in green). Click **Accept** to apply the comment to your code, or click **Close** to discard the suggestion. You just used a slash command, a shortcut to streamline a task, these commands eliminate the need for verbose prompts.
7272

7373
9. **Save** the file.
7474

@@ -94,13 +94,13 @@ You've added a new endpoint with the help of GitHub Copilot! You saw how Copilot
9494
|:-----------------------------------|------------------------------------------:|
9595

9696
[breeds-endpoint]: http://localhost:5100/api/breeds
97-
[client-code]: /app/client/
97+
[client-code]: ../../app/client/
9898
[copilot-suggestions]: https://docs.github.com/en/copilot/using-github-copilot/getting-code-suggestions-in-your-ide-with-github-copilot
9999
[flask-routing]: https://flask.palletsprojects.com/en/stable/quickstart/#routing
100100
[http-methods]: https://www.w3schools.com/tags/ref_httpmethods.asp
101101
[prompt-crafting]: https://code.visualstudio.com/docs/copilot/prompt-crafting
102102
[inline-chat]: https://code.visualstudio.com/docs/copilot/chat/inline-chat
103-
[server-code]: /app/server/
103+
[server-code]: ../../app/server/
104104
[vscode-copilot]: https://code.visualstudio.com/docs/copilot/ai-powered-suggestions
105105
[walkthrough-previous]: ./0-setup.md
106106
[walkthrough-next]: ./2-explore-project.md

0 commit comments

Comments
 (0)