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

Enable paths with environment variables for local steps in the offline workflow editor #315

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions _tests/integration/step_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package integration
import (
"strings"
"testing"
"os"

"github.com/bitrise-io/go-utils/command"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -47,6 +48,14 @@ func TestStepInfo(t *testing.T) {
require.Equal(t, localTestStepDefinitionJSON, out)
}

t.Log("local step - environment variable path --format json")
{
os.Setenv("STEP", ".")
out, err := command.New(binPath(), "step-info", "--collection", "path", "--id", "$STEP/test-step", "--format", "json").RunAndReturnTrimmedCombinedOutput()
require.NoError(t, err, out)
require.Equal(t, localTestStepDefinitionJSON, out)
}

t.Log("git step")
{
out, err := command.New(binPath(), "step-info", "--collection", "git", "--id", "https://github.com/bitrise-steplib/steps-xamarin-user-management.git", "--version", "1.0.3").RunAndReturnTrimmedCombinedOutput()
Expand Down
4 changes: 3 additions & 1 deletion cli/step_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"fmt"
"os"
"path/filepath"
"time"

Expand Down Expand Up @@ -162,7 +163,8 @@ func QueryStepInfoFromGit(gitURL, tagOrBranch string) (models.StepInfoModel, err
}

// QueryStepInfoFromPath returns step info from a local path source
func QueryStepInfoFromPath(dir string) (models.StepInfoModel, error) {
func QueryStepInfoFromPath(envdir string) (models.StepInfoModel, error) {
dir := os.ExpandEnv(envdir)
stepDefinitionPth := filepath.Join(dir, "step.yml")
if exist, err := pathutil.IsPathExists(stepDefinitionPth); err != nil {
return models.StepInfoModel{}, fmt.Errorf("query local step info: check if step.yml exist: %s", err)
Expand Down