Skip to content

Commit

Permalink
split project list: stable projects and general projects
Browse files Browse the repository at this point in the history
  • Loading branch information
pacoxu committed Feb 23, 2022
1 parent a6da79c commit 31bfa85
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
12 changes: 9 additions & 3 deletions github.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func readFile(path string) (string, error) {
return string(content), err
}

func fetchAllRepos(projectsPath string, client *github.Client) []*github.Repository {
func fetchAllRepos(projectsPath string, client *github.Client) ([]*github.Repository, []string) {
// load repos from json
repos, err := readFile(projectsPath)
if err != nil {
Expand All @@ -69,13 +69,16 @@ func fetchAllRepos(projectsPath string, client *github.Client) []*github.Reposit
var allRepos []*github.Repository
reposList := configFromFile.Spec.Repos
log.Println("repos: ", reposList)
// #TODO #2 Github has a rate limit of 60 per hour, so don't add more than 60 projects now
var skippedRepos []string
for repo, _ := range reposList {
if len(strings.Split(repo, "/")) == 2 {
splits := strings.Split(repo, "/")
// org/reponame is splits
repository, _, err := client.Repositories.Get(context.Background(), splits[0], splits[1])
if err != nil {
log.Printf("WARNING: skip repo: %s for error: %s", repo, err)
skippedRepos = append(skippedRepos, repo)
continue
}
allRepos = append(allRepos, repository)
Expand All @@ -85,7 +88,7 @@ func fetchAllRepos(projectsPath string, client *github.Client) []*github.Reposit

}
log.Println("repos: ", reposList)
return allRepos
return allRepos, skippedRepos
}

func makeMdTable(data [][]string, header []string) string {
Expand Down Expand Up @@ -126,14 +129,17 @@ func makeReposString(repos []*github.Repository) string {
func main() {
flag.Parse()
client := github.NewClient(nil)
repos := fetchAllRepos(projectsPath, client)
repos, skippedRepos := fetchAllRepos(projectsPath, client)
// change sort logic here
sort.Slice(repos[:], func(i, j int) bool {
return *repos[j].StargazersCount < *repos[i].StargazersCount
})

newContentString := makeReposString(repos)
log.Println("Repos Status: \n", newContentString)
newContentString += "\n\n"
newContentString += "## Skipped repos\n"
newContentString += strings.Join(skippedRepos, "\n")

readMeFile := path.Join(os.Getenv("GITHUB_WORKSPACE"), "README.md")
log.Println("README.md path: ", readMeFile)
Expand Down
31 changes: 6 additions & 25 deletions projects.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
{
"spec": {
"repos": {
"kubernetes/kubernetes": "",
"containerd/containerd": "",
"istio/istio": "",
"envoyproxy/envoy": "",
"helm/helm": "",
"prometheus/prometheus": "",
"moby/moby": "",
"coredns/coredns": "",
"projectcalico/calico": "",
"opencontainers/runc": "",
"kubernetes/ingress-nginx": "",
"flannel-io/flannel": "",
"vmware-tanzu/velero": "",
"etcd-io/etcd": "",
"torvalds/linux": "",
"cilium/cilium": "",
"knative/serving": "",
"kubernetes-sigs/cluster-api": "",
"kubeedge/kubeedge": "",
"chaos-mesh/chaos-mesh": "",
"piraeusdatastore/piraeus": "",
"merbridge/merbridge": "",
"clusterpedia-io/clusterpedia": "",
"goharbor/harbor": "",
"klts-io/kubernetes-lts": "",
"ferry-proxy/ferry": "",
"kubeedge/kubeedge": "",
"chaos-mesh/chaos-mesh": "",
"karmada-io/karmada": "",
"piraeusdatastore/piraeus": "",
"kubesphere/kubesphere": "",
"volcano-sh/volcano": "",
"kubeovn/kube-ovn": "",
Expand All @@ -34,14 +17,12 @@
"FabEdge/fabedge": "",
"superedge/superedge": "",
"carina-io/carina": "",
"klts-io/kubernetes-lts": "",
"bfenetworks/bfe": "",
"openelb/openelb": "",
"oam-dev/kubevela": "",
"openyurtio/openyurt": "",
"dragonflyoss/Dragonfly": "",
"dragonflyoss/Dragonfly2": "",
"ferry-proxy/ferry": ""
"dragonflyoss/Dragonfly2": ""
}
},
"status": {}
Expand Down
26 changes: 26 additions & 0 deletions stable_projects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"spec": {
"repos": {
"kubernetes/kubernetes": "",
"containerd/containerd": "",
"istio/istio": "",
"envoyproxy/envoy": "",
"helm/helm": "",
"prometheus/prometheus": "",
"moby/moby": "",
"coredns/coredns": "",
"projectcalico/calico": "",
"opencontainers/runc": "",
"kubernetes/ingress-nginx": "",
"flannel-io/flannel": "",
"vmware-tanzu/velero": "",
"etcd-io/etcd": "",
"torvalds/linux": "",
"cilium/cilium": "",
"knative/serving": "",
"kubernetes-sigs/cluster-api": "",
"goharbor/harbor": ""
}
},
"status": {}
}

0 comments on commit 31bfa85

Please sign in to comment.