diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6f380f..e070f53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,8 +1,6 @@ name: Build on: - pull_request: - branches: [ main, master, develop ] workflow_run: workflows: [ "Changelog generator" ] types: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..02ab38a --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,115 @@ +name: Validate PR +on: + pull_request: + +env: + ReportOutput: '${{github.workspace}}' + TestReportFileName: 'TestReport.${{github.run_number}}.md' + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + + # Dotnet Setup + DOTNET_VERSION: 3.1.401 + + # Stop wasting time caching packages + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + + # Disable sending usage data to Microsoft + DOTNET_CLI_TELEMETRY_OPTOUT: true + + # Solution Setup + CONFIG: 'Release' + + # Nuget Setup + NUGET_VERSION: 'latest' + +jobs: + build-and-test: + runs-on: windows-latest + steps: + - name: Checkout commit + uses: actions/checkout@v2 + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Configure NuGet + uses: nuget/setup-nuget@v1 + with: + nuget-version: ${{ env.NUGET_VERSION }} + + - name: NuGet Restore + shell: powershell + working-directory: ${{ github.workspace }} + run: | + $solutions = Get-ChildItem -Path . -Recurse -Include *.sln + + foreach ($solutionFile in $solutions){ + nuget restore "$solutionFile" + } + + - name: Install Dependencies + shell: powershell + working-directory: ${{ github.workspace }} + run: | + $solutions = Get-ChildItem -Path . -Recurse -Include *.sln + + foreach ($solutionFile in $solutions){ + dotnet restore "$solutionFile" + } + + - name: Build + shell: powershell + working-directory: ${{ github.workspace }} + run: | + $solutions = Get-ChildItem -Path . -Recurse -Include *.sln + + foreach ($solutionFile in $solutions){ + msbuild.exe "$solutionFile" ` + /p:Configuration=${{ env.CONFIG }} ` + /p:DeployOnBuild=false ` + /p:SkipInvalidConfigurations=true ` + /p:TransformWebConfigEnabled=False ` + /p:AutoParameterizationWebConfigConnectionStrings=False ` + /p:MarkWebConfigAssistFilesAsExclude=False + } + + - name: Set PR build number + id: PRNUMBER + if: ${{ github.event_name == 'pull_request' }} + uses: kkak10/pr-number-action@v1.3 + + - name: Set Test Title + run: | + echo "::set-env name=title::Test Run for PR #${{ steps.PRNUMBER.outputs.pr }} (${{ github.run_number }})" + + - name: Run Tests + run: dotnet test --no-restore --no-build --configuration ${{ env.CONFIG }} --logger:"liquid.md;LogFileName=${{ env.ReportOutput}}\${{ env.TestReportFileName }};Title=${{ env.Title }};" + + - name: Upload test results + uses: actions/upload-artifact@v2 + with: + name: results + path: ${{ env.ReportOutput}}\${{ env.TestReportFileName }} + + commenting: + needs: build-and-test + runs-on: ubuntu-latest + steps: + - name: Checkout commit + uses: actions/checkout@v2 + + - uses: actions/download-artifact@v1 + with: + name: results + + - name: Comment PR + uses: machine-learning-apps/pr-comment@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + path: results/${{ env.TestReportFileName }}