Skip to content

New branch01 #87

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 14 commits into from
Closed
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/AzureDeployment.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 }}
123 changes: 123 additions & 0 deletions .github/workflows/donnetdeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: .NET CI

env:
registryName: b6dxcqbxqrzqwmpnpreg.azurecr.io
repositoryName: techexcel/dotnetcoreapp
dockerFolderPath: ./src/Application/src/RazorPagesTestSample
tag: ${{github.run_number}}

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

- 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

dockerBuildPush:
runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@v3

- name: Docker Login
# You may pin to the exact commit or the version.
# uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
uses: docker/[email protected]
with:
# Server address of Docker registry. If not set then will default to Docker Hub
registry: ${{ secrets.ACR_LOGIN_SERVER }}
# Username used to log against the Docker registry
username: ${{ secrets.ACR_USERNAME }}
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.ACR_PASSWORD }}
# Log out from the Docker registry at the end of a job
logout: true

- name: Docker Build
run: docker build -t $registryName/$repositoryName:$tag --build-arg build_version=$tag $dockerFolderPath

- name: Docker Push
run: docker push $registryName/$repositoryName:$tag

deploy-to-dev:

runs-on: ubuntu-latest
needs: dockerBuildPush
environment:
name: dev
url: https://b6dxcqbxqrzqw-dev.azurewebsites.net/

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

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

deploy-to-test:

runs-on: ubuntu-latest
needs: deploy-to-dev
environment:
name: test
url: https://b6dxcqbxqrzqw-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: 'b6dxcqbxqrzqw-test'
images: b6dxcqbxqrzqwmpnpreg.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}

deploy-to-prod:

runs-on: ubuntu-latest
needs: deploy-to-test
environment:
name: prod
url: https://b6dxcqbxqrzqw-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: 'b6dxcqbxqrzqw-prod'
images: b6dxcqbxqrzqwmpnpreg.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.

1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/src/Application/ sayedpfe
12 changes: 11 additions & 1 deletion src/Application/src/RazorPagesTestSample/Data/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ public class Message
{
public int Id { get; set; }

[Required]
/// <summary>
/// Gets or sets the text of the message.
/// </summary>
/// <value>
/// The text content of the message, limited to 200 characters.
/// </value>
/// <remarks>
/// This property is required and must be a text data type.
/// If the text exceeds 200 characters, an error message will be displayed.
/// </remarks>
/// /// /// /// /// /// /// /// /// /// [Required]
[DataType(DataType.Text)]
[StringLength(200, ErrorMessage = "There's a 200 character limit on messages. Please shorten your message.")]
public string Text { get; set; }
Expand Down
18 changes: 18 additions & 0 deletions src/Application/src/RazorPagesTestSample/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build-env /app/out .
# Default ASP.NET port changed with .NET 8.0
ENV ASPNETCORE_HTTP_PORTS=80
ENTRYPOINT ["dotnet", "RazorPagesTestSample.dll"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@page
@model IndexModel
@{
ViewData["Title"] = "Munson's Pickles and Preserves Team Messaging System";
ViewData["Title"] = "Sayed's Pickles and Preserves Team Messaging System";
}

<h1>@ViewData["Title"]</h1>
Expand Down
19 changes: 6 additions & 13 deletions src/Application/src/RazorPagesTestSample/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,13 @@
}
else
{
// Speed loop. Lower this number once every quarter so we
// get our performance improvement quarterly bonus.
for (int i = 0; i < 3000; i++) {
Thread.Sleep(1);
}
// Remove the speed loop for actual performance optimization
// for (int i = 0; i < 3000; i++) {
// await Task.Delay(1);
// }

var wordCount = 0;

foreach (var message in Messages)
{
wordCount += message.Text.Split(' ').Length;
}

var avgWordCount = Decimal.Divide(wordCount, Messages.Count);
var totalWords = Messages.Sum(message => message.Text.Split(' ').Length);

Check failure on line 80 in src/Application/src/RazorPagesTestSample/Pages/Index.cshtml.cs

View workflow job for this annotation

GitHub Actions / build

'IList<Message>' does not contain a definition for 'Sum' and no accessible extension method 'Sum' accepting a first argument of type 'IList<Message>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 80 in src/Application/src/RazorPagesTestSample/Pages/Index.cshtml.cs

View workflow job for this annotation

GitHub Actions / build

'IList<Message>' does not contain a definition for 'Sum' and no accessible extension method 'Sum' accepting a first argument of type 'IList<Message>' could be found (are you missing a using directive or an assembly reference?)
var avgWordCount = Decimal.Divide(totalWords, Messages.Count);
MessageAnalysisResult = $"The average message length is {avgWordCount:0.##} words.";
}

Expand Down
Loading
Loading