mirror of
https://github.com/bitwarden/server.git
synced 2024-11-21 12:05:42 +01:00
Wire up code coverage (#3618)
This commit is contained in:
parent
9b50cf89b7
commit
1f8e2385db
@ -4,27 +4,11 @@
|
||||
"tools": {
|
||||
"swashbuckle.aspnetcore.cli": {
|
||||
"version": "6.5.0",
|
||||
"commands": [
|
||||
"swagger"
|
||||
]
|
||||
},
|
||||
"coverlet.console": {
|
||||
"version": "3.1.2",
|
||||
"commands": [
|
||||
"coverlet"
|
||||
]
|
||||
},
|
||||
"dotnet-reportgenerator-globaltool": {
|
||||
"version": "5.1.6",
|
||||
"commands": [
|
||||
"reportgenerator"
|
||||
]
|
||||
"commands": ["swagger"]
|
||||
},
|
||||
"dotnet-ef": {
|
||||
"version": "7.0.14",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
]
|
||||
"commands": ["dotnet-ef"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
46
.github/workflows/build.yml
vendored
46
.github/workflows/build.yml
vendored
@ -61,28 +61,14 @@ jobs:
|
||||
echo "GitHub ref: $GITHUB_REF"
|
||||
echo "GitHub event: $GITHUB_EVENT"
|
||||
|
||||
- name: Restore
|
||||
run: dotnet restore --locked-mode
|
||||
shell: pwsh
|
||||
|
||||
- name: Remove SQL proj
|
||||
run: dotnet sln bitwarden-server.sln remove src/Sql/Sql.sqlproj
|
||||
|
||||
- name: Build OSS solution
|
||||
run: dotnet build bitwarden-server.sln -p:Configuration=Debug -p:DefineConstants="OSS" --verbosity minimal
|
||||
shell: pwsh
|
||||
|
||||
- name: Build solution
|
||||
run: dotnet build bitwarden-server.sln -p:Configuration=Debug --verbosity minimal
|
||||
shell: pwsh
|
||||
|
||||
- name: Test OSS solution
|
||||
run: dotnet test ./test --configuration Debug --no-build --logger "trx;LogFileName=oss-test-results.trx"
|
||||
shell: pwsh
|
||||
run: dotnet test ./test --configuration Release --logger "trx;LogFileName=oss-test-results.trx" /p:CoverletOutputFormatter="cobertura" --collect:"XPlat Code Coverage"
|
||||
|
||||
- name: Test Bitwarden solution
|
||||
run: dotnet test ./bitwarden_license/test --configuration Debug --no-build --logger "trx;LogFileName=bw-test-results.trx"
|
||||
shell: pwsh
|
||||
run: dotnet test ./bitwarden_license/test --configuration Release --logger "trx;LogFileName=bw-test-results.trx" /p:CoverletOutputFormatter="cobertura" --collect:"XPlat Code Coverage"
|
||||
|
||||
- name: Report test results
|
||||
uses: dorny/test-reporter@c9b3d0e2bd2a4e96aaf424dbaa31c46b42318226 # v1.6.0
|
||||
@ -93,6 +79,11 @@ jobs:
|
||||
reporter: dotnet-trx
|
||||
fail-on-error: true
|
||||
|
||||
- name: Upload to codecov.io
|
||||
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
build-artifacts:
|
||||
name: Build artifacts
|
||||
runs-on: ubuntu-22.04
|
||||
@ -156,14 +147,6 @@ jobs:
|
||||
echo "GitHub ref: $GITHUB_REF"
|
||||
echo "GitHub event: $GITHUB_EVENT"
|
||||
|
||||
- name: Restore/Clean project
|
||||
working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
|
||||
run: |
|
||||
echo "Restore"
|
||||
dotnet restore
|
||||
echo "Clean"
|
||||
dotnet clean -c "Release" -o obj/build-output/publish
|
||||
|
||||
- name: Build node
|
||||
if: ${{ matrix.node }}
|
||||
working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
|
||||
@ -357,9 +340,6 @@ jobs:
|
||||
- name: Login to PROD ACR
|
||||
run: az acr login -n $_AZ_REGISTRY --only-show-errors
|
||||
|
||||
- name: Restore
|
||||
run: dotnet tool restore
|
||||
|
||||
- name: Make Docker stubs
|
||||
if: github.ref == 'refs/heads/main' ||
|
||||
github.ref == 'refs/heads/rc' ||
|
||||
@ -443,10 +423,8 @@ jobs:
|
||||
- name: Build Swagger
|
||||
run: |
|
||||
cd ./src/Api
|
||||
echo "Restore"
|
||||
dotnet restore
|
||||
echo "Clean"
|
||||
dotnet clean -c "Release" -o obj/build-output/publish
|
||||
echo "Restore tools"
|
||||
dotnet tool restore
|
||||
echo "Publish"
|
||||
dotnet publish -c "Release" -o obj/build-output/publish
|
||||
|
||||
@ -495,11 +473,6 @@ jobs:
|
||||
echo "GitHub ref: $GITHUB_REF"
|
||||
echo "GitHub event: $GITHUB_EVENT"
|
||||
|
||||
- name: Restore project
|
||||
run: |
|
||||
echo "Restore"
|
||||
dotnet restore
|
||||
|
||||
- name: Publish project
|
||||
run: |
|
||||
dotnet publish -c "Release" -o obj/build-output/publish -r ${{ matrix.target }} -p:PublishSingleFile=true \
|
||||
@ -521,7 +494,6 @@ jobs:
|
||||
path: util/MsSqlMigratorUtility/obj/build-output/publish/MsSqlMigratorUtility
|
||||
if-no-files-found: error
|
||||
|
||||
|
||||
self-host-build:
|
||||
name: Trigger self-host build
|
||||
runs-on: ubuntu-22.04
|
||||
|
@ -1,31 +0,0 @@
|
||||
param(
|
||||
[string][Alias('c')]$Configuration = "Release",
|
||||
[string][Alias('o')]$Output = "CoverageOutput",
|
||||
[string][Alias('rt')]$ReportType = "lcov"
|
||||
)
|
||||
|
||||
function Install-Tools {
|
||||
dotnet tool restore
|
||||
}
|
||||
|
||||
function Print-Environment {
|
||||
dotnet --version
|
||||
}
|
||||
|
||||
function Prepare-Output {
|
||||
if (Test-Path -Path $Output) {
|
||||
Remove-Item $Output -Recurse
|
||||
}
|
||||
}
|
||||
|
||||
function Run-Tests {
|
||||
dotnet test $PSScriptRoot/bitwarden.tests.sln /p:CoverletOutputFormatter="cobertura" --collect:"XPlat Code Coverage" --results-directory:"$Output" -c $Configuration
|
||||
|
||||
dotnet tool run reportgenerator -reports:$Output/**/*.cobertura.xml -targetdir:$Output -reporttypes:"$ReportType"
|
||||
}
|
||||
|
||||
Write-Host "Collecting Code Coverage"
|
||||
Install-Tools
|
||||
Print-Environment
|
||||
Prepare-Output
|
||||
Run-Tests
|
@ -1,53 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set defaults if no values supplied
|
||||
CONFIGURATION="Release"
|
||||
OUTPUT="CoverageOutput"
|
||||
REPORT_TYPE="lcov"
|
||||
|
||||
|
||||
# Read in arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
|
||||
case $key in
|
||||
-c|--configuration)
|
||||
|
||||
CONFIGURATION="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-o|--output)
|
||||
OUTPUT="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-rt|--reportType)
|
||||
REPORT_TYPE="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "CONFIGURATION = ${CONFIGURATION}"
|
||||
echo "OUTPUT = ${OUTPUT}"
|
||||
echo "REPORT_TYPE = ${REPORT_TYPE}"
|
||||
|
||||
echo "Collectiong Code Coverage"
|
||||
# Install tools
|
||||
dotnet tool restore
|
||||
# Print Environment
|
||||
dotnet --version
|
||||
|
||||
if [[ -d $OUTPUT ]]; then
|
||||
echo "Cleaning output location"
|
||||
rm -rf $OUTPUT
|
||||
fi
|
||||
|
||||
dotnet test "./bitwarden.tests.sln" /p:CoverletOutputFormatter="cobertura" --collect:"XPlat Code Coverage" --results-directory:"$OUTPUT" -c $CONFIGURATION
|
||||
|
||||
dotnet tool run reportgenerator -reports:$OUTPUT/**/*.cobertura.xml -targetdir:$OUTPUT -reporttype:"$REPORT_TYPE"
|
Loading…
Reference in New Issue
Block a user