Skip to content

Commit

Permalink
Add bash debug
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomationD committed Aug 8, 2024
1 parent 697bcbd commit ba0a6c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run.e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:

on:
workflow_dispatch:
pull_request:
# pull_request: # Re-enable after nvm bug is fixed

jobs:
build:
Expand Down
32 changes: 21 additions & 11 deletions internal/manager/serverless/native.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (sls *Manager) runNpmInstall(w io.Writer) error {
nvmDir = "$HOME/.nvm"
}

command := fmt.Sprintf("source %s/nvm.sh && nvm use %s && npm install --save-dev", nvmDir, sls.App.NodeVersion)
command := fmt.Sprintf("source --debug %s/nvm.sh && nvm use %s && npm install --save-dev", nvmDir, sls.App.NodeVersion)

if sls.App.UseYarn {
command = npmToYarn(command)
Expand All @@ -46,6 +46,16 @@ func (sls *Manager) nvm(w io.Writer, command string) error {
nvmDir = "$HOME/.nvm"
}

// Check if nvm.sh exists in the nvmDir
nvmShPath := filepath.Join(nvmDir, "nvm.sh")
if _, err := os.Stat(nvmShPath); os.IsNotExist(err) {
logrus.Debugf("nvm.sh does not exist in the directory:", nvmDir)

Check failure on line 52 in internal/manager/serverless/native.go

View workflow job for this annotation

GitHub Actions / Unit Tests

github.com/sirupsen/logrus.Debugf call has arguments but no formatting directives

Check failure on line 52 in internal/manager/serverless/native.go

View workflow job for this annotation

GitHub Actions / Unit Tests

github.com/sirupsen/logrus.Debugf call has arguments but no formatting directives
return err
} else if err != nil {
logrus.Debugf("Error checking nvm.sh:", err)

Check failure on line 55 in internal/manager/serverless/native.go

View workflow job for this annotation

GitHub Actions / Unit Tests

github.com/sirupsen/logrus.Debugf call has arguments but no formatting directives

Check failure on line 55 in internal/manager/serverless/native.go

View workflow job for this annotation

GitHub Actions / Unit Tests

github.com/sirupsen/logrus.Debugf call has arguments but no formatting directives
return err
}

// TODO: If nvm.sh doesn't exist in the nvmDir, we should install it
// curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash

Expand All @@ -54,9 +64,9 @@ func (sls *Manager) nvm(w io.Writer, command string) error {
return err
}

logrus.Debugf("Running: bash -c source %s/nvm.sh && nvm install %s && %s", nvmDir, sls.App.NodeVersion, command)
cmd := exec.Command("bash", "-c",
fmt.Sprintf("source %s/nvm.sh && nvm install %s && %s", nvmDir, sls.App.NodeVersion, command),
logrus.Debugf("Running: bash -c source --debug %s/nvm.sh && nvm install %s && %s", nvmDir, sls.App.NodeVersion, command)
cmd := exec.Command("bash", "-xv", "-c",
fmt.Sprintf("source --debug %s/nvm.sh && nvm install %s && %s", nvmDir, sls.App.NodeVersion, command),
)

// Capture stderr in a buffer
Expand Down Expand Up @@ -105,7 +115,7 @@ func (sls *Manager) runNvm(w io.Writer) error {
return err
}

command := fmt.Sprintf("source %s/nvm.sh && nvm install %s", nvmDir, sls.App.NodeVersion)
command := fmt.Sprintf("source --debug %s/nvm.sh && nvm install %s", nvmDir, sls.App.NodeVersion)

logrus.SetOutput(w)
logrus.Debugf("command: %s", command)
Expand Down Expand Up @@ -143,7 +153,7 @@ func (sls *Manager) runDeploy(w io.Writer) error {
// SLS v3 has breaking changes in syntax
if sls.App.ServerlessVersion == "3" {
command = fmt.Sprintf(
`source %s/nvm.sh &&
`source --debug %s/nvm.sh &&
nvm use %s &&
npx serverless deploy \
--config=%s \
Expand All @@ -157,7 +167,7 @@ func (sls *Manager) runDeploy(w io.Writer) error {
sls.App.AwsProfile, sls.Project.Env)
} else {
command = fmt.Sprintf(
`source %s/nvm.sh &&
`source --debug %s/nvm.sh &&
nvm use %s &&
npx serverless deploy \
--config %s \
Expand Down Expand Up @@ -218,7 +228,7 @@ func (sls *Manager) runRemove(w io.Writer) error {
// SLS v3 has breaking changes in syntax
if sls.App.ServerlessVersion == "3" {
command = fmt.Sprintf(
`source %s/nvm.sh && \
`source --debug %s/nvm.sh && \
nvm use %s && \
npx serverless remove \
--config=%s \
Expand All @@ -232,7 +242,7 @@ func (sls *Manager) runRemove(w io.Writer) error {
sls.App.AwsProfile, sls.Project.Env)
} else {
command = fmt.Sprintf(
`source %s/nvm.sh && \
`source --debug %s/nvm.sh && \
nvm use %s && \
npx serverless remove \
--config %s \
Expand Down Expand Up @@ -283,7 +293,7 @@ func (sls *Manager) runCreateDomain(w io.Writer) error {
}

command := fmt.Sprintf(
`source %s/nvm.sh && \
`source --debug %s/nvm.sh && \
nvm use %s && \
npx serverless create_domain \
--verbose \
Expand Down Expand Up @@ -330,7 +340,7 @@ func (sls *Manager) runRemoveDomain(w io.Writer) error {
}

command := fmt.Sprintf(
`source %s/nvm.sh && \
`source --debug %s/nvm.sh && \
nvm use %s && \
npx serverless delete_domain \
--verbose \
Expand Down

0 comments on commit ba0a6c0

Please sign in to comment.