@@ -14,6 +14,7 @@ import (
14
14
15
15
"coder.com/coder-registry/cmd/github"
16
16
"github.com/go-git/go-git/v5"
17
+ "github.com/go-git/go-git/v5/plumbing"
17
18
"github.com/joho/godotenv"
18
19
)
19
20
@@ -66,7 +67,10 @@ func main() {
66
67
// Start main validation
67
68
log .Println ("Starting README validation" )
68
69
69
- // Validate file structure of main README directory
70
+ // Validate file structure of main README directory. Have to do this
71
+ // synchronously and before everything else, or else there's no way to for
72
+ // the other main validation functions can't make any safe assumptions
73
+ // about where they should look in the repo
70
74
log .Println ("Validating directory structure of the README directory" )
71
75
err = validateRepoStructure ()
72
76
if err != nil {
@@ -76,18 +80,22 @@ func main() {
76
80
// Set up concurrency for validating each category of README file
77
81
var readmeValidationErrors []error
78
82
errChan := make (chan error , 1 )
83
+ doneChan := make (chan struct {})
79
84
wg := sync.WaitGroup {}
80
85
go func () {
81
86
for err := range errChan {
82
87
readmeValidationErrors = append (readmeValidationErrors , err )
83
88
}
89
+ close (doneChan )
84
90
}()
85
91
86
92
// Validate contributor README files
87
93
wg .Add (1 )
88
94
go func () {
89
95
defer wg .Done ()
90
- validateAllContributors (errChan )
96
+ if err := validateAllContributors (); err != nil {
97
+ errChan <- fmt .Errorf ("contributor validation: %v" , err )
98
+ }
91
99
}()
92
100
93
101
// Validate modules
@@ -117,7 +125,11 @@ func main() {
117
125
return
118
126
}
119
127
activeBranchName := head .Name ().Short ()
120
- fmt .Println ("-----" , activeBranchName )
128
+ _ , err = repo .Reference (plumbing .ReferenceName (activeBranchName ), true )
129
+ if err != nil {
130
+ errChan <- err
131
+ return
132
+ }
121
133
}()
122
134
123
135
// Validate templates
@@ -126,9 +138,10 @@ func main() {
126
138
defer wg .Done ()
127
139
}()
128
140
129
- // Clean up and log errors
141
+ // Clean up and then log errors
130
142
wg .Wait ()
131
143
close (errChan )
144
+ <- doneChan
132
145
for _ , err := range readmeValidationErrors {
133
146
log .Println (err )
134
147
}
0 commit comments