diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 87e0fb56f0..3a7def9a18 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -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"] } } -} \ No newline at end of file +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c3a76e517..96061b128e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/test/coverage.ps1 b/test/coverage.ps1 deleted file mode 100644 index bf8780c493..0000000000 --- a/test/coverage.ps1 +++ /dev/null @@ -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 diff --git a/test/coverage.sh b/test/coverage.sh deleted file mode 100755 index b061a34c61..0000000000 --- a/test/coverage.sh +++ /dev/null @@ -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"