Skip to content

Commit

Permalink
Merge branch 'version/0-43-0-RC1' into mitchell/dx-2194
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell-as committed Nov 9, 2023
2 parents 206131d + f66597c commit b3f453f
Show file tree
Hide file tree
Showing 293 changed files with 4,112 additions and 6,203 deletions.
Empty file.
Binary file removed .github/deps/Linux/bin/state
Binary file not shown.
Binary file removed .github/deps/Linux/bin/state-svc
Binary file not shown.
Empty file.
Binary file removed .github/deps/Windows/bin/state-svc.exe
Binary file not shown.
Binary file removed .github/deps/Windows/bin/state.exe
Binary file not shown.
Empty file.
Binary file removed .github/deps/macOS/bin/state
Binary file not shown.
Binary file removed .github/deps/macOS/bin/state-svc
Binary file not shown.
13 changes: 13 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}

- # === Install State Tool ===
name: Install State Tool
uses: ActiveState/setup-state-tool@v1

- # === Setup ===
name: Setup
shell: bash
Expand Down Expand Up @@ -413,6 +417,10 @@ jobs:
with:
go-version: ${{ matrix.go-version }}

- # === Install State Tool ===
name: Install State Tool
uses: ActiveState/setup-state-tool@v1

- # === Setup ===
name: Setup
shell: bash
Expand Down Expand Up @@ -462,6 +470,11 @@ jobs:
aws-region: ${{ env.AWS_REGION }}
mask-aws-account-id: true

- # === Generate updated master versions.json if necessary ===
name: Generate version list
shell: bash
run: state run generate-versions-list

- # === Deploy ===
name: Deploy
shell: bash
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/propagate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
with:
go-version: ${{ matrix.go-version }}

- # === Install State Tool ===
name: Install State Tool
uses: ActiveState/setup-state-tool@v1

- # === Setup ===
name: Setup
shell: bash
Expand Down Expand Up @@ -85,6 +89,13 @@ jobs:
"type": "mrkdwn",
"text": "Propagate-PR failed for *<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>*\nFailure should be addressed by *${{ github.event.pull_request.user.login }}*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Failed job: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
}
]
}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
with:
go-version: ${{ matrix.go-version }}

- # === Install State Tool ===
name: Install State Tool
uses: ActiveState/setup-state-tool@v1

- # === Setup ===
name: Setup
shell: bash
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
with:
go-version: '1.20.x'

- # === Install State Tool ===
name: Install State Tool
uses: ActiveState/setup-state-tool@v1

- # === Setup ===
name: Setup
shell: bash
Expand Down
11 changes: 10 additions & 1 deletion activestate.generators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ scripts:
value: |
set -e
$constants.SET_ENV
echo "# Generate payload"
go run ./scripts/ci/payload-generator/main.go "$@"
- name: generate-update
Expand Down Expand Up @@ -120,3 +120,12 @@ scripts:
go run scripts/ci/payload-generator/main.go -b ${TEST_CHANNEL} -v ${TEST_VERSION}
copy_test_payload
go run scripts/ci/update-generator/main.go -b ${TEST_CHANNEL} -v ${TEST_VERSION} -o ${TEST_ARCHIVE_DIR}
- name: generate-versions-list
language: bash
standalone: true
description: Generates master versions.json from S3 and info.json's from generate-update
value: |
set -e
$constants.SET_ENV
go run scripts/ci/update-version-list/main.go ./build/update
37 changes: 0 additions & 37 deletions activestate.offlineinstall.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ from use by external code.
#### internal/runbits/

Packages that are made available for use by "runner" packages. In essence,
`internal/runners/internal/runbits`. A synonymous and deprecated directory
exists at `pkg/cmdlets/`.
`internal/runners/internal/runbits`.

#### internal/runners/

Expand Down
6 changes: 3 additions & 3 deletions cmd/state-exec/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os/exec"
)

func runCmd(meta *executorMeta) error {
func runCmd(meta *executorMeta) (int, error) {
userArgs := os.Args[1:]
cmd := exec.Command(meta.MatchingBin, userArgs...)
cmd.Stdin = os.Stdin
Expand All @@ -15,8 +15,8 @@ func runCmd(meta *executorMeta) error {
cmd.Env = meta.TransformedEnv

if err := cmd.Run(); err != nil {
return fmt.Errorf("command %q failed: %w", meta.MatchingBin, err)
return -1, fmt.Errorf("command %q failed: %w", meta.MatchingBin, err)
}

return nil
return cmd.ProcessState.ExitCode(), nil
}
4 changes: 2 additions & 2 deletions cmd/state-exec/comm.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const (
msgWidth = 1024
)

func sendMsgToService(sockPath string, hb *svcmsg.Heartbeat) error {
func sendMsgToService(sockPath string, msg svcmsg.Messager) error {
conn, err := net.Dial(network, sockPath)
if err != nil {
return fmt.Errorf("dial failed: %w", err)
}
defer conn.Close()

_, err = conn.Write([]byte(hb.SvcMsg()))
_, err = conn.Write([]byte(msg.SvcMsg()))
if err != nil {
return fmt.Errorf("write to connection failed: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/state-exec/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import "os"

// onCI is copied from the internal/condition package (to minimize depdencies).
func onCI() bool {
return os.Getenv("CI") != "" || os.Getenv("BUILDER_OUTPUT") != ""
// inActiveStateCI is copied from the internal/condition package (to minimize dependencies).
func inActiveStateCI() bool {
return os.Getenv("ACTIVESTATE_CI") == "true"
}
17 changes: 17 additions & 0 deletions cmd/state-exec/exitcode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"fmt"
"os"
"strconv"

"github.com/ActiveState/cli/internal/svcctl/svcmsg"
)

func newExitCodeMessage(exitCode int) (*svcmsg.ExitCode, error) {
execPath, err := os.Executable()
if err != nil {
return nil, fmt.Errorf("cannot get executable info: %w", err)
}
return &svcmsg.ExitCode{execPath, strconv.Itoa(exitCode)}, nil
}
19 changes: 17 additions & 2 deletions cmd/state-exec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,31 @@ func run() error {
if err := sendMsgToService(meta.SockPath, hb); err != nil {
logr.Debug(" sock - error: %v", err)

if onCI() { // halt control flow on CI only
if inActiveStateCI() { // halt control flow on CI only
return fmt.Errorf("cannot send message to service (this error is handled in CI only): %w", err)
}
}

logr.Debug("cmd - running: %s", meta.MatchingBin)
if err := runCmd(meta); err != nil {
exitCode, err := runCmd(meta)
if err != nil {
logr.Debug(" running - failed: bins (%v)", meta.ExecMeta.Bins)
return fmt.Errorf("cannot run command: %w", err)
}

msg, err := newExitCodeMessage(exitCode)
if err != nil {
return fmt.Errorf("cannot create new exit code message: %w", err)
}
logr.Debug("message data - exec: %s, exit code: %s", msg.ExecPath, msg.ExitCode)

if err := sendMsgToService(meta.SockPath, msg); err != nil {
logr.Debug(" sock - error: %v", err)

if inActiveStateCI() { // halt control flow on CI only
return fmt.Errorf("cannot send message to service (this error is handled in CI only): %w", err)
}
}

return nil
}
15 changes: 14 additions & 1 deletion cmd/state-installer/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (
"github.com/ActiveState/cli/internal/output"
"github.com/ActiveState/cli/internal/primer"
"github.com/ActiveState/cli/internal/rollbar"
"github.com/ActiveState/cli/internal/runbits/errors"
"github.com/ActiveState/cli/internal/runbits/panics"
"github.com/ActiveState/cli/internal/subshell"
"github.com/ActiveState/cli/internal/subshell/bash"
"github.com/ActiveState/cli/pkg/cmdlets/errors"
"github.com/ActiveState/cli/pkg/project"
"github.com/ActiveState/cli/pkg/sysinfo"
"golang.org/x/crypto/ssh/terminal"
Expand Down Expand Up @@ -123,6 +123,19 @@ func main() {
logging.Debug("Original Args: %v", os.Args)
logging.Debug("Processed Args: %v", processedArgs)

// Store sessionToken to config
for _, envVar := range []string{constants.OverrideSessionTokenEnvVarName, constants.SessionTokenEnvVarName} {
sessionToken, ok := os.LookupEnv(envVar)
if !ok {
continue
}
err := cfg.Set(anaConst.CfgSessionToken, sessionToken)
if err != nil {
multilog.Error("Unable to set session token: " + errs.JoinMessage(err))
}
break
}

an = sync.New(anaConst.SrcStateInstaller, cfg, nil, out)
an.Event(anaConst.CatInstallerFunnel, "start")

Expand Down
18 changes: 3 additions & 15 deletions cmd/state-installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

svcApp "github.com/ActiveState/cli/cmd/state-svc/app"
svcAutostart "github.com/ActiveState/cli/cmd/state-svc/autostart"
anaConst "github.com/ActiveState/cli/internal/analytics/constants"
"github.com/ActiveState/cli/internal/config"
"github.com/ActiveState/cli/internal/constants"
"github.com/ActiveState/cli/internal/errs"
Expand All @@ -30,10 +29,9 @@ import (
)

type Installer struct {
out output.Outputer
cfg *config.Instance
payloadPath string
sessionToken string
out output.Outputer
cfg *config.Instance
payloadPath string
*Params
}

Expand All @@ -49,13 +47,6 @@ func NewInstaller(cfg *config.Instance, out output.Outputer, payloadPath string,
}

func (i *Installer) Install() (rerr error) {
// Store sessionToken to config
if i.sessionToken != "" && i.cfg.GetString(anaConst.CfgSessionToken) == "" {
if err := i.cfg.Set(anaConst.CfgSessionToken, i.sessionToken); err != nil {
return errs.Wrap(err, "Failed to set session token")
}
}

// Store update tag
if i.updateTag != "" {
if err := i.cfg.Set(updater.CfgUpdateTag, i.updateTag); err != nil {
Expand Down Expand Up @@ -145,9 +136,6 @@ func (i *Installer) InstallPath() string {

// sanitizeInput cleans up the input and inserts fallback values
func (i *Installer) sanitizeInput() error {
if sessionToken, ok := os.LookupEnv(constants.SessionTokenEnvVarName); ok {
i.sessionToken = sessionToken
}
if tag, ok := os.LookupEnv(constants.UpdateTagEnvVarName); ok {
i.updateTag = tag
}
Expand Down
Loading

0 comments on commit b3f453f

Please sign in to comment.