From 8ec88fd2cc1b02ae6f6f62edcbe6d10a8ffaa595 Mon Sep 17 00:00:00 2001 From: David Federman Date: Tue, 24 Sep 2024 15:53:49 -0700 Subject: [PATCH] Move PR build to GitHub Actions --- .github/workflows/pr.yml | 65 ++++++++++++ azure-pipelines-ci.yml | 219 --------------------------------------- 2 files changed, 65 insertions(+), 219 deletions(-) create mode 100644 .github/workflows/pr.yml delete mode 100644 azure-pipelines-ci.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..e1c56c1 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,65 @@ +name: Build and Test + +on: + pull_request: + branches: + - main + - refs/tags/* + +jobs: + build: + strategy: + matrix: + os: [windows-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Git Versioning requires a non-shallow clone + + - name: Install .NET 6 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '6.x' + + - name: Install .NET 7 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '7.x' + + - name: Install .NET 8 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.x' + + - name: Restore + run: dotnet restore -bl:logs/restore.binlog + + - name: Build + run: dotnet build --configuration Release --no-restore -bl:logs/build.binlog + + - name: Test + run: dotnet test --configuration Release --no-build --logger trx --results-directory TestResults --collect:"Code Coverage;Format=Cobertura" + # TODO: Fix tests on Linux + if: matrix.os != 'ubuntu-latest' + + - name: Upload test results + uses: actions/upload-artifact@v4 + with: + name: test-results-${{ matrix.os }} + path: ./TestResults + if: ${{ always() }} # Always run this step even on failure + + - name: Upload logs + uses: actions/upload-artifact@v4 + with: + name: logs-${{ matrix.os }} + path: ./logs + if: ${{ always() }} # Always run this step even on failure + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: artifacts-${{ matrix.os }} + path: ./artifacts + if: ${{ always() }} # Always run this step even on failure \ No newline at end of file diff --git a/azure-pipelines-ci.yml b/azure-pipelines-ci.yml deleted file mode 100644 index bbb03a9..0000000 --- a/azure-pipelines-ci.yml +++ /dev/null @@ -1,219 +0,0 @@ -variables: - Solution: 'MSBuildPrediction.sln' - LogDirectory: $(Build.ArtifactStagingDirectory)/logs - ArtifactsDirectory: artifacts - BuildConfiguration: 'Release' - BuildPlatform: 'Any CPU' - DotNet6Version: '6.x' - DotNet7Version: '7.x' - DotNet8Version: '8.x' - MSBuildArgs: '"/p:Platform=$(BuildPlatform)" "/p:Configuration=$(BuildConfiguration)" "/BinaryLogger:$(LogDirectory)/msbuild.binlog"' - SignType: 'Test' - -schedules: -- cron: '0 0 * * *' - displayName: Daily midnight build - branches: - include: - - main - -trigger: - batch: true - branches: - include: - - 'main' - - 'refs/tags/*' - -jobs: -- job: WindowsBuild - displayName: 'Build and Test (Windows)' - pool: - vmImage: windows-latest - steps: - - - task: UseDotNet@2 - displayName: 'Install .NET $(DotNet6Version)' - inputs: - version: '$(DotNet6Version)' - - - task: UseDotNet@2 - displayName: 'Install .NET $(DotNet7Version)' - inputs: - version: '$(DotNet7Version)' - - - task: UseDotNet@2 - displayName: 'Install .NET $(DotNet8Version)' - inputs: - version: '$(DotNet8Version)' - - - task: DotNetCoreCLI@2 - displayName: 'Build Solution' - inputs: - command: 'build' - projects: '$(Solution)' - arguments: '$(MSBuildArgs)' - - # UTs fail: The tools version "Current" is unrecognized. Available tools versions are "2.0", "3.5", "4.0". - #- task: DotNetCoreCLI@2 - # displayName: 'Run Unit Tests (.NET Framework)' - # inputs: - # command: 'test' - # arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --framework net472 /noautorsp' - # testRunTitle: 'Windows .NET Framework' - # condition: succeededOrFailed() - - - task: DotNetCoreCLI@2 - displayName: 'Run Unit Tests (.NET 6.0)' - inputs: - command: 'test' - arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --framework net6.0 /noautorsp' - testRunTitle: 'Windows .NET 6.0' - condition: succeededOrFailed() - - - task: DotNetCoreCLI@2 - displayName: 'Run Unit Tests (.NET 7.0)' - inputs: - command: 'test' - arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --framework net7.0 /noautorsp' - testRunTitle: 'Windows .NET 7.0' - condition: succeededOrFailed() - - - task: DotNetCoreCLI@2 - displayName: 'Run Unit Tests (.NET 8.0)' - inputs: - command: 'test' - arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --framework net8.0 /noautorsp' - testRunTitle: 'Windows .NET 8.0' - condition: succeededOrFailed() - - - publish: $(ArtifactsDirectory) - displayName: Publish Artifacts - artifact: '$(System.JobDisplayName) artifacts' - condition: always() - - - publish: $(LogDirectory) - displayName: Publish Logs - artifact: '$(System.JobDisplayName) logs' - condition: always() - -- job: LinuxBuild - displayName: 'Build and Test (Linux)' - pool: - vmImage: ubuntu-latest - steps: - - - task: UseDotNet@2 - displayName: 'Install .NET $(DotNet6Version)' - inputs: - version: '$(DotNet6Version)' - - - task: UseDotNet@2 - displayName: 'Install .NET $(DotNet7Version)' - inputs: - version: '$(DotNet7Version)' - - - task: UseDotNet@2 - displayName: 'Install .NET $(DotNet8Version)' - inputs: - version: '$(DotNet8Version)' - - - task: DotNetCoreCLI@2 - displayName: 'dotnet build' - inputs: - command: 'build' - arguments: '$(MSBuildArgs)' - - #- task: DotNetCoreCLI@2 - # displayName: 'Run Unit Tests (.NET 6.0)' - # inputs: - # command: 'test' - # arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --framework net6.0 /noautorsp' - # testRunTitle: 'Linux .NET 6.0' - # condition: succeededOrFailed() - - #- task: DotNetCoreCLI@2 - # displayName: 'Run Unit Tests (.NET 7.0)' - # inputs: - # command: 'test' - # arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --framework net7.0 /noautorsp' - # testRunTitle: 'Linux .NET 7.0' - # condition: succeededOrFailed() - - #- task: DotNetCoreCLI@2 - # displayName: 'Run Unit Tests (.NET 8.0)' - # inputs: - # command: 'test' - # arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --framework net8.0 /noautorsp' - # testRunTitle: 'Linux .NET 8.0' - # condition: succeededOrFailed() - - - publish: $(ArtifactsDirectory) - displayName: Publish Artifacts - artifact: '$(System.JobDisplayName) artifacts' - condition: always() - - - publish: $(LogDirectory) - displayName: Publish Logs - artifact: '$(System.JobDisplayName) logs' - condition: always() - -- job: MacOSBuild - displayName: 'Build and Test (Mac)' - pool: - vmImage: macOS-latest - steps: - - - task: UseDotNet@2 - displayName: 'Install .NET $(DotNet6Version)' - inputs: - version: '$(DotNet6Version)' - - - task: UseDotNet@2 - displayName: 'Install .NET $(DotNet7Version)' - inputs: - version: '$(DotNet7Version)' - - - task: UseDotNet@2 - displayName: 'Install .NET $(DotNet8Version)' - inputs: - version: '$(DotNet8Version)' - - - task: DotNetCoreCLI@2 - displayName: 'dotnet build' - inputs: - command: 'build' - arguments: '$(MSBuildArgs)' - - #- task: DotNetCoreCLI@2 - # displayName: 'Run Unit Tests (.NET 6.0)' - # inputs: - # command: 'test' - # arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --framework net6.0 /noautorsp' - # testRunTitle: 'MacOS .NET 6.0' - # condition: succeededOrFailed() - - #- task: DotNetCoreCLI@2 - # displayName: 'Run Unit Tests (.NET 7.0)' - # inputs: - # command: 'test' - # arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --framework net7.0 /noautorsp' - # testRunTitle: 'MacOS .NET 7.0' - # condition: succeededOrFailed() - - #- task: DotNetCoreCLI@2 - # displayName: 'Run Unit Tests (.NET 8.0)' - # inputs: - # command: 'test' - # arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --framework net8.0 /noautorsp' - # testRunTitle: 'MacOS .NET 8.0' - # condition: succeededOrFailed() - - - publish: $(ArtifactsDirectory) - displayName: Publish Artifacts - artifact: '$(System.JobDisplayName) artifacts' - condition: always() - - - publish: $(LogDirectory) - displayName: Publish Logs - artifact: '$(System.JobDisplayName) logs' - condition: always()