diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml
index 01ef1a22..fc1679cb 100644
--- a/.github/workflows/analysis.yml
+++ b/.github/workflows/analysis.yml
@@ -2,9 +2,10 @@ name: Analysis
on: [push, pull_request]
jobs:
- build:
+ analysis:
name: Static Analysis
runs-on: ubuntu-latest
+ if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v2
with:
@@ -28,16 +29,27 @@ jobs:
run: |
mkdir -p ./.sonar/scanner
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
+ - name: Wait for tests to run
+ uses: lewagon/wait-on-check-action@master
+ with:
+ ref: ${{github.ref}}
+ check-name: tests
+ repo-token: ${{secrets.GITHUB_TOKEN}}
+ running-workflow-name: analysis
+ allowed-conclusions: success,skipped,cancelled,neutral,failure
+ - name: Download coverage report
+ uses: dawidd6/action-download-artifact@v2
+ with:
+ commit: ${{env.COMMIT_SHA}}
+ workflow: tests.yml
+ github_token: ${{secrets.GITHUB_TOKEN}}
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: bash
run: |
- dotnet test \
- '-p:CollectCoverage=true;CoverletOutputFormat=opencover' \
- '-p:SkipTranscoder=true;SkipWebApp=true' || echo "Test failed. Skipping..."
-
+ find . -name 'coverage.opencover.xml'
dotnet build-server shutdown
./.sonar/scanner/dotnet-sonarscanner begin \
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 67ab67dd..65a3646f 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -3,17 +3,40 @@ name: Testing
on: [push, pull_request]
jobs:
- build:
+ tests:
runs-on: ubuntu-latest
+ if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
+ container: mcr.microsoft.com/dotnet/sdk:5.0
+ services:
+ postgres:
+ image: postgres
+ env:
+ POSTGRES_PASSWORD: postgres
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
steps:
- uses: actions/checkout@v2
- - name: Setup .NET
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
- run: dotnet build --no-restore '-p:SkipWebApp=true;SkipTranscoder=true'
+ run: |
+ dotnet build --no-restore '-p:SkipWebApp=true;SkipTranscoder=true' -p:CopyLocalLockFileAssemblies=true
+ cp ./Kyoo.Common/bin/Debug/net5.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll ./Kyoo.Tests/bin/Debug/net5.0/
- name: Test
- run: dotnet test --no-build
+ run: dotnet test --no-build '-p:CollectCoverage=true;CoverletOutputFormat=opencover'
+ env:
+ POSTGRES_HOST: postgres
+ POSTGRES_USERNAME: postgres
+ POSTGRES_PASSWORD: postgres
+ - name: Sanitize coverage output
+ if: ${{ always() }}
+ run: sed -i "s'$(pwd)'.'" Kyoo.Tests/coverage.opencover.xml
+ - name: Upload coverage report
+ if: ${{ always() }}
+ uses: actions/upload-artifact@v2
+ with:
+ name: coverage.xml
+ path: "**/coverage.opencover.xml"
diff --git a/Kyoo.Common/Controllers/ILibraryManager.cs b/Kyoo.Common/Controllers/ILibraryManager.cs
index 2cd0c909..938d3029 100644
--- a/Kyoo.Common/Controllers/ILibraryManager.cs
+++ b/Kyoo.Common/Controllers/ILibraryManager.cs
@@ -77,6 +77,11 @@ namespace Kyoo.Controllers
///
IProviderRepository ProviderRepository { get; }
+ ///
+ /// The repository that handle users.
+ ///
+ IUserRepository UserRepository { get; }
+
///
/// Get the resource by it's ID
///
@@ -149,16 +154,6 @@ namespace Kyoo.Controllers
[ItemNotNull]
Task Get(string showSlug, int seasonNumber, int episodeNumber);
- ///
- /// Get a track from it's slug and it's type.
- ///
- /// The slug of the track
- /// The type (Video, Audio or Subtitle)
- /// If the item is not found
- /// The track found
- [ItemNotNull]
- Task