aboutsummaryrefslogtreecommitdiff
path: root/ci/azure-steps.yml
blob: 9d143db7df61fcac227b06d067dd7e8a493024b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
steps:
- powershell: |
     python ./skip_ci.py --base-branch-env=SYSTEM_PULLREQUEST_TARGETBRANCH --is-pull-env=SYSTEM_PULLREQUEST_PULLREQUESTID --base-branch-origin
     if ($LastExitCode -ne 0) {
        exit 0
     }

     # remove Chocolately, MinGW, Strawberry Perl from path, so we don't find gcc/gfortran and try to use it
     $env:Path = ($env:Path.Split(';') | Where-Object { $_ -notmatch 'mingw|Strawberry|Chocolatey' }) -join ';'

     # download and install prerequisites
     function DownloadFile([String] $Source, [String] $Destination) {
       $retries = 10
       for ($i = 1; $i -le $retries; $i++) {
           try {
               (New-Object net.webclient).DownloadFile($Source, $Destination)
               break # succeeded
           } catch [net.WebException] {
               if ($i -eq $retries) {
                   throw # fail on last retry
               }
               $backoff = (10 * $i) # backoff 10s, 20s, 30s...
               echo ('{0}: {1}' -f $Source, $_.Exception.Message)
               echo ('Retrying in {0}s...' -f $backoff)
               Start-Sleep -m ($backoff * 1000)
              }
          }
     }

     DownloadFile -Source 'https://github.com/mesonbuild/cidata/raw/master/ninja.exe' -Destination $(System.WorkFolder)\ninja.exe
     DownloadFile -Source 'http://nirbheek.in/files/binaries/pkg-config/win32/pkg-config.exe' -Destination $(System.WorkFolder)\pkg-config.exe
     DownloadFile -Source 'https://download.microsoft.com/download/D/B/B/DBB64BA1-7B51-43DB-8BF1-D1FB45EACF7A/msmpisdk.msi' -Destination msmpisdk.msi
     DownloadFile -Source 'https://download.microsoft.com/download/D/B/B/DBB64BA1-7B51-43DB-8BF1-D1FB45EACF7A/MSMpiSetup.exe' -Destination MSMpiSetup.exe
     if ($env:compiler -ne 'msvc2015') {
       Start-Process msiexec.exe -ArgumentList '/i msmpisdk.msi /quiet' -Wait
       # installer fails "requires an interactive window station" with vs2015 image
       Start-Process .\MSMpiSetup.exe -ArgumentList '-unattend -full' -Wait
     }

     # import ms-mpi env vars (set by installer)
     foreach ($p in "MSMPI_INC", "MSMPI_LIB32", "MSMPI_LIB64") {
       $v = [Environment]::GetEnvironmentVariable($p, "Machine")
       Set-Content "env:$p" "$v"
     }

     if ($env:compiler -eq 'msvc2015') {
       if ($env:arch -eq 'x86') {
         $forcex86 = "--forcex86"
       }

       # download and install python3 and add to path (since it's not installed in vs2015 image!)
       Set-ExecutionPolicy Bypass -Scope Process -Force
       iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
       choco install python3 -y --no-progress $forcex86 --params "/InstallDir:C:\Python3"
       $env:Path = "C:\Python3;$env:Path"

       # add JDK installed in vs2015 image to PATH
       $env:Path = "C:\java\jdk\jdk1.8.0_102\bin\;$env:Path"
     }

     # install boost (except for clang-cl)
     if ($env:arch -eq 'x86') { $boost_bitness = '32' } else { $boost_bitness = '64' }
     if ($env:compiler -eq 'msvc2015') {
       $boost_version = '1.60.0' ; $boost_abi_tag = '14.0'
     } elseif ($env:compiler -eq 'msvc2017') {
       $boost_version = '1.64.0' ; $boost_abi_tag = '14.1'
     }
     if ($boost_version) {
       $boost_filename = $boost_version.Replace('.', '_')
       Downloadfile -Source "https://sourceforge.net/projects/boost/files/boost-binaries/$boost_version/boost_$boost_filename-msvc-$boost_abi_tag-$boost_bitness.exe" -Destination boost_$boost_filename-msvc-$boost_abi_tag-$boost_bitness.exe
       Start-Process "boost_$boost_filename-msvc-$boost_abi_tag-$boost_bitness.exe" -ArgumentList "/dir=$(System.WorkFolder)\boost_$boost_filename /silent" -Wait
       $env:BOOST_ROOT = "$(System.WorkFolder)\boost_$boost_filename"
       $env:Path = "$env:Path;$env:BOOST_ROOT\lib$boost_bitness-msvc-$boost_abi_tag"
     } else {
       $env:BOOST_ROOT = ""
     }

     # install D compiler and dub packages
     if ($env:backend -eq 'ninja') {
          & .\ci\install-dmd.ps1
          $arch = 'x86_mscoff'
          if ($Env:arch -eq 'x64') {
            $arch = 'x86_64'
          }
          & dub fetch urld
          & dub build urld --compiler=dmd --arch=$arch
          & dub fetch dubtestproject
          & dub build dubtestproject:test1 --compiler=dmd --arch=$arch
          & dub build dubtestproject:test2 --compiler=dmd --arch=$arch
        }

     # test_find_program exercises some behaviour which relies on .py being in PATHEXT
     $env:PATHEXT += ';.py'

     # add downloads to PATH
     $env:Path = "$env:SYSTEM_WORKFOLDER;$env:Path"

     $origPath = $env:Path
     # import visual studio variables
     if ($env:compiler -eq 'msvc2015') {
       $vcvars = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
     } else {
       $vcvars = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
     }

     ## ask cmd.exe to output the environment table after the batch file completes
     $tempFile = [IO.Path]::GetTempFileName()
     cmd /c " `"$vcvars`" $env:arch && set > `"$tempFile`" "

     ## go through the environment variables in the temp file.
     ## for each of them, set the variable in our local environment.
     Get-Content $tempFile | Foreach-Object {
       if($_ -match "^(.*?)=(.*)$") {
         Set-Content "env:\$($matches[1])" $matches[2]
       }
     }
     Remove-Item $tempFile

     if ($env:compiler -eq 'clang-cl') {
       # drop visual studio from PATH
       # (but leave INCLUDE, LIB and WindowsSdkDir environment variables set)
       $env:Path = $origPath

       # install llvm for clang-cl builds
       DownloadFile -Source 'http://releases.llvm.org/7.0.0/LLVM-7.0.0-win64.exe' -Destination LLVM-7.0.0-win64.exe
       Start-Process .\LLVM-7.0.0-win64.exe -ArgumentList '/S' -Wait
       $env:Path = "C:\Program Files\LLVM\bin;$env:Path"
       $env:CC = "clang-cl"
       $env:CXX = "clang-cl"

       # and use Windows SDK tools
       $env:Path = "$env:WindowsSdkDir\bin\$env:Arch;$env:Path"
     }

     # add .NET framework tools to path for resgen for C# tests
     # (always use 32-bit tool, as there doesn't seem to be a 64-bit tool)
     if ((Get-Command "resgen.exe" -ErrorAction SilentlyContinue) -eq $null) {
       $env:Path = "$env:WindowsSDK_ExecutablePath_x86;$env:Path"
     }

     if ($env:backend -eq 'ninja') {
       ninja --version
     } else {
       MSBuild /version
     }

     echo "=== PATH BEGIN ==="
     echo ($env:Path).Replace(';',"`n")
     echo "=== PATH END ==="
     echo ""
     echo "Locating Python:"
     where.exe python
     python --version

     echo ""
     echo "=== Start running tests ==="
     python run_tests.py --backend $(backend)

- task: PublishTestResults@2
  inputs:
    testResultsFiles: meson-test-run.xml
    testRunTitle: $(System.JobName)
    publishRunAttachments: true
  condition: not(canceled())

- task: CopyFiles@2
  inputs:
    contents: 'meson-test-run.*'
    targetFolder: $(Build.ArtifactStagingDirectory)
  condition: not(canceled())

- task: PublishBuildArtifacts@1
  inputs:
    artifactName: $(System.JobName)
  condition: not(canceled())