Skip to content

Commit

Permalink
fix: trim leading dot-slash from paths (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcreey authored Feb 29, 2024
1 parent 135ea47 commit 1da32e1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ jobs:
with:
go-version: '1.21'

- run: |-
- name: 'Run tests'
env:
ACTIONS_TOKEN: '${{ github.token }}'
run: |-
go test -count=1 -shuffle=on -timeout=10m -race ./...
1 change: 1 addition & 0 deletions command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func loadYAMLFiles(fsys fs.FS, paths []string) (loadResults, error) {
r := make(loadResults, 0, len(paths))

for _, pth := range paths {
pth = strings.TrimPrefix(pth, "./")
contents, err := fs.ReadFile(fsys, pth)
if err != nil {
return nil, fmt.Errorf("failed to read file %s: %w", pth, err)
Expand Down
25 changes: 25 additions & 0 deletions command/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,31 @@ func Test_loadYAMLFiles(t *testing.T) {
uses: 'my-org/my-repo/.github/workflows/my-workflow.yml@v0'
final_job:
uses: './local/path/to/action'
`,
},
{
name: "handles-leading-dot-slash",
yamlFilenames: []string{"./testdata/github.yml"},
want: `jobs:
my_job:
runs-on: 'ubuntu-latest'
container:
image: 'ubuntu:20.04'
services:
nginx:
image: 'nginx:1.21'
steps:
- uses: 'actions/checkout@v3'
- uses: 'docker://ubuntu:20.04'
with:
uses: '/path/to/user.png'
image: '/path/to/image.jpg'
- runs: |-
echo "Hello 😀"
other_job:
uses: 'my-org/my-repo/.github/workflows/my-workflow.yml@v0'
final_job:
uses: './local/path/to/action'
`,
},
}
Expand Down

0 comments on commit 1da32e1

Please sign in to comment.