File tree Expand file tree Collapse file tree 2 files changed +24
-10
lines changed
Expand file tree Collapse file tree 2 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -11,22 +11,25 @@ import (
1111 yaml "gopkg.in/yaml.v3"
1212)
1313
14+ var ciYamlSuffixes = []string {
15+ ".rayci.yaml" , ".rayci.yml" ,
16+ ".ci.yaml" , ".ci.yml" ,
17+ }
18+
1419func isRayCIYaml (p string ) bool {
15- if strings .HasSuffix (p , ".rayci.yaml" ) {
16- return true
17- }
18- if strings .HasSuffix (p , ".rayci.yml" ) {
19- return true
20+ for _ , suffix := range ciYamlSuffixes {
21+ if strings .HasSuffix (p , suffix ) {
22+ return true
23+ }
2024 }
2125 return false
2226}
2327
2428func stripRayCIYamlSuffix (p string ) string {
25- if strings .HasSuffix (p , ".rayci.yaml" ) {
26- return strings .TrimSuffix (p , ".rayci.yaml" )
27- }
28- if strings .HasSuffix (p , ".rayci.yml" ) {
29- return strings .TrimSuffix (p , ".rayci.yml" )
29+ for _ , suffix := range ciYamlSuffixes {
30+ if strings .HasSuffix (p , suffix ) {
31+ return strings .TrimSuffix (p , suffix )
32+ }
3033 }
3134 return p
3235}
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ func TestIsRayCIYaml(t *testing.T) {
1515 for _ , f := range []string {
1616 "foo.rayci.yaml" ,
1717 "foo.rayci.yml" ,
18+ "foo.ci.yaml" ,
19+ "foo.ci.yml" ,
1820 "dir/foo.rayci.yml" ,
1921 } {
2022 if ! isRayCIYaml (f ) {
@@ -24,6 +26,8 @@ func TestIsRayCIYaml(t *testing.T) {
2426
2527 for _ , f := range []string {
2628 "rayci.yaml" ,
29+ "ci.yaml" ,
30+ "ci.yml" ,
2731 "pipeline.build.yaml" ,
2832 "pipeline.tests.yml" ,
2933 } {
@@ -42,6 +46,10 @@ func TestListCIYamlFiles(t *testing.T) {
4246 "foo.rayci.yml" ,
4347 "dir/foo.rayci.yml" ,
4448 "pipeline.build.yaml" ,
49+ "foo.ci.yaml" ,
50+ "bar.ci.yaml" ,
51+ "foo.ci.yml" ,
52+ "dir/foo.ci.yml" ,
4553 } {
4654 dir := filepath .Join (tmp , filepath .Dir (f ))
4755 if err := os .MkdirAll (dir , 0o700 ); err != nil {
@@ -59,7 +67,10 @@ func TestListCIYamlFiles(t *testing.T) {
5967 }
6068
6169 want := []string {
70+ "bar.ci.yaml" ,
6271 "bar.rayci.yaml" ,
72+ "foo.ci.yaml" ,
73+ "foo.ci.yml" ,
6374 "foo.rayci.yaml" ,
6475 "foo.rayci.yml" ,
6576 }
You can’t perform that action at this time.
0 commit comments