ci/cd: improve azure pipelines style (#8614)

This commit is contained in:
Diego Heras 2020-05-12 21:31:22 +02:00 committed by GitHub
parent 45011259ef
commit 071e50f859
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 446 additions and 447 deletions

View File

@ -1,475 +1,474 @@
---
name: $(majorVersion).$(minorVersion).$(patchVersion) name: $(majorVersion).$(minorVersion).$(patchVersion)
variables: variables:
majorVersion: 0 majorVersion: 0
minorVersion: 16 minorVersion: 16
patchVersion: $[counter(variables['minorVersion'], 1)] #this will reset when we bump minor patchVersion: $[counter(variables['minorVersion'], 1)] # this will reset when we bump minor
jackettVersion: $(majorVersion).$(minorVersion).$(patchVersion) jackettVersion: $(majorVersion).$(minorVersion).$(patchVersion)
buildConfiguration: Release buildConfiguration: Release
netCoreFramework: netcoreapp3.1 netCoreFramework: netcoreapp3.1
netCoreSdkVersion: 3.1.x netCoreSdkVersion: 3.1.x
system.debug: true # system.debug: true
trigger: trigger:
branches: branches:
include: include:
- '*' - '*'
pr: pr:
branches: branches:
include: include:
- '*' - '*'
stages: stages:
- stage: BuildJackett - stage: BuildJackett
displayName: Create Binaries displayName: Create Binaries
jobs: jobs:
- job: Build - job: Build
workspace: workspace:
clean: all clean: all
strategy: strategy:
matrix: matrix:
Mono: Mono:
buildDescription: Mono buildDescription: Mono
imageName: ubuntu-latest imageName: ubuntu-latest
framework: net461 framework: net461
runtime: linux-x64 runtime: linux-x64
archiveType: tar archiveType: tar
artifactName: Jackett.Binaries.Mono.tar.gz artifactName: Jackett.Binaries.Mono.tar.gz
Windows: Windows:
buildDescription: Windows buildDescription: Windows
imageName: windows-latest imageName: windows-latest
framework: $(netCoreFramework) framework: $(netCoreFramework)
runtime: win-x86 runtime: win-x86
archiveType: zip archiveType: zip
artifactName: Jackett.Binaries.Windows.zip artifactName: Jackett.Binaries.Windows.zip
macOS: macOS:
buildDescription: macOS buildDescription: macOS
imageName: macOS-latest imageName: macOS-latest
framework: $(netCoreFramework) framework: $(netCoreFramework)
runtime: osx-x64 runtime: osx-x64
archiveType: tar archiveType: tar
artifactName: Jackett.Binaries.macOS.tar.gz artifactName: Jackett.Binaries.macOS.tar.gz
LinuxAmdx64: LinuxAmdx64:
buildDescription: Linux AMD x64 buildDescription: Linux AMD x64
imageName: ubuntu-latest imageName: ubuntu-latest
framework: $(netCoreFramework) framework: $(netCoreFramework)
runtime: linux-x64 runtime: linux-x64
archiveType: tar archiveType: tar
artifactName: Jackett.Binaries.LinuxAMDx64.tar.gz artifactName: Jackett.Binaries.LinuxAMDx64.tar.gz
LinuxARM32: LinuxARM32:
buildDescription: Linux ARM32 buildDescription: Linux ARM32
imageName: ubuntu-latest imageName: ubuntu-latest
framework: $(netCoreFramework) framework: $(netCoreFramework)
runtime: linux-arm runtime: linux-arm
archiveType: tar archiveType: tar
artifactName: Jackett.Binaries.LinuxARM32.tar.gz artifactName: Jackett.Binaries.LinuxARM32.tar.gz
LinuxARM64: LinuxARM64:
buildDescription: Linux ARM64 buildDescription: Linux ARM64
imageName: ubuntu-latest imageName: ubuntu-latest
framework: $(netCoreFramework) framework: $(netCoreFramework)
runtime: linux-arm64 runtime: linux-arm64
archiveType: tar archiveType: tar
artifactName: Jackett.Binaries.LinuxARM64.tar.gz artifactName: Jackett.Binaries.LinuxARM64.tar.gz
pool: pool:
vmImage: $(imageName) vmImage: $(imageName)
displayName: ${{ variables.buildDescription }} displayName: ${{ variables.buildDescription }}
steps: steps:
- checkout: self - checkout: self
- task: UseDotNet@2 - task: UseDotNet@2
displayName: Install .NET Core SDK displayName: Install .NET Core SDK
inputs: inputs:
packageType: sdk packageType: sdk
version: $(netCoreSdkVersion) version: $(netCoreSdkVersion)
installationPath: $(Agent.ToolsDirectory)/dotnet installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: Build Jackett Server displayName: Build Jackett Server
inputs: inputs:
command: publish command: publish
projects: 'src/Jackett.Server/Jackett.Server.csproj' projects: 'src/Jackett.Server/Jackett.Server.csproj'
publishWebProjects: false publishWebProjects: false
zipAfterPublish: false zipAfterPublish: false
arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework) --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)' arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework) --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)'
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: Build Jackett Updater displayName: Build Jackett Updater
inputs: inputs:
command: publish command: publish
projects: 'src/Jackett.Updater/Jackett.Updater.csproj' projects: 'src/Jackett.Updater/Jackett.Updater.csproj'
publishWebProjects: false publishWebProjects: false
zipAfterPublish: false zipAfterPublish: false
arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework) --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)' arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework) --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)'
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: Build Jackett Tray (Windows only) displayName: Build Jackett Tray (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win')) condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs: inputs:
command: publish command: publish
projects: 'src/Jackett.Tray/Jackett.Tray.csproj' projects: 'src/Jackett.Tray/Jackett.Tray.csproj'
publishWebProjects: false publishWebProjects: false
zipAfterPublish: false zipAfterPublish: false
arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework) --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)' arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework) --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)'
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: Build Jackett Service (Windows only) displayName: Build Jackett Service (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win')) condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs: inputs:
command: publish command: publish
projects: 'src/Jackett.Service/Jackett.Service.csproj' projects: 'src/Jackett.Service/Jackett.Service.csproj'
publishWebProjects: false publishWebProjects: false
zipAfterPublish: false zipAfterPublish: false
arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework) --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)' arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework) --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)'
- task: CopyFiles@2 - task: CopyFiles@2
displayName: Copy Jackett Server displayName: Copy Jackett Server
inputs: inputs:
SourceFolder: $(Build.BinariesDirectory)/Jackett.Server SourceFolder: $(Build.BinariesDirectory)/Jackett.Server
contents: '**' contents: '**'
targetFolder: $(Build.BinariesDirectory)/Jackett targetFolder: $(Build.BinariesDirectory)/Jackett
- task: CopyFiles@2 - task: CopyFiles@2
displayName: Copy Jackett Updater displayName: Copy Jackett Updater
inputs: inputs:
SourceFolder: $(Build.BinariesDirectory)/Jackett.Updater SourceFolder: $(Build.BinariesDirectory)/Jackett.Updater
contents: JackettUpdater* contents: JackettUpdater*
targetFolder: $(Build.BinariesDirectory)/Jackett targetFolder: $(Build.BinariesDirectory)/Jackett
- task: CopyFiles@2 - task: CopyFiles@2
displayName: Copy Jackett Tray (Windows only) displayName: Copy Jackett Tray (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win')) condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs: inputs:
SourceFolder: $(Build.BinariesDirectory)/Jackett.Tray SourceFolder: $(Build.BinariesDirectory)/Jackett.Tray
contents: | contents: |
System.Drawing.dll System.Drawing.dll
System.Security.Cryptography.ProtectedData.dll System.Security.Cryptography.ProtectedData.dll
WindowsBase.dll WindowsBase.dll
targetFolder: $(Build.BinariesDirectory)/Jackett targetFolder: $(Build.BinariesDirectory)/Jackett
overWrite: true overWrite: true
- task: CopyFiles@2 - task: CopyFiles@2
displayName: Copy Jackett Tray Part 2 (Windows only) displayName: Copy Jackett Tray Part 2 (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win')) condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs: inputs:
SourceFolder: $(Build.BinariesDirectory)/Jackett.Tray SourceFolder: $(Build.BinariesDirectory)/Jackett.Tray
contents: '*' contents: '*'
targetFolder: $(Build.BinariesDirectory)/Jackett targetFolder: $(Build.BinariesDirectory)/Jackett
overWrite: false overWrite: false
- task: CopyFiles@2 - task: CopyFiles@2
displayName: Copy Jackett Service (Windows only) displayName: Copy Jackett Service (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win')) condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs: inputs:
SourceFolder: $(Build.BinariesDirectory)/Jackett.Service SourceFolder: $(Build.BinariesDirectory)/Jackett.Service
contents: JackettService* contents: JackettService*
targetFolder: $(Build.BinariesDirectory)/Jackett targetFolder: $(Build.BinariesDirectory)/Jackett
- task: CopyFiles@2 - task: CopyFiles@2
displayName: Copy Mono Specific Scripts displayName: Copy Mono Specific Scripts
condition: and(succeeded(), startsWith(variables['buildDescription'], 'Mono')) condition: and(succeeded(), startsWith(variables['buildDescription'], 'Mono'))
inputs: inputs:
SourceFolder: $(Build.SourcesDirectory) SourceFolder: $(Build.SourcesDirectory)
contents: | contents: |
install_service_systemd_mono.sh install_service_systemd_mono.sh
Upstart.config Upstart.config
targetFolder: $(Build.BinariesDirectory)/Jackett targetFolder: $(Build.BinariesDirectory)/Jackett
- task: CopyFiles@2 - task: CopyFiles@2
displayName: Copy macOS Specific Scripts displayName: Copy macOS Specific Scripts
condition: and(succeeded(), startsWith(variables['buildDescription'], 'macOS')) condition: and(succeeded(), startsWith(variables['buildDescription'], 'macOS'))
inputs: inputs:
SourceFolder: $(Build.SourcesDirectory) SourceFolder: $(Build.SourcesDirectory)
contents: install_service_macos contents: install_service_macos
targetFolder: $(Build.BinariesDirectory)/Jackett targetFolder: $(Build.BinariesDirectory)/Jackett
- task: CopyFiles@2 - task: CopyFiles@2
displayName: Copy Linux Specific Scripts displayName: Copy Linux Specific Scripts
condition: and(succeeded(), startsWith(variables['buildDescription'], 'Linux')) condition: and(succeeded(), startsWith(variables['buildDescription'], 'Linux'))
inputs: inputs:
SourceFolder: $(Build.SourcesDirectory) SourceFolder: $(Build.SourcesDirectory)
contents: | contents: |
install_service_systemd.sh install_service_systemd.sh
jackett_launcher.sh jackett_launcher.sh
targetFolder: $(Build.BinariesDirectory)/Jackett targetFolder: $(Build.BinariesDirectory)/Jackett
#There is an issue with Mono 5.8 (fixed in Mono 5.12) where its expecting to use its own patched version of System.Net.Http.dll, instead of the version supplied in folder # There is an issue with Mono 5.8 (fixed in Mono 5.12) where its expecting to use its own patched version of
#https://github.com/dotnet/corefx/issues/19914 # System.Net.Http.dll, instead of the version supplied in folder
#https://bugzilla.xamarin.com/show_bug.cgi?id=60315 # https://github.com/dotnet/corefx/issues/19914
#The workaround is to delete System.Net.Http.dll and patch the .exe.config file # https://bugzilla.xamarin.com/show_bug.cgi?id=60315
#Mono on FreeBSD doesn't like the bundled System.Runtime.InteropServices.RuntimeInformation -> Delete it # The workaround is to delete System.Net.Http.dll and patch the .exe.config file
#https://github.com/dotnet/corefx/issues/23989 # Mono on FreeBSD doesn't like the bundled System.Runtime.InteropServices.RuntimeInformation -> Delete it
#https://github.com/Jackett/Jackett/issues/3547 # https://github.com/dotnet/corefx/issues/23989
- task: PowerShell@2 # https://github.com/Jackett/Jackett/issues/3547
displayName: Patch Mono Build (Mono only) - task: PowerShell@2
condition: and(succeeded(), startsWith(variables['buildDescription'], 'Mono')) displayName: Patch Mono Build (Mono only)
inputs: condition: and(succeeded(), startsWith(variables['buildDescription'], 'Mono'))
workingDirectory: $(Build.BinariesDirectory)/Jackett inputs:
targetType: inline workingDirectory: $(Build.BinariesDirectory)/Jackett
script: | targetType: inline
$file = '$(Build.BinariesDirectory)/Jackett/JackettConsole.exe.config' script: |
$xml = [xml] (Get-Content $file) $file = '$(Build.BinariesDirectory)/Jackett/JackettConsole.exe.config'
$newVersion = $xml.SelectSingleNode("configuration/runtime/*[name()='assemblyBinding']/*[name()='dependentAssembly']/*[name()='assemblyIdentity'][@name='System.Net.Http']/../*[name()='bindingRedirect']/@newVersion") $xml = [xml] (Get-Content $file)
$newVersion.Value = '4.0.0.0' $newVersion = $xml.SelectSingleNode("configuration/runtime/*[name()='assemblyBinding']/*[name()='dependentAssembly']/*[name()='assemblyIdentity'][@name='System.Net.Http']/../*[name()='bindingRedirect']/@newVersion")
$xml.Save($file) $newVersion.Value = '4.0.0.0'
Remove-Item '$(Build.BinariesDirectory)/Jackett/System.Net.Http.dll' $xml.Save($file)
Remove-Item '$(Build.BinariesDirectory)/Jackett/System.Runtime.InteropServices.RuntimeInformation.dll' Remove-Item '$(Build.BinariesDirectory)/Jackett/System.Net.Http.dll'
Remove-Item '$(Build.BinariesDirectory)/Jackett/System.Runtime.InteropServices.RuntimeInformation.dll'
- task: Bash@3 - task: Bash@3
displayName: Set Folder and File Permissions (Mono, Linux and macOS) displayName: Set Folder and File Permissions (Mono, Linux and macOS)
condition: and(succeeded(), not(startsWith(variables['runtime'], 'win'))) condition: and(succeeded(), not(startsWith(variables['runtime'], 'win')))
inputs: inputs:
workingDirectory: $(Build.BinariesDirectory)/Jackett workingDirectory: $(Build.BinariesDirectory)/Jackett
targetType: inline targetType: inline
script: | script: |
chmod 755 $(find "$(Build.BinariesDirectory)"/Jackett -type d) chmod 755 $(find "$(Build.BinariesDirectory)"/Jackett -type d)
chmod 644 $(find "$(Build.BinariesDirectory)"/Jackett -type f) chmod 644 $(find "$(Build.BinariesDirectory)"/Jackett -type f)
chmod 755 jackett chmod 755 jackett
chmod 755 JackettUpdater chmod 755 JackettUpdater
if [ -f install_service_systemd_mono.sh ]; then chmod 755 install_service_systemd_mono.sh; fi if [ -f install_service_systemd_mono.sh ]; then chmod 755 install_service_systemd_mono.sh; fi
if [ -f install_service_macos ]; then chmod 755 install_service_macos; fi if [ -f install_service_macos ]; then chmod 755 install_service_macos; fi
if [ -f install_service_systemd.sh ]; then chmod 755 install_service_systemd.sh; fi if [ -f install_service_systemd.sh ]; then chmod 755 install_service_systemd.sh; fi
if [ -f jackett_launcher.sh ]; then chmod 755 jackett_launcher.sh; fi if [ -f jackett_launcher.sh ]; then chmod 755 jackett_launcher.sh; fi
- task: ArchiveFiles@2 - task: ArchiveFiles@2
displayName: Compress Binaries displayName: Compress Binaries
inputs: inputs:
rootFolderOrFile: $(Build.BinariesDirectory)/Jackett rootFolderOrFile: $(Build.BinariesDirectory)/Jackett
includeRootFolder: true includeRootFolder: true
archiveType: '$(archiveType)' archiveType: '$(archiveType)'
tarCompression: gz tarCompression: gz
archiveFile: '$(Build.ArtifactStagingDirectory)/$(artifactName)' archiveFile: '$(Build.ArtifactStagingDirectory)/$(artifactName)'
- task: CmdLine@2 - task: CmdLine@2
displayName: Create Jackett Installer (Windows only) displayName: Create Jackett Installer (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win')) condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs: inputs:
script: > script: >
iscc.exe $(Build.SourcesDirectory)/Installer.iss iscc.exe $(Build.SourcesDirectory)/Installer.iss
/O"$(Build.ArtifactStagingDirectory)" /O"$(Build.ArtifactStagingDirectory)"
/DMyFileForVersion=$(Build.BinariesDirectory)/Jackett/Jackett.Common.dll /DMyFileForVersion=$(Build.BinariesDirectory)/Jackett/Jackett.Common.dll
/DMySourceFolder=$(Build.BinariesDirectory)/Jackett /DMySourceFolder=$(Build.BinariesDirectory)/Jackett
/DMyOutputFilename=Jackett.Installer.Windows /DMyOutputFilename=Jackett.Installer.Windows
- task: PublishBuildArtifacts@1 - task: PublishBuildArtifacts@1
inputs: inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)' pathtoPublish: '$(Build.ArtifactStagingDirectory)'
- stage: CodeStyle - stage: CodeStyle
displayName: Code Style Compliance displayName: Code Style Compliance
dependsOn: [] dependsOn: []
jobs: jobs:
- job: Linting - job: Linting
pool: pool:
vmImage: ubuntu-latest vmImage: ubuntu-latest
workspace: workspace:
clean: all clean: all
steps: steps:
- checkout: self - checkout: self
- task: UseDotNet@2 - task: UseDotNet@2
displayName: Install .NET Core SDK displayName: Install .NET Core SDK
inputs: inputs:
packageType: sdk packageType: sdk
version: $(netCoreSdkVersion) version: $(netCoreSdkVersion)
installationPath: $(Agent.ToolsDirectory)/dotnet installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: Install Dotnet Format displayName: Install Dotnet Format
inputs: inputs:
command: custom command: custom
custom: tool custom: tool
arguments: update -g dotnet-format arguments: update -g dotnet-format
- task: Bash@3
displayName: Lint Dotnet
inputs:
workingDirectory: $(Build.SourcesDirectory)
targetType: inline
failOnStderr: true
script: |
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/DateTimeRoutines
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Common
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.IntegrationTests
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Server
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Service
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Test
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Tray
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Updater
- task: Bash@3
displayName: Lint Dotnet
inputs:
workingDirectory: $(Build.SourcesDirectory)
targetType: inline
failOnStderr: true
script: |
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/DateTimeRoutines
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Common
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.IntegrationTests
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Server
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Service
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Test
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Tray
dotnet-format --dry-run --check --verbosity diagnostic --folder ./src/Jackett.Updater
- stage: UnitTestJackett - stage: UnitTestJackett
displayName: Unit Tests displayName: Unit Tests
dependsOn: CodeStyle dependsOn: CodeStyle
jobs: jobs:
- job: UnitTest - job: UnitTest
workspace: workspace:
clean: all clean: all
strategy: strategy:
matrix: matrix:
Mono: Mono:
buildDescription: Mono buildDescription: Mono
imageName: ubuntu-latest imageName: ubuntu-latest
framework: net461 framework: net461
runtime: linux-x64 runtime: linux-x64
Windows: Windows:
buildDescription: Windows buildDescription: Windows
imageName: windows-latest imageName: windows-latest
framework: $(netCoreFramework) framework: $(netCoreFramework)
runtime: win-x86 runtime: win-x86
macOS: macOS:
buildDescription: macOS buildDescription: macOS
imageName: macOS-latest imageName: macOS-latest
framework: $(netCoreFramework) framework: $(netCoreFramework)
runtime: osx-x64 runtime: osx-x64
LinuxAmdx64: LinuxAmdx64:
buildDescription: Linux AMD x64 buildDescription: Linux AMD x64
imageName: ubuntu-latest imageName: ubuntu-latest
framework: $(netCoreFramework) framework: $(netCoreFramework)
runtime: linux-x64 runtime: linux-x64
LinuxARM32: LinuxARM32:
buildDescription: Linux ARM32 buildDescription: Linux ARM32
imageName: ubuntu-latest imageName: ubuntu-latest
framework: $(netCoreFramework) framework: $(netCoreFramework)
runtime: linux-arm runtime: linux-arm
LinuxARM64: LinuxARM64:
buildDescription: Linux ARM64 buildDescription: Linux ARM64
imageName: ubuntu-latest imageName: ubuntu-latest
framework: $(netCoreFramework) framework: $(netCoreFramework)
runtime: linux-arm64 runtime: linux-arm64
pool: pool:
vmImage: $(imageName) vmImage: $(imageName)
displayName: ${{ variables.buildDescription }} displayName: ${{ variables.buildDescription }}
steps: steps:
- checkout: self - checkout: self
- task: UseDotNet@2 - task: UseDotNet@2
displayName: Install .NET Core SDK displayName: Install .NET Core SDK
inputs: inputs:
packageType: sdk packageType: sdk
version: $(netCoreSdkVersion) version: $(netCoreSdkVersion)
installationPath: $(Agent.ToolsDirectory)/dotnet installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: Build Test Project displayName: Build Test Project
inputs: inputs:
command: build command: build
projects: '**/*.Test*/*.csproj' projects: '**/*.Test*/*.csproj'
arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework)' arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework)'
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: Unit Tests (Mono, Linux and macOS) displayName: Unit Tests (Mono, Linux and macOS)
condition: and(succeeded(), not(startsWith(variables['runtime'], 'win'))) condition: and(succeeded(), not(startsWith(variables['runtime'], 'win')))
inputs: inputs:
command: test command: test
projects: '**/*.Test*/*.csproj' projects: '**/*.Test*/*.csproj'
arguments: '--configuration $(buildConfiguration) --framework $(framework) --runtime $(runtime)' arguments: '--configuration $(buildConfiguration) --framework $(framework) --runtime $(runtime)'
testRunTitle: 'Unit - $(buildDescription) - $(Build.BuildId)' testRunTitle: 'Unit - $(buildDescription) - $(Build.BuildId)'
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: Unit Tests & Code Coverage (Windows only) displayName: Unit Tests & Code Coverage (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win')) condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs: inputs:
command: test command: test
projects: '**/*.Test*/*.csproj' projects: '**/*.Test*/*.csproj'
arguments: '--configuration $(buildConfiguration) --framework $(framework) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura' arguments: '--configuration $(buildConfiguration) --framework $(framework) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
testRunTitle: 'Unit - $(buildDescription) - $(Build.BuildId)' testRunTitle: 'Unit - $(buildDescription) - $(Build.BuildId)'
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: Install Coverage ReportGenerator Tool (Windows only) displayName: Install Coverage ReportGenerator Tool (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win')) condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs: inputs:
command: custom command: custom
custom: tool custom: tool
arguments: install --tool-path . dotnet-reportgenerator-globaltool arguments: install --tool-path . dotnet-reportgenerator-globaltool
- task: PowerShell@2 - task: PowerShell@2
displayName: Generate Coverage Report (Windows only) displayName: Generate Coverage Report (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win')) condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs: inputs:
targetType: inline targetType: inline
script: ./reportgenerator -reports:$(Build.SourcesDirectory)/src/*.Test*/coverage.*.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"Cobertura" script: ./reportgenerator -reports:$(Build.SourcesDirectory)/src/*.Test*/coverage.*.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"Cobertura"
- task: PublishCodeCoverageResults@1 - task: PublishCodeCoverageResults@1
displayName: Publish Code Coverage (Windows only) displayName: Publish Code Coverage (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win')) condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs: inputs:
codeCoverageTool: Cobertura codeCoverageTool: Cobertura
summaryFileLocation: $(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml summaryFileLocation: $(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml
- stage: Integration - stage: Integration
displayName: Integration Tests displayName: Integration Tests
dependsOn: BuildJackett dependsOn: BuildJackett
jobs: jobs:
- job: Selenium - job: Selenium
workspace: workspace:
clean: all clean: all
strategy: strategy:
matrix: matrix:
Mono: Mono:
buildDescription: Mono buildDescription: Mono
imageName: ubuntu-latest imageName: ubuntu-latest
artifactName: Jackett.Binaries.Mono.tar.gz artifactName: Jackett.Binaries.Mono.tar.gz
Windows: Windows:
buildDescription: Windows buildDescription: Windows
imageName: windows-latest imageName: windows-latest
artifactName: Jackett.Binaries.Windows.zip artifactName: Jackett.Binaries.Windows.zip
macOS: macOS:
buildDescription: macOS buildDescription: macOS
imageName: macOS-latest imageName: macOS-latest
artifactName: Jackett.Binaries.macOS.tar.gz artifactName: Jackett.Binaries.macOS.tar.gz
LinuxAmdx64: LinuxAmdx64:
buildDescription: Linux AMD x64 buildDescription: Linux AMD x64
imageName: ubuntu-latest imageName: ubuntu-latest
artifactName: Jackett.Binaries.LinuxAMDx64.tar.gz artifactName: Jackett.Binaries.LinuxAMDx64.tar.gz
pool: pool:
vmImage: $(imageName) vmImage: $(imageName)
displayName: ${{ variables.buildDescription }} displayName: ${{ variables.buildDescription }}
steps: steps:
- checkout: self - checkout: self
- task: DownloadBuildArtifacts@0 - task: DownloadBuildArtifacts@0
displayName: Download artifacts for integration tests displayName: Download artifacts for integration tests
inputs: inputs:
downloadType: specific downloadType: specific
- task: PowerShell@2 - task: PowerShell@2
displayName: Install Jackett (Windows only) displayName: Install Jackett (Windows only)
condition: and(succeeded(), eq(variables['buildDescription'], 'Windows')) condition: and(succeeded(), eq(variables['buildDescription'], 'Windows'))
inputs: inputs:
workingDirectory: $(Build.ArtifactStagingDirectory)/drop workingDirectory: $(Build.ArtifactStagingDirectory)/drop
targetType: inline targetType: inline
script: | script: |
Start-Process ./Jackett.Installer.Windows.exe /silent -NoNewWindow -Wait Start-Process ./Jackett.Installer.Windows.exe /silent -NoNewWindow -Wait
- task: Bash@3 - task: Bash@3
displayName: Install Jackett (Mono, Linux and macOS) displayName: Install Jackett (Mono, Linux and macOS)
condition: and(succeeded(), ne(variables['buildDescription'], 'Windows')) condition: and(succeeded(), ne(variables['buildDescription'], 'Windows'))
inputs: inputs:
workingDirectory: $(Build.ArtifactStagingDirectory)/drop workingDirectory: $(Build.ArtifactStagingDirectory)/drop
targetType: inline targetType: inline
script: | script: |
tar xzf "$(artifactName)" tar xzf "$(artifactName)"
cd Jackett cd Jackett
if [[ "$(artifactName)" == *"Mono"* ]]; then mono --version; fi if [[ "$(artifactName)" == *"Mono"* ]]; then mono --version; fi
if [[ "$(artifactName)" == *"Mono"* ]]; then sudo ./install_service_systemd_mono.sh; fi if [[ "$(artifactName)" == *"Mono"* ]]; then sudo ./install_service_systemd_mono.sh; fi
if [[ "$(artifactName)" == *"macOS"* ]]; then ./install_service_macos; fi if [[ "$(artifactName)" == *"macOS"* ]]; then ./install_service_macos; fi
if [[ "$(artifactName)" == *"LinuxAMDx64"* ]]; then sudo ./install_service_systemd.sh; fi if [[ "$(artifactName)" == *"LinuxAMDx64"* ]]; then sudo ./install_service_systemd.sh; fi
- task: UseDotNet@2 - task: UseDotNet@2
displayName: Install .NET Core SDK displayName: Install .NET Core SDK
inputs: inputs:
packageType: sdk packageType: sdk
version: $(netCoreSdkVersion) version: $(netCoreSdkVersion)
installationPath: $(Agent.ToolsDirectory)/dotnet installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
displayName: Run Integration Tests
inputs:
command: test
projects: '**/*IntegrationTest*/*.csproj'
testRunTitle: 'Integration - $(buildDescription) - $(Build.BuildId)'
- task: DotNetCoreCLI@2
displayName: Run Integration Tests
inputs:
command: test
projects: '**/*IntegrationTest*/*.csproj'
testRunTitle: 'Integration - $(buildDescription) - $(Build.BuildId)'
- stage: PublishGithub - stage: PublishGithub
displayName: Publish to Github displayName: Publish to Github
@ -478,50 +477,50 @@ stages:
- Integration - Integration
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/master')) condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs: jobs:
- job: Publish - job: Publish
workspace: workspace:
clean: all clean: all
steps: steps:
- checkout: self - checkout: self
- task: DownloadBuildArtifacts@0 - task: DownloadBuildArtifacts@0
displayName: Download Artifacts for Publish displayName: Download Artifacts for Publish
inputs: inputs:
downloadType: specific downloadType: specific
- task: GitHubRelease@1 - task: GitHubRelease@1
displayName: Create Github release displayName: Create Github release
inputs: inputs:
gitHubConnection: JackettPublish gitHubConnection: JackettPublish
repositoryName: '$(Build.Repository.Name)' repositoryName: '$(Build.Repository.Name)'
action: create action: create
target: $(Build.SourceVersion) target: $(Build.SourceVersion)
tagSource: userSpecifiedTag tagSource: userSpecifiedTag
tag: v$(Build.BuildNumber) tag: v$(Build.BuildNumber)
title: v$(Build.BuildNumber) title: v$(Build.BuildNumber)
assets: $(Build.ArtifactStagingDirectory)/drop/* assets: $(Build.ArtifactStagingDirectory)/drop/*
assetUploadMode: replace assetUploadMode: replace
isDraft: true isDraft: true
addChangeLog: true addChangeLog: true
compareWith: lastNonDraftRelease compareWith: lastNonDraftRelease
- task: PowerShell@2 - task: PowerShell@2
displayName: Ensure all artifacts are uploaded to Github displayName: Ensure all artifacts are uploaded to Github
inputs: inputs:
targetType: inline targetType: inline
script: | script: |
$json = Invoke-WebRequest 'https://dev.azure.com/Jackett/Jackett/_apis/build/builds/$(Build.BuildId)/logs?api-version=5.0' | ConvertFrom-Json $json = Invoke-WebRequest 'https://dev.azure.com/Jackett/Jackett/_apis/build/builds/$(Build.BuildId)/logs?api-version=5.0' | ConvertFrom-Json
$lastTwoLogUrls = $json.value[-1..-2].url $lastTwoLogUrls = $json.value[-1..-2].url
foreach($logUrl in $lastTwoLogUrls) foreach($logUrl in $lastTwoLogUrls)
{ {
Write-Output $logUrl Write-Output $logUrl
$logText = Invoke-WebRequest $logUrl $logText = Invoke-WebRequest $logUrl
if ($logText -like '*Creating a release for tag:*') if ($logText -like '*Creating a release for tag:*')
{ {
$logInspect = ($logText -split "Creating a release for tag:")[-1] $logInspect = ($logText -split "Creating a release for tag:")[-1]
$successCount = (Select-String "Uploaded file successfully:" -InputObject $logInspect -AllMatches).Matches.Count $successCount = (Select-String "Uploaded file successfully:" -InputObject $logInspect -AllMatches).Matches.Count
$failureCount = (Select-String "Duplicate asset found:" -InputObject $logInspect -AllMatches).Matches.Count $failureCount = (Select-String "Duplicate asset found:" -InputObject $logInspect -AllMatches).Matches.Count
Write-Output "Success count is: $successCount and failure count is: $failureCount" Write-Output "Success count is: $successCount and failure count is: $failureCount"
if (($successCount -ne 7) -or ($failureCount -ne 0)) { Write-Host "##vso[task.complete result=Failed;]DONE" } if (($successCount -ne 7) -or ($failureCount -ne 0)) { Write-Host "##vso[task.complete result=Failed;]DONE" }
} }
} }