From be86917b42058c4e06afcd7f77cc6420c56798bf Mon Sep 17 00:00:00 2001 From: Thomas Petchel Date: Mon, 30 Sep 2019 10:07:05 -0700 Subject: [PATCH 01/10] Initial --- azure-pipelines.yml | 132 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..c69dfff9a --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,132 @@ +variables: + buildConfiguration: 'Release' + +stages: +- stage: 'Build' + displayName: 'Build the web application' + jobs: + - job: 'Build' + displayName: 'Build job' + pool: + vmImage: 'Ubuntu-16.04' + demands: + - npm + + variables: + wwwrootDir: 'Tailspin.SpaceGame.Web/wwwroot' + dotnetSdkVersion: '2.1.505' + + steps: + - task: DotNetCoreInstaller@0 + displayName: 'Use .NET Core SDK $(dotnetSdkVersion)' + inputs: + version: '$(dotnetSdkVersion)' + + - task: Npm@1 + displayName: 'Run npm install' + inputs: + verbose: false + + - script: './node_modules/.bin/node-sass $(wwwrootDir) --output $(wwwrootDir)' + displayName: 'Compile Sass assets' + + - task: gulp@1 + displayName: 'Run gulp tasks' + + - script: 'echo "$(Build.DefinitionName), $(Build.BuildId), $(Build.BuildNumber)" > buildinfo.txt' + displayName: 'Write build info' + workingDirectory: $(wwwrootDir) + + - task: DotNetCoreCLI@2 + displayName: 'Restore project dependencies' + inputs: + command: 'restore' + projects: '**/*.csproj' + + - task: DotNetCoreCLI@2 + displayName: 'Build the project - $(buildConfiguration)' + inputs: + command: 'build' + arguments: '--no-restore --configuration $(buildConfiguration)' + projects: '**/*.csproj' + + - task: DotNetCoreCLI@2 + displayName: 'Publish the project - $(buildConfiguration)' + inputs: + command: 'publish' + projects: '**/*.csproj' + publishWebProjects: false + arguments: '--no-build --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)/$(buildConfiguration)' + zipAfterPublish: true + + - publish: '$(Build.ArtifactStagingDirectory)' + artifact: drop + +- stage: 'Dev' + displayName: 'Deploy to the dev environment' + dependsOn: Build + jobs: + - deployment: Deploy + pool: + vmImage: 'Ubuntu-16.04' + environment: dev + variables: + - group: Release + strategy: + runOnce: + deploy: + steps: + - download: current + artifact: drop + - task: AzureWebApp@1 + displayName: 'Azure App Service Deploy: website' + inputs: + azureSubscription: 'Resource Manager - Tailspin - Space Game' + appName: '$(WebAppNameDev)' + package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip' + +- stage: 'Test' + displayName: 'Deploy to the test environment' + dependsOn: Dev + jobs: + - deployment: Deploy + pool: + vmImage: 'Ubuntu-16.04' + environment: test + variables: + - group: 'Release' + strategy: + runOnce: + deploy: + steps: + - download: current + artifact: drop + - task: AzureWebApp@1 + displayName: 'Azure App Service Deploy: website' + inputs: + azureSubscription: 'Resource Manager - Tailspin - Space Game' + appName: '$(WebAppNameTest)' + package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip' + +- stage: 'Staging' + displayName: 'Deploy to the staging environment' + dependsOn: Test + jobs: + - deployment: Deploy + pool: + vmImage: 'Ubuntu-16.04' + environment: staging + variables: + - group: 'Release' + strategy: + runOnce: + deploy: + steps: + - download: current + artifact: drop + - task: AzureWebApp@1 + displayName: 'Azure App Service Deploy: website' + inputs: + azureSubscription: 'Resource Manager - Tailspin - Space Game' + appName: '$(WebAppNameStaging)' + package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip' \ No newline at end of file From 494649e85a110f1d0f85722079985448e9488c0a Mon Sep 17 00:00:00 2001 From: Thomas Petchel Date: Thu, 23 Jan 2020 20:28:04 -0800 Subject: [PATCH 02/10] Update to .NET Core 3.1 Plus a few other cleanup items. --- .../Controllers/HomeController.cs | 44 +++++++++---------- Tailspin.SpaceGame.Web/Startup.cs | 29 +++++++----- .../Tailspin.SpaceGame.Web.csproj | 4 +- azure-pipelines.yml | 15 ++++--- 4 files changed, 50 insertions(+), 42 deletions(-) diff --git a/Tailspin.SpaceGame.Web/Controllers/HomeController.cs b/Tailspin.SpaceGame.Web/Controllers/HomeController.cs index ed71be596..365e38e66 100644 --- a/Tailspin.SpaceGame.Web/Controllers/HomeController.cs +++ b/Tailspin.SpaceGame.Web/Controllers/HomeController.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Linq.Expressions; +using System.Linq.Expressions; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using TailSpin.SpaceGame.Web.Models; @@ -33,28 +33,28 @@ public async Task Index( ) { // Create the view model with initial values we already know. - var vm = new LeaderboardViewModel - { - Page = page, - PageSize = pageSize, - SelectedMode = mode, - SelectedRegion = region, - + var vm = new LeaderboardViewModel + { + Page = page, + PageSize = pageSize, + SelectedMode = mode, + SelectedRegion = region, + GameModes = new List() { "Solo", "Duo", "Trio" - }, - - GameRegions = new List() + }, + + GameRegions = new List() { "Milky Way", "Andromeda", "Pinwheel", "NGC 1300", - "Messier 82", - } + "Messier 82", + } }; try @@ -63,7 +63,7 @@ public async Task Index( // This expression selects all scores that match the provided game // mode and region (map). // Select the score if the game mode or region is empty. - Expression> queryPredicate = score => + Expression> queryPredicate = score => (string.IsNullOrEmpty(mode) || score.GameMode == mode) && (string.IsNullOrEmpty(region) || score.GameRegion == region); @@ -74,7 +74,7 @@ public async Task Index( IEnumerable scores = await _scoreRepository.GetItemsAsync( queryPredicate, // the predicate defined above score => score.HighScore, // sort descending by high score - page - 1, // subtract 1 to make the query 0-based + page - 1, // subtract 1 to make the query 0-based pageSize ); @@ -94,9 +94,9 @@ public async Task Index( // Fetch the user profile for each score. // This creates a list that's parallel with the scores collection. var profiles = new List>(); - foreach (var score in scores) - { - profiles.Add(_profileRespository.GetItemAsync(score.ProfileId)); + foreach (var score in scores) + { + profiles.Add(_profileRespository.GetItemAsync(score.ProfileId)); } Task.WaitAll(profiles.ToArray()); @@ -105,10 +105,10 @@ public async Task Index( return View(vm); } - catch (Exception ex) + catch (Exception) { return View(vm); - } + } } [Route("/profile/{id}")] @@ -119,7 +119,7 @@ public async Task Profile(string id, string rank="") // Fetch the user profile with the given identifier. return View(new ProfileViewModel { Profile = await _profileRespository.GetItemAsync(id), Rank = rank }); } - catch (Exception ex) + catch (Exception) { return RedirectToAction("/"); } @@ -136,4 +136,4 @@ public IActionResult Error() return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } } -} +} \ No newline at end of file diff --git a/Tailspin.SpaceGame.Web/Startup.cs b/Tailspin.SpaceGame.Web/Startup.cs index 34a97db49..a7282b6e6 100644 --- a/Tailspin.SpaceGame.Web/Startup.cs +++ b/Tailspin.SpaceGame.Web/Startup.cs @@ -1,11 +1,16 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using TailSpin.SpaceGame.Web.Models; - +using Microsoft.Extensions.Hosting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using TailSpin.SpaceGame.Web.Models; + namespace TailSpin.SpaceGame.Web { public class Startup @@ -20,6 +25,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + services.AddControllersWithViews(); services.Configure(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. @@ -27,15 +33,13 @@ public void ConfigureServices(IServiceCollection services) options.MinimumSameSitePolicy = SameSiteMode.None; }); - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - // Add document stores. These are passed to the HomeController constructor. services.AddSingleton>(new LocalDocumentDBRepository(@"SampleData/scores.json")); services.AddSingleton>(new LocalDocumentDBRepository(@"SampleData/profiles.json")); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { @@ -49,14 +53,17 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseHttpsRedirection(); app.UseStaticFiles(); - app.UseCookiePolicy(); - app.UseMvc(routes => + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => { - routes.MapRoute( + endpoints.MapControllerRoute( name: "default", - template: "{controller=Home}/{action=Index}/{id?}"); + pattern: "{controller=Home}/{action=Index}/{id?}"); }); } } -} +} \ No newline at end of file diff --git a/Tailspin.SpaceGame.Web/Tailspin.SpaceGame.Web.csproj b/Tailspin.SpaceGame.Web/Tailspin.SpaceGame.Web.csproj index 47ee6ec16..7bb85276b 100644 --- a/Tailspin.SpaceGame.Web/Tailspin.SpaceGame.Web.csproj +++ b/Tailspin.SpaceGame.Web/Tailspin.SpaceGame.Web.csproj @@ -1,13 +1,11 @@ - netcoreapp2.1 + netcoreapp3.1 {A0C4E31E-AC75-4F39-9F59-0AA19D9B8F46} - - diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c69dfff9a..08af735e6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,3 +1,6 @@ +trigger: +- '*' + variables: buildConfiguration: 'Release' @@ -8,16 +11,16 @@ stages: - job: 'Build' displayName: 'Build job' pool: - vmImage: 'Ubuntu-16.04' + vmImage: 'ubuntu-16.04' demands: - npm variables: wwwrootDir: 'Tailspin.SpaceGame.Web/wwwroot' - dotnetSdkVersion: '2.1.505' + dotnetSdkVersion: '3.1.100' steps: - - task: DotNetCoreInstaller@0 + - task: UseDotNet@2 displayName: 'Use .NET Core SDK $(dotnetSdkVersion)' inputs: version: '$(dotnetSdkVersion)' @@ -68,7 +71,7 @@ stages: jobs: - deployment: Deploy pool: - vmImage: 'Ubuntu-16.04' + vmImage: 'ubuntu-16.04' environment: dev variables: - group: Release @@ -91,7 +94,7 @@ stages: jobs: - deployment: Deploy pool: - vmImage: 'Ubuntu-16.04' + vmImage: 'ubuntu-16.04' environment: test variables: - group: 'Release' @@ -114,7 +117,7 @@ stages: jobs: - deployment: Deploy pool: - vmImage: 'Ubuntu-16.04' + vmImage: 'ubuntu-16.04' environment: staging variables: - group: 'Release' From 6a369a4776007d275463489b55b668db0308af87 Mon Sep 17 00:00:00 2001 From: Thomas Petchel Date: Mon, 15 Jun 2020 15:02:19 -0700 Subject: [PATCH 03/10] Bump Ubuntu, .NET Core SDK versions --- azure-pipelines.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 08af735e6..af3591a2c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,13 +11,13 @@ stages: - job: 'Build' displayName: 'Build job' pool: - vmImage: 'ubuntu-16.04' + vmImage: 'ubuntu-18.04' demands: - - npm + - npm variables: wwwrootDir: 'Tailspin.SpaceGame.Web/wwwroot' - dotnetSdkVersion: '3.1.100' + dotnetSdkVersion: '3.1.300' steps: - task: UseDotNet@2 @@ -71,7 +71,7 @@ stages: jobs: - deployment: Deploy pool: - vmImage: 'ubuntu-16.04' + vmImage: 'ubuntu-18.04' environment: dev variables: - group: Release @@ -94,7 +94,7 @@ stages: jobs: - deployment: Deploy pool: - vmImage: 'ubuntu-16.04' + vmImage: 'ubuntu-18.04' environment: test variables: - group: 'Release' @@ -117,7 +117,7 @@ stages: jobs: - deployment: Deploy pool: - vmImage: 'ubuntu-16.04' + vmImage: 'ubuntu-18.04' environment: staging variables: - group: 'Release' @@ -132,4 +132,4 @@ stages: inputs: azureSubscription: 'Resource Manager - Tailspin - Space Game' appName: '$(WebAppNameStaging)' - package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip' \ No newline at end of file + package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip' From 467a471d69c66ba02cc6cead5fc0537ce47191cc Mon Sep 17 00:00:00 2001 From: Thomas Petchel Date: Mon, 21 Jun 2021 14:06:21 -0700 Subject: [PATCH 04/10] Bump Ubuntu, .NET versions --- azure-pipelines.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index af3591a2c..860a0aa00 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,17 +11,17 @@ stages: - job: 'Build' displayName: 'Build job' pool: - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' demands: - npm variables: wwwrootDir: 'Tailspin.SpaceGame.Web/wwwroot' - dotnetSdkVersion: '3.1.300' + dotnetSdkVersion: '5.x' steps: - task: UseDotNet@2 - displayName: 'Use .NET Core SDK $(dotnetSdkVersion)' + displayName: 'Use .NET SDK $(dotnetSdkVersion)' inputs: version: '$(dotnetSdkVersion)' @@ -71,7 +71,7 @@ stages: jobs: - deployment: Deploy pool: - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' environment: dev variables: - group: Release @@ -94,7 +94,7 @@ stages: jobs: - deployment: Deploy pool: - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' environment: test variables: - group: 'Release' @@ -117,7 +117,7 @@ stages: jobs: - deployment: Deploy pool: - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' environment: staging variables: - group: 'Release' From 7be83f880f99c70bf75c100300010de1c0802109 Mon Sep 17 00:00:00 2001 From: Nighteyez07 Date: Tue, 26 Jul 2022 18:55:03 -0700 Subject: [PATCH 05/10] Bump dotnetSdkVersion from 5.x to 6.x --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 860a0aa00..dfd41b0b5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,7 +17,7 @@ stages: variables: wwwrootDir: 'Tailspin.SpaceGame.Web/wwwroot' - dotnetSdkVersion: '5.x' + dotnetSdkVersion: '6.x' steps: - task: UseDotNet@2 From ceeb1ef6ae229ff50fbb5b850a59913dfc642430 Mon Sep 17 00:00:00 2001 From: Hector Morales Date: Thu, 27 Oct 2022 01:58:16 -0500 Subject: [PATCH 06/10] Trigger the pipeline From c2bcc7cf95c3826bfe1597c27c7e10f89a1bd340 Mon Sep 17 00:00:00 2001 From: Hector Morales Date: Thu, 27 Oct 2022 02:59:50 -0500 Subject: [PATCH 07/10] Trigger the pipeline From 46cb2c6162929be4b2c5b91358cc43b080ff333a Mon Sep 17 00:00:00 2001 From: Hector Morales Date: Thu, 27 Oct 2022 03:15:11 -0500 Subject: [PATCH 08/10] Swap deployment slots --- azure-pipelines.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dfd41b0b5..ba5a8198e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -131,5 +131,17 @@ stages: displayName: 'Azure App Service Deploy: website' inputs: azureSubscription: 'Resource Manager - Tailspin - Space Game' + deployToSlotOrASE: 'true' + resourceGroupName: 'tailspin-space-game-rg' + slotName: 'swap' appName: '$(WebAppNameStaging)' package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip' + - task: AzureAppServiceManage@0 + displayName: 'Swap deployment slots' + inputs: + azureSubscription: 'Resource Manager - Tailspin - Space Game' + resourceGroupName: 'tailspin-space-game-rg' + webAppName: '$(WebAppNameStaging)' + sourceSlot: 'swap' + targetSlot: 'production' + action: 'Swap Slots' \ No newline at end of file From 6ea39d224833f3e8d47362a017960d84abcdf5a6 Mon Sep 17 00:00:00 2001 From: Hector Morales Date: Thu, 27 Oct 2022 03:21:52 -0500 Subject: [PATCH 09/10] Change text and colors on the home page --- Tailspin.SpaceGame.Web/Views/Home/Index.cshtml | 2 +- Tailspin.SpaceGame.Web/wwwroot/css/site.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml b/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml index f7c4c8860..70e7cc000 100644 --- a/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml +++ b/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml @@ -5,7 +5,7 @@
Space Game -

An example site for learning

+

Welcome to the official Space Game site!

diff --git a/Tailspin.SpaceGame.Web/wwwroot/css/site.scss b/Tailspin.SpaceGame.Web/wwwroot/css/site.scss index 7bd6ecaa7..4e7acf8c1 100644 --- a/Tailspin.SpaceGame.Web/wwwroot/css/site.scss +++ b/Tailspin.SpaceGame.Web/wwwroot/css/site.scss @@ -22,7 +22,7 @@ section { .intro { height: 350px; - background-color: #666; + background-color: green; background-image: url('/images/space-background.svg'); background-size: 1440px; background-position: center top; From 841cd09eed6c4a5c27f38fb62c9cb19d3ac2de86 Mon Sep 17 00:00:00 2001 From: Hector Morales Date: Thu, 27 Oct 2022 03:27:16 -0500 Subject: [PATCH 10/10] Revert "Change text and colors on the home page" This reverts commit 6ea39d224833f3e8d47362a017960d84abcdf5a6. --- Tailspin.SpaceGame.Web/Views/Home/Index.cshtml | 2 +- Tailspin.SpaceGame.Web/wwwroot/css/site.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml b/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml index 70e7cc000..f7c4c8860 100644 --- a/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml +++ b/Tailspin.SpaceGame.Web/Views/Home/Index.cshtml @@ -5,7 +5,7 @@
Space Game -

Welcome to the official Space Game site!

+

An example site for learning

diff --git a/Tailspin.SpaceGame.Web/wwwroot/css/site.scss b/Tailspin.SpaceGame.Web/wwwroot/css/site.scss index 4e7acf8c1..7bd6ecaa7 100644 --- a/Tailspin.SpaceGame.Web/wwwroot/css/site.scss +++ b/Tailspin.SpaceGame.Web/wwwroot/css/site.scss @@ -22,7 +22,7 @@ section { .intro { height: 350px; - background-color: green; + background-color: #666; background-image: url('/images/space-background.svg'); background-size: 1440px; background-position: center top;