Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit

Permalink
Add ability to dump sprint status to special spreadsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
Frostman committed Aug 22, 2023
1 parent 0897143 commit 776a97b
Show file tree
Hide file tree
Showing 7 changed files with 388 additions and 16 deletions.
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

ORAS ?= $(LOCALBIN)/oras

ORAS_VERSION ?= v1.0.0

.PHONY: oras
oras: $(ORAS) ## Download oras locally if necessary.
$(ORAS): $(LOCALBIN)
test -s $(LOCALBIN)/oras || GOBIN=$(LOCALBIN) go install oras.land/oras/cmd/oras@$(ORAS_VERSION)

.PHONY: build-amd64
build-mdbook-gh-project-amd64: ## Build binary for amd64.
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/mdbook-gh-project cmd/mdbook-gh-project/main.go

BIN_REGISTRY ?= ghcr.io
BIN_MDBOOK_GH_PROJECT_URL ?= ghcr.io/githedgehog/mdbook-gh-project

.PHONY: bin-registry-login
bin-registry-login: oras
$(ORAS) login -u "$(USERNAME)" -p "$(PASSWORD)" $(BIN_REGISTRY)

.PHONY: bin-mdbook-gh-project-push
bin-mdbook-gh-project-push: build-mdbook-gh-project-amd64 oras
cd bin && $(ORAS) push $(BIN_MDBOOK_GH_PROJECT_URL):latest mdbook-gh-project
64 changes: 62 additions & 2 deletions cmd/gh-project-dump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,88 @@ import (
"fmt"
"log"
"os"
"strings"
"time"

"github.com/urfave/cli/v2"
"go.githedgehog.com/gh-tools/pkg/gdrive"
"go.githedgehog.com/gh-tools/pkg/github"
)

func main() {
var name, sprint string

app := &cli.App{
Name: "gh-project-dump",
Version: "0.0.0", // TODO load proper version using ld flags
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Aliases: []string{"n"},
Value: "0w0-test",
Usage: "update name",
Destination: &name,
},
&cli.StringFlag{
Name: "sprint",
Aliases: []string{"s"},
Value: "0w0",
Usage: "sprint name",
Destination: &sprint,
},
},
Action: func(ctx *cli.Context) error {
log.Println("Sprint:", sprint)
log.Println("Name:", name)

githubProjectID := "PVT_kwDOBvRah84AMA6Y"

sheetID := 0
spreadsheetID := "1hP2dy9JXPgTqMx3-x66cykojhp9JHbweBumfdwypQ3Y"

gh := github.New()

items, err := gh.GetProjectItems(context.Background(), "PVT_kwDOBvRah84AMA6Y")
items, err := gh.GetProjectItems(context.Background(), githubProjectID)
if err != nil {
log.Printf("Error getting github items: %#v\n", err)
return err
}
log.Println("Loaded project items:", len(items))

updated := time.Now().Format(time.DateTime)

records := [][]string{}
for _, item := range items {
fmt.Println(">>>", item.Milestone(), "<<<", item.Number(), item.Title(), item.Status(), item.Sprint(), item.Assignees(), item.Progress(), item.Component(), item.Estimate(), item.Jira(), item.Resource())
if item.Sprint() != sprint {
continue
}

resource := strings.ReplaceAll(item.Resource()[13:], "/issues/", "#")
records = append(records, []string{
name,
updated,
fmt.Sprintf("=HYPERLINK(\"%s\",\"%s\")", item.URL(), resource),
item.Title(),
item.Status(),
item.Assignee(),
fmt.Sprintf("%.2f", item.Estimate()),
item.Progress(),
fmt.Sprintf("%.2f", item.ProgressPercentage()),
fmt.Sprintf("%.2f", item.ProgressEstimate()),
item.Sprint(),
item.Component(),
item.Jira(),
fmt.Sprint(item.Assignees()),
item.SprintStartDate(),
})
}
log.Println("Records in current sprint:", len(records))

err = gdrive.New().AppendToSpreadsheet(context.Background(), spreadsheetID, sheetID, records)
if err != nil {
return err
}
log.Println("Spreadsheet updated")

return nil
},
Expand Down
25 changes: 21 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,35 @@ go 1.20

require (
github.com/shurcooL/githubv4 v0.0.0-20230305132112-efb623903184
golang.org/x/oauth2 v0.6.0
golang.org/x/oauth2 v0.11.0
google.golang.org/api v0.138.0
)

require (
cloud.google.com/go/compute v1.23.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/s2a-go v0.1.5 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect
google.golang.org/grpc v1.57.0 // indirect
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/pkg/errors v0.9.1
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shurcooL/graphql v0.0.0-20220606043923-3cf50f8a0a29 // indirect
github.com/urfave/cli/v2 v2.25.1
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/net v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
Loading

0 comments on commit 776a97b

Please sign in to comment.