authorgravatar for hadrien.dorio@gmail.comHadrien Dorio <hadrien.dorio@gmail.com> 2022-02-17 04:33:08+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-02-16 22:33:08-05:00
log02902cc099d9736d589ac4f0e0ff671d7dfa9557
treed21f8466cdd55c84a8d09622fd9fdffe44434b41
parentdf8c325012ce8b9a93606edb0ffcc58739071891
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

ci: azure: split build-and-test step (#10853)

replace the .bat script by a pwsh script

3 files changed, 139 insertions(+), 113 deletions(-)

CMakeLists.txt+1-1
......@@ -63,7 +63,7 @@ if("${ZIG_VERSION}" STREQUAL "")
6363 endif()
6464 endif()
6565endif()
66message("Configuring zig version ${ZIG_VERSION}")
66message(STATUS "Configuring zig version ${ZIG_VERSION}")
6767
6868set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
6969set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")
ci/azure/pipelines.yml+138-18
......@@ -22,29 +22,149 @@ jobs:
2222 name: main
2323 displayName: 'Build'
2424- job: BuildWindows
25 timeoutInMinutes: 360
2526 pool:
2627 vmImage: 'windows-2019'
27 timeoutInMinutes: 360
28 variables:
29 TARGET: 'x86_64-windows-gnu'
30 ZIG_LLVM_CLANG_LLD_NAME: 'zig+llvm+lld+clang-${{ variables.TARGET }}-0.9.1'
31 ZIG_LLVM_CLANG_LLD_URL: 'https://ziglang.org/deps/${{ variables.ZIG_LLVM_CLANG_LLD_NAME }}.zip'
2832 steps:
29 - powershell: |
30 (New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2022-01-28/msys2-base-x86_64-20220128.sfx.exe", "sfx.exe")
31 .\sfx.exe -y -o\
32 displayName: Download/Extract/Install MSYS2
33 - script: |
34 @REM install updated filesystem package first without dependency checking
35 @REM because of: https://github.com/msys2/MSYS2-packages/issues/2021
36 %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Sydd filesystem"
37 displayName: Workaround filesystem dash MSYS2 dependency issue
38 - script: |
39 %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu"
40 %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu"
41 displayName: Update MSYS2
33 - pwsh: |
34 (New-Object Net.WebClient).DownloadFile("$(ZIG_LLVM_CLANG_LLD_URL)", "${ZIG_LLVM_CLANG_LLD_NAME}.zip")
35 & 'C:\Program Files\7-Zip\7z.exe' x "${ZIG_LLVM_CLANG_LLD_NAME}.zip"
36 name: install
37 displayName: 'Install ZIG/LLVM/CLANG/LLD'
38
39 - pwsh: |
40 Set-Variable -Name ZIGBUILDDIR -Value "$(Get-Location)\build"
41 Set-Variable -Name ZIGINSTALLDIR -Value "${ZIGBUILDDIR}\dist"
42 Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$(ZIG_LLVM_CLANG_LLD_NAME)"
43
44 # Make the `zig version` number consistent.
45 # This will affect the `zig build` command below which uses `git describe`.
46 git config core.abbrev 9
47 git fetch --tags
48 if ((git rev-parse --is-shallow-repository) -eq "true") {
49 git fetch --unshallow # `git describe` won't work on a shallow repo
50 }
51
52 # The dev kit zip file that we have here is old, and may be incompatible with
53 # the build.zig script of master branch. So we keep an old version of build.zig
54 # here in the CI directory.
55 mv build.zig build.zig.master
56 mv ci/azure/build.zig build.zig
57
58 mkdir $ZIGBUILDDIR
59 cd $ZIGBUILDDIR
60
61 & "${ZIGPREFIXPATH}/bin/zig.exe" build `
62 --prefix "$ZIGINSTALLDIR" `
63 --search-prefix "$ZIGPREFIXPATH" `
64 -Dstage1 `
65 <# stage2 is omitted until we resolve https://github.com/ziglang/zig/issues/6485 #> `
66 -Domit-stage2 `
67 -Dstatic-llvm `
68 -Drelease `
69 -Dstrip `
70 -Duse-zig-libcxx `
71 -Dtarget=$(TARGET)
72
73 cd -
74
75 # Now that we have built an up-to-date zig.exe, we restore the original
76 # build script from master branch.
77 rm build.zig
78 mv build.zig.master build.zig
79
80 name: build
81 displayName: 'Build'
82
83 - pwsh: |
84 Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\build\dist"
85
86 # Sadly, stage2 is omitted from this build to save memory on the CI server. Once self-hosted is
87 # built with itself and does not gobble as much memory, we can enable these tests.
88 #& "$ZIGINSTALLDIR\bin\zig.exe" test "..\test\behavior.zig" -fno-stage1 -fLLVM -I "..\test" 2>&1
89
90 & "$ZIGINSTALLDIR\bin\zig.exe" build test-toolchain -Dskip-non-native -Dskip-stage2-tests 2>&1
91 & "$ZIGINSTALLDIR\bin\zig.exe" build test-std -Dskip-non-native 2>&1
92 name: test
93 displayName: 'Test'
94
95 - pwsh: |
96 Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\build\dist"
97
98 & "$ZIGINSTALLDIR\bin\zig.exe" build docs
99 timeoutInMinutes: 60
100 name: doc
101 displayName: 'Documentation'
102
42103 - task: DownloadSecureFile@1
43104 inputs:
44 secureFile: s3cfg
45 - script: ci/azure/windows_script.bat
46 name: main
47 displayName: 'Build and test'
105 name: aws_credentials
106 secureFile: aws_credentials
107
108 - pwsh: |
109 Set-Variable -Name ZIGBUILDDIR -Value "$(Get-Location)\build"
110 $Env:AWS_SHARED_CREDENTIALS_FILE = "$Env:DOWNLOADSECUREFILE_SECUREFILEPATH"
111
112 # Workaround Azure networking issue
113 # https://github.com/aws/aws-cli/issues/5749
114 $Env:AWS_EC2_METADATA_DISABLED = "true"
115 $Env:AWS_REGION = "us-west-2"
116
117 cd "$ZIGBUILDDIR"
118 mv ../LICENSE dist/
119 mv ../zig-cache/langref.html dist/
120 mv dist/bin/zig.exe dist/
121 rmdir dist/bin
122
123 # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
124 mv dist/lib/zig dist/lib2
125 rmdir dist/lib
126 mv dist/lib2 dist/lib
127
128 Set-Variable -Name VERSION -Value $(./dist/zig.exe version)
129 Set-Variable -Name DIRNAME -Value "zig-windows-x86_64-$VERSION"
130 Set-Variable -Name TARBALL -Value "$DIRNAME.zip"
131 mv dist "$DIRNAME"
132 7z a "$TARBALL" "$DIRNAME"
133
134 aws s3 cp `
135 "$TARBALL" `
136 s3://ziglang.org/builds/ `
137 --acl public-read `
138 --cache-control 'public, max-age=31536000, immutable'
139
140 Set-Variable -Name SHASUM -Value (Get-FileHash "$TARBALL" -Algorithm SHA256 | select-object -ExpandProperty Hash)
141 Set-Variable -Name BYTESIZE -Value (Get-Item "$TARBALL").length
142
143 Set-Variable -Name JSONFILE -Value "windows-${Env:BUILD_SOURCEBRANCHNAME}.json"
144 echo $null > $JSONFILE
145 echo ('{"tarball": "' + $TARBALL + '",') >> $JSONFILE
146 echo ('"shasum": "' + $SHASUM + '",') >> $JSONFILE
147 echo ('"size": ' + $BYTESIZE + '}' ) >> $JSONFILE
148
149 aws s3 cp `
150 "$JSONFILE" `
151 s3://ziglang.org/builds/ `
152 --acl public-read `
153 --cache-control 'max-age=0, must-revalidate'
154
155 aws s3 cp `
156 "$JSONFILE" `
157 "s3://ziglang.org/builds/x86_64-windows-${VERSION}.json" `
158 --acl public-read
159
160 echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
161 echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
162 echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
163
164 name: upload
165 condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
166 displayName: 'Upload'
167
48168- job: OnMasterSuccess
49169 dependsOn:
50170 - BuildMacOS
ci/azure/windows_script deleted-94
......@@ -1,94 +0,0 @@
1#!/bin/sh
2
3set -x
4set -e
5
6pacman -Suy --needed --noconfirm
7pacman -S --needed --noconfirm wget p7zip python3-pip git
8pip install s3cmd
9
10ZIGDIR="$(pwd)"
11ARCH="x86_64"
12TARGET="$ARCH-windows-gnu"
13CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.9.1"
14PREFIX="$HOME/$CACHE_BASENAME"
15ZIG="$PREFIX/bin/zig.exe"
16
17rm -rf $PREFIX
18cd $HOME
19
20wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.zip"
217z x "$CACHE_BASENAME.zip"
22
23cd $ZIGDIR
24
25# Make the `zig version` number consistent.
26# This will affect the `zig build` command below.
27git config core.abbrev 9
28git fetch --unshallow || true
29git fetch --tags
30
31# The dev kit zip file that we have here is old, and may be incompatible with
32# the build.zig script of master branch. So we keep an old version of build.zig
33# here in the CI directory.
34mv build.zig build.zig.master
35mv ci/azure/build.zig build.zig
36
37# stage2 is omitted until we resolve https://github.com/ziglang/zig/issues/6485
38$ZIG build \
39 --prefix dist \
40 --search-prefix "$PREFIX" \
41 -Dstage1 \
42 -Domit-stage2 \
43 -Dstatic-llvm \
44 -Drelease \
45 -Dstrip \
46 -Duse-zig-libcxx \
47 -Dtarget=$TARGET
48
49# Now that we have built an up-to-date zig.exe, we restore the original
50# build script from master branch.
51mv build.zig.master build.zig
52
53dist/bin/zig.exe build test-toolchain -Dskip-non-native -Dskip-stage2-tests
54dist/bin/zig.exe build test-std -Dskip-non-native
55dist/bin/zig.exe build docs
56
57if [ "${BUILD_REASON}" != "PullRequest" ]; then
58 mv LICENSE dist/
59 mv zig-cache/langref.html dist/
60 mv dist/bin/zig.exe dist/
61 rmdir dist/bin
62
63 # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
64 mv dist/lib/zig dist/lib2
65 rmdir dist/lib
66 mv dist/lib2 dist/lib
67
68 VERSION=$(dist/zig.exe version)
69 DIRNAME="zig-windows-x86_64-$VERSION"
70 TARBALL="$DIRNAME.zip"
71 mv dist "$DIRNAME"
72 7z a "$TARBALL" "$DIRNAME"
73
74 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
75
76 SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
77 BYTESIZE=$(wc -c < $TARBALL)
78
79 JSONFILE="windows-$GITBRANCH.json"
80 touch $JSONFILE
81 echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
82 echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
83 echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
84
85 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
86 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-windows-$VERSION.json"
87
88 # `set -x` causes these variables to be mangled.
89 # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
90 set +x
91 echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
92 echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
93 echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
94fi