From 1984dbdaaf4bab7d97e8458cfb337288add5d796 Mon Sep 17 00:00:00 2001 From: "azure-pipelines[bot]" Date: Sun, 18 Nov 2018 09:04:42 -0500 Subject: [PATCH] Set up CI with Azure Pipelines (#862) * Set up CI with Azure Pipelines * trial & error * use robocopy * fix slash * handle robocopy exit code * rm goroot * build proxy * build & test proxy * Skip Test_checkFilePerms on Win until issue resolved * start minio and mongo * do not create a new network on win 2016 * use win docker img for mongo * download and start minio since there is no win docker img * fix minio download & exec * add minio access key and secret * use new mongodb img * fix docker-compose mongo * trying to fix mongo tests * ipconfig * lets try that * use docker inspect to get the container ip * echo mongo container ip * debuging docker inspect ipaddress * set mongo env var to internal addr * debug * quotation is difficult * without docker * pass db dir * split steps * add some echos to know what takes so long * cleanup * add downloadURL var for minio and mongo * rm windows docker compose file --- azure-pipelines.yml | 59 +++++++++++++++++++++++++++++++++++++++ pkg/config/config_test.go | 7 +++++ pkg/storage/s3/s3_test.go | 8 +++++- 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..b54c8f15 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,59 @@ +# Go +# Build your Go project. +# Add steps that test, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/go + +pool: + vmImage: 'vs2017-win2016' + +variables: + GOBIN: '$(GOPATH)\bin' # Go binaries path + GOPATH: '$(system.defaultWorkingDirectory)\gopath' # Go workspace path + GO111MODULE: 'on' + modulePath: '$(GOPATH)\src\github.com\$(build.repository.name)' # Path to the module's code + +steps: +- powershell: | + mkdir "$env:GOBIN" | out-null + mkdir "$env:GOPATH\pkg" | out-null + mkdir "$env:modulePath" | out-null + robocopy "$env:system_defaultWorkingDirectory\" "$env:modulePath\" /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD "$env:GOPATH" + exit ($LastExitCode -band 24) + displayName: 'set up the Go workspace' + +- powershell: | + $downloadURL = "https://dl.minio.io/server/minio/release/windows-amd64/minio.exe" + Write-Host "download minio from $downloadURL - start" + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + Invoke-WebRequest -Uri $downloadURL -OutFile "minio.exe" + Write-Host "download minio - end" + Start-Process -NoNewWindow minio.exe 'server --address ":9001" .' + env: + MINIO_ACCESS_KEY: "minio" + MINIO_SECRET_KEY: "minio123" + displayName: 'start minio' + +- powershell: | + $downloadURL = "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.4-signed.msi" + Write-Host "download mongo from $downloadURL - start" + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + Invoke-WebRequest -Uri $downloadURL -OutFile "mongo.msi" + Write-Host "download mongo - end" + Write-Host "install mongo - start" + Start-Process msiexec -Wait -ArgumentList @('/i', 'mongo.msi', '/quiet', '/qn', 'INSTALLLOCATION=C:\mongodb', 'ADDLOCAL=all') + $env:PATH = 'C:\mongodb\bin;' + $env:PATH + [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine) + mkdir C:\data\db | out-null + mkdir C:\data\configdb | out-null + Write-Host "install mongo - end" + Start-Process -NoNewWindow mongod.exe '--bind_ip_all --dbpath="C:\data\db"' + displayName: 'install & start mongo' + +- powershell: | + go test -mod=vendor -race ./... + env: + ATHENS_MINIO_ENDPOINT: "127.0.0.1:9001" + ATHENS_MONGO_STORAGE_URL: "127.0.0.1:27017" + workingDirectory: '$(modulePath)' + displayName: 'run tests' + diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 6a2dbb0b..13dd25cc 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -4,6 +4,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "strconv" "testing" @@ -297,6 +298,12 @@ func restoreEnv(envVars map[string]string) { } func Test_checkFilePerms(t *testing.T) { + // TODO: os.Chmod(..) doesn't work on Windows as it does on Unix + // Skip for now + // issue: https://github.com/gomods/athens/issues/879 + if runtime.GOOS == "windows" { + t.SkipNow() + } f1, err := ioutil.TempFile(os.TempDir(), "prefix-") if err != nil { t.FailNow() diff --git a/pkg/storage/s3/s3_test.go b/pkg/storage/s3/s3_test.go index 47e024dd..0a5ead97 100644 --- a/pkg/storage/s3/s3_test.go +++ b/pkg/storage/s3/s3_test.go @@ -2,6 +2,7 @@ package s3 import ( "context" + "os" "testing" "github.com/aws/aws-sdk-go/aws" @@ -68,8 +69,13 @@ func (s *Storage) createBucket() error { } func getStorage(t testing.TB) *Storage { + url := os.Getenv("ATHENS_MINIO_ENDPOINT") + if url == "" { + t.SkipNow() + } + options := func(conf *aws.Config) { - conf.Endpoint = aws.String("127.0.0.1:9001") + conf.Endpoint = aws.String(url) conf.DisableSSL = aws.Bool(true) conf.S3ForcePathStyle = aws.Bool(true) }