-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add version update mechanism for ci dependencies
Signed-off-by: Mark Sagi-Kazar <[email protected]>
- Loading branch information
1 parent
7658cbf
commit 35fcd7e
Showing
8 changed files
with
148 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"strings" | ||
|
||
"github.com/dave/jennifer/jen" | ||
"github.com/google/go-github/v63/github" | ||
|
||
"github.com/openmeterio/openmeter/ci/internal/dagger" | ||
) | ||
|
||
func (m *Ci) Dev() *Dev { | ||
return &Dev{ | ||
Source: m.Source, | ||
} | ||
} | ||
|
||
type Dev struct { | ||
Source *dagger.Directory | ||
} | ||
|
||
// Udate dependency versions used in CI. | ||
func (m *Dev) UpdateVersions( | ||
ctx context.Context, | ||
|
||
// +optional | ||
githubToken *dagger.Secret, | ||
) (*dagger.File, error) { | ||
githubClient := github.NewClient(nil) | ||
|
||
if githubToken != nil { | ||
token, err := githubToken.Plaintext(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
githubClient = githubClient.WithAuthToken(token) | ||
} | ||
|
||
versions := make(map[string]string) | ||
|
||
// GolangCI Lint | ||
{ | ||
release, _, err := githubClient.Repositories.GetLatestRelease(ctx, "golangci", "golangci-lint") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
versions["golangciLint"] = release.GetTagName() | ||
} | ||
|
||
// Helm | ||
{ | ||
release, _, err := githubClient.Repositories.GetLatestRelease(ctx, "helm", "helm") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
versions["helm"] = strings.TrimPrefix(release.GetTagName(), "v") | ||
} | ||
|
||
// Helm docs | ||
{ | ||
release, _, err := githubClient.Repositories.GetLatestRelease(ctx, "norwoodj", "helm-docs") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
versions["helmDocs"] = release.GetTagName() | ||
} | ||
|
||
// Spectral | ||
{ | ||
release, _, err := githubClient.Repositories.GetLatestRelease(ctx, "stoplightio", "spectral") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
versions["spectral"] = strings.TrimPrefix(release.GetTagName(), "v") | ||
} | ||
|
||
f := jen.NewFile("main") | ||
|
||
f.Const().DefsFunc(func(g *jen.Group) { | ||
for tool, version := range versions { | ||
g.Id(tool + "Version").Op("=").Lit(version) | ||
} | ||
}) | ||
|
||
var buf bytes.Buffer | ||
|
||
err := f.Render(&buf) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return dag.Directory().WithNewFile("versions.go", buf.String()).File("versions.go"), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
const ( | ||
golangciLintVersion = "v1.59.1" | ||
helmVersion = "3.15.3" | ||
helmDocsVersion = "v1.14.2" | ||
spectralVersion = "6.11.1" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
const ( | ||
// Alpine is required for our current build (due to Kafka and CGO), but it doesn't seem to work well with golangci-lint | ||
goVersion = "1.22.5" | ||
|
||
kafkaVersion = "3.6" | ||
clickhouseVersion = "24.5.5.78" | ||
redisVersion = "7.0.12" | ||
postgresVersion = "14.9" | ||
|
||
// TODO: add update mechanism for versions below | ||
|
||
// Alpine is required for our current build (due to Kafka and CGO), but it doesn't seem to work well with golangci-lint | ||
goBuildVersion = goVersion + "-alpine3.19@sha256:0642d4f809abf039440540de1f0e83502401686e3946ed8e7398a1d94648aa6d" | ||
xxBaseImage = "tonistiigi/xx:1.4.0@sha256:0cd3f05c72d6c9b038eb135f91376ee1169ef3a330d34e418e65e2a5c2e9c0d4" | ||
|
||
alpineBaseImage = "alpine:3.20.1@sha256:b89d9c93e9ed3597455c90a0b88a8bbb5cb7188438f70953fede212a0c4394e0" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters