diff options
| author | Hadrien Dorio <hadrien.dorio@gmail.com> | 2022-02-04 10:27:18 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-02-08 19:47:46 -0500 |
| commit | 846eb701821a3f2af514bbad770478e3276b2d89 (patch) | |
| tree | 2efee0c2fa6480ff697e9f26b82a51eb9395d46b /ci | |
| parent | 5a00e249632716b86edac088f69d19d82e307a28 (diff) | |
| download | zig-846eb701821a3f2af514bbad770478e3276b2d89.tar.gz zig-846eb701821a3f2af514bbad770478e3276b2d89.zip | |
ci: azure: split build-and-test step
replace the .bat script by a pwsh script
Diffstat (limited to 'ci')
| -rw-r--r-- | ci/azure/pipelines.yml | 132 | ||||
| -rw-r--r-- | ci/azure/windows_msvc_install | 16 | ||||
| -rw-r--r-- | ci/azure/windows_msvc_script.bat | 39 | ||||
| -rwxr-xr-x | ci/azure/windows_upload | 46 |
4 files changed, 114 insertions, 119 deletions
diff --git a/ci/azure/pipelines.yml b/ci/azure/pipelines.yml index 4524ee9fb1..f0df4558c2 100644 --- a/ci/azure/pipelines.yml +++ b/ci/azure/pipelines.yml @@ -10,6 +10,7 @@ jobs: - script: ci/azure/macos_script name: main displayName: 'Build and test' + - job: BuildMacOS_arm64 pool: vmImage: 'macOS-10.15' @@ -21,30 +22,125 @@ jobs: - script: ci/azure/macos_arm64_script name: main displayName: 'Build' + - job: BuildWindows + timeoutInMinutes: 360 pool: vmImage: 'windows-2019' - timeoutInMinutes: 360 + variables: + LLVM_CLANG_LLD_URL: 'https://ziglang.org/deps/llvm+clang+lld-13.0.0-x86_64-windows-msvc-release-mt.tar.xz' + LLVM_CLANG_LLD_DIR: 'llvm+clang+lld-13.0.0-x86_64-windows-msvc-release-mt' steps: - - powershell: | - (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") - .\sfx.exe -y -o\ - displayName: Download/Extract/Install MSYS2 - - script: | - @REM install updated filesystem package first without dependency checking - @REM because of: https://github.com/msys2/MSYS2-packages/issues/2021 - %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Sydd filesystem" - displayName: Workaround filesystem dash MSYS2 dependency issue - - script: | - %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" - %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" - displayName: Update MSYS2 + - pwsh: | + (New-Object Net.WebClient).DownloadFile("$(LLVM_CLANG_LLD_URL)", "${LLVM_CLANG_LLD_DIR}.tar.xz") + & 'C:\Program Files\7-Zip\7z.exe' x "${LLVM_CLANG_LLD_DIR}.tar.xz" + & 'C:\Program Files\7-Zip\7z.exe' x "${LLVM_CLANG_LLD_DIR}.tar" + name: install + displayName: 'Install LLVM/CLANG/LLD' + + - pwsh: | + Set-Variable -Name ZIGBUILDDIR -Value "$(Get-Location)\build" + Set-Variable -Name ZIGINSTALLDIR -Value "$ZIGBUILDDIR\dist" + Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$(LLVM_CLANG_LLD_DIR)" + + # Make the `zig version` number consistent. + # This will affect the cmake command below. + git config core.abbrev 9 + git fetch --tags + + mkdir $ZIGBUILDDIR + cd $ZIGBUILDDIR + & "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + cmake .. ` + -Thost=x64 ` + -G "Visual Studio 16 2019" ` + -A x64 ` + -DCMAKE_INSTALL_PREFIX="$ZIGINSTALLDIR" ` + -DCMAKE_PREFIX_PATH="$ZIGPREFIXPATH" ` + -DCMAKE_BUILD_TYPE=Release ` + -DZIG_OMIT_STAGE2=ON 2> out-null + & "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe" ` + /maxcpucount /p:Configuration=Release INSTALL.vcxproj + name: build + displayName: 'Build' + + - pwsh: | + Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\build\dist" + + # Sadly, stage2 is omitted from this build to save memory on the CI server. Once self-hosted is + # built with itself and does not gobble as much memory, we can enable these tests. + #& "$ZIGINSTALLDIR\bin\zig.exe" test "..\test\behavior.zig" -fno-stage1 -fLLVM -I "..\test" 2>&1 + + & "$ZIGINSTALLDIR\bin\zig.exe" build test-toolchain -Dskip-non-native -Dskip-stage2-tests 2>&1 + & "$ZIGINSTALLDIR\bin\zig.exe" build test-std -Dskip-non-native 2>&1 + name: test + displayName: 'Test' + + - pwsh: | + Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\build\dist" + + & "$ZIGINSTALLDIR\bin\zig.exe" build docs + timeoutInMinutes: 60 + name: doc + displayName: 'Documentation' + - task: DownloadSecureFile@1 inputs: - secureFile: s3cfg - - script: ci/azure/windows_msvc_script.bat - name: main - displayName: 'Build and test' + name: aws_credentials + secureFile: aws_credentials + + - pwsh: | + Set-Variable -Name ZIGBUILDDIR -Value "$(Get-Location)\build" + $Env:AWS_SHARED_CREDENTIALS_FILE = "$(aws_credentials.secureFilePath)" + + cd "$ZIGBUILDDIR" + mv ../LICENSE dist/ + mv ../zig-cache/langref.html dist/ + mv dist/bin/zig.exe dist/ + rmdir dist/bin + + # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig + mv dist/lib/zig dist/lib2 + rmdir dist/lib + mv dist/lib2 dist/lib + + Set-Variable -Name VERSION -Value $(./dist/zig.exe version) + Set-Variable -Name DIRNAME -Value "zig-windows-x86_64-$VERSION" + Set-Variable -Name TARBALL -Value "$DIRNAME.zip" + mv dist "$DIRNAME" + 7z a "$TARBALL" "$DIRNAME" + + aws s3 cp ` + "$TARBALL" ` + s3://ziglang.org/builds/ ` + --cache-control 'public, max-age=31536000, immutable' + + Set-Variable -Name SHASUM -Value (Get-FileHash "$TARBALL" -Algorithm SHA256 | select-object -ExpandProperty Hash) + Set-Variable -Name BYTESIZE -Value (Get-Item "$TARBALL").length + + Set-Variable -Name JSONFILE -Value "windows-${GITBRANCH}.json" + echo $null > $JSONFILE + echo ('{"tarball": "' + $TARBALL + '",') >> $JSONFILE + echo ('"shasum": "' + $SHASUM + '",') >> $JSONFILE + echo ('"size": ' + $BYTESIZE + '}' ) >> $JSONFILE + + aws s3 cp ` + "$JSONFILE" ` + s3://ziglang.org/builds/ ` + --cache-control 'max-age=0, must-revalidate' + + aws s3 cp ` + "$JSONFILE" ` + "s3://ziglang.org/builds/x86_64-windows-${VERSION}.json" + + echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL" + echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM" + echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE" + + name: upload + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) + displayName: 'Upload' + - job: OnMasterSuccess dependsOn: - BuildMacOS diff --git a/ci/azure/windows_msvc_install b/ci/azure/windows_msvc_install deleted file mode 100644 index 2df445fe12..0000000000 --- a/ci/azure/windows_msvc_install +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -set -x -set -e - -pacman -Suy --needed --noconfirm -pacman -S --needed --noconfirm wget p7zip python3-pip tar xz - -TARBALL="llvm+clang+lld-13.0.0-x86_64-windows-msvc-release-mt.tar.xz" - -pip install s3cmd -wget -nv "https://ziglang.org/deps/$TARBALL" -# If the first extraction fails, re-try it once; this can happen if the tarball -# contains symlinks that are in the table of contents before the files that -# they point to. -tar -xf $TARBALL || tar --overwrite -xf $TARBALL diff --git a/ci/azure/windows_msvc_script.bat b/ci/azure/windows_msvc_script.bat deleted file mode 100644 index c61c88093c..0000000000 --- a/ci/azure/windows_msvc_script.bat +++ /dev/null @@ -1,39 +0,0 @@ -@echo on -SET "SRCROOT=%cd%" -SET "PREVPATH=%PATH%" -SET "PREVMSYSTEM=%MSYSTEM%" - -set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" -SET "MSYSTEM=MINGW64" -bash -lc "cd ${SRCROOT} && ci/azure/windows_msvc_install" || exit /b -SET "PATH=%PREVPATH%" -SET "MSYSTEM=%PREVMSYSTEM%" - -SET "ZIGBUILDDIR=%SRCROOT%\build" -SET "ZIGINSTALLDIR=%ZIGBUILDDIR%\dist" -SET "ZIGPREFIXPATH=%SRCROOT%\llvm+clang+lld-13.0.0-x86_64-windows-msvc-release-mt" - -call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - -REM Make the `zig version` number consistent. -REM This will affect the cmake command below. -git.exe config core.abbrev 9 -git.exe fetch --unshallow -git.exe fetch --tags - -mkdir %ZIGBUILDDIR% -cd %ZIGBUILDDIR% -cmake.exe .. -Thost=x64 -G"Visual Studio 16 2019" -A x64 "-DCMAKE_INSTALL_PREFIX=%ZIGINSTALLDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release -DZIG_OMIT_STAGE2=ON || exit /b -msbuild /maxcpucount /p:Configuration=Release INSTALL.vcxproj || exit /b - -REM Sadly, stage2 is omitted from this build to save memory on the CI server. Once self-hosted is -REM built with itself and does not gobble as much memory, we can enable these tests. -REM "%ZIGINSTALLDIR%\bin\zig.exe" test "..\test\behavior.zig" -fno-stage1 -fLLVM -I "..\test" || exit /b - -"%ZIGINSTALLDIR%\bin\zig.exe" build test-toolchain -Dskip-non-native -Dskip-stage2-tests || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-std -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build docs || exit /b - -set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" -SET "MSYSTEM=MINGW64" -bash -lc "cd ${SRCROOT} && ci/azure/windows_upload" || exit /b diff --git a/ci/azure/windows_upload b/ci/azure/windows_upload deleted file mode 100755 index 9c5e07e5f9..0000000000 --- a/ci/azure/windows_upload +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -set -x -set -e - -if [ "${BUILD_REASON}" != "PullRequest" ]; then - cd "$ZIGBUILDDIR" - - mv ../LICENSE dist/ - mv ../zig-cache/langref.html dist/ - mv dist/bin/zig.exe dist/ - rmdir dist/bin - - # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig - mv dist/lib/zig dist/lib2 - rmdir dist/lib - mv dist/lib2 dist/lib - - VERSION=$(dist/zig.exe version) - DIRNAME="zig-windows-x86_64-$VERSION" - TARBALL="$DIRNAME.zip" - mv dist "$DIRNAME" - 7z a "$TARBALL" "$DIRNAME" - - # mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg" - s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/ - - SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1) - BYTESIZE=$(wc -c < $TARBALL) - - JSONFILE="windows-$GITBRANCH.json" - touch $JSONFILE - echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE - echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE - echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE - - s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE" - s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-windows-$VERSION.json" - - # `set -x` causes these variables to be mangled. - # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html - set +x - echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL" - echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM" - echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE" -fi |
