Skip to content

Commit 862b83a

Browse files
authored
fix: allow target hyphenated alphanumeric sequence (#153)
1 parent 7a775d5 commit 862b83a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

cli/pkg/scanners/file_scanner.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ func getTargetRegex(target string) string {
8080
if strings.HasSuffix(target, "-*") {
8181
// Should start with given target
8282
// followed by hyphen and followed by one or more lowercase letters or numbers
83-
return fmt.Sprintf("^%s-(?:[a-z0-9]+)?$", regexp.QuoteMeta(target[:len(target)-2]))
83+
// allows for additional hyphenated alphanumeric sequences
84+
return fmt.Sprintf("^%s-[a-z0-9]+(?:-[a-z0-9]+)*$", regexp.QuoteMeta(target[:len(target)-2]))
8485
}
8586

8687
// Match the exact target

cli/pkg/scanners/file_scanner_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ var _ = Describe("FileScanner", func() {
113113
},
114114
Entry("scanning 'docker', target in file is 'docker'", "docker", "docker"),
115115
Entry("scanning 'docker-*', target in file is 'docker-test'", "docker-*", "docker-test"),
116+
Entry("scanning 'docker-*', target in file is 'docker-test-test2'", "docker-*", "docker-test-test2"),
117+
Entry("scanning 'docker-*', target in file is 'docker-test-test2-test3'", "docker-*", "docker-test-test2-test3"),
116118
)
117119
DescribeTable("when Earthfile contain no target",
118120
func(target string) {

docs/src/onboarding/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The output of the check phase may looks like the following:
5757

5858
```json
5959
{
60-
"/home/work/test": ["check-test1", "check-test2", "check-test3"],
60+
"/home/work/test": ["check-test1", "check-test2", "check-test3", "check-test-test4"],
6161
"/home/work/test2": ["check"]
6262
}
6363
```
@@ -71,7 +71,8 @@ The output of the check phase may looks like the following:
7171
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
7272
multiplexes executing the filtered targets from each of the discovered `Earthfile`s.
7373
The filtered targets will be retrieved from the map according to which Earthfile is currently running.
74-
For example, from the above example, running `/home/work/test` will run the targets `check-test1`, `check-test2`, and `check-test3`.
74+
For example, from the above example, running `/home/work/test` will run the targets `check-test1`, `check-test2`, `check-test3` and
75+
`check-test-test4`.
7576

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

184185
```json
185186
{
186-
"/home/work/test": ["check-test1", "check-test2", "check-test3"],
187+
"/home/work/test": ["check-test1", "check-test2", "check-test3", "check-test-test4"],
187188
"/home/work/test2": ["check-test1"]
188189
}
189190
```

0 commit comments

Comments
 (0)