Skip to content

Commit a8c9c0f

Browse files
committed
YAML for exercise 7 zip and updates based on exercise 7 testing
1 parent a50e7a3 commit a8c9c0f

2 files changed

Lines changed: 111 additions & 4 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# This workflow is triggered on two events: workflow_dispatch and push.
2+
#
3+
# - The workflow_dispatch event allows you to manually trigger the workflow from GitHub's UI.
4+
# - The push event triggers the workflow whenever there's a push to the master branch, but only
5+
# if the changes include files in the LearnModuleExercises/SampleApps/** directory.
6+
#
7+
# The defaults section sets the default shell for all run commands in the workflow to PowerShell (pwsh).
8+
#
9+
# The workflow consists of a single job named create_zip, which runs on the latest version of Ubuntu.
10+
#
11+
# This job has three steps:
12+
#
13+
# 1. The Checkout step uses the actions/checkout@v4 action to checkout the repository's code onto the
14+
# runner. This is a common first step in most workflows as it allows subsequent steps to operate on
15+
# the codebase.
16+
#
17+
# 2. The Create SampleApps zip step changes the current directory to ./LearnModuleExercises/SampleApps
18+
# and then creates a zip file of all the files in that directory, including those in the .vscode
19+
# subdirectory. The -r option is used to zip directories recursively and the -q option is used to run
20+
# the command quietly without printing a lot of output. The resulting zip file is saved in the
21+
# ../Downloads directory with the name SampleApps.zip.
22+
#
23+
# 3. The Commit and push step uses the Endbug/add-and-commit@v7 action to add the newly created zip file
24+
# to the repository, commit the changes with the message 'Updating Zip for API source files', and then
25+
# push the changes back to the repository. The add input is set to the path of the zip file and the push
26+
# input is set to true to enable pushing.
27+
#
28+
# This workflow is useful for automatically packaging and versioning sample applications whenever changes
29+
# are made to them.
30+
#
31+
name: CreateGHCopilotEx7SamplesZip
32+
on:
33+
workflow_dispatch:
34+
push:
35+
branches:
36+
- 'main'
37+
paths:
38+
- DownloadableCodeProjects/standalone-lab-projects/simplify-complex-conditionals/**
39+
40+
defaults:
41+
run:
42+
shell: pwsh
43+
44+
jobs:
45+
create_zip:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
- name: Create GHCopilotEx7 SampleApps zip
51+
run: |
52+
cd ./DownloadableCodeProjects/standalone-lab-projects/simplify-complex-conditionals
53+
rm -f ../Downloads/GHCopilotEx7LabApps.zip
54+
zip -r -q ../Downloads/GHCopilotEx7LabApps.zip $(git ls-files)
55+
- name: Commit and push
56+
uses: Endbug/add-and-commit@v7
57+
with:
58+
add: '["DownloadableCodeProjects/Downloads/GHCopilotEx7LabApps.zip"]'
59+
message: 'Updating Zip with sample app source files'
60+
push: true

Instructions/Labs/LAB_AK_07_simplify_complex_conditionals.md

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
# Simplify complex conditionals using GitHub Copilot
88

9-
This lab exercise guides you through examining and refactoring two complex C# codebases using GitHub Copilot tools: an E-commerce Pricing Engine and a Loan Approval Workflow. Both scenarios feature deeply nested conditional logic that mirrors real-world business rules. The E-commerce scenario focuses on dynamic pricing, discounts, and shipping rules, while the Loan Approval scenario models financial eligibility and fallback loan offers. You will use GitHub Copilot to analyze, explain, and simplify these conditionals into more maintainable structures.
9+
In this exercise, you use GitHub Copilot to analyze and simplify deeply nested conditional logic that mirrors real-world business rules. You'll work with two sample applications that reflect real-world scenarios:
10+
11+
1. E-commerce pricing engine.
12+
2. Loan approval workflow.
1013

1114
This exercise should take approximately **30** minutes to complete.
1215

@@ -52,7 +55,10 @@ If you're using a hosted lab environment for this exercise:
5255

5356
## Exercise scenario
5457

55-
You're a software development engineer working for a consulting agency. Your clients have complex C# codebases that require refactoring to improve maintainability and readability. The first codebase is an E-commerce Pricing Engine that calculates dynamic pricing based on various business rules, including membership levels, order values, coupon codes, product categories, and shipping rules. The second codebase is a Loan Approval Workflow that evaluates loan applications based on credit scores, income, employment status, debt ratios, collateral, criminal records, and residency.
58+
You're a software developer working for a consulting agency. New clients need help refactoring conditional logic to improve code maintainability and readability.
59+
60+
- E-commerce pricing demo: The first app is an E-commerce Pricing Engine that calculates dynamic pricing based on various business rules. Conditionals include membership levels, order values, coupon codes, product categories, and shipping rules.
61+
- Loan approval demo: The second app is a Loan Approval Workflow that evaluates loan applications based on various factors. Conditionals include income, employment status, debt ratios, collateral, and credit history.
5662
5763
This exercise includes the following tasks:
5864
@@ -70,9 +76,50 @@ Part 2: Loan approval workflow
7076
1. Refactor the loan approval code with GitHub Copilot.
7177
1. Test the refactored loan approval code.
7278
79+
## Download sample projects
80+
81+
Use the following steps to download the sample projects and open them in Visual Studio Code:
82+
83+
1. Open a browser window in your lab environment.
84+
85+
1. To download a zip file containing the sample app projects, paste the following URL into your browser's address bar: [GitHub Copilot lab - develop code features](https://github.com/MicrosoftLearning/mslearn-github-copilot-dev/raw/refs/heads/main/DownloadableCodeProjects/Downloads/GHCopilotEx7LabApps.zip)
86+
87+
The zip file is named **GHCopilotEx7LabApps.zip**.
88+
89+
1. Extract the files from the **GHCopilotEx7LabApps.zip** file.
90+
91+
For example:
92+
93+
1. Navigate to the downloads folder in your lab environment.
94+
95+
1. Right-click *GHCopilotEx7LabApps.zip*, and then select **Extract all**.
96+
97+
1. Select **Show extracted files when complete**, and then select **Extract**.
98+
99+
1. Open the extracted files folder, then copy the **ECommercePricingEngine** folder to a location that's easy to access, such as your Windows Desktop folder.
100+
101+
1. Open the **ECommercePricingEngine** folder in Visual Studio Code.
102+
103+
For example:
104+
105+
1. Open Visual Studio Code in your lab environment.
106+
107+
1. In Visual Studio Code, on the **File** menu, select **Open Folder**.
108+
109+
1. Navigate to the Windows Desktop folder, select **ECommercePricingEngine** and then select **Select Folder**.
110+
111+
1. In the Visual Studio Code SOLUTION EXPLORER view, verify the following solution structure:
112+
113+
- ECommercePricingEngine\
114+
- ECommercePricingDemo.cs
115+
116+
1. Ensure that the solution builds successfully.
117+
118+
For example, in the SOLUTION EXPLORER view, right-click **ECommercePricingEngine**, and then select **Build**.
119+
73120
## Part 1: E-commerce pricing engine
74121
75-
In this section, you will examine the E-commerce Pricing Engine code and use GitHub Copilot to refactor it.
122+
In this section, you examine the E-commerce Pricing Engine sample app and use GitHub Copilot to refactor the conditional logic.
76123
77124
### Task 1: Review the E-commerce pricing code
78125
@@ -225,7 +272,7 @@ Use the following steps to complete this task:
225272
226273
## Part 2: Loan approval workflow
227274
228-
In this section, you will examine the Loan Approval Workflow code and use GitHub Copilot to refactor it.
275+
In this section, you examine the Loan Approval Workflow sample app and use GitHub Copilot to refactor the conditional logic.
229276
230277
### Task 1: Review the loan approval code
231278

0 commit comments

Comments
 (0)