Skip to content

Commit

Permalink
undo my incorrect assumptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshMcCullough committed May 13, 2023
1 parent 1ca036b commit 17970ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pkg/model/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@ func (j JobType) String() string {

// Type returns the type of the job
func (j *Job) Type() JobType {
isLocal := strings.HasPrefix(j.Uses, "./")
isLocal := strings.HasPrefix(j.Uses, "./.github/workflows/")
isYaml, _ := regexp.MatchString(`\.(ya?ml)(?:$|@)`, j.Uses)
hasVersion, _ := regexp.MatchString(`@`, j.Uses)
hasVersion, _ := regexp.MatchString(`\.ya?ml@`, j.Uses)

if isYaml {
if isLocal {
Expand Down
17 changes: 7 additions & 10 deletions pkg/model/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,26 +147,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: echo
remote-reusable-workflow-with-ref:
remote-reusable-workflow-yml:
uses: remote/repo/.github/workflows/workflow.yml@main
remote-reusable-workflow-custom-path:
uses: remote/repo/do-something/workflow.yml@main
remote-reusable-workflow-yaml:
uses: remote/repo/do-something/workflow.yaml@main
local-reusable-workflow:
uses: remote/repo/.github/workflows/workflow.yaml@main
local-reusable-workflow-yml:
uses: ./.github/workflows/workflow.yml
local-reusable-workflow-yaml:
uses: ./.github/workflows/workflow.yml
uses: ./.github/workflows/workflow.yaml
`

workflow, err := ReadWorkflow(strings.NewReader(yaml))
assert.NoError(t, err, "read workflow should succeed")
assert.Len(t, workflow.Jobs, 6)
assert.Len(t, workflow.Jobs, 5)
assert.Equal(t, workflow.Jobs["default-job"].Type(), JobTypeDefault)
assert.Equal(t, workflow.Jobs["remote-reusable-workflow-with-ref"].Type(), JobTypeReusableWorkflowRemote)
assert.Equal(t, workflow.Jobs["remote-reusable-workflow-custom-path"].Type(), JobTypeReusableWorkflowRemote)
assert.Equal(t, workflow.Jobs["remote-reusable-workflow-yml"].Type(), JobTypeReusableWorkflowRemote)
assert.Equal(t, workflow.Jobs["remote-reusable-workflow-yaml"].Type(), JobTypeReusableWorkflowRemote)
assert.Equal(t, workflow.Jobs["local-reusable-workflow"].Type(), JobTypeReusableWorkflowLocal)
assert.Equal(t, workflow.Jobs["local-reusable-workflow-yml"].Type(), JobTypeReusableWorkflowLocal)
assert.Equal(t, workflow.Jobs["local-reusable-workflow-yaml"].Type(), JobTypeReusableWorkflowLocal)
}

Expand Down

0 comments on commit 17970ab

Please sign in to comment.