Skip to content

Commit

Permalink
add more normal test cases for local actions check
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Mar 12, 2024
1 parent b8c6cbe commit c7e970f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
22 changes: 21 additions & 1 deletion action_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,31 @@ func TestLocalActionsFindMetadata(t *testing.T) {
if err != nil {
t.Fatal(err)
}
testCachedFlag(t, cached, false)
if !cmp.Equal(want, have) {
t.Fatal(cmp.Diff(want, have))
}
testCachedFlag(t, cached, false)
})

for _, using := range []string{"docker", "composite"} {
a, u := "./"+using, using
t.Run(a, func(t *testing.T) {
want := &ActionMetadata{
Name: "My action",
Runs: ActionMetadataRuns{
Using: u,
},
}
have, cached, err := c.FindMetadata(a)
if err != nil {
t.Fatal(err)
}
testCachedFlag(t, cached, false)
if !cmp.Equal(want, have) {
t.Fatal(cmp.Diff(want, have))
}
})
}
}

func TestLocalActionsFindConcurrently(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions rule_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func (rule *RuleAction) checkLocalAction(path string, action *ExecAction) {
}

if !cached {
rule.Debug("Checking runner metadata of %s action %q at %q", meta.Runs, meta.Name, path)
rule.checkLocalActionRunner(path, meta, action.Uses.Pos)
}

Expand Down
8 changes: 8 additions & 0 deletions testdata/action_metadata/composite/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: 'My action'
author: 'rhysd <https://rhysd.github.io>'
description: 'my action'

runs:
using: composite
steps:
- run: echo hello
1 change: 1 addition & 0 deletions testdata/action_metadata/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM alpine:latest
7 changes: 7 additions & 0 deletions testdata/action_metadata/docker/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: 'My action'
author: 'rhysd <https://rhysd.github.io>'
description: 'my action'

runs:
using: docker
image: Dockerfile

0 comments on commit c7e970f

Please sign in to comment.