Skip to content

Commit

Permalink
fix: allow target hyphenated alphanumeric sequence (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkioshn authored Jan 11, 2024
1 parent 7a775d5 commit 862b83a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cli/pkg/scanners/file_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ func getTargetRegex(target string) string {
if strings.HasSuffix(target, "-*") {
// Should start with given target
// followed by hyphen and followed by one or more lowercase letters or numbers
return fmt.Sprintf("^%s-(?:[a-z0-9]+)?$", regexp.QuoteMeta(target[:len(target)-2]))
// allows for additional hyphenated alphanumeric sequences
return fmt.Sprintf("^%s-[a-z0-9]+(?:-[a-z0-9]+)*$", regexp.QuoteMeta(target[:len(target)-2]))
}

// Match the exact target
Expand Down
2 changes: 2 additions & 0 deletions cli/pkg/scanners/file_scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ var _ = Describe("FileScanner", func() {
},
Entry("scanning 'docker', target in file is 'docker'", "docker", "docker"),
Entry("scanning 'docker-*', target in file is 'docker-test'", "docker-*", "docker-test"),
Entry("scanning 'docker-*', target in file is 'docker-test-test2'", "docker-*", "docker-test-test2"),
Entry("scanning 'docker-*', target in file is 'docker-test-test2-test3'", "docker-*", "docker-test-test2-test3"),
)
DescribeTable("when Earthfile contain no target",
func(target string) {
Expand Down
7 changes: 4 additions & 3 deletions docs/src/onboarding/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The output of the check phase may looks like the following:

```json
{
"/home/work/test": ["check-test1", "check-test2", "check-test3"],
"/home/work/test": ["check-test1", "check-test2", "check-test3", "check-test-test4"],
"/home/work/test2": ["check"]
}
```
Expand All @@ -71,7 +71,8 @@ The output of the check phase may looks like the following:
This list of `path` is fed into a [matrix job](https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs) that
multiplexes executing the filtered targets from each of the discovered `Earthfile`s.
The filtered targets will be retrieved from the map according to which Earthfile is currently running.
For example, from the above example, running `/home/work/test` will run the targets `check-test1`, `check-test2`, and `check-test3`.
For example, from the above example, running `/home/work/test` will run the targets `check-test1`, `check-test2`, `check-test3` and
`check-test-test4`.

Executing each discovered Earthfile in parallel will maximize network throughput
and create a more easily digestible view of the CI status.
Expand Down Expand Up @@ -183,7 +184,7 @@ The examples are provided below:

```json
{
"/home/work/test": ["check-test1", "check-test2", "check-test3"],
"/home/work/test": ["check-test1", "check-test2", "check-test3", "check-test-test4"],
"/home/work/test2": ["check-test1"]
}
```
Expand Down

0 comments on commit 862b83a

Please sign in to comment.