Merge branch 'cargo' into 'main'
[tor.git] / .appveyor.yml
blob134a0c49fff12832beffc722198ccd3ced4f1804
1 version: 1.0.{build}
3 clone_depth: 50
5 # Appveyor images are named after the Visual Studio version they contain.
6 # But we compile using MinGW, not Visual Studio.
7 # We use these images because they have different Windows versions.
8 image:
9   # Windows Server 2019
10   - Visual Studio 2019
12 environment:
13   compiler: mingw
15   matrix:
16   - target: i686-w64-mingw32
17     compiler_path: mingw32
18     mingw_prefix: mingw-w64-i686
19     hardening: --enable-all-bugs-are-fatal
20   - target: x86_64-w64-mingw32
21     compiler_path: mingw64
22     mingw_prefix: mingw-w64-x86_64
23     # hardening doesn't work with mingw-w64-x86_64-gcc, because it's gcc 8
24     hardening: --disable-gcc-hardening
26 matrix:
27   # Don't keep building failing jobs
28   fast_finish: true
29   # Skip the 32-bit Windows Server 2019 job, and the 64-bit Windows Server
30   # 2012 R2 job, to speed up the build.
31   # The environment variables must be listed without the 'environment' tag.
32   exclude:
33     - image: Visual Studio 2019
34       target: i686-w64-mingw32
35       compiler_path: mingw32
36       mingw_prefix: mingw-w64-i686
37       hardening: --enable-all-bugs-are-fatal
39 install:
40 - ps: >-
41     Function Execute-Command ($commandPath)
42     {
43         & $commandPath $args 2>&1
44         if ( $LastExitCode -ne 0 ) {
45             $host.SetShouldExit( $LastExitCode )
46         }
47     }
48     Function Execute-Bash ()
49     {
50         Execute-Command 'c:\msys64\usr\bin\bash' '-e' '-c' $args
51     }
52     <# mingw packages start with ${env:mingw_prefix}
53      # unprefixed packages are from MSYS2, which is like Cygwin. Avoid them.
54      #
55      # Use pacman --debug to show package downloads and install locations
56      #
57      # All installed library dlls must be copied to the test and app
58      # directories, before running tor's tests. (See below.)
59      #>
60     Execute-Command "C:\msys64\usr\bin\pacman" -Syu --verbose --noconfirm pacman ;
61 - ps: >-
62     Execute-Command "C:\msys64\usr\bin\pacman" -Sy --verbose --needed --noconfirm ${env:mingw_prefix}-libevent ${env:mingw_prefix}-openssl ${env:mingw_prefix}-pkg-config ${env:mingw_prefix}-xz ${env:mingw_prefix}-zstd ;
64 build_script:
65 - ps: >-
66     if ($env:compiler -eq "mingw") {
67             <# use the MSYS2 compiler and user binaries to build and install #>
68             $oldpath = ${env:Path} -split ';'
69             $buildpath = @("C:\msys64\${env:compiler_path}\bin", "C:\msys64\usr\bin") + $oldpath
70             $env:Path = @($buildpath) -join ';'
71             $env:build = @("${env:APPVEYOR_BUILD_FOLDER}", $env:target) -join '\'
72             Set-Location "${env:APPVEYOR_BUILD_FOLDER}"
73             Execute-Bash 'autoreconf -i'
74             mkdir "${env:build}"
75             Set-Location "${env:build}"
76             Execute-Bash "which ${env:target}-gcc"
77             Execute-Bash "${env:target}-gcc --version"
78             <# compile for mingw
79              # mingw zstd doesn't come with a pkg-config file, so we manually
80              # configure its flags. liblzma just works.
81              #>
82             Execute-Bash "ZSTD_CFLAGS='-L/${env:compiler_path}/include' ZSTD_LIBS='-L/${env:compiler_path}/lib -lzstd' ../configure --prefix=/${env:compiler_path} --build=${env:target} --host=${env:target} --with-openssl-dir=/${env:compiler_path} --disable-asciidoc --enable-fatal-warnings ${env:hardening} CFLAGS='-D__USE_MINGW_ANSI_STDIO=0'"
83             Execute-Bash "V=1 make -k -j2"
84             Execute-Bash "V=1 make -k -j2 install"
85      }
87 test_script:
88 - ps: >-
89     if ($env:compiler -eq "mingw") {
90             <# use the MSYS2 compiler binaries to make check #>
91             $oldpath = ${env:Path} -split ';'
92             $buildpath = @("C:\msys64\${env:compiler_path}\bin") + $oldpath
93             $env:Path = $buildpath -join ';'
94             Set-Location "${env:build}"
95             <# Some compiler dlls must be copied to the test and app
96              # directories, before running tor's tests.
97              #>
98             Copy-Item "C:/msys64/${env:compiler_path}/bin/libssp-0.dll","C:/msys64/${env:compiler_path}/bin/zlib1.dll" -Destination "${env:build}/src/test"
99             Copy-Item "C:/msys64/${env:compiler_path}/bin/libssp-0.dll","C:/msys64/${env:compiler_path}/bin/zlib1.dll" -Destination "${env:build}/src/app"
100             <# All installed library dlls must be copied to the test and app
101              # directories, before running tor's tests.
102              # (See install command above.)
103              #>
104             Copy-Item "C:/${env:compiler_path}/bin/libcrypto*.dll","C:/${env:compiler_path}/bin/libssl*.dll","C:/${env:compiler_path}/bin/liblzma*.dll","C:/${env:compiler_path}/bin/libevent*.dll","C:/${env:compiler_path}/bin/libzstd*.dll" -Destination "${env:build}/src/test"
105             Copy-Item "C:/${env:compiler_path}/bin/libcrypto*.dll","C:/${env:compiler_path}/bin/libssl*.dll","C:/${env:compiler_path}/bin/liblzma*.dll","C:/${env:compiler_path}/bin/libevent*.dll","C:/${env:compiler_path}/bin/libzstd*.dll" -Destination "${env:build}/src/app"
106             Execute-Bash "VERBOSE=1 TOR_SKIP_TESTCASES=crypto/openssl_version make -k -j2 check"
107     }
109 on_finish:
110 - ps: >-
111     <# if we failed before install:, these functions won't be defined #>
112     Function Execute-Command ($commandPath)
113     {
114         & $commandPath $args 2>&1
115         if ( $LastExitCode -ne 0 ) {
116             $host.SetShouldExit( $LastExitCode )
117         }
118     }
119     Function Execute-Bash ()
120     {
121         Execute-Command 'c:\msys64\usr\bin\bash' '-e' '-c' $args
122     }
123     if ($env:compiler -eq "mingw") {
124             <# use the MSYS2 user binaries to archive failures #>
125             $oldpath = ${env:Path} -split ';'
126             $buildpath = @("C:\msys64\usr\bin") + $oldpath
127             $env:Path = @($buildpath) -join ';'
128             Set-Location "${env:build}"
129             <# store logs as appveyor artifacts: see the artifacts tab #>
130             Execute-Bash "7z a logs.zip config.log || true"
131             Execute-Bash "7z a logs.zip test-suite.log || true"
132             Execute-Bash "appveyor PushArtifact logs.zip || true"
133             Execute-Bash "tail -1000 config.log || true"
134             Execute-Bash "cat test-suite.log || true"
135     }
137 # notify the IRC channel of any failures
138 on_failure:
139 - cmd: C:\Python27\python.exe %APPVEYOR_BUILD_FOLDER%\scripts\test\appveyor-irc-notify.py irc.oftc.net:6697 tor-ci failure