Skip to content

Commit aba4c75

Browse files
authored
Merge pull request ActiveState#3286 from ActiveState/version/0-44-0-RC3
Version 0.44.0-RC3
2 parents 840207d + d958ce0 commit aba4c75

File tree

481 files changed

+43124
-3775
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

481 files changed

+43124
-3775
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ env:
2929

3030
# === JOBS ===
3131
jobs:
32-
3332
# === OS Specific Job (runs on each OS) ===
3433
os_specific:
3534
name: ${{ matrix.sys.os }}
@@ -39,8 +38,8 @@ jobs:
3938
go-version:
4039
- 1.20.x
4140
sys:
42-
- {os: ubuntu-20.04}
43-
- {os: macos-11, shell: zsh}
41+
- {os: ubuntu-latest}
42+
- {os: macos-12, shell: zsh}
4443
- {os: windows-2019}
4544
fail-fast: false
4645
runs-on: ${{ matrix.sys.os }}
@@ -130,6 +129,10 @@ jobs:
130129
export PATH="$(pwd)/.github/deps/${{ runner.os }}/bin:$PATH"
131130
parallelize "$(cat <<'EOF'
132131
[
132+
{
133+
"ID": "Check-Format",
134+
"Args": ["state", "run", "check-format"]
135+
},
133136
{
134137
"ID": "Unit-Tests",
135138
"Args": ["state", "run", "test", "-json", "2>&1"]
@@ -168,6 +171,13 @@ jobs:
168171
JIRA_USERNAME: ${{ secrets.JIRA_EMAIL }}
169172
JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }}
170173

174+
- # === Unit Tests ===
175+
name: Check Format
176+
id: check_format
177+
shell: bash
178+
if: "!contains(fromJSON('[\"refs/heads/beta\", \"refs/heads/release\", \"refs/heads/LTS\"]'), github.ref) && !startsWith(github.event.pull_request.head.ref, 'version/')"
179+
run: parallelize results Check-Format
180+
171181
- # === Unit Tests ===
172182
name: Unit Tests
173183
id: unit_tests
@@ -323,7 +333,7 @@ jobs:
323333
export TEST_SUITE_TAGS="$TEST_SUITE_TAGS"
324334
TIMEOUT=30m
325335
if [[ "$TEST_SUITE_TAGS" == "all" ]]; then
326-
TIMEOUT=60m
336+
TIMEOUT=90m
327337
fi
328338
SHELL='${{ matrix.sys.shell }}' go test -timeout $TIMEOUT -v `go list ./... | grep "integration"` -json 2>&1 | gotestfmt -hide empty-packages
329339
continue-on-error: ${{ github.event_name == 'schedule' }}

.golangci.yaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
run:
2-
skip-dirs:
1+
issues:
2+
exclude-dirs:
33
- vendor
4+
exclude-rules:
5+
- linters:
6+
- staticcheck
7+
text: "SA9004"
48

59
linters-settings:
610
errcheck:
711
exclude-functions:
12+
- fmt.Fprintln
813
- (*github.com/ActiveState/termtest.TermTest).Expect
914
- (*github.com/ActiveState/termtest.TermTest).ExpectExitCode
1015
- (*github.com/ActiveState/termtest.TermTest).ExpectNotExitCode
@@ -13,9 +18,24 @@ linters-settings:
1318
- (*github.com/ActiveState/termtest.TermTest).WaitForInput
1419
- (*github.com/ActiveState/termtest.TermTest).SendLine
1520
- (*github.com/ActiveState/termtest.TermTest).ExpectInput
21+
- (*github.com/ActiveState/termtest.TermTest).ExpectExit
1622
- (*github.com/ActiveState/termtest.TermTest).Wait
1723
- (*github.com/ActiveState/logging.fileHandler).Printf
1824
- (*github.com/ActiveState/logging.standardHandler).Printf
25+
- (*github.com/ActiveState/cli/internal/testhelpers/e2e.Session).Close
26+
- (*github.com/ActiveState/cli/internal/testhelpers/e2e.SpawnedCmd).ExpectInput
27+
- (*github.com/ActiveState/cli/internal/testhelpers/e2e.SpawnedCmd).Send
28+
- (*github.com/ActiveState/cli/internal/testhelpers/e2e.SpawnedCmd).SendLine
29+
- (*github.com/ActiveState/cli/internal/testhelpers/e2e.SpawnedCmd).SendEnter
30+
- (*github.com/ActiveState/cli/internal/testhelpers/e2e.SpawnedCmd).SendKeyDown
31+
- (*github.com/ActiveState/cli/internal/testhelpers/e2e.SpawnedCmd).ExpectRe
32+
- (*github.com/ActiveState/cli/internal/testhelpers/e2e.SpawnedCmd).Wait
33+
- (*github.com/ActiveState/cli/internal/testhelpers/e2e.Session).ClearCache
34+
- (*github.com/ActiveState/cli/internal/testhelpers/e2e.Dirs).Close
35+
- (*github.com/ActiveState/cli/pkg/platform/runtime/artifactcache.testArtifactCache).Store
36+
- github.com/ActiveState/cli/internal/testhelpers/osutil.RemoveConfigFile
37+
- (*github.com/ActiveState/cli/internal/logging.standardHandler).Emit
38+
- (*github.com/ActiveState/cli/internal/logging.fileHandler).Emit
1939
govet:
2040
disable:
2141
- composites

activestate.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,40 @@ scripts:
360360
value: |
361361
golangci-lint run --no-config
362362
actionlint
363+
- name: check-format
364+
language: bash
365+
description: "Checks if the code is formatted correctly"
366+
value: |
367+
set -e
368+
369+
TARGET_BRANCH=$GITHUB_BASE_REF
370+
if [ "$GITHUB_BASE_REF" == "" ]; then
371+
TARGET_BRANCH="master"
372+
fi
373+
374+
git fetch --quiet origin $TARGET_BRANCH:refs/remotes/origin/$TARGET_BRANCH
375+
376+
CHANGED=$(git diff --name-only origin/$TARGET_BRANCH)
377+
NO_NEWLINE=0
378+
for FILE in $CHANGED; do
379+
if [[ $FILE == vendor/* ]]; then
380+
continue
381+
fi
382+
383+
if file "$FILE" | grep -q -E 'text|ASCII'; then
384+
if [ $(tail -c 1 "$FILE" | wc -l) -eq 0 ]; then
385+
echo "Missing newline at end of file: $FILE"
386+
NO_NEWLINE=1
387+
fi
388+
fi
389+
done
390+
391+
if [ "$NO_NEWLINE" -ne 0 ]; then
392+
echo "Error: Some text files are missing a newline at the end."
393+
exit 1
394+
else
395+
echo "Success: All modified text files end with a newline."
396+
fi
363397
- name: grab-mergecommits
364398
language: bash
365399
value: |

changelog.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,66 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to
77
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## 0.44.0
10+
11+
### Added
12+
13+
* We've added the `state manifest` command, which lists all your package, bundle and language requirements in your
14+
project. This command deprecates the old `state packages`, `state languages` and `state bundles` commands.
15+
* `state artifacts` now indicates which artifacts are still building.
16+
* You can now use wildcard versions when running `state install` and `state languages install`, just like you can
17+
with `state init`. eg. `state install [email protected]`.
18+
* We now warn you when installing the State Tool as an administrator on Windows.
19+
* `state publish` now lets you specify the type of a dependency (ie. runtime, buildtime, or testing) via the new
20+
`--depend-build`, `--depend-runtime` and `--depend-test` flags. The existing `--depend` flag maps to `--depend-build`.
21+
* We now ensure the runtime is not currently in use before making changes to it. If the runtime is the user will receive
22+
an error asking them to stop using the runtime before proceeding.
23+
* You can now supply multiple packages to the `state install` and `state uninstall` commands.
24+
25+
### Changed
26+
27+
* Increased the time State Tool will wait for the state-svc to start, which is required for using the State Tool. This
28+
is mainly intended for when you just started your system, when it is still under heavy load and thus processes can
29+
take longer to start.
30+
* You will now receive an actionable error when your activestate.yaml does not contain a commit ID.
31+
* State revert "HEAD" has been renamed to "REMOTE", though "HEAD" is still supported with a deprecation warning. This
32+
is to avoid confusion with how git uses the HEAD term, which isn't how we were using it.
33+
* `state run` and `state exec` now use powershell under the hood instead of cmd. This means that invoking shell
34+
built-ins like `where` will no longer work as powershell has different built-ins. But if you're invoking shell
35+
built-ins you probably shouldn't be using these commands anyway.
36+
* State tool now identifies more network errors, making for more actionable error messages.
37+
* We have introduced a new project file versioning mechanic. You'll start seeing a new `config_version` property in your
38+
activestate.yaml. Do not edit or delete this or you may run into issues.
39+
* Buildscripts are no longer automatically created when opted in. Instead you need to run `state reset LOCAL` in order
40+
to first create the buildscript. You only need to do this once, after it exists it will be updated as needed.
41+
* This is merely a growing pain while this feature is optin only. Once buildscripts ship as stable you will not need
42+
to do this.
43+
* CVE information provided when running `state install` is now recursive, meaning we show CVE information for the
44+
requested package as well as all its dependencies.
45+
* `state init` now automatically assumes wildcards when a partial version is specified.
46+
47+
### Fixed
48+
49+
* Fixed issue where `state refresh` would tell you you have uncommitted changes when you are up to date (when opted into
50+
buildscripts).
51+
* Fixed issue where `state uninstall` would give you superfluous output intended for `state install`.
52+
* Fixed issue where running `state update` would show deprecation messages for the version you are updating from.
53+
* Fixed issue where `state run` and `state exec` would not forward arguments correctly on Windows. This is a limitation
54+
of the `cmd` shell. We now utilize powershell instead to facilitate commands.
55+
* Fixed issue where `state languages` would show a larger than / smaller than version notation rather than `auto`.
56+
* Fixed issue where `state checkout` would save the `main` branch to your activestate.yaml when you checked out a commit
57+
on a sub-branch. It now correctly saves the sub-branch.
58+
* Fixed issue where `state search` gave an unintended "wrapped tips" error when given an invalid version number.
59+
* Fixed issue where text was wrapped when producing non-interactive output, making it impossible to use the output in
60+
automations without first cleaning up the output.
61+
* Fixed issue where manually resolving conflicts when running `state pull` would not allow you to commit these changes
62+
if you picked only the local changes. This only applies if opted in to buildscripts.
63+
* Fixed issue where conflicts on the `at_time` buildscript field would show the wrong local value.
64+
65+
### Removed
66+
67+
* `state export recipe` has been removed, as the platform no longer uses recipes.
68+
969
## 0.43.0
1070

1171
### Added

cmd/state-installer/cmd.go

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
"github.com/ActiveState/cli/internal/subshell/bash"
3535
"github.com/ActiveState/cli/pkg/project"
3636
"github.com/ActiveState/cli/pkg/sysinfo"
37-
"golang.org/x/crypto/ssh/terminal"
37+
"golang.org/x/term"
3838
)
3939

4040
type Params struct {
@@ -47,10 +47,15 @@ type Params struct {
4747
activate *project.Namespaced
4848
activateDefault *project.Namespaced
4949
showVersion bool
50+
nonInteractive bool
5051
}
5152

5253
func newParams() *Params {
53-
return &Params{activate: &project.Namespaced{}, activateDefault: &project.Namespaced{}}
54+
return &Params{
55+
activate: &project.Namespaced{},
56+
activateDefault: &project.Namespaced{},
57+
nonInteractive: !term.IsTerminal(int(os.Stdin.Fd())),
58+
}
5459
}
5560

5661
func main() {
@@ -109,7 +114,6 @@ func main() {
109114
return
110115
}
111116

112-
var garbageBool bool
113117
var garbageString string
114118

115119
// We have old install one liners around that use `-activate` instead of `--activate`
@@ -189,8 +193,8 @@ func main() {
189193
Name: "version", // note: no shorthand because install.sh uses -v for selecting version
190194
Value: &params.showVersion,
191195
},
196+
{Name: "non-interactive", Shorthand: "n", Hidden: true, Value: &params.nonInteractive}, // don't prompt
192197
// The remaining flags are for backwards compatibility (ie. we don't want to error out when they're provided)
193-
{Name: "nnn", Shorthand: "n", Hidden: true, Value: &garbageBool}, // don't prompt; useless cause we don't prompt anyway
194198
{Name: "channel", Hidden: true, Value: &garbageString},
195199
{Name: "bbb", Shorthand: "b", Hidden: true, Value: &garbageString},
196200
{Name: "vvv", Shorthand: "v", Hidden: true, Value: &garbageString},
@@ -341,7 +345,7 @@ func installOrUpdateFromLocalSource(out output.Outputer, cfg *config.Instance, a
341345
return err
342346
}
343347

344-
installer, err := NewInstaller(cfg, out, payloadPath, params)
348+
installer, err := NewInstaller(cfg, out, an, payloadPath, params)
345349
if err != nil {
346350
out.Print(fmt.Sprintf("[ERROR]Could not create installer: %s[/RESET]", errs.JoinMessage(err)))
347351
return err
@@ -424,7 +428,7 @@ func postInstallEvents(out output.Outputer, cfg *config.Instance, an analytics.D
424428
an.EventWithLabel(anaConst.CatInstallerFunnel, "forward-activate-default-err", err.Error())
425429
return errs.Silence(errs.Wrap(err, "Could not activate %s, error returned: %s", params.activateDefault.String(), errs.JoinMessage(err)))
426430
}
427-
case !params.isUpdate && terminal.IsTerminal(int(os.Stdin.Fd())) && os.Getenv(constants.InstallerNoSubshell) != "true" && os.Getenv("TERM") != "dumb":
431+
case !params.isUpdate && term.IsTerminal(int(os.Stdin.Fd())) && os.Getenv(constants.InstallerNoSubshell) != "true" && os.Getenv("TERM") != "dumb":
428432
if err := ss.SetEnv(osutils.InheritEnv(envMap(binPath))); err != nil {
429433
return locale.WrapError(err, "err_subshell_setenv")
430434
}
@@ -489,37 +493,3 @@ func assertCompatibility() error {
489493

490494
return nil
491495
}
492-
493-
func noArgs() bool {
494-
return len(os.Args[1:]) == 0
495-
}
496-
497-
func shouldUpdateInstalledStateTool(stateExePath string) bool {
498-
logging.Debug("Checking if installed state tool is an older version.")
499-
500-
stdout, _, err := osutils.ExecSimple(stateExePath, []string{"--version", "--output", "json"}, os.Environ())
501-
if err != nil {
502-
logging.Debug("Could not determine state tool version.")
503-
return true // probably corrupted install
504-
}
505-
stdout = strings.Split(stdout, "\x00")[0] // TODO: DX-328
506-
507-
versionData := installation.VersionData{}
508-
err = json.Unmarshal([]byte(stdout), &versionData)
509-
if err != nil {
510-
logging.Debug("Could not read state tool version output")
511-
return true
512-
}
513-
514-
if versionData.Channel != constants.ChannelName {
515-
logging.Debug("State tool channel is different from installer.")
516-
return false // do not update, require --force
517-
}
518-
519-
if versionData.Version != constants.Version {
520-
logging.Debug("State tool version is different from installer.")
521-
return true
522-
}
523-
524-
return false
525-
}

cmd/state-installer/installer.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package main
22

33
import (
44
"errors"
5-
"io/ioutil"
65
"os"
76
"path/filepath"
87
"strings"
98

109
svcApp "github.com/ActiveState/cli/cmd/state-svc/app"
1110
svcAutostart "github.com/ActiveState/cli/cmd/state-svc/autostart"
11+
"github.com/ActiveState/cli/internal/analytics"
1212
"github.com/ActiveState/cli/internal/config"
1313
"github.com/ActiveState/cli/internal/constants"
1414
"github.com/ActiveState/cli/internal/errs"
@@ -22,6 +22,8 @@ import (
2222
"github.com/ActiveState/cli/internal/osutils"
2323
"github.com/ActiveState/cli/internal/osutils/autostart"
2424
"github.com/ActiveState/cli/internal/output"
25+
"github.com/ActiveState/cli/internal/prompt"
26+
"github.com/ActiveState/cli/internal/rtutils/ptr"
2527
"github.com/ActiveState/cli/internal/subshell"
2628
"github.com/ActiveState/cli/internal/subshell/sscommon"
2729
"github.com/ActiveState/cli/internal/updater"
@@ -30,12 +32,13 @@ import (
3032
type Installer struct {
3133
out output.Outputer
3234
cfg *config.Instance
35+
an analytics.Dispatcher
3336
payloadPath string
3437
*Params
3538
}
3639

37-
func NewInstaller(cfg *config.Instance, out output.Outputer, payloadPath string, params *Params) (*Installer, error) {
38-
i := &Installer{cfg: cfg, out: out, payloadPath: payloadPath, Params: params}
40+
func NewInstaller(cfg *config.Instance, out output.Outputer, an analytics.Dispatcher, payloadPath string, params *Params) (*Installer, error) {
41+
i := &Installer{cfg: cfg, out: out, an: an, payloadPath: payloadPath, Params: params}
3942
if err := i.sanitizeInput(); err != nil {
4043
return nil, errs.Wrap(err, "Could not sanitize input")
4144
}
@@ -46,6 +49,21 @@ func NewInstaller(cfg *config.Instance, out output.Outputer, payloadPath string,
4649
}
4750

4851
func (i *Installer) Install() (rerr error) {
52+
isAdmin, err := osutils.IsAdmin()
53+
if err != nil {
54+
return errs.Wrap(err, "Could not determine if running as Windows administrator")
55+
}
56+
if isAdmin && !i.Params.force && !i.Params.isUpdate && !i.Params.nonInteractive {
57+
prompter := prompt.New(true, i.an)
58+
confirm, err := prompter.Confirm("", locale.T("installer_prompt_is_admin"), ptr.To(false))
59+
if err != nil {
60+
return errs.Wrap(err, "Unable to confirm")
61+
}
62+
if !confirm {
63+
return locale.NewInputError("installer_aborted", "Installation aborted by the user")
64+
}
65+
}
66+
4967
// Store update tag
5068
if i.updateTag != "" {
5169
if err := i.cfg.Set(updater.CfgUpdateTag, i.updateTag); err != nil {
@@ -59,7 +77,7 @@ func (i *Installer) Install() (rerr error) {
5977
}
6078

6179
// Detect if existing installation needs to be cleaned
62-
err := detectCorruptedInstallDir(i.path)
80+
err = detectCorruptedInstallDir(i.path)
6381
if errors.Is(err, errCorruptedInstall) {
6482
err = i.sanitizeInstallPath()
6583
if err != nil {
@@ -97,10 +115,6 @@ func (i *Installer) Install() (rerr error) {
97115

98116
// Set up the environment
99117
binDir := filepath.Join(i.path, installation.BinDirName)
100-
isAdmin, err := osutils.IsAdmin()
101-
if err != nil {
102-
return errs.Wrap(err, "Could not determine if running as Windows administrator")
103-
}
104118

105119
// Install the state service as an app if necessary
106120
if err := i.installSvcApp(binDir); err != nil {
@@ -194,7 +208,7 @@ func detectCorruptedInstallDir(path string) error {
194208
}
195209

196210
// Detect if the install dir has files in it
197-
files, err := ioutil.ReadDir(path)
211+
files, err := os.ReadDir(path)
198212
if err != nil {
199213
return errs.Wrap(err, "Could not read directory: %s", path)
200214
}

0 commit comments

Comments
 (0)