start redis-server on appveyor
Asked Answered
D

4

5

I want to run some xUnit tests on AppVeyor that needs an available instance of redis. I didn't found Redis within the "Service" of AppVeyor so I end up with a custom solution, as you can see from the 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 stuck at 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 ?

Durazzo answered 23/2, 2015 at 12:24 Comment(0)
D
3

For anyone interested, that's the appveyor.yml that did the trick. It basically download the release directly from github, unzip in a folder, install and start 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
Durazzo answered 24/2, 2015 at 8:55 Comment(0)
T
4

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'
Toaster answered 24/2, 2015 at 2:48 Comment(3)
good idea! unfortunately the 2.6.12 version of redis don't support to be installed as a service, but I'll try the same idea through chocolateyDurazzo
It Worked! ;) I'm going to post the answer hereDurazzo
Great! For future reference - another way to start a process without blocking the build is using Start-Process PowerShell cmdlet. Usually, you should add some delay on the next line with Start-Sleep cmdlet to allow process to start.Toaster
A
4

Personally I would always use chocolatey to install any infrastructure needed on on AppVeyor Build Worker. So here's the appveyor.yml that I would use (and which works for me on my own project needing 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
Allpurpose answered 15/5, 2016 at 13:17 Comment(0)
D
3

For anyone interested, that's the appveyor.yml that did the trick. It basically download the release directly from github, unzip in a folder, install and start 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
Durazzo answered 24/2, 2015 at 8:55 Comment(0)
D
1

Here is example of appveyor.yml with a powershell script that works with redis-3.2.100 which is not currently available on chocolately:

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 ..
Diametral answered 12/9, 2017 at 12:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.