Difference between revisions of "Continuous Integration"

From D Wiki
Jump to: navigation, search
m (Testing 32-bit: fix typo)
(Update appveyor.yml: Support wider variety of newer & older DMD/LDC, always with RDMD and DUB.)
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
Continuously testing your project is ensures a conflict-free shipping.
 
Continuously testing your project is ensures a conflict-free shipping.
For all the listed Continuous Integration provides, you will need a free account
+
For all the listed Continuous Integration providers, you will need a free account
 
to enable building.
 
to enable building.
  
Line 6: Line 6:
  
 
Travis has built-in support for D and building your project with D is as easy as
 
Travis has built-in support for D and building your project with D is as easy as
adding to your <code>.travis.yml</code> the compilers to be tested :
+
adding to your <code>.travis.yml</code> file, the compilers to be tested :
  
 
<syntaxhighlight lang="yaml">
 
<syntaxhighlight lang="yaml">
Line 23: Line 23:
 
   - ldc-1.0.0
 
   - ldc-1.0.0
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
A full list of supported compiler versions along with the corresponding DMD frontend versions is available at https://semitwist.com/travis-d-compilers.
  
 
Travis also offers  
 
Travis also offers  
Line 54: Line 56:
 
== CircleCi ==
 
== CircleCi ==
  
CircleCi doesn't support D out-of-the-box yet, but it is easy to install dmd and
+
CircleCi doesn't support D out-of-the-box yet, but it is easy to install <code>dmd</code> and
dub with a single line in your `circle.yml`:
+
<code>dub</code> with a single line in your `circle.yml`:
  
 
<syntaxhighlight lang="yaml">
 
<syntaxhighlight lang="yaml">
Line 89: Line 91:
 
     arch: x86
 
     arch: x86
 
   - DC: ldc
 
   - DC: ldc
     DVersion: '1.0.0-alpha1'
+
     DVersion: 1.0.0
 
     arch: x64
 
     arch: x64
 
   - DC: ldc
 
   - DC: ldc
Line 102: Line 104:
  
 
install:
 
install:
 +
  - ps: function ResolveDMD
 +
        {
 +
            $version = $env:DVersion;
 +
            if($version -eq "stable") {
 +
                $latest = (Invoke-WebRequest "http://downloads.dlang.org/releases/LATEST").toString();
 +
                $urls = @("http://downloads.dlang.org/releases/2.x/$($latest)/dmd.$($latest).windows.7z");
 +
            }elseif($version -eq "beta") {
 +
                $latest = (Invoke-WebRequest "http://downloads.dlang.org/pre-releases/LATEST").toString();
 +
                $latestVersion = $latest.split("-")[0].split("~")[0];
 +
                $urls = @("http://downloads.dlang.org/pre-releases/2.x/$($latestVersion)/dmd.$($latest).windows.7z");
 +
            }elseif($version -eq "nightly") {
 +
                $urls = @("http://nightlies.dlang.org/dmd-master-2017-05-20/dmd.master.windows.7z");
 +
            }else {
 +
                $urls = @("http://downloads.dlang.org/releases/2.x/$($version)/dmd.$($version).windows.7z");
 +
            }
 +
            $env:PATH += ";C:\dmd2\windows\bin;";
 +
            return $urls;
 +
        }
 +
  - ps: function ResolveLDC
 +
        {
 +
            if($env:arch -eq "x86"){
 +
                $archBits = "32";
 +
            }
 +
            elseif($env:arch -eq "x64"){
 +
                $archBits = "64";
 +
            }
 +
            $version = $env:DVersion;
 +
            $arch = $env:arch;
 +
            if($version -eq "stable") {
 +
                $latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST").toString().replace("`n","").replace("`r","");
 +
                $urls = @("https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-windows-$($arch).7z");
 +
            }elseif($version -eq "beta") {
 +
                $latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST_BETA").toString().replace("`n","").replace("`r","");
 +
                $urls = @("https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-windows-$($arch).7z");
 +
            } else {
 +
                $latest = $version;
 +
                $urls = @("https://github.com/ldc-developers/ldc/releases/download/v$($version)/ldc2-$($version)-windows-$($arch).7z");
 +
                $urls += "https://github.com/ldc-developers/ldc/releases/download/v$($version)/ldc2-$($version)-win$($archBits)-msvc.zip";
 +
            }
 +
            $env:PATH += ";C:\ldc2-$($latest)-windows-$($arch)\bin;C:\ldc2-$($latest)-win$($archBits)-msvc\bin";
 +
            $env:DC = "ldc2";
 +
            return $urls;
 +
        }
 
   - ps: function SetUpDCompiler
 
   - ps: function SetUpDCompiler
 
         {
 
         {
 +
            $env:toolchain = "msvc";
 
             if($env:DC -eq "dmd"){
 
             if($env:DC -eq "dmd"){
              if($env:arch -eq "x86"){
+
                 $env:DMD = "dmd";
                 $env:DConf = "m32";
+
                 $urls = ResolveDMD;
              }
 
              elseif($env:arch -eq "x64"){
 
                 $env:DConf = "m64";
 
              }
 
              echo "downloading ...";
 
              $env:toolchain = "msvc";
 
              $version = $env:DVersion;
 
              Invoke-WebRequest "http://downloads.dlang.org/releases/2.x/$($version)/dmd.$($version).windows.7z" -OutFile "c:\dmd.7z";
 
              echo "finished.";
 
              pushd c:\\;
 
              7z x dmd.7z > $null;
 
              popd;
 
 
             }
 
             }
 
             elseif($env:DC -eq "ldc"){
 
             elseif($env:DC -eq "ldc"){
              echo "downloading ...";
+
                $env:DC = "ldmd2";
              if($env:arch -eq "x86"){
+
                $env:DMD = "ldmd2";
                 $env:DConf = "m32";
+
                 $urls = ResolveLDC;
              }
+
            }
              elseif($env:arch -eq "x64"){
+
            echo "downloading...";
                 $env:DConf = "m64";
+
            echo urls=$urls;
              }
+
            foreach($tryUrl in $urls){
              $env:toolchain = "msvc";
+
                 $dloadOk = $true;
              $version = $env:DVersion;
+
                echo Trying $tryUrl;
              Invoke-WebRequest "https://github.com/ldc-developers/ldc/releases/download/v$($version)/ldc2-$($version)-win64-msvc.zip" -OutFile "c:\ldc.zip";
+
                try{
              echo "finished.";
+
                    Invoke-WebRequest $tryUrl -OutFile "c:\compiler.archive";
              pushd c:\\;
+
                }
              7z x ldc.zip > $null;
+
                catch [Net.WebException]{
              popd;
+
                    $dloadOk = $false;
 +
                }
 +
                if($dloadOk -eq $true){
 +
                    break;
 +
                }
 
             }
 
             }
 +
            echo "extracting...";
 +
            pushd c:\\;
 +
            7z x compiler.archive > $null;
 +
            popd;
 +
            echo "finished.";
 
         }
 
         }
 
   - ps: SetUpDCompiler
 
   - ps: SetUpDCompiler
   - powershell -Command Invoke-WebRequest https://code.dlang.org/files/1.0.0-beta.1-windows-x86.zip -OutFile dub.zip
+
   - powershell -Command Invoke-WebRequest https://code.dlang.org/files/dub-1.9.0-windows-x86.zip -OutFile dub.zip
 
   - 7z x dub.zip -odub > nul
 
   - 7z x dub.zip -odub > nul
 
   - set PATH=%CD%\%binpath%;%CD%\dub;%PATH%
 
   - set PATH=%CD%\%binpath%;%CD%\dub;%PATH%
 
   - dub --version
 
   - dub --version
 +
  # Some older LDC/GDC compilers don't come with rdmd
 +
  - ps: function SetUpRDMD
 +
        {
 +
            if((Get-Command "rdmd.exe" -ErrorAction SilentlyContinue) -eq $null)
 +
            {
 +
                Invoke-WebRequest "http://downloads.dlang.org/releases/2.x/2.080.0/dmd.2.080.0.windows.7z" -OutFile "c:\rdmd-dmd.7z";
 +
                pushd c:\\;
 +
                7z x -ordmd-dmd rdmd-dmd.7z > $null;
 +
                popd;
 +
            }
 +
        }
 +
  - ps: SetUpRDMD
 +
  - set PATH=%PATH%;c:\rdmd-dmd\dmd2\windows\bin
  
 
before_build:
 
before_build:
Line 147: Line 203:
 
             $env:compilersetupargs = "x86";
 
             $env:compilersetupargs = "x86";
 
             $env:Darch = "x86";
 
             $env:Darch = "x86";
          }
+
            $env:DConf = "m32";
         elseif($env:arch -eq "x64"){
+
         }elseif($env:arch -eq "x64"){
 
             $env:compilersetupargs = "amd64";
 
             $env:compilersetupargs = "amd64";
 
             $env:Darch = "x86_64";
 
             $env:Darch = "x86_64";
 +
            $env:DConf = "m64";
 
         }
 
         }
  - ps : if($env:DC -eq "dmd"){
 
          $env:PATH += ";C:\dmd2\windows\bin;";
 
        }
 
        elseif($env:DC -eq "ldc"){
 
          $version = $env:DVersion;
 
          $env:PATH += ";C:\ldc2-$($version)-win64-msvc\bin";
 
          $env:DC = "ldc2";
 
        }
 
 
   - ps: $env:compilersetup = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall";
 
   - ps: $env:compilersetup = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall";
 
   - '"%compilersetup%" %compilersetupargs%'
 
   - '"%compilersetup%" %compilersetupargs%'
Line 170: Line 219:
 
  - echo %Darch%
 
  - echo %Darch%
 
  - echo %DC%
 
  - echo %DC%
 +
- echo %DMD%
 
  - echo %PATH%
 
  - echo %PATH%
  - '%DC% --version'
+
  - '%DC% --help'
 
  - dub test --arch=%Darch% --compiler=%DC%
 
  - dub test --arch=%Darch% --compiler=%DC%
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 178: Line 228:
 
If you have troubles with a specific version or compiler on Windows, you might want to allow failure in your build matrix until you get them fixed. For example to allow failure with ldc, you would add the following:
 
If you have troubles with a specific version or compiler on Windows, you might want to allow failure in your build matrix until you get them fixed. For example to allow failure with ldc, you would add the following:
  
<syntaxhighlight>
+
<syntaxhighlight lang="yaml">
 
matrix:
 
matrix:
 
   allow_failures:
 
   allow_failures:
 
     - DC: ldc
 
     - DC: ldc
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
For a up-to-date AppVeyor setup, you can also always head to [https://github.com/Abscissa/AppVeyor-D/blob/master/appveyor.yml AppVeyor-D], or [https://github.com/dlang/dub/blob/master/appveyor.yml DUB] or [https://github.com/libmir/mir/blob/master/appveyor.yml Mir].

Revision as of 08:10, 31 May 2018

Continuously testing your project is ensures a conflict-free shipping. For all the listed Continuous Integration providers, you will need a free account to enable building.

Travis

Travis has built-in support for D and building your project with D is as easy as adding to your .travis.yml file, the compilers to be tested :

# latest dmd, gdc and ldc
d:
  - dmd
  - gdc
  - ldc

You can also choose specific versions:

d:
  - dmd-2.071.0
  - ldc-1.0.0

A full list of supported compiler versions along with the corresponding DMD frontend versions is available at https://semitwist.com/travis-d-compilers.

Travis also offers OS X build environment, which you can enable by adding:

os:
 - linux
 - osx

More information is also available at Travis's documentation.

Testing 32-bit

All Travis containers use 64-bit, so if you want to test 32-bit is a bit tricky. One common trick is to use Travis build matrix feature to individually toggle extra builds as Mac OS X is x86-64 only since 10.7.

env:
 - ARCH="x86_64"
matrix:
  include:
    - {os: linux, d: dmd-2.071.0, env: ARCH="x86", addons: {apt: {packages: [[gcc-multilib]]}}}
    - {os: linux, d: ldc-1.0.0, env: ARCH="x86", addons: {apt: {packages: [[gcc-multilib]]}}}
script:
 - dub test --arch "$ARCH"

CircleCi

CircleCi doesn't support D out-of-the-box yet, but it is easy to install dmd and dub with a single line in your `circle.yml`:

dependencies:
  override:
    - source "$(curl -fsS  --retry 3 https://dlang.org/install.sh | bash -s dmd --activate)"
test:
  override:
    - dub test

AppVeyor (Windows)

Testing your project on Windows is currently a bit more complicated, but we are working on simplifying this integration. At the moment the best way to go is to extend your setup from this `appveyor.yml`:

platform: x64
environment:
 matrix:
  - DC: dmd
    DVersion: 2.071.0
    arch: x64
  - DC: dmd
    DVersion: 2.071.0
    arch: x86
  - DC: dmd
    DVersion: 2.070.0
    arch: x64
  - DC: dmd
    DVersion: 2.070.0
    arch: x86
  - DC: ldc
    DVersion: 1.0.0
    arch: x64
  - DC: ldc
    DVersion: 0.17.0
    arch: x64

skip_tags: true
branches:
  only:
    - master
    - stable

install:
  - ps: function ResolveDMD
        {
            $version = $env:DVersion;
            if($version -eq "stable") {
                $latest = (Invoke-WebRequest "http://downloads.dlang.org/releases/LATEST").toString();
                $urls = @("http://downloads.dlang.org/releases/2.x/$($latest)/dmd.$($latest).windows.7z");
            }elseif($version -eq "beta") {
                $latest = (Invoke-WebRequest "http://downloads.dlang.org/pre-releases/LATEST").toString();
                $latestVersion = $latest.split("-")[0].split("~")[0];
                $urls = @("http://downloads.dlang.org/pre-releases/2.x/$($latestVersion)/dmd.$($latest).windows.7z");
            }elseif($version -eq "nightly") {
                $urls = @("http://nightlies.dlang.org/dmd-master-2017-05-20/dmd.master.windows.7z");
            }else {
                $urls = @("http://downloads.dlang.org/releases/2.x/$($version)/dmd.$($version).windows.7z");
            }
            $env:PATH += ";C:\dmd2\windows\bin;";
            return $urls;
        }
  - ps: function ResolveLDC
        {
            if($env:arch -eq "x86"){
                $archBits = "32";
            }
            elseif($env:arch -eq "x64"){
                $archBits = "64";
            }
            $version = $env:DVersion;
            $arch = $env:arch;
            if($version -eq "stable") {
                $latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST").toString().replace("`n","").replace("`r","");
                $urls = @("https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-windows-$($arch).7z");
            }elseif($version -eq "beta") {
                $latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST_BETA").toString().replace("`n","").replace("`r","");
                $urls = @("https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-windows-$($arch).7z");
            } else {
                $latest = $version;
                $urls = @("https://github.com/ldc-developers/ldc/releases/download/v$($version)/ldc2-$($version)-windows-$($arch).7z");
                $urls += "https://github.com/ldc-developers/ldc/releases/download/v$($version)/ldc2-$($version)-win$($archBits)-msvc.zip";
            }
            $env:PATH += ";C:\ldc2-$($latest)-windows-$($arch)\bin;C:\ldc2-$($latest)-win$($archBits)-msvc\bin";
            $env:DC = "ldc2";
            return $urls;
        }
  - ps: function SetUpDCompiler
        {
            $env:toolchain = "msvc";
            if($env:DC -eq "dmd"){
                $env:DMD = "dmd";
                $urls = ResolveDMD;
            }
            elseif($env:DC -eq "ldc"){
                $env:DC = "ldmd2";
                $env:DMD = "ldmd2";
                $urls = ResolveLDC;
            }
            echo "downloading...";
            echo urls=$urls;
            foreach($tryUrl in $urls){
                $dloadOk = $true;
                echo Trying $tryUrl;
                try{
                    Invoke-WebRequest $tryUrl -OutFile "c:\compiler.archive";
                }
                catch [Net.WebException]{
                    $dloadOk = $false;
                }
                if($dloadOk -eq $true){
                    break;
                }
            }
            echo "extracting...";
            pushd c:\\;
            7z x compiler.archive > $null;
            popd;
            echo "finished.";
        }
  - ps: SetUpDCompiler
  - powershell -Command Invoke-WebRequest https://code.dlang.org/files/dub-1.9.0-windows-x86.zip -OutFile dub.zip
  - 7z x dub.zip -odub > nul
  - set PATH=%CD%\%binpath%;%CD%\dub;%PATH%
  - dub --version
  # Some older LDC/GDC compilers don't come with rdmd
  - ps: function SetUpRDMD
        {
            if((Get-Command "rdmd.exe" -ErrorAction SilentlyContinue) -eq $null)
            {
                Invoke-WebRequest "http://downloads.dlang.org/releases/2.x/2.080.0/dmd.2.080.0.windows.7z" -OutFile "c:\rdmd-dmd.7z";
                pushd c:\\;
                7z x -ordmd-dmd rdmd-dmd.7z > $null;
                popd;
            }
        }
  - ps: SetUpRDMD
  - set PATH=%PATH%;c:\rdmd-dmd\dmd2\windows\bin

before_build:
  - ps: if($env:arch -eq "x86"){
            $env:compilersetupargs = "x86";
            $env:Darch = "x86";
            $env:DConf = "m32";
        }elseif($env:arch -eq "x64"){
            $env:compilersetupargs = "amd64";
            $env:Darch = "x86_64";
            $env:DConf = "m64";
        }
  - ps: $env:compilersetup = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall";
  - '"%compilersetup%" %compilersetupargs%'

build_script:
 - echo dummy build script - dont remove me

test_script:
 - echo %PLATFORM%
 - echo %Darch%
 - echo %DC%
 - echo %DMD%
 - echo %PATH%
 - '%DC% --help'
 - dub test --arch=%Darch% --compiler=%DC%


If you have troubles with a specific version or compiler on Windows, you might want to allow failure in your build matrix until you get them fixed. For example to allow failure with ldc, you would add the following:

matrix:		
  allow_failures:		
    - DC: ldc

For a up-to-date AppVeyor setup, you can also always head to AppVeyor-D, or DUB or Mir.