Skip to content

Commit

Permalink
Added a basic code pr check workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-c-dfe committed Jan 18, 2024
1 parent db218e9 commit fdbf4a0
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/actions/build-dotnet-app/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build DotNet App
description: Sets up .Net for specified version and builds application

inputs:
dotnet_version:
required: true
type: string
solution_filename:
required: true
type: string

runs:
using: composite

steps:
- name: Setup .NET Core SDK ${{ inputs.dotnet_version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ inputs.dotnet_version }}
- name: Install dependencies
shell: bash
run: dotnet restore ${{ inputs.solution_filename }}
- name: Build
shell: bash
run: dotnet build ${{ inputs.solution_filename }} --configuration Release --no-restore --output ./build
23 changes: 23 additions & 0 deletions .github/actions/run-unit-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run Unit Tests
description: Runs the unit tests and publishes them to the workflow runs

inputs:
solution_filename:
required: true
type: string

runs:
using: composite

steps:
- name: Test
shell: bash
run: dotnet test ${{ inputs.solution_filename }} --no-restore --verbosity normal --collect:"XPlat Code Coverage" --logger:"trx;LogFileName=test-results.trx" || true
- name: Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: DotNET Tests
path: "**/test-results.trx"
reporter: dotnet-trx
fail-on-error: true
43 changes: 43 additions & 0 deletions .github/workflows/code-pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Code PR Check

on:
push:
branches: ["main"]
paths:
- 'src/**'
- 'tests/**'
pull_request:
branches: ["main"]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/code-pr-check.yml'

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

env:
DOTNET_VERSION: 8
SOLUTION_NAME: 'Dfe.EarlyYearsQualification.sln'

jobs:

build-app:
name: Build and run unit tests
runs-on: ubuntu-22.04

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Build web app
uses: ./.github/actions/build-dotnet-app
with:
dotnet_version: ${{ env.DOTNET_VERSION }}
solution_filename: ${{ env.SOLUTION_NAME }}

- name: Run unit tests
uses: ./.github/actions/run-unit-tests
with:
solution_filename: ${{ env.SOLUTION_NAME }}

0 comments on commit fdbf4a0

Please sign in to comment.