diff --git a/.gitattributes b/.gitattributes index 1b274cb93..e67ee2ab0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,9 @@ # Auto detect text files and perform LF normalization *text eol=lf +# Explicitly set bash scripts to have unix endings +*.sh text eol=lf + # Custom for Visual Studio *.cs diff=csharp *.sln merge=union diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 20ca25182..f1f1fb8e8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,7 +27,8 @@ pr: - develop stages: - - stage: Build + - stage: Build_Backend + displayName: Build Backend jobs: - job: Backend @@ -37,7 +38,7 @@ stages: osName: 'Linux' imageName: 'ubuntu-16.04' Mac: - osName: 'MacOS' + osName: 'Mac' imageName: 'macos-10.13' Windows: osName: 'Windows' @@ -67,19 +68,21 @@ stages: - publish: $(outputFolder) artifact: '$(osName)Backend' condition: and(succeeded(), eq(variables['osName'], 'Windows')) - - publish: $(Build.SourcesDirectory) - artifact: 'CoverageBuild' - condition: and(succeeded(), eq(variables['osName'], 'Windows')) + # - publish: $(Build.SourcesDirectory) + # artifact: 'CoverageBuild' + # condition: and(succeeded(), eq(variables['osName'], 'Windows')) + - bash: | + pwd + ls -R ./ - publish: $(testsFolder) artifact: 'Tests' condition: and(succeeded(), eq(variables['osName'], 'Windows')) - # - task: PublishPipelineArtifact@0 - # displayName: Publish Tests Artifact - # inputs: - # artifactName: 'Tests' - # targetPath: '$(testsFolder)' - + - stage: Build_Frontend + displayName: Build Backend + dependsOn: [] + + jobs: - job: Frontend strategy: matrix: @@ -87,7 +90,7 @@ stages: osName: 'Linux' imageName: 'ubuntu-16.04' Mac: - osName: 'MacOS' + osName: 'Mac' imageName: 'macos-10.13' Windows: osName: 'Windows' @@ -107,39 +110,10 @@ stages: artifact: '$(osName)Frontend' condition: and(succeeded(), eq(variables['osName'], 'Windows')) - # - job: macOS - # displayName: macOS - # pool: - # vmImage: 'macOS-10.13' - # steps: - # - task: NodeTool@0 - # inputs: - # versionSpec: '10.x' - # - checkout: self - # submodules: true - # - task: Bash@3 - # displayName: Build Lidarr - # inputs: - # targetType: 'filePath' - # filePath: ./build.sh - - # - job: Linux - # displayName: Linux - # pool: - # vmImage: 'ubuntu-16.04' - # steps: - # - task: NodeTool@0 - # inputs: - # versionSpec: '10.x' - # - checkout: self - # submodules: true - # - task: Bash@3 - # displayName: Build Lidarr - # inputs: - # targetType: 'filePath' - # filePath: ./build.sh - - stage: Package + dependsOn: + - Build_Backend + - Build_Frontend jobs: - job: Windows_Packages displayName: Windows Packages @@ -206,20 +180,36 @@ stages: env: SENTRY_AUTH_TOKEN: $(sentryAuthToken) - - stage: Test - dependsOn: Package + - stage: Unit_Test + displayName: Unit Tests + dependsOn: Build_Backend condition: succeeded() jobs: - - job: Linux_Unit_Tests - displayName: Linux Unit + - job: Unit + strategy: + matrix: + Linux: + osName: 'Linux' + imageName: 'ubuntu-16.04' + Mac: + osName: 'Mac' + imageName: 'macos-10.13' + Windows: + osName: 'Windows' + imageName: 'vs2017-win2016' + pool: - vmImage: 'ubuntu-16.04' + vmImage: $(imageName) + steps: - - script: | + - bash: | wget https://github.com/acoustid/chromaprint/releases/download/v1.4.3/chromaprint-fpcalc-1.4.3-linux-x86_64.tar.gz sudo tar xf chromaprint-fpcalc-1.4.3-linux-x86_64.tar.gz --strip-components=1 --directory /usr/bin displayName: Install fpcalc - - checkout: self + condition: and(succeeded(), eq(variables['osName'], 'Linux')) + - powershell: Set-Service SCardSvr -StartupType Manual + condition: and(succeeded(), eq(variables['osName'], 'Windows')) + - checkout: none - task: DownloadPipelineArtifact@2 displayName: Download Test Artifact inputs: @@ -227,17 +217,71 @@ stages: artifactName: Tests targetPath: $(testsFolder) - task: Bash@3 - displayName: Linux Unit Tests + displayName: Run Tests inputs: targetType: 'filePath' - filePath: ./test.sh - arguments: Linux Unit Test + filePath: '$(testsFolder)/test.sh' + arguments: '$(osName) Unit Test' - task: PublishTestResults@2 + displayName: Publish Test Results inputs: testResultsFormat: 'NUnit' testResultsFiles: '**/TestResult.xml' - testRunTitle: 'Linux Unit Tests' + testRunTitle: '$(osName) Unit Tests' + # - job: Windows_Unit_Tests + # displayName: Windows Unit + # pool: + # vmImage: 'vs2017-win2016' + # steps: + # - checkout: self + # - task: DownloadPipelineArtifact@2 + # displayName: Download Test Artifact + # inputs: + # buildType: 'current' + # artifactName: Tests + # targetPath: $(testsFolder) + # - task: Bash@3 + # displayName: Windows Unit Tests + # inputs: + # targetType: 'filePath' + # filePath: ./test.sh + # arguments: Windows Unit Test + # - task: PublishTestResults@2 + # inputs: + # testResultsFormat: 'NUnit' + # testResultsFiles: '**/TestResult.xml' + # testRunTitle: 'Windows Unit Tests' + + # - job: Mac_Unit_Tests + # displayName: macOS Unit + # pool: + # vmImage: 'macOS-10.13' + # steps: + # - checkout: self + # - task: DownloadPipelineArtifact@2 + # displayName: Download Test Artifact + # inputs: + # buildType: 'current' + # artifactName: Tests + # targetPath: $(testsFolder) + # - task: Bash@3 + # displayName: macOS Unit Tests + # inputs: + # targetType: 'filePath' + # filePath: ./test.sh + # arguments: Mac Unit Test + # - task: PublishTestResults@2 + # inputs: + # testResultsFormat: 'NUnit' + # testResultsFiles: '**/TestResult.xml' + # testRunTitle: 'macOS Unit Tests' + + - stage: Integration_Automation + displayName: Integration / Tests + dependsOn: Package + jobs: + - job: Linux_Integration_Tests displayName: Linux Integration pool: @@ -280,29 +324,6 @@ stages: testResultsFiles: '**/TestResult.xml' testRunTitle: 'Linux Integration Tests' - - job: Windows_Unit_Tests - displayName: Windows Unit - pool: - vmImage: 'vs2017-win2016' - steps: - - checkout: self - - task: DownloadPipelineArtifact@2 - displayName: Download Test Artifact - inputs: - buildType: 'current' - artifactName: Tests - targetPath: $(testsFolder) - - task: Bash@3 - displayName: Windows Unit Tests - inputs: - targetType: 'filePath' - filePath: ./test.sh - arguments: Windows Unit Test - - task: PublishTestResults@2 - inputs: - testResultsFormat: 'NUnit' - testResultsFiles: '**/TestResult.xml' - testRunTitle: 'Windows Unit Tests' - job: Windows_Integration_Tests displayName: Windows Integration @@ -380,32 +401,9 @@ stages: testResultsFiles: '**/TestResult.xml' testRunTitle: 'Windows Automation Tests' - - job: Mac_Unit_Tests - displayName: macOS Unit - pool: - vmImage: 'macOS-10.13' - steps: - - checkout: self - - task: DownloadPipelineArtifact@2 - displayName: Download Test Artifact - inputs: - buildType: 'current' - artifactName: Tests - targetPath: $(testsFolder) - - task: Bash@3 - displayName: macOS Unit Tests - inputs: - targetType: 'filePath' - filePath: ./test.sh - arguments: Mac Unit Test - - task: PublishTestResults@2 - inputs: - testResultsFormat: 'NUnit' - testResultsFiles: '**/TestResult.xml' - testRunTitle: 'macOS Unit Tests' - stage: Coverage - dependsOn: Package + dependsOn: Build_Backend condition: succeeded() jobs: - job: Unit_Test_Coverage @@ -413,18 +411,25 @@ stages: pool: vmImage: 'vs2017-win2016' steps: - - checkout: none + - checkout: self + submodules: true #- bash: ./build.sh --only-backend # displayName: Build Lidarr Backend + # - task: DownloadPipelineArtifact@2 + # inputs: + # buildType: 'current' + # artifactName: CoverageBuild + # targetPath: $(Build.SourcesDirectory) + #- publish: $(testsFolder) + # artifact: 'CoverageTest' - task: DownloadPipelineArtifact@2 inputs: buildType: 'current' - artifactName: CoverageBuild - targetPath: $(Build.SourcesDirectory) + artifactName: Tests + targetPath: $(testsFolder) - bash: | + pwd ls -R ./ - #- publish: $(testsFolder) - # artifact: 'CoverageTest' - task: Bash@3 displayName: Coverage Unit Tests inputs: diff --git a/build.sh b/build.sh index 514385a83..9ebe84062 100755 --- a/build.sh +++ b/build.sh @@ -145,26 +145,6 @@ RunGulp() ProgressEnd 'Running gulp' } -CreateMdbs() -{ - local path=$1 - if [ $runtime = "dotnet" ] ; then - local pdbFiles=( $(find $path -name "*.pdb") ) - for filename in "${pdbFiles[@]}" - do - if [ -e ${filename%.pdb}.dll ] ; then - tools/pdb2mdb/pdb2mdb.exe ${filename%.pdb}.dll - fi - if [ -e ${filename%.pdb}.exe ] ; then - tools/pdb2mdb/pdb2mdb.exe ${filename%.pdb}.exe - fi - done - - echo "Removing PDBs" - find $path -name "*.pdb" -exec rm "{}" \; - fi -} - PackageMono() { ProgressStart 'Creating Mono Package' @@ -174,9 +154,6 @@ PackageMono() echo "Copying Binaries" cp -r $outputFolder $outputFolderLinux - echo "Creating MDBs" - CreateMdbs $outputFolderLinux - echo "Removing Service helpers" rm -f $outputFolderLinux/ServiceUninstall.* rm -f $outputFolderLinux/ServiceInstall.* @@ -270,9 +247,6 @@ PackageTests() cp $outputFolder/fpcalc $testPackageFolder cp ./test.sh $testPackageFolder - echo "Creating MDBs for tests" - CreateMdbs $testPackageFolder - rm -f $testPackageFolder/*.log.config CleanFolder $testPackageFolder true @@ -283,8 +257,8 @@ PackageTests() echo "Copying CurlSharp libraries" cp $sourceFolder/ExternalModules/CurlSharp/libs/i386/* $testPackageFolder - echo "Copying dylibs" - cp -r $outputFolderMacOS/*.dylib $testPackageFolder + echo "Adding sqlite dylibs" + cp $sourceFolder/Libraries/Sqlite/*.dylib $testPackageFolder ProgressEnd 'Creating Test Package' } diff --git a/test.sh b/test.sh index 14be52619..eaec65bc4 100755 --- a/test.sh +++ b/test.sh @@ -7,12 +7,13 @@ TEST_DIR="." TEST_PATTERN="*Test.dll" ASSEMBLIES="" TEST_LOG_FILE="TestLog.txt" -COVERAGE_FILE="$TEST_DIR/Coverage.xml" if [ -d "$TEST_DIR/_tests" ]; then TEST_DIR="$TEST_DIR/_tests" fi +COVERAGE_FILE="$TEST_DIR/Coverage.xml" + rm -f "$TEST_LOG_FILE" # Uncomment to log test output to a file instead of the console @@ -23,7 +24,9 @@ NUNIT_COMMAND="$NUNIT" NUNIT_PARAMS="--workers=1" if [ "$PLATFORM" = "Mac" ]; then + echo "Mac sqlite options:" LD_LIBRARY_PATH=/usr/bin:$LD_LIBRARY_PATH + echo $LD_LIBRARY_PATH sqlite3 -version sqlite3 :memory: "pragma compile_options" fi @@ -56,13 +59,13 @@ for i in `find $TEST_DIR -name "$TEST_PATTERN"`; done if [ "$COVERAGE" = "Coverage" ]; then - if [ "$PLATFORM" = "Windows" ] ; then - dotnet tool install coverlet.console --tool-path=./_tests/coverlet/ - OPEN_COVER="./_tests/coverlet/coverlet" - $OPEN_COVER ./_tests/ --verbosity "detailed" --format "cobertura" --output "$COVERAGE_FILE" --exclude "[Lidarr.*.Test]*" --exclude "[Lidarr.Test.*]*" --exclude "[Marr.Data]*" --exclude "[MonoTorrent]*" --exclude "[CurlSharp]*" --target "$NUNIT" --targetargs "$NUNIT_PARAMS --where=\"$WHERE\" $ASSEMBLIES"; + if [ "$PLATFORM" = "Windows" ] || [ "$PLATFORM" = "Linux" ]; then + dotnet tool install coverlet.console --tool-path="$TEST_DIR/coverlet/" + OPEN_COVER="$TEST_DIR/coverlet/coverlet" + $OPEN_COVER "$TEST_DIR/" --verbosity "detailed" --format "cobertura" --output "$COVERAGE_FILE" --exclude "[Lidarr.*.Test]*" --exclude "[Lidarr.Test.*]*" --exclude "[Marr.Data]*" --exclude "[MonoTorrent]*" --exclude "[CurlSharp]*" --target "$NUNIT" --targetargs "$NUNIT_PARAMS --where=\"$WHERE\" $ASSEMBLIES"; EXIT_CODE=$? else - echo "Coverage only supported on Windows" + echo "Coverage only supported on Windows and Linux" exit 3 fi elif [ "$COVERAGE" = "Test" ] ; then