Skip to content

Commit

Permalink
feat: added pull request workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
aochmann committed May 26, 2021
1 parent 7b108e1 commit d1d0fb9
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Build

on:
pull_request:
branches: [ main, master, develop ]
workflow_run:
workflows: [ "Changelog generator" ]
types:
Expand Down
115 changes: 115 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit d1d0fb9

Please sign in to comment.