TUN-8066: Define scripts to build on Windows agents
This commit is contained in:
parent
12dd91ada1
commit
33baad35b8
|
@ -0,0 +1,28 @@
|
|||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
|
||||
# Relative path to working directory
|
||||
$CloudflaredDirectory = "go\src\github.com\cloudflare\cloudflared"
|
||||
|
||||
cd $CloudflaredDirectory
|
||||
|
||||
Write-Output "Building for amd64"
|
||||
$env:TARGET_OS = "windows"
|
||||
$env:CGO_ENABLED = 1
|
||||
$env:TARGET_ARCH = "amd64"
|
||||
$env:Path = "$Env:Temp\go\bin;$($env:Path)"
|
||||
|
||||
go env
|
||||
go version
|
||||
|
||||
& make cloudflared
|
||||
if ($LASTEXITCODE -ne 0) { throw "Failed to build cloudflared for amd64" }
|
||||
copy .\cloudflared.exe .\cloudflared-windows-amd64.exe
|
||||
|
||||
Write-Output "Building for 386"
|
||||
$env:CGO_ENABLED = 0
|
||||
$env:TARGET_ARCH = "386"
|
||||
make cloudflared
|
||||
if ($LASTEXITCODE -ne 0) { throw "Failed to build cloudflared for 386" }
|
||||
copy .\cloudflared.exe .\cloudflared-windows-386.exe
|
|
@ -0,0 +1,82 @@
|
|||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
|
||||
$WorkingDirectory = Get-Location
|
||||
$CloudflaredDirectory = "$WorkingDirectory\go\src\github.com\cloudflare\cloudflared"
|
||||
|
||||
Write-Output "Installing python..."
|
||||
|
||||
$PythonVersion = "3.10.11"
|
||||
$PythonZipFile = "$env:Temp\python-$PythonVersion-embed-amd64.zip"
|
||||
$PipInstallFile = "$env:Temp\get-pip.py"
|
||||
$PythonZipUrl = "https://www.python.org/ftp/python/$PythonVersion/python-$PythonVersion-embed-amd64.zip"
|
||||
$PythonPath = "$WorkingDirectory\Python"
|
||||
$PythonBinPath = "$PythonPath\python.exe"
|
||||
|
||||
# Download Python zip file
|
||||
Invoke-WebRequest -Uri $PythonZipUrl -OutFile $PythonZipFile
|
||||
|
||||
# Download Python pip file
|
||||
Invoke-WebRequest -Uri "https://bootstrap.pypa.io/get-pip.py" -OutFile $PipInstallFile
|
||||
|
||||
# Extract Python files
|
||||
Expand-Archive $PythonZipFile -DestinationPath $PythonPath -Force
|
||||
|
||||
# Add Python to PATH
|
||||
$env:Path = "$PythonPath\Scripts;$PythonPath;$($env:Path)"
|
||||
|
||||
Write-Output "Installed to $PythonPath"
|
||||
|
||||
# Install pip
|
||||
& $PythonBinPath $PipInstallFile
|
||||
|
||||
# Add package paths in pythonXX._pth to unblock python -m pip
|
||||
$PythonImportPathFile = "$PythonPath\python310._pth"
|
||||
$ComponentTestsDir = "$CloudflaredDirectory\component-tests\"
|
||||
@($ComponentTestsDir, "Lib\site-packages", $(Get-Content $PythonImportPathFile)) | Set-Content $PythonImportPathFile
|
||||
|
||||
# Test Python installation
|
||||
& $PythonBinPath --version
|
||||
& $PythonBinPath -m pip --version
|
||||
|
||||
go env
|
||||
go version
|
||||
|
||||
$env:TARGET_OS = "windows"
|
||||
$env:CGO_ENABLED = 1
|
||||
$env:TARGET_ARCH = "amd64"
|
||||
$env:Path = "$Env:Temp\go\bin;$($env:Path)"
|
||||
|
||||
& $PythonBinPath --version
|
||||
& $PythonBinPath -m pip --version
|
||||
|
||||
cd $CloudflaredDirectory
|
||||
|
||||
go env
|
||||
go version
|
||||
|
||||
Write-Output "Building cloudflared"
|
||||
|
||||
& make cloudflared
|
||||
if ($LASTEXITCODE -ne 0) { throw "Failed to build cloudflared" }
|
||||
|
||||
echo $LASTEXITCODE
|
||||
|
||||
Write-Output "Running unit tests"
|
||||
|
||||
# Not testing with race detector because of https://github.com/golang/go/issues/61058
|
||||
# We already test it on other platforms
|
||||
& go test -failfast -mod=vendor ./...
|
||||
if ($LASTEXITCODE -ne 0) { throw "Failed unit tests" }
|
||||
|
||||
Write-Output "Running component tests"
|
||||
|
||||
& $PythonBinPath -m pip install --upgrade -r component-tests/requirements.txt
|
||||
& $PythonBinPath component-tests/setup.py --type create
|
||||
& $PythonBinPath -m pytest component-tests -o log_cli=true --log-cli-level=INFO
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
& $PythonBinPath component-tests/setup.py --type cleanup
|
||||
throw "Failed component tests"
|
||||
}
|
||||
& $PythonBinPath component-tests/setup.py --type cleanup
|
|
@ -0,0 +1,16 @@
|
|||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
|
||||
Write-Output "Downloading cloudflare go..."
|
||||
|
||||
Set-Location "$Env:Temp"
|
||||
|
||||
git clone -q https://github.com/cloudflare/go
|
||||
Write-Output "Building go..."
|
||||
cd go/src
|
||||
# https://github.com/cloudflare/go/tree/34129e47042e214121b6bbff0ded4712debed18e is version go1.21.5-devel-cf
|
||||
git checkout -q 34129e47042e214121b6bbff0ded4712debed18e
|
||||
& ./make.bat
|
||||
|
||||
Write-Output "Installed"
|
|
@ -0,0 +1,20 @@
|
|||
$ErrorActionPreference = "Stop"
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
$GoMsiVersion = "go1.21.5.windows-amd64.msi"
|
||||
|
||||
Write-Output "Downloading go installer..."
|
||||
|
||||
Set-Location "$Env:Temp"
|
||||
|
||||
(New-Object System.Net.WebClient).DownloadFile(
|
||||
"https://go.dev/dl/$GoMsiVersion",
|
||||
"$Env:Temp\$GoMsiVersion"
|
||||
)
|
||||
|
||||
Write-Output "Installing go..."
|
||||
Install-Package "$Env:Temp\$GoMsiVersion" -Force
|
||||
|
||||
# Go installer updates global $PATH
|
||||
go env
|
||||
|
||||
Write-Output "Installed"
|
|
@ -1,8 +1,8 @@
|
|||
cloudflare==2.8.15
|
||||
cloudflare==2.14.3
|
||||
flaky==3.7.0
|
||||
pytest==7.3.1
|
||||
pytest-asyncio==0.21.0
|
||||
pyyaml==5.4.1
|
||||
pyyaml==6.0.1
|
||||
requests==2.28.2
|
||||
retrying==1.3.4
|
||||
websockets==11.0.1
|
||||
|
|
|
@ -74,7 +74,7 @@ def delete_tunnel(config):
|
|||
|
||||
@retry(stop_max_attempt_number=MAX_RETRIES, wait_fixed=BACKOFF_SECS * 1000)
|
||||
def create_dns(config, hostname, type, content):
|
||||
cf = CloudFlare.CloudFlare(debug=True, token=get_env("DNS_API_TOKEN"))
|
||||
cf = CloudFlare.CloudFlare(debug=False, token=get_env("DNS_API_TOKEN"))
|
||||
cf.zones.dns_records.post(
|
||||
config["zone_tag"],
|
||||
data={'name': hostname, 'type': type, 'content': content, 'proxied': True}
|
||||
|
@ -89,7 +89,7 @@ def create_named_dns(config, random_uuid):
|
|||
|
||||
@retry(stop_max_attempt_number=MAX_RETRIES, wait_fixed=BACKOFF_SECS * 1000)
|
||||
def delete_dns(config, hostname):
|
||||
cf = CloudFlare.CloudFlare(debug=True, token=get_env("DNS_API_TOKEN"))
|
||||
cf = CloudFlare.CloudFlare(debug=False, token=get_env("DNS_API_TOKEN"))
|
||||
zone_tag = config["zone_tag"]
|
||||
dns_records = cf.zones.dns_records.get(zone_tag, params={'name': hostname})
|
||||
if len(dns_records) > 0:
|
||||
|
|
|
@ -4,6 +4,7 @@ import platform
|
|||
import subprocess
|
||||
from contextlib import contextmanager
|
||||
from time import sleep
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -14,8 +15,14 @@ from retrying import retry
|
|||
|
||||
from constants import METRICS_PORT, MAX_RETRIES, BACKOFF_SECS
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
def configure_logger():
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
handler = logging.StreamHandler(sys.stdout)
|
||||
logger.addHandler(handler)
|
||||
return logger
|
||||
|
||||
LOGGER = configure_logger()
|
||||
|
||||
def select_platform(plat):
|
||||
return pytest.mark.skipif(
|
||||
|
|
Loading…
Reference in New Issue