wip: commit more progress on script
This commit is contained in:
parent
20204b0153
commit
902b32fd29
6
.github/scripts/readme-validation/go.mod
vendored
6
.github/scripts/readme-validation/go.mod
vendored
@ -1,5 +1,7 @@
|
|||||||
module coder.com/static_terraform_registry
|
module coder.com/readme-validation
|
||||||
|
|
||||||
go 1.23.2
|
go 1.23.2
|
||||||
|
|
||||||
require sigs.k8s.io/yaml v1.4.0 // indirect
|
require github.com/ghodss/yaml v1.0.0
|
||||||
|
|
||||||
|
require gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
|
|||||||
8
.github/scripts/readme-validation/go.sum
vendored
8
.github/scripts/readme-validation/go.sum
vendored
@ -1,4 +1,6 @@
|
|||||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||||
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
|||||||
52
.github/scripts/readme-validation/main.go
vendored
52
.github/scripts/readme-validation/main.go
vendored
@ -12,7 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"sigs.k8s.io/yaml"
|
"github.com/ghodss/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
const rootRegistryPath = "./registry"
|
const rootRegistryPath = "./registry"
|
||||||
@ -306,6 +306,11 @@ website:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Avatar URL
|
||||||
|
if yml.AvatarUrl != nil {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,7 +343,12 @@ func remapContributorProfile(
|
|||||||
}
|
}
|
||||||
if employeeGitHubNames != nil {
|
if employeeGitHubNames != nil {
|
||||||
remapped.EmployeeGithubUsernames = employeeGitHubNames[:]
|
remapped.EmployeeGithubUsernames = employeeGitHubNames[:]
|
||||||
slices.Sort(remapped.EmployeeGithubUsernames)
|
slices.SortFunc(
|
||||||
|
remapped.EmployeeGithubUsernames,
|
||||||
|
func(name1 string, name2 string) int {
|
||||||
|
return strings.Compare(name1, name2)
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return remapped
|
return remapped
|
||||||
@ -447,18 +457,36 @@ func parseContributorFiles(input []directoryReadme) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
func backfillAvatarUrls(contributors map[string]contributorProfile) error {
|
func backfillAvatarUrls(contributors map[string]contributorProfile) error {
|
||||||
wg := sync.WaitGroup{}
|
if contributors == nil {
|
||||||
requestBuffer := make(chan struct{}, 10)
|
return errors.New("provided map is nil")
|
||||||
errors := []error{}
|
}
|
||||||
|
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
errors := []error{}
|
||||||
|
errorsMutex := sync.Mutex{}
|
||||||
|
|
||||||
|
// Todo: Add actual fetching logic once everything else has been verified
|
||||||
|
requestAvatarUrl := func(string) (string, error) {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for ghUsername, conCopy := range contributors {
|
||||||
|
if conCopy.AvatarUrl != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
for _, c := range contributors {
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
requestBuffer <- struct{}{}
|
defer wg.Done()
|
||||||
// Do request stuff
|
url, err := requestAvatarUrl(ghUsername)
|
||||||
|
if err != nil {
|
||||||
<-requestBuffer
|
errorsMutex.Lock()
|
||||||
wg.Done()
|
errors = append(errors, err)
|
||||||
|
errorsMutex.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
conCopy.AvatarUrl = url
|
||||||
|
contributors[ghUsername] = conCopy
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,12 +509,12 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
allReadmeFiles := []directoryReadme{}
|
allReadmeFiles := []directoryReadme{}
|
||||||
fsErrors := workflowPhaseError{
|
fsErrors := workflowPhaseError{
|
||||||
Phase: "FileSystem reading",
|
Phase: "FileSystem reading",
|
||||||
Errors: []error{},
|
Errors: []error{},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range dirEntries {
|
for _, e := range dirEntries {
|
||||||
dirPath := path.Join(rootRegistryPath, e.Name())
|
dirPath := path.Join(rootRegistryPath, e.Name())
|
||||||
if !e.IsDir() {
|
if !e.IsDir() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user