Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

application_test.ps1 fails when the version is dirty or a release version #189

Open
aiyengar2 opened this issue May 13, 2024 · 0 comments
Open

Comments

@aiyengar2
Copy link
Contributor

The logic in the following code will always result in a failure when executing tests on a tagged commit since it checks that the reported version by the wins binary is equivalent to the commit hash.

$version = Execute-Binary -FilePath "git.exe" -ArgumentList @("rev-parse", "--short", "HEAD") -PassThru
if (-not $version.Ok) {
Log-Error $version.Output
$false | Should -Be $true
}

This results in the following error on jobs:

Starting discovery in 1 files.
Discovery found 3 tests in 1.02s.
Running tests.
Error: [-] application.upgrade.watching 39.52s (39.52s|3ms)
Message
Tests completed in 45.69s
Tests Passed: 2, Failed: 1, Skipped: 0 NotRun: 0
FATA Failed to pass D:\a\wins\wins\tests\integration\application_test.ps1
Error: running "powershell.exe tests\integration\integration_suite_test.ps1" failed with exit code 1
Error: Process completed with exit code 1.

Failed Job: https://github.com/rancher/wins/actions/runs/8851112339/job/24306934261

The fix for this issue should be to change the logic here to match the logic within the magefile:

func Version() error {
c, err := magetools.GetCommit()
if err != nil {
return err
}
commit = c
dt := os.Getenv("DRONE_TAG")
isClean, err := magetools.IsGitClean()
if err != nil {
return err
}
if dt != "" && isClean {
version = dt
return nil
}
tag, err := magetools.GetLatestTag()
if err != nil {
return err
}
if tag != "" && isClean {
version = tag
return nil
}
version = commit
if !isClean {
version = commit + "-dirty"
log.Printf("[Version] dirty version encountered: %s \n", version)
}
// check if this is a release version and fail if the version contains `dirty`
if strings.Contains(version, "dirty") && os.Getenv("DRONE_TAG") != "" || tag != "" {
return fmt.Errorf("[Version] releases require a non-dirty tag: %s", version)
}
log.Printf("[Version] version: %s \n", version)
return nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant