Skip to content

Commit 65cc91d

Browse files
heschigopherbot
authored andcommitted
cmd/releaseschedule: create
Add a program that generates the release schedule diagram used on the release schedule wiki. For golang/go#58820 Change-Id: I8117e28704ecad2da016bcd5b0f34cb198d0e440 Reviewed-on: https://go-review.googlesource.com/c/build/+/474675 Reviewed-by: Carlos Amedee <[email protected]> Run-TryBot: Heschi Kreinick <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Heschi Kreinick <[email protected]>
1 parent d0c5f51 commit 65cc91d

File tree

3 files changed

+110
-3
lines changed

3 files changed

+110
-3
lines changed

cmd/releaseschedule/main.go

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"math"
6+
"os"
7+
"strings"
8+
9+
svg "github.com/ajstarks/svgo"
10+
)
11+
12+
func main() {
13+
if err := doMain(); err != nil {
14+
panic(err)
15+
}
16+
}
17+
18+
func doMain() error {
19+
f, err := os.OpenFile("release.svg", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
20+
if err != nil {
21+
return err
22+
}
23+
defer f.Close()
24+
canvas := svg.New(f)
25+
canvas.Start(600, 400)
26+
canvas.Translate(300, 200)
27+
for i, month := range strings.Split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", " ") {
28+
angle := func(midx int) float64 {
29+
return (float64(midx) - 3) * 2 * math.Pi / 12
30+
}
31+
begin, end := angle(i), angle(i+1)
32+
33+
// Draw a single black wedge of the calendar.
34+
path := fmt.Sprintf("M 0,0 L %v,%v A 100,100 0 0 0 %v,%v L 0 0",
35+
100*math.Sin(begin), 100*math.Cos(begin), 100*math.Sin(end), 100*math.Cos(end))
36+
canvas.Path(path, "stroke: black; fill:none")
37+
38+
// Draw the text. Spin it around for readability in the second half.
39+
canvas.RotateTranslate(50, 0, angle(i)*360/(2*math.Pi)+20)
40+
if i < 6 {
41+
canvas.Text(0, 0, month)
42+
} else {
43+
canvas.Group(`transform="rotate(180)"`, `transform-origin="13 -3"`)
44+
canvas.Text(0, 0, month)
45+
canvas.Gend()
46+
}
47+
canvas.Gend()
48+
}
49+
50+
type milestone struct {
51+
month, week int
52+
name string
53+
}
54+
milestones := []milestone{
55+
{1, 1, "Planning"},
56+
{1, 3, "General development"},
57+
{5, 4, "Freeze"},
58+
{6, 2, "First RC"},
59+
{8, 2, "Release"},
60+
}
61+
for relIdx, relName := range []string{"Summer", "Winter"} {
62+
angle := func(m milestone) float64 {
63+
return (float64(m.month-1) - 3 + (float64(m.week)-0.5)/4) * 2 * math.Pi / 12
64+
}
65+
66+
// Shift the milestones 6 months for the winter release.
67+
milestones := milestones
68+
for i := range milestones {
69+
milestones[i].month = (milestones[i].month + 6*relIdx) % 12
70+
}
71+
72+
frozen := false
73+
for i, m := range milestones {
74+
x, y := math.Cos(angle(m)), math.Sin(angle(m))
75+
// Align the text away from the center of the circle.
76+
textAnchor := "start"
77+
if x < 0 {
78+
textAnchor = "end"
79+
}
80+
// Color the arc depending on the freeze state.
81+
if m.name == "Freeze" {
82+
frozen = true
83+
}
84+
color := "green"
85+
if frozen {
86+
color = "blue"
87+
}
88+
89+
// Center radius of the release arc.
90+
arcRadius := float64(120 + 20*relIdx)
91+
// Length of the line to the label. Vary a bit to avoid text overlap.
92+
lineLength := float64(30 + 5*((i+1)%2))
93+
// Distance from the end of the line to the text.
94+
textoff := float64(10)
95+
96+
// Draw the arc to the next milestone.
97+
if i+1 < len(milestones) {
98+
nx, ny := math.Cos(angle(milestones[i+1])), math.Sin(angle(milestones[i+1]))
99+
canvas.Arc(int(x*arcRadius), int(y*arcRadius), int(arcRadius), int(arcRadius), 0, false, true, int(nx*arcRadius), int(ny*arcRadius), "stroke-width:10; fill:none; stroke: "+color)
100+
}
101+
// Draw the line from the inner edge of the arc.
102+
canvas.Line(int(x*(arcRadius-5)), int(y*(arcRadius-5)), int(x*(arcRadius+lineLength)), int(y*(arcRadius+lineLength)), "stroke:black")
103+
canvas.Text(int(x*(arcRadius+lineLength+textoff)), int(y*(arcRadius+lineLength+textoff)), relName+": "+m.name, "text-anchor: "+textAnchor)
104+
}
105+
}
106+
canvas.Gend()
107+
canvas.End()
108+
return f.Close()
109+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
contrib.go.opencensus.io/exporter/stackdriver v0.13.5
1414
github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20190129172621-c8b1d7a94ddf
1515
github.com/NYTimes/gziphandler v1.1.1
16+
github.com/ajstarks/svgo v0.0.0-20210923152817-c3b6e2f0c527
1617
github.com/aws/aws-sdk-go v1.30.15
1718
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625
1819
github.com/creack/pty v1.1.18
@@ -73,7 +74,6 @@ require (
7374
cloud.google.com/go/monitoring v1.4.0 // indirect
7475
cloud.google.com/go/trace v1.2.0 // indirect
7576
github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794 // indirect
76-
github.com/ajstarks/svgo v0.0.0-20210923152817-c3b6e2f0c527 // indirect
7777
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
7878
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
7979
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,8 +1028,6 @@ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ
10281028
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
10291029
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg=
10301030
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
1031-
golang.org/x/perf v0.0.0-20220913151710-7c6e287988f3 h1:ChUtQhjSq/uYjerTlcpLrOkD2bGMcrRuDutZVPHo3WE=
1032-
golang.org/x/perf v0.0.0-20220913151710-7c6e287988f3/go.mod h1:UBKtEnL8aqnd+0JHqZ+2qoMDwtuy6cYhhKNoHLBiTQc=
10331031
golang.org/x/perf v0.0.0-20221222170352-3fd27c239283 h1:MTXrvYGLsaCdRXRtex0LY6RotT5TXmQ3Ru+5d1CnPIM=
10341032
golang.org/x/perf v0.0.0-20221222170352-3fd27c239283/go.mod h1:UBKtEnL8aqnd+0JHqZ+2qoMDwtuy6cYhhKNoHLBiTQc=
10351033
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

0 commit comments

Comments
 (0)