Skip to content

Commit 1237648

Browse files
authored
Merge pull request #3804 from ActiveState/version/0-48-1-RC2
0.48.1-RC2
2 parents b1ea6fa + 5fb2264 commit 1237648

File tree

16 files changed

+58
-83
lines changed

16 files changed

+58
-83
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
# === OS Specific Job (runs on each OS) ===
3333
os_specific:
3434
name: ${{ matrix.sys.os }}
35-
timeout-minutes: 90
35+
timeout-minutes: 120
3636
strategy:
3737
matrix:
3838
go-version:
@@ -327,15 +327,14 @@ jobs:
327327
export TEST_SUITE_TAGS="$TEST_SUITE_TAGS"
328328
TIMEOUT=30m
329329
if [[ "$TEST_SUITE_TAGS" == "all" ]]; then
330-
TIMEOUT=90m
330+
TIMEOUT=120m
331331
fi
332332
SHELL='${{ matrix.sys.shell }}' go test -timeout $TIMEOUT -v `go list ./... | grep "integration"` -json 2>&1 | gotestfmt -hide empty-packages
333333
continue-on-error: ${{ github.event_name == 'schedule' }}
334334
env:
335335
INTEGRATION_TEST_USERNAME: ${{ secrets.INTEGRATION_TEST_USERNAME }}
336336
INTEGRATION_TEST_PASSWORD: ${{ secrets.INTEGRATION_TEST_PASSWORD }}
337337
INTEGRATION_TEST_TOKEN: ${{ secrets.INTEGRATION_TEST_TOKEN }}
338-
PLATFORM_API_TOKEN: ${{ secrets.PLATFORM_API_TOKEN }}
339338

340339
- # === Check if Unit Tests Failed ===
341340
name: Check if Unit Tests Failed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to
1515
### Fixed
1616

1717
- Fixed occasional panic due to a concurrent map read/write during runtime setup.
18+
- Fixed `state clean cache` from accidentally deleting State Tool binaries on Windows.
1819

1920
## 0.48.0
2021

cmd/state-svc/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ func main() {
5555
}
5656

5757
if err := events.WaitForEvents(5*time.Second, rollbar.Wait, authentication.LegacyClose, logging.Close); err != nil {
58-
logging.Warning("Failing to wait events")
58+
// Note: logger is closed, so cannot log here. Also, the activate integration tests seem to be
59+
// affected by a write to os.Stderr. Regardless, since state-svc runs in the background for
60+
// the most part, we realistically will not see this error.
61+
//fmt.Fprintf(os.Stderr, "Warning: failed to wait for events")
5962
}
6063
os.Exit(exitCode)
6164
}()

cmd/state-svc/test/integration/svc_int_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ func (suite *SvcIntegrationTestSuite) TestStartDuplicateErrorOutput() {
157157
func (suite *SvcIntegrationTestSuite) TestSingleSvc() {
158158
suite.OnlyRunForTags(tagsuite.Service)
159159
ts := e2e.New(suite.T(), false)
160-
defer ts.Close()
160+
// TODO: CP-1268 should remove this conditional.
161+
if runtime.GOOS != "windows" || !condition.OnCI() {
162+
defer ts.Close()
163+
}
161164

162165
ts.SpawnCmdWithOpts(ts.SvcExe, e2e.OptArgs("stop"))
163166
time.Sleep(2 * time.Second) // allow for some time to stop the existing available process

internal/installation/storage/storage.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,13 @@ func CachePath() string {
105105
return path
106106
}
107107

108-
return filepath.Join(BaseCachePath(), relativeCachePath())
108+
cachePath = filepath.Join(BaseCachePath(), relativeCachePath())
109+
if runtime.GOOS == "windows" {
110+
// Explicitly append "cache" dir as the cachedir on Windows.
111+
// It is the same as the local appdata dir (conflicts with config)
112+
cachePath = filepath.Join(cachePath, "cache")
113+
}
114+
return cachePath
109115
}
110116

111117
func GlobalBinDir() string {

internal/installation/storage/storage_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ func BaseCachePath() string {
1818
return cache
1919
}
2020

21-
return filepath.Join(homeDir, "AppData", "Local", "cache")
21+
return filepath.Join(homeDir, "AppData", "Local")
2222
}

internal/testhelpers/e2e/clean.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,12 @@
11
package e2e
22

33
import (
4-
"testing"
5-
64
"github.com/ActiveState/cli/internal/errs"
75
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/projects"
8-
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/users"
96
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_models"
107
"github.com/ActiveState/cli/pkg/platform/authentication"
11-
"github.com/ActiveState/cli/pkg/platform/model"
128
)
139

14-
func cleanUser(t *testing.T, username string, auth *authentication.Auth) error {
15-
projects, err := getProjects(username, auth)
16-
if err != nil {
17-
return err
18-
}
19-
for _, proj := range projects {
20-
err = model.DeleteProject(username, proj.Name, auth)
21-
if err != nil {
22-
return err
23-
}
24-
}
25-
26-
return deleteUser(username, auth)
27-
}
28-
2910
func getProjects(org string, auth *authentication.Auth) ([]*mono_models.Project, error) {
3011
authClient, err := auth.Client()
3112
if err != nil {
@@ -40,20 +21,3 @@ func getProjects(org string, auth *authentication.Auth) ([]*mono_models.Project,
4021

4122
return listProjectsOK.Payload, nil
4223
}
43-
44-
func deleteUser(name string, auth *authentication.Auth) error {
45-
authClient, err := auth.Client()
46-
if err != nil {
47-
return errs.Wrap(err, "Could not get auth client")
48-
}
49-
50-
params := users.NewDeleteUserParams()
51-
params.SetUsername(name)
52-
53-
_, err = authClient.Users.DeleteUser(params, auth.ClientAuth())
54-
if err != nil {
55-
return err
56-
}
57-
58-
return nil
59-
}

internal/testhelpers/e2e/session.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ type Session struct {
5656
Env []string
5757
retainDirs bool
5858
createdProjects []*project.Namespaced
59-
// users created during session
60-
users []string
6159
T *testing.T
6260
Exe string
6361
SvcExe string
@@ -542,11 +540,6 @@ func (s *Session) Close() error {
542540

543541
s.spawned = []*SpawnedCmd{}
544542

545-
if os.Getenv("PLATFORM_API_TOKEN") == "" {
546-
s.T.Log("PLATFORM_API_TOKEN env var not set, not running suite tear down")
547-
return nil
548-
}
549-
550543
auth := authentication.New(cfg)
551544

552545
if os.Getenv(constants.APIHostEnvVarName) == "" {
@@ -560,9 +553,11 @@ func (s *Session) Close() error {
560553
}
561554

562555
err = auth.AuthenticateWithModel(&mono_models.Credentials{
563-
Token: os.Getenv("PLATFORM_API_TOKEN"),
556+
Username: PersistentUsername,
557+
Password: PersistentPassword,
564558
})
565559
if err != nil {
560+
s.T.Errorf("Could not login: %v", errs.JoinMessage(err))
566561
return err
567562
}
568563

@@ -586,14 +581,7 @@ func (s *Session) Close() error {
586581
for _, proj := range s.createdProjects {
587582
err := model.DeleteProject(proj.Owner, proj.Project, auth)
588583
if err != nil {
589-
s.T.Errorf("Could not delete project %s: %v", proj.Project, errs.JoinMessage(err))
590-
}
591-
}
592-
593-
for _, user := range s.users {
594-
err := cleanUser(s.T, user, auth)
595-
if err != nil {
596-
s.T.Errorf("Could not delete user %s: %v", user, errs.JoinMessage(err))
584+
s.T.Errorf("Could not delete project %s/%s: %v", proj.Owner, proj.Project, errs.JoinMessage(err))
597585
}
598586
}
599587

@@ -799,7 +787,7 @@ func (s *Session) SetupRCFileCustom(subshell subshell.SubShell) {
799787
rcFile, err := subshell.RcFile()
800788
require.NoError(s.T, err)
801789

802-
if fileutils.TargetExists(filepath.Join(s.Dirs.HomeDir, filepath.Base(rcFile))) {
790+
if fileutils.TargetExists(rcFile) && fileutils.TargetExists(filepath.Join(s.Dirs.HomeDir, filepath.Base(rcFile))) {
803791
err = fileutils.CopyFile(rcFile, filepath.Join(s.Dirs.HomeDir, filepath.Base(rcFile)))
804792
} else {
805793
err = fileutils.Touch(filepath.Join(s.Dirs.HomeDir, filepath.Base(rcFile)))

test/integration/buildscript_int_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (suite *BuildScriptIntegrationTestSuite) TestBuildScriptRequirementVersionA
179179
cp.ExpectExitCode(0)
180180

181181
cp = ts.Spawn("install", "dotenv")
182-
cp.Expect("Added: language/python/dotenv@Auto")
182+
cp.Expect("Added: language/python/dotenv@Auto", e2e.RuntimeSolvingTimeoutOpt)
183183
cp.ExpectExitCode(0)
184184
}
185185

test/integration/commit_int_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (suite *CommitIntegrationTestSuite) TestCommitAtTimeChange() {
6767
ts := e2e.New(suite.T(), false)
6868
defer ts.Close()
6969

70-
ts.PrepareProjectAndBuildScript("ActiveState-CLI/Commit-Test-A", "7a1b416e-c17f-4d4a-9e27-cbad9e8f5655")
70+
ts.PrepareProjectAndBuildScript("ActiveState-CLI/Commit-Test-A", "2ab50eba-4410-4be2-ba9d-c04ebeda640d")
7171

7272
proj, err := project.FromPath(ts.Dirs.Work)
7373
suite.NoError(err, "Error loading project")
@@ -76,11 +76,11 @@ func (suite *CommitIntegrationTestSuite) TestCommitAtTimeChange() {
7676
suite.Require().NoError(err) // verify validity
7777

7878
// Update top-level at_time variable.
79-
dateTime := "2023-06-21T12:34:56Z"
79+
dateTime := "2025-12-11T12:34:56Z"
8080
buildScriptFile := filepath.Join(proj.Dir(), constants.BuildScriptFileName)
8181
contents, err := fileutils.ReadFile(buildScriptFile)
8282
suite.Require().NoError(err)
83-
contents = bytes.Replace(contents, []byte("2023-06-22T21:56:10Z"), []byte(dateTime), 1)
83+
contents = bytes.Replace(contents, []byte("2025-12-10T17:03:26Z"), []byte(dateTime), 1)
8484
suite.Require().NoError(fileutils.WriteFile(buildScriptFile, contents))
8585
suite.Require().Contains(string(fileutils.ReadFileUnsafe(filepath.Join(proj.Dir(), constants.BuildScriptFileName))), dateTime)
8686

@@ -152,14 +152,16 @@ func (suite *CommitIntegrationTestSuite) TestCommitSkipValidation() {
152152
suite.Require().NoError(fileutils.WriteFile(scriptPath, data))
153153

154154
cp := ts.Spawn("commit")
155-
cp.Expect("solver_version in body should be")
155+
cp.Expect("solver_version")
156+
cp.Expect("should be")
156157
cp.ExpectExitCode(1)
157158

158159
cp = ts.Spawn("commit", "--skip-validation")
159160
cp.ExpectExitCode(0)
160161

161162
cp = ts.Spawn("refresh")
162-
cp.Expect("solver_version in body should be")
163+
cp.Expect("solver_version")
164+
cp.Expect("should be")
163165
cp.ExpectExitCode(1)
164166
}
165167

0 commit comments

Comments
 (0)