Skip to content

Commit

Permalink
Adding Smoketests to nightly runs (#16226)
Browse files Browse the repository at this point in the history
* Adding Smoketests to nightly runs

* updating location, fixes to script

* starting go script

* finishing script

* updating yml file

* formatting

* adding snippet for finding go code

* adding funcitonality for copying examples

* trimming out unused funcs

* fixed regexp, thanks benbp

* fixing smoke test program to create go.mod file correctly, update powershell for nightly

* removing need for argument in go program, updating yml and powershell to reflect

* scripts not common

* smoketests, plural not singular

* finally got the right directory

* fixed script locally, running into permissions issue on ci

* updating script to exit properly, logging an error instead of panicing

* manually set go111module to on

* removing references to go111module

* issue with duplicated function names...

* updating to only pull examples from the service directory if one is provided

* runs samples now too!

* adding 'go run .' step to ps1, triggering for tables

* adding step to analyze.yml file

* adding debugging for ci

* updating to work in ci

* updating to specify go module name, removing print statements

* updating scripts to fmt for prettier printing, find all environment variables

* working on loading environment variables from file

* removing env vars from example_test.go for testing

* adding the environment variable portion to the generated main.go file

* forgot to remove change to nightly script

* adding import to the main file

* cleaning up code, adding comments

* don't import os if no env vars

* small changes for checking all packages

* removing _test suffix on copied files

* converting to use cobra for better support

* formatting
  • Loading branch information
seankane-msft authored Jan 3, 2022
1 parent 6533539 commit 555bdb5
Show file tree
Hide file tree
Showing 10 changed files with 1,378 additions and 2 deletions.
7 changes: 6 additions & 1 deletion eng/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
},
{
"Name": "data",
"CoverageGoal": 0.62
"CoverageGoal": 0.62,
"EnvironmentVariables": {
"TABLES_STORAGE_ACCOUNT_NAME": "fakeaccount",
"TABLES_PRIMARY_STORAGE_ACCOUNT_KEY": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
"TABLES_SHARED_ACCESS_SIGNATURE": "?sig=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
}
},
{
"Name": "eng/tools",
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/templates/jobs/archetype-go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ stages:
displayName: 'Release: ${{ parameters.ServiceDirectory }}'
dependsOn: CheckRelease
condition: and(succeeded(), eq(dependencies.CheckRelease.outputs['CheckReleaseJob.Verify.NeedToRelease'], 'true'))
jobs:
jobs:
- deployment: TagRepository
displayName: "Create release tag"
condition: and(succeeded(), ne(variables['Skip.TagRepository'], 'true'))
Expand Down
8 changes: 8 additions & 0 deletions eng/pipelines/templates/steps/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,11 @@ steps:
parameters:
PackageName: 'sdk/${{parameters.ServiceDirectory}}'
ForRelease: false

- task: PowerShell@2
displayName: 'Run Nightly SmokeTests'
inputs:
targetType: 'filePath'
filePath: ./eng/scripts/Smoke_Tests_Nightly.ps1
pwsh: true
arguments: '${{ parameters.ServiceDirectory }}'
44 changes: 44 additions & 0 deletions eng/scripts/Smoke_Tests_Nightly.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#Requires -Version 7.0

Param(
[string] $serviceDirectory
)

$repoRoot = Resolve-Path "$PSScriptRoot/../../"

Push-Location $repoRoot/eng/tools/smoketests

# create a smoketests directory
$smoketestsDir = Join-Path $repoRoot sdk smoketests
Write-Host "Creating a new directory for smoketests at $smoketestsDir"
New-Item -Path $smoketestsDir -ItemType Directory

Push-Location $smoketestsDir
Write-Host "Running 'go mod init' in $pwd"
go mod init github.com/Azure/azure-sdk-for-go/sdk/smoketests
Pop-Location

# Run smoketests script
Write-Host "Running 'go run . -serviceDirectory $serviceDirectory'"
go run . -serviceDirectory $serviceDirectory
if ($LASTEXITCODE) {
exit $LASTEXITCODE
}

Pop-Location

# Run go mod tidy and go build. If these succeed the smoke tests pass
Push-Location $smoketestsDir
go fmt ./...
Write-Host "Printing content of go.mod file:"
Get-Content go.mod
Write-Host "Printing content of main.go file"
Get-Content main.go
go mod tidy
go build ./...
go run .

Pop-Location

# Clean-up the directory created
Remove-Item -Path $smoketestsDir -Recurse -Force
11 changes: 11 additions & 0 deletions eng/scripts/Smoke_Tests_Release.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Requires -Version 7.0

Param(
[string] $serviceDirectory
)

Write-Host $PSScriptRoot

# 1. Every module uses a replace directive to the local version
# 2. Include every module (data & mgmt) in a go.mod file
# 3. Run `go mod tidy` and ensure it succeeds
38 changes: 38 additions & 0 deletions eng/tools/smoketests/cmd/models.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import "fmt"

type ConfigFile struct {
Packages []Package
}

type Package struct {
Name string
CoverageGoal float64
EnvironmentVariables map[string]string
}

type Module struct {
Name string
Version string
Replace string
}

type SemVer struct {
Major, Minor, Patch int
}

func (s SemVer) Newer(s2 SemVer) bool {
if s.Major > s2.Major {
return true
} else if s.Major == s2.Major && s.Minor > s2.Minor {
return true
} else if s.Major == s2.Major && s.Minor == s2.Minor && s.Patch > s2.Patch {
return true
}
return false
}

func (s SemVer) String() string {
return fmt.Sprintf("v%d.%d.%d", s.Major, s.Minor, s.Patch)
}
Loading

0 comments on commit 555bdb5

Please sign in to comment.