Run redis server on tape

I want to run some xUnit tests for AppVeyor that need an available redis instance. I did not find Redis in the AppVeyor "Service", so in the end I got a custom solution, as you can see from appveyor.yml

version: 1.0.{build} before_build: - nuget restore .\Hangfire.Redis.StackExchange.sln - START .\packages\Redis-32.2.6.12.1\tools\redis-server.exe ".\packages\Redis-32.2.6.12.1\tools\redis.conf" - '@ECHO Redis Started' build: publish_nuget: true publish_nuget_symbols: true verbosity: minimal 

Unfortunately, the build process is stuck in START .\packages\Redis-32.2.6.12.1\tools\redis-server.exe ".\packages\Redis-32.2.6.12.1\tools\redis.conf"

any idea or possible workaround?

+5
source share
4 answers

For anyone interested, appveyor.yml did the trick. It basically downloads the release directly from github, unpacks it into a folder, installs and runs Redis as a service

 version: 1.0.{build} before_build: - ps: >- Invoke-WebRequest "https://github.com/MSOpenTech/redis/releases/download/win-2.8.17.4/redis-2.8.17.zip" -OutFile .\redis-2.8.17.zip; $destFolder = "redis-2.8.17"; $shell = new-object -com shell.application; $zip = $shell.NameSpace("$pwd\redis-2.8.17.zip"); if (Test-Path $pwd\$destFolder ) { del $pwd\$destFolder -Force -Recurse } md ".\redis-2.8.17"; foreach($item in $zip.items()) { $shell.Namespace("$pwd\redis-2.8.17").copyhere($item); it kind of worked cd $destFolder .\redis-server.exe --service-install .\redis-server.exe --service-start cd .. - nuget restore Hangfire.Redis.StackExchange.sln build: publish_nuget: true publish_nuget_symbols: true verbosity: minimal 
+3
source

Try running Redis as a Windows service:

 before_build: - nuget restore .\Hangfire.Redis.StackExchange.sln - packages\Redis-32.2.6.12.1\tools\redis-server.exe --service-install - packages\Redis-32.2.6.12.1\tools\redis-server.exe --service-start - '@ECHO Redis Started' 
+4
source

Personally, I would always use chocolate to install any infrastructure needed for the AppVeyor Build Worker. So here is the appveyor.yml that I would use (and which works for me in my own project that needs Redis):

 version: 1.0.{build} before_build: - choco install redis-64 - redis-server --service-install - redis-server --service-start - nuget restore .\Hangfire.Redis.StackExchange.sln build: publish_nuget: true publish_nuget_symbols: true verbosity: minimal 
+4
source

Here is an example appveyor.yml with a powershell script that works with redis-3.2.100, which is currently not available in chocolate:

appveyor.yml

 install: - cmd: cd c:\ && mkdir c:\redis-3.2.100 - ps: c:\Users\root\repos\<YOUR_REPO>\deploy\redis.ps1 

redis.ps1

 Add-Type -assembly "system.io.compression.filesystem" $source="https://github.com/MicrosoftArchive/redis/releases/download/win-3.2.100/Redis-x64-3.2.100.zip" $destination="c:\redisarchive" Invoke-WebRequest $source -OutFile $destination [IO.Compression.ZipFile]::ExtractToDirectory('c:\redisarchive', 'c:\redis-3.2.100') cd c:\redis-3.2.100 .\redis-server.exe --service-install .\redis-server.exe --service-start cd .. 
+1
source

Source: https://habr.com/ru/post/1213982/


All Articles