Skip to content

250 #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed

250 #41

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Azure Bicep

on:
workflow_dispatch

env:
targetEnv: dev

jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
steps:
# Checkout code
- uses: actions/checkout@main

# Log into Azure
- uses: azure/[email protected]
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true

# Deploy ARM template
- name: Run ARM deploy
uses: azure/arm-deploy@v1
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resourceGroupName: ${{ secrets.AZURE_RG }}
template: ./src/InfrastructureAsCode/main.bicep
parameters: environment=${{ env.targetEnv }}
71 changes: 71 additions & 0 deletions .github/workflows/dotnet-deploy-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: .NET CI/CD

on:
push:
branches: [ main ]
paths:
- src/Application/**
pull_request:
branches: [ main ]
paths:
- src/Application/**
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
- name: Build
run: dotnet build --no-restore src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
- name: Test
run: dotnet test --no-build --verbosity normal src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj

deploy-to-test:
runs-on: ubuntu-latest
needs: build
environment:
name: test
url: https://mpplabajep-test.azurewebsites.net/

steps:
- uses: actions/checkout@v3

- name: 'Login via Azure CLI'
uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: azure/webapps-deploy@v2
with:
app-name: 'mpplabajep-test'
images: mpplabajep.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}

deploy-to-prod:
runs-on: ubuntu-latest
needs: deploy-to-test
environment:
name: prod
url: https://mpplabajep-prod.azurewebsites.net/

steps:
- uses: actions/checkout@v3

- name: 'Login via Azure CLI'
uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: azure/webapps-deploy@v2
with:
app-name: 'mpplabajep-prod'
images: mpplabajep.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}
56 changes: 56 additions & 0 deletions .github/workflows/first-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# The name of the job is what will display on the GitHub repository in the Actions tab.
name: First Workflow

# The 'on' section tells GitHub under what conditions we want to run this workflow.
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
# Common scenarios include:
# workflow-dispatch (manual execution)
# issues
# push
# pull_request
# schedule
on:
workflow_dispatch:
issues:
types: [opened]

# This section covers the work to perform.
# We include one or more jobs in this section.
jobs:
# Each individual job will include details like execution order,
# pre-requisite jobs, and execution platform.
job1:
# We can run jobs on GitHub hosted VM runners in Windows, Ubuntu, and Mac OS.
# We can also run jobs on self-hosted hardware.
runs-on: ubuntu-latest

# Each job contains one or more steps. A step needs to have at least a name and a command.
steps:
- name: Step one
# The 'run' command executes a shell or command script. Because this is Ubuntu, the
# default run command will be /bin/bash
run: echo "Log from step one"
# This section does not appear in the solution file but demonstrates how to set
# custom variables that will be available in the run script.
env:
VARIABLE_NAME: value
- name: Step two
run: echo "Log from step two"

job2:
# Job 2 will only run after job 1 completes.
# Removing this 'needs' section would make the jobs run simultaneously.
needs: job1
runs-on: ubuntu-latest

steps:
- name: Cowsays
# The 'uses' command executes a remote GitHub action.
# A command like mscoutermarsh/cowsays-action means you can
# find this code at https://github.com/mscoutermarsh/cowsays-action
uses: mscoutermarsh/cowsays-action@master
# The 'with' block includes parameters that the workflow will pass
# to this action. Parameters are all in key-value format.
with:
text: 'Ready for prod--ship it!'
color: 'magenta'
62 changes: 0 additions & 62 deletions .github/workflows/pages.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Save All Files",
"command": "${command:workbench.action.files.saveAll}",
"type": "shell",
"problemMatcher": []
},
{
"label": "Build Project",
"dependsOn": "Save All Files",
"command": "dotnet build",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile"
}
]
}
2 changes: 1 addition & 1 deletion docs/03_improve_deploy_app/0301.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ We have a work machine configured, so now it is time to ensure that everything w

## Description

Developers at Munson's Pickles and Preserves like the Team Messaging System in general, but they consistently bring up issues with one aspect of the application: it limits messages to 200 characters or fewer. Developers have made a case that the app should support messages of up to 250 characters in length instead.
Developers at Munson's Pickles and Preserves like the Team Messaging System in general, but they consistently bring up issues with one aspect of the application: it limits messages to 250 characters or fewer. Developers have made a case that the app should support messages of up to 250 characters in length instead.

In this task, you will modify the application to support 250 characters instead of 200. You will also follow a feature branching strategy and use a pull request to bring your change into the `main` branch. If you wish to complete this task using a Test-Driven Design approach, please read the **Advanced Challenges (optional)** section below before making any changes.

Expand Down
4 changes: 2 additions & 2 deletions src/Application/src/RazorPagesTestSample/Data/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class Message

[Required]
[DataType(DataType.Text)]
[StringLength(200, ErrorMessage = "There's a 200 character limit on messages. Please shorten your message.")]
[StringLength(250, ErrorMessage = "There's a 250 character limit on messages. Please shorten your message.")]
public string Text { get; set; }
}
#endregion
}
}
24 changes: 24 additions & 0 deletions src/Application/src/RazorPagesTestSample/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use the official .NET 8 SDK image as a build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app

# Copy the project file and restore dependencies
COPY *.csproj .
RUN dotnet restore

# Copy the rest of the application code
COPY . .

# Build the application
RUN dotnet publish -c Release -o out

# Use the official .NET 8 runtime image as a runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/out .

# Set the environment variable for ASP.NET Core HTTP ports
ENV ASPNETCORE_HTTP_PORTS=80

# Set the entry point for the application
ENTRYPOINT ["dotnet", "RazorPagesTestSample.dll"]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
<h3 class="text-danger">An error occurred while processing your request.</h3>

@if (Model.ShowRequestId)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<!-- https://github.com/NuGet/Home/issues/4412 -->


<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="xunit" Version="2.7.0" />
Expand All @@ -22,12 +18,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>


<ItemGroup>
<Reference Include="RazorPagesTestSample">
<HintPath>..\..\src\RazorPagesTestSample\bin\Debug\net8.0\RazorPagesTestSample.dll</HintPath>
</Reference>
<ProjectReference Include="..\..\src\RazorPagesTestSample\RazorPagesTestSample.csproj" />
</ItemGroup>

</Project>
</Project>
Loading
Loading