Skip to content

Commit 4daa127

Browse files
authored
Exercise draft of Copilot modernize my legacy code (#1)
* Refactor exercise structure and update workflows for modernizing legacy COBOL application - Removed outdated step files and replaced with new structured steps for the exercise. - Added new step files for creating a test plan and converting COBOL code to Node.js. - Updated workflows to reflect new step files and ensure proper execution order. - Enhanced README with clear objectives and prerequisites for the exercise. - Introduced COBOL source files for the legacy accounting system. - Updated .gitignore to exclude COBOL binaries and Node.js modules. * Update README.md fix default template naming
1 parent dbec582 commit 4daa127

22 files changed

+1010
-224
lines changed

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "copilot-flow-state",
3+
"image": "mcr.microsoft.com/devcontainers/base:jammy",
4+
"features": {
5+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
6+
"ghcr.io/devcontainers/features/github-cli:1": {},
7+
"ghcr.io/devcontainers/features/node:1": {
8+
"version": "lts",
9+
"pnpmVersion": "latest",
10+
"nvmVersion": "latest"
11+
}
12+
},
13+
"customizations": {
14+
"vscode": {
15+
"extensions": [
16+
"GitHub.copilot-insiders",
17+
"dbaeumer.vscode-eslint",
18+
"DavidAnson.vscode-markdownlint",
19+
"bierner.markdown-mermaid",
20+
"bitlang.cobol"
21+
],
22+
"settings": {
23+
"chat.agent.enabled": true,
24+
"chat.mcp.enabled": true
25+
}
26+
}
27+
},
28+
"forwardPorts": [],
29+
"postCreateCommand": "sudo chmod +x ./.devcontainer/*.sh && sudo ./.devcontainer/postCreate.sh"
30+
}

.devcontainer/postCreate.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
# Update packages and install GnuCOBOL
4+
echo "Installing GnuCOBOL compiler..."
5+
sudo apt-get update && sudo apt-get install -y gnucobol

.github/copilot-instructions.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Custom Instructions for Copilot: COBOL Dev Container Setup
2+
3+
When working in this repository, follow these steps to automate the COBOL application setup after the dev container is created:
4+
5+
1. Navigate to the COBOL source directory:
6+
7+
```bash
8+
cd /workspaces/copilot-modernize-your-legacy-code/src/cobol/
9+
```
10+
11+
1. Compile the COBOL application:
12+
13+
```bash
14+
cobc -x main.cob operations.cob data.cob -o /workspaces/copilot-modernize-your-legacy-code/accountsystem
15+
```
16+
17+
1. Return to the project root:
18+
19+
```bash
20+
cd /workspaces/copilot-modernize-your-legacy-code/
21+
```
22+
23+
1. The compiled application can be run with:
24+
```bash
25+
./accountsystem
26+
```
27+
28+
These steps ensure the COBOL application is built and ready to use in the dev container environment.

.github/steps/1-preparing.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
## Step 1: Help me modernize Copilot
2+
3+
Welcome to Merginton High School's IT team! You've joined at a critical time. The school has been using the same COBOL-based accounting system since the early 1990s to manage student fees, cafeteria accounts, and school supplies purchases. The original programmer retired years ago, and the current IT staff struggles to maintain the system whenever changes are needed.
4+
5+
### 📖 Theory: Educational Legacy Systems Modernization
6+
7+
> [!NOTE]
8+
> Legacy code modernization in educational settings means transforming outdated systems into modern technologies while preserving essential school business operations and data integrity.
9+
10+
Many educational institutions still rely on legacy COBOL systems for critical administrative functions. While these systems have reliably managed school finances for decades, they now present significant challenges:
11+
12+
- Few IT staff with COBOL knowledge remain in the education sector
13+
- Limited integration with modern school management systems and online payment platforms
14+
- Difficulty supporting new educational programs and fee structures
15+
- Rising maintenance costs eating into limited school technology budgets
16+
17+
Modernizing the school's accounting system will provide numerous benefits:
18+
19+
- Seamless integration with student information systems and online payment portals
20+
- Better reporting capabilities for administrative decision-making
21+
- Easier maintenance by the existing IT team
22+
- Ability to quickly adapt to new educational programs and fee structures
23+
24+
GitHub Copilot can transform this modernization process by:
25+
26+
1. Helping decipher the decades-old COBOL code that lacks documentation
27+
1. Translating COBOL structures to modern Node.js equivalents
28+
1. Suggesting modern approaches to student account management
29+
1. Assisting with test creation to ensure student financial data remains accurate
30+
31+
### ⌨️ Activity: Setting Up Your Environment
32+
33+
To get started, we will set up a GitHub Codespace with the necessary tools and extensions to use GitHub Copilot effectively.
34+
35+
> [!TIP]
36+
> 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.
37+
38+
1. Left-click the below button to open the **Create Codespace** page in a new tab. Use the default configuration.
39+
40+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/{{full_repo_name}}?quickstart=1)
41+
42+
1. Confirm the **Repository** field is your copy of the exercise, not the original, then click the green **Create Codespace** button.
43+
44+
- ✅ Your copy: `/{{{full_repo_name}}}`
45+
- ❌ Original: `/skills/getting-started-with-github-copilot`
46+
47+
1. Wait a moment for Visual Studio Code to load in your browser.
48+
49+
1. In the left sidebar, click the extensions tab and verify that the `GitHub Copilot` and `Python` extensions are installed and enabled.
50+
51+
<img width="350" alt="copilot extension for VS Code" src="https://github.com/user-attachments/assets/ef1ef984-17fc-4b20-a9a6-65a866def468" />
52+
53+
1. At the top of VS Code, locate and click the **Copilot icon** to open a Copilot Chat panel.
54+
55+
<img width="150" alt="image" src="https://github.com/user-attachments/assets/5e64db46-95cb-415d-badc-b6b8677f10c1" />
56+
57+
1. If this is your first time using GitHub Copilot, you will need to accept the usage terms to continue.
58+
59+
### :keyboard: Activity: Use Copilot to help remember a terminal command 🙋
60+
61+
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.
62+
63+
1. If not already there, return to VS Code.
64+
65+
1. In the bottom panel, select the **Terminal** tab. On the right side, click the plus `+` sign to create a new terminal window.
66+
67+
> **Note:** This will avoid stopping the existing debug session that is hosting our web application service.
68+
69+
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**.
70+
71+
1. Let's ask Copilot to help us remember a command we have forgotten: creating a branch and publishing it.
72+
73+
> ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot)
74+
>
75+
> ```prompt
76+
> Hey copilot, how can I create and publish a new git branch called modernize-legacy-code?
77+
> ```
78+
79+
> **Tip:** This is a simple example, but Copilot is great at providing more tailored commands that might involve loops, pattern matching, file modification, and more! Don't be afraid to ask Copilot for a suggestion. Just remember it is a suggestion and you should always verify it first to be safe.
80+
81+
```shell
82+
git checkout -b modernize-legacy-code
83+
git push -u origin modernize-legacy-code
84+
```
85+
86+
1. Now that we are happy with the command, press the `Run` button to let Copilot run it for us. No need to copy and paste!
87+
88+
1. Now that your branch is pushed to GitHub, Mona should already be busy checking your work. Give her a moment and keep watch in the comments. You will see her respond with progress info and the next lesson.
89+
90+
<details>
91+
<summary>Having trouble? 🤷</summary><br/>
92+
- If you don't see the Copilot icon, make sure you have the GitHub Copilot extension installed and enabled.
93+
- If you don't see the Copilot chat panel, try reloading the codespace or checking your extension settings.
94+
- If Copilot doesn't understand your command, try rephrasing it or providing more context.
95+
- If you encounter any issues with the terminal, make sure you have the correct permissions to create branches in the repository.
96+
</details>

.github/steps/1-step.md

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
## Step 2: Understanding the School's Legacy COBOL Accounting System
2+
3+
In this step, you'll explore the school's legacy COBOL accounting system to understand its structure and functionality. This will help you prepare for the modernization process.
4+
5+
### ⌨️ Activity: Exploring the School's Legacy Accounting System
6+
7+
1. Take a few minutes to explore the COBOL files in the repository (`main.cob`, `operations.cob`, and `data.cob`)
8+
1. Open `src/cobol/main.cob`, `src/cobol/operations.cob`, `src/cobol/data.cob` and select "Agent" from the Copilot Chat window.
9+
1. click "Add Context..." in the Copilot Chat sidebar and click "Open Editors" to add the open COBOL files as context.
10+
1. Explain the purpose of each file in the context of the school's accounting system:
11+
- `main.cob`: This file contains the main program logic for managing student accounts, including user interaction and menu options.
12+
- `operations.cob`: This file implements the core operations for processing payments, recording purchases, and managing student balances.
13+
- `data.cob`: This file handles data storage and retrieval for student account balances.
14+
1. Create a docs/README.md file in the repository and document your findings, including:
15+
- The purpose of each COBOL file
16+
- Key functions and operations performed by the system
17+
- Any specific business rules or constraints related to student accounts
18+
19+
> ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot)
20+
>
21+
> ```prompt
22+
> @workspace Create a README.md file in a new /docs directory folder in the repository. Document the purpose of each COBOL file, key functions, and any specific business rules related to student accounts.
23+
> ```
24+
25+
<details>
26+
<summary>Having trouble? 🤷</summary><br/>
27+
28+
- COBOL is a column-sensitive language. The code is organized in divisions (IDENTIFICATION, DATA, PROCEDURE) and sections.
29+
- The `main.cob` file handles the user interface and menu options (view student balance, process payment, record purchase, exit)
30+
- The `operations.cob` file contains the logic for different student account operations
31+
- The `data.cob` file manages the storage of student account balances
32+
33+
</details>
34+
35+
### ⌨️ Activity: Create a data flow diagram
36+
37+
Create a Mermaid data flow diagram (DFD) that illustrates how data moves through the school's accounting system.
38+
39+
> ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot)
40+
>
41+
> ```prompt
42+
> @workspace can you create a sequence diagram of the app showing the data flow of the app. Please create this in mermaid format so that I can render this in the docs/README.md markdown file.
43+
> ```
44+
45+
Make sure you can preview the diagram in the `docs/README.md` file.
46+
47+
1. In the left sidebar, select the `Source Control` tab and make sure you are making changes on `modernize-legacy-code`branch.
48+
49+
> **Tip:** Opening a file from the source control area will show the differences to the original rather than simply opening it.
50+
51+
1. Find the `docs/README.md` file and press the `+` sign to collect your changes together in the staging area.
52+
53+
1. Above the list of staged changes, find the **Message** text box, but **don't enter anything** for now.
54+
55+
- Typically, you would write a short description of the changes here, but now we have Copilot to help out!
56+
57+
1. To the right of the **Message** text box, find and click the **Generate Commit Message with Copilot** button (sparkles icon).
58+
59+
1. Press the **Commit** button and **Sync Changes** button to push your changes to the `modernize-legacy-code`branch on GitHub.
60+
61+
1. Wait a moment for Mona to check your work, provide feedback, and share the next lesson.
62+
63+
<details>
64+
<summary>Having trouble? 🤷</summary><br/>
65+
66+
If you don't get feedback, here are some things to check:
67+
68+
- Make sure your pushed the `docs/README.md` file changes to the branch `modernize-legacy-code`.
69+
70+
</details>

.github/steps/2-step.md

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
## Step 2: Run the COBOL application and create a test plan to ensure quality of our legacy codebase
2+
3+
In the following activies we will build and run the COBOL accounting application and create a test plan that we can use to ensure the quality of our legacy codebase.
4+
5+
### ⌨️ Activity: Build and run the COBOL application
6+
7+
1. Compile the COBOL source code using the appropriate compiler.
8+
1. Execute the compiled program with sample input data.
9+
1. Observe the output and verify it against expected results.
10+
11+
> ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot)
12+
>
13+
> ```prompt
14+
> @workspace Using our custom Copilot instructions, please build and run the COBOL application using the provided source code and sample data. Make sure the application is in the root of the repository with the name accountsystem.
15+
> ```
16+
17+
Try playing with the different options of the COBOL accounting app and when you are done select option `4` to exit.
18+
19+
### ⌨️ Activity: Generate a test plan to validate the current implementation
20+
21+
Given the features of our existing legacy accounting system we want to generate a comprehensive test plan that covers all critical functionalities and edge cases.
22+
23+
> ![Static Badge](https://img.shields.io/badge/-Prompt-text?style=social&logo=github%20copilot)
24+
>
25+
> ```prompt
26+
> @workspace The current Cobol app has no tests. Can you please create a test plan of the
27+
> current business logic that I can use to validate with business stakeholders about the current implementation in a file called docs/TESTPLAN.md.
28+
> Later I would like to use this test plan to create unit and integration tests in a node.js app. I am in the middle of transforming the current Cobol app to a node.js app.
29+
> The test plan should include the following headings:
30+
> 1. Test Case ID
31+
> 2. Test Case Description
32+
> 3. Pre-conditions
33+
> 4. Test Steps
34+
> 5. Expected Result
35+
> 6. Actual Result
36+
> 7. Status (Pass/Fail)
37+
> 8. Comments
38+
>
39+
> Please create the test plan in a markdown table format. The test plan should cover all the business logic in the current Cobol app.
40+
>
41+
> ```
42+
43+
Make sure you can preview the test plan in the `docs/TESTPLAN.md` file.
44+
45+
1. In the left sidebar, select the `Source Control` tab and make sure you are making changes on `modernize-legacy-code`branch.
46+
47+
> **Tip:** Opening a file from the source control area will show the differences to the original rather than simply opening it.
48+
49+
1. Find the `docs/TESTPLAN.md` file and press the `+` sign to collect your changes together in the staging area.
50+
51+
1. Above the list of staged changes, find the **Message** text box, but **don't enter anything** for now.
52+
53+
- Typically, you would write a short description of the changes here, but now we have Copilot to help out!
54+
55+
1. To the right of the **Message** text box, find and click the **Generate Commit Message with Copilot** button (sparkles icon).
56+
57+
1. Press the **Commit** button and **Sync Changes** button to push your changes to the `modernize-legacy-code`branch on GitHub.
58+
59+
1. Wait a moment for Mona to check your work, provide feedback, and share the next lesson.
60+
61+
<details>
62+
<summary>Having trouble? 🤷</summary><br/>
63+
64+
If you don't get feedback, here are some things to check:
65+
66+
- Make sure your pushed the `docs/TESTPLAN.md` file changes to the branch `modernize-legacy-code`.
67+
68+
</details>

.github/steps/3-step.md

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

0 commit comments

Comments
 (0)