Skip to content

Commit 89699fa

Browse files
authored
Merge pull request #35 from mozilla-services/add-capability-to-query-deployed-commits
Add capability to query deployed commits 📦
2 parents a431e1e + 9252c27 commit 89699fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3111
-825
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ go 1.21.3
44

55
require (
66
github.com/google/go-cmp v0.6.0
7+
github.com/google/go-github/v68 v68.0.0
78
github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7
89
github.com/spf13/cobra v1.8.1
910
golang.org/x/oauth2 v0.25.0
1011
)
1112

1213
require (
14+
github.com/google/go-querystring v1.1.0 // indirect
1315
github.com/inconshreveable/mousetrap v1.1.0 // indirect
1416
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect
1517
github.com/spf13/pflag v1.0.5 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
2+
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
23
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
34
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
5+
github.com/google/go-github/v68 v68.0.0 h1:ZW57zeNZiXTdQ16qrDiZ0k6XucrxZ2CGmoTvcCyQG6s=
6+
github.com/google/go-github/v68 v68.0.0/go.mod h1:K9HAUBovM2sLwM408A18h+wd9vqdLOEqTUCbnRIcx68=
7+
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
8+
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
49
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
510
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
611
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
@@ -14,5 +19,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
1419
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
1520
golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70=
1621
golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
22+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
1723
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1824
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

metrics/cmd/compare.go

Lines changed: 0 additions & 74 deletions
This file was deleted.

metrics/cmd/deployments.go

Lines changed: 0 additions & 63 deletions
This file was deleted.

metrics/cmd/deployments_test.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,37 @@ func TestDeployments(t *testing.T) {
2323
tests := []test.TestCase{{
2424
Name: "deployments__repo_owner__required",
2525
Args: []string{"github", "-n", repo.Name, "deployments"},
26-
ErrContains: "Repo.Owner and Repo.Name are required. Set env vars or pass flags",
26+
ErrContains: "repo.Owner and repo.Name are required. Set env vars or pass flags",
2727
Env: env,
2828
}, {
2929
Name: "deployments__repo_name__required",
3030
Args: []string{"github", "-o", repo.Owner, "deployments"},
31-
ErrContains: "Repo.Owner and Repo.Name are required. Set env vars or pass flags",
31+
ErrContains: "repo.Owner and repo.Name are required. Set env vars or pass flags",
3232
Env: env,
3333
}, {
3434
Name: "deployments__default",
3535
Args: []string{"github", "-o", repo.Owner, "-n", repo.Name, "deployments"},
36-
WantFixture: test.NewFixture("deployments", "want__default.json"),
36+
WantFixture: test.NewFixture("github", "deployments", "want__default.json"),
3737
Env: env,
3838
}, {
3939
Name: "deployments__limit",
4040
Args: []string{"github", "-o", repo.Owner, "-n", repo.Name, "deployments", "-l", "2"},
41-
WantFixture: test.NewFixture("deployments", "want__limit.json"),
41+
WantFixture: test.NewFixture("github", "deployments", "want__limit.json"),
4242
Env: env,
4343
}, {
4444
Name: "deployments__json",
4545
Args: []string{"github", "-o", repo.Owner, "-n", repo.Name, "deployments", "-e", "json"},
46-
WantFixture: test.NewFixture("deployments", "want__default.json"),
46+
WantFixture: test.NewFixture("github", "deployments", "want__default.json"),
4747
Env: env,
4848
}, {
4949
Name: "deployments__csv",
5050
Args: []string{"github", "-o", repo.Owner, "-n", repo.Name, "deployments", "-e", "csv"},
51-
WantFixture: test.NewFixture("deployments", "want__default.csv"),
51+
WantFixture: test.NewFixture("github", "deployments", "want__default.csv"),
5252
Env: env,
5353
}, {
5454
Name: "deployments__filename",
5555
Args: []string{"github", "-o", repo.Owner, "-n", repo.Name, "deployments", "-f", filepath.Join(tempDir, "r.json")},
56-
WantFixture: test.NewFixture("deployments", "want__default.json"),
56+
WantFixture: test.NewFixture("github", "deployments", "want__default.json"),
5757
WantFile: filepath.Join(tempDir, "r.json"),
5858
Env: env,
5959
}, {
@@ -76,7 +76,12 @@ func TestDeployments(t *testing.T) {
7676
},
7777
},
7878
Env: env,
79+
}, {
80+
Name: "deployments__env__debug",
81+
Args: []string{"github", "-o", repo.Owner, "-n", repo.Name, "deployments", "--env", "prod", "--debug"},
82+
WantLog: "level=DEBUG msg=cmd.runDeployments github.DeploymentsService=*graphql.API config.repo=hackebrot/turtle config.envs=[prod] config.limit=10",
83+
Env: env,
7984
}}
8085

81-
test.RunTests(t, newRootCmd, tests)
86+
test.RunTests(t, NewRootCmd, tests)
8287
}

metrics/cmd/fixtures/deployments/want__default.json

Lines changed: 0 additions & 54 deletions
This file was deleted.

metrics/cmd/fixtures/deployments/query.json renamed to metrics/cmd/fixtures/github/deployments/query.json

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
"State": "ACTIVE",
2121
"Commit": {
2222
"AbbreviatedOid": "1abc111",
23-
"Oid": "1abc111aaaaaaaaaaa"
23+
"Oid": "1abc111aaaaaaaaaaa",
24+
"AuthoredDate": "2022-05-01T20:18:05Z",
25+
"CommittedDate": "2022-05-01T20:18:05Z",
26+
"Message": "commit changes 333"
2427
}
2528
},
2629
{
@@ -33,7 +36,10 @@
3336
"State": "ACTIVE",
3437
"Commit": {
3538
"AbbreviatedOid": "1abc111",
36-
"Oid": "1abc111aaaaaaaaaaa"
39+
"Oid": "1abc111aaaaaaaaaaa",
40+
"AuthoredDate": "2022-05-01T20:18:05Z",
41+
"CommittedDate": "2022-05-01T20:18:05Z",
42+
"Message": "commit changes 333"
3743
}
3844
},
3945
{
@@ -46,7 +52,21 @@
4652
"State": "INACTIVE",
4753
"Commit": {
4854
"AbbreviatedOid": "2abc111",
49-
"Oid": "2abc111bbbbbbbbbbb"
55+
"Oid": "2abc111bbbbbbbbbbb",
56+
"AuthoredDate": "2022-04-01T20:24:05Z",
57+
"CommittedDate": "2022-04-01T20:24:05Z",
58+
"Message": "commit changes 2222",
59+
"Parents": {
60+
"Nodes": [
61+
{
62+
"AbbreviatedOid": "3abc111",
63+
"Oid": "3abc111ccccccccccc",
64+
"AuthoredDate": "2022-02-01T18:25:05Z",
65+
"CommittedDate": "2022-02-01T18:25:05Z",
66+
"Message": "commit changes"
67+
}
68+
]
69+
}
5070
}
5171
}
5272
]

metrics/cmd/fixtures/deployments/query_abc123.json renamed to metrics/cmd/fixtures/github/deployments/query_abc123.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
"State": "ACTIVE",
2121
"Commit": {
2222
"AbbreviatedOid": "3abc111",
23-
"Oid": "3abc111ccccccccccc"
23+
"Oid": "3abc111ccccccccccc",
24+
"AuthoredDate": "2022-02-01T18:25:05Z",
25+
"CommittedDate": "2022-02-01T18:25:05Z",
26+
"Message": "commit changes"
2427
}
2528
}
2629
]
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
description,createdAt,updatedAt,originalEnvironment,latestEnvironment,task,state,abbreviatedCommitOid,commitOid
1+
description,createdAt,updatedAt,originalEnvironment,latestEnvironment,task,state,abbreviatedCommitSHA,commitSHA
22
Deployment03,2022-05-02T20:25:05Z,2022-05-02T20:25:05Z,prod,prod,deploy,ACTIVE,1abc111,1abc111aaaaaaaaaaa
33
Deployment03,2022-05-01T20:20:05Z,2022-05-01T20:20:05Z,stage,stage,deploy,ACTIVE,1abc111,1abc111aaaaaaaaaaa
44
Deployment02,2022-04-01T20:25:05Z,2022-04-01T20:25:05Z,stage,stage,deploy,INACTIVE,2abc111,2abc111bbbbbbbbbbb
5-
Deployment01,2022-02-01T20:25:05Z,2022-02-01T20:25:05Z,hello,hello,deploy,ACTIVE,3abc111,3abc111ccccccccccc
5+
Deployment01,2022-02-01T20:25:05Z,2022-02-01T20:25:05Z,hello,hello,deploy,ACTIVE,3abc111,3abc111ccccccccccc

0 commit comments

Comments
 (0)