diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..b3620dd1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: Build + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + +jobs: + build: + name: Build and test + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 10.0.x + + - name: Restore + run: dotnet restore src/AspNetCoreTemplate.sln + + - name: Build + run: dotnet build src/AspNetCoreTemplate.sln -c Release --no-restore + + # AspNetCoreTemplate.Web.Tests is excluded: its two example tests boot the + # whole app through WebApplicationFactory, which connects to SQL Server. + # Run them locally against a database. + - name: Test + run: > + dotnet test src/Tests/AspNetCoreTemplate.Services.Data.Tests/AspNetCoreTemplate.Services.Data.Tests.csproj + -c Release --no-build --logger "trx;LogFileName=test-results.trx" + + # The renamer tool has its own solution and still targets net6.0; the + # current SDK builds it from the NuGet targeting pack. + - name: Build the template renamer + run: dotnet build tools/TemplateRenamer/TemplateRenamer.sln -c Release + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-results + path: '**/TestResults/*.trx' + if-no-files-found: ignore diff --git a/README.md b/README.md index 90685d79..549f7291 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A ready-to-use template for ASP.NET Core with repositories, services, models map ## Build status -[![Build Status](https://nikolayit.visualstudio.com/AspNetCoreTemplate/_apis/build/status/NikolayIT.ASP.NET-Core-Template?branchName=master)](https://nikolayit.visualstudio.com/AspNetCoreTemplate/_build/latest?definitionId=15&branchName=master) +[![Build](https://github.com/NikolayIT/ASP.NET-Core-Template/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/NikolayIT/ASP.NET-Core-Template/actions/workflows/build.yml) ## Authors diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 6d417832..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,34 +0,0 @@ -# ASP.NET -# Build and test ASP.NET projects. -# Add steps that publish symbols, save build artifacts, deploy, and more: -# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4 - -trigger: -- master - -pool: - vmImage: 'windows-latest' - -variables: - solution: '**/*.sln' - buildPlatform: 'Any CPU' - buildConfiguration: 'Release' - -steps: -- task: NuGetToolInstaller@1 - -- task: NuGetCommand@2 - inputs: - restoreSolution: '$(solution)' - -- task: VSBuild@1 - inputs: - solution: '$(solution)' - msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"' - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)' - -- task: VSTest@2 - inputs: - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)'