Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Farshad DASHTI authored and Farshad DASHTI committed Nov 22, 2024
0 parents commit 5be875c
Show file tree
Hide file tree
Showing 122 changed files with 7,005 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
22 changes: 22 additions & 0 deletions .github/workflows/build-test-asyncprocessing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build DfE.CoreLibs.AsyncProcessing

on:
push:
branches:
- main
paths:
- 'src/DfE.CoreLibs.AsyncProcessing/**'
pull_request:
branches:
- main
paths:
- 'src/DfE.CoreLibs.AsyncProcessing/**'

jobs:
build-and-test:
uses: ./.github/workflows/build-test-template.yml
with:
project_name: DfE.CoreLibs.AsyncProcessing
project_path: src/DfE.CoreLibs.AsyncProcessing
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/build-test-caching.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build DfE.CoreLibs.Caching

on:
push:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Caching/**'
pull_request:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Caching/**'

jobs:
build-and-test:
uses: ./.github/workflows/build-test-template.yml
with:
project_name: DfE.CoreLibs.Caching
project_path: src/DfE.CoreLibs.Caching
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/build-test-contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build DfE.CoreLibs.Contracts

on:
push:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Contracts/**'
pull_request:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Contracts/**'

jobs:
build-and-test:
uses: ./.github/workflows/build-test-template.yml
with:
project_name: DfE.CoreLibs.Contracts
project_path: src/DfE.CoreLibs.Contracts
run_tests: false
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/build-test-http.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build DfE.CoreLibs.Http

on:
push:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Http/**'
pull_request:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Http/**'

jobs:
build-and-test:
uses: ./.github/workflows/build-test-template.yml
with:
project_name: DfE.CoreLibs.Http
project_path: src/DfE.CoreLibs.Http
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/build-test-security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build DfE.CoreLibs.Security

on:
push:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Security/**'
pull_request:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Security/**'

jobs:
build-and-test:
uses: ./.github/workflows/build-test-template.yml
with:
project_name: DfE.CoreLibs.Security
project_path: src/DfE.CoreLibs.Security
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
98 changes: 98 additions & 0 deletions .github/workflows/build-test-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: .NET Build and Test Template

on:
workflow_call:
inputs:
project_name:
required: true
type: string
description: "The name of the project"
project_path:
required: true
type: string
description: "The relative path to the project directory"
run_tests:
required: false
type: boolean
default: true
description: "Flag to run or skip tests"
secrets:
SONAR_TOKEN:
required: true
env:
DOTNET_VERSION: '8.0.x'
EF_VERSION: '6.0.5'
JAVA_VERSION: '17'

jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
packages: read
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: ${{ env.JAVA_VERSION }}

- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Install SonarCloud scanners
run: dotnet tool install --global dotnet-sonarscanner

- name: Install EF for tests
run: dotnet tool install --global dotnet-ef --version ${{ env.EF_VERSION }}

- name: Install dotnet reportgenerator
run: dotnet tool install --global dotnet-reportgenerator-globaltool

- name: Add nuget package source
run: dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/DFE-Digital/index.json"

- name: Restore dependencies
run: dotnet restore ${{ inputs.project_path }}

- name: Set Test Project Path
run: |
test_project_path="${{ inputs.project_path }}"
test_project_path="${test_project_path/src\//src\/Tests\/}.Tests"
echo "test_project_path=$test_project_path" >> $GITHUB_ENV
- name: Build, Test and Analyze
env:
CI: true
run: |
echo "run_tests is set to: ${{ inputs.run_tests }}"
if [ "${{ inputs.run_tests }}" == "true" ]; then
dotnet-sonarscanner begin /k:"DFE-Digital_rsd-core-libs" /o:"dfe-digital" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverageReportPaths=CoverageReport/SonarQube.xml;
else
dotnet-sonarscanner begin /k:"DFE-Digital_rsd-core-libs" /o:"dfe-digital" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io";
fi
dotnet build --no-restore -p:CI=${CI} ${{ inputs.project_path }}
- name: Run Tests
if: ${{ inputs.run_tests }}
run: dotnet test --verbosity normal --collect:"XPlat Code Coverage" ${{ env.test_project_path }}

- name: Generate Code Coverage Report
if: ${{ inputs.run_tests }}
run: reportgenerator -reports:./**/coverage.cobertura.xml -targetdir:./CoverageReport -reporttypes:SonarQube

- name: Complete Sonar Scan
run: dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
23 changes: 23 additions & 0 deletions .github/workflows/build-test-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build DfE.CoreLibs.Testing

on:
push:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Testing/**'
pull_request:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Testing/**'

jobs:
build-and-test:
uses: ./.github/workflows/build-test-template.yml
with:
project_name: DfE.CoreLibs.Testing
project_path: src/DfE.CoreLibs.Testing
run_tests: false
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/build-test-utilities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build DfE.CoreLibs.Utilities

on:
push:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Utilities/**'
pull_request:
branches:
- main
paths:
- 'src/DfE.CoreLibs.Utilities/**'

jobs:
build-and-test:
uses: ./.github/workflows/build-test-template.yml
with:
project_name: DfE.CoreLibs.Utilities
project_path: src/DfE.CoreLibs.Utilities
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Loading

0 comments on commit 5be875c

Please sign in to comment.