CI: Update CI/CD tooling and pipelines from main (#76814)

* CI: Update CI/CD tooling and pipelines from main

* Update Makefile

* Comment out validate_openapi_spec_step

* Update broken frontend tests

* Fix validate-npm-packages regex to work without suffix

* Fix cypress image version
This commit is contained in:
Guilherme Caulada
2023-10-19 17:02:22 -03:00
committed by GitHub
parent 8757cb124b
commit 03ecb1db39
46 changed files with 2237 additions and 2858 deletions
+11 -1
View File
@@ -222,15 +222,25 @@ func ldflags(opts BuildOpts) (string, error) {
commitSha = v
}
var enterpriseCommitSha string
if opts.enterprise {
enterpriseCommitSha = getGitEnterpriseSha()
if v := os.Getenv("ENTERPRISE_COMMIT_SHA"); v != "" {
enterpriseCommitSha = v
}
}
buildBranch := getGitBranch()
if v := os.Getenv("BUILD_BRANCH"); v != "" {
buildBranch = v
}
var b bytes.Buffer
b.WriteString("-w")
b.WriteString(fmt.Sprintf(" -X main.version=%s", opts.version))
b.WriteString(fmt.Sprintf(" -X main.commit=%s", commitSha))
if enterpriseCommitSha != "" {
b.WriteString(fmt.Sprintf(" -X main.enterpriseCommit=%s", enterpriseCommitSha))
}
b.WriteString(fmt.Sprintf(" -X main.buildstamp=%d", buildStamp))
b.WriteString(fmt.Sprintf(" -X main.buildBranch=%s", buildBranch))
if v := os.Getenv("LDFLAGS"); v != "" {
+1 -1
View File
@@ -232,7 +232,7 @@ func getSHA256(u string) ([]byte, error) {
return sha256, nil
}
func postRequest(cfg packaging.PublishConfig, pth string, obj interface{}, descr string) error {
func postRequest(cfg packaging.PublishConfig, pth string, obj any, descr string) error {
var sfx string
switch cfg.Edition {
case config.EditionOSS:
+3 -3
View File
@@ -68,7 +68,7 @@ func VerifyDrone(c *cli.Context) error {
return nil
}
func readConfig(fpath string) ([]map[string]interface{}, error) {
func readConfig(fpath string) ([]map[string]any, error) {
//nolint:gosec
f, err := os.Open(fpath)
if err != nil {
@@ -82,9 +82,9 @@ func readConfig(fpath string) ([]map[string]interface{}, error) {
// The YAML stream may contain multiple pipeline configurations, read them all
dec := yaml.NewDecoder(f)
var c []map[string]interface{}
var c []map[string]any
for {
var m map[string]interface{}
var m map[string]any
if err := dec.Decode(&m); err != nil {
if errors.Is(err, io.EOF) {
break
+20 -6
View File
@@ -3,6 +3,7 @@ package config
import (
"context"
"fmt"
"log"
"strconv"
"time"
@@ -10,9 +11,10 @@ import (
)
type Revision struct {
Timestamp int64
SHA256 string
Branch string
Timestamp int64
SHA256 string
EnterpriseCommit string
Branch string
}
func GrafanaTimestamp(ctx context.Context, dir string) (int64, error) {
@@ -42,14 +44,26 @@ func GrafanaRevision(ctx context.Context, grafanaDir string) (Revision, error) {
return Revision{}, err
}
enterpriseCommit, err := executil.OutputAt(ctx, grafanaDir, "git", "-C", "../grafana-enterprise", "rev-parse", "--short", "HEAD")
if err != nil {
enterpriseCommit, err = executil.OutputAt(ctx, grafanaDir, "git", "-C", "..", "rev-parse", "--short", "HEAD")
if err != nil {
enterpriseCommit, err = executil.OutputAt(ctx, grafanaDir, "git", "-C", "/tmp/grafana-enterprise", "rev-parse", "--short", "HEAD")
if err != nil {
log.Println("Could not get enterprise commit. Error:", err)
}
}
}
branch, err := executil.OutputAt(ctx, grafanaDir, "git", "rev-parse", "--abbrev-ref", "HEAD")
if err != nil {
return Revision{}, err
}
return Revision{
SHA256: sha,
Branch: branch,
Timestamp: stamp,
SHA256: sha,
EnterpriseCommit: enterpriseCommit,
Branch: branch,
Timestamp: stamp,
}, nil
}
+1 -1
View File
@@ -94,7 +94,7 @@ func GetPackageJSONVersion(grafanaDir string) (string, error) {
if err != nil {
return "", fmt.Errorf("failed to read %q: %w", pkgJSONPath, err)
}
pkgObj := map[string]interface{}{}
pkgObj := map[string]any{}
if err := json.Unmarshal(pkgJSONB, &pkgObj); err != nil {
return "", fmt.Errorf("failed decoding %q: %w", pkgJSONPath, err)
}
+21 -16
View File
@@ -1,7 +1,5 @@
package config
const PublicBucket = "grafana-downloads"
var Versions = VersionMap{
PullRequestMode: {
Variants: []Variant{
@@ -9,8 +7,9 @@ var Versions = VersionMap{
VariantLinuxAmd64Musl,
VariantDarwinAmd64,
VariantWindowsAmd64,
VariantArm64,
VariantArm64Musl,
// https://github.com/golang/go/issues/58425 disabling arm builds until go issue is resolved
// VariantArm64,
// VariantArm64Musl,
},
PluginSignature: PluginSignature{
Sign: false,
@@ -29,9 +28,10 @@ var Versions = VersionMap{
},
MainMode: {
Variants: []Variant{
VariantArmV6,
VariantArmV7,
VariantArmV7Musl,
// https://github.com/golang/go/issues/58425 disabling arm builds until go issue is resolved
// VariantArmV6,
// VariantArmV7,
// VariantArmV7Musl,
VariantArm64,
VariantArm64Musl,
VariantDarwinAmd64,
@@ -48,7 +48,8 @@ var Versions = VersionMap{
Architectures: []Architecture{
ArchAMD64,
ArchARM64,
ArchARMv7, // GOARCH=ARM is used for both armv6 and armv7. They are differentiated by the GOARM variable.
// https://github.com/golang/go/issues/58425 disabling arm builds until go issue is resolved
// ArchARMv7, // GOARCH=ARM is used for both armv6 and armv7. They are differentiated by the GOARM variable.
},
Distribution: []Distribution{
Alpine,
@@ -64,9 +65,10 @@ var Versions = VersionMap{
},
DownstreamMode: {
Variants: []Variant{
VariantArmV6,
VariantArmV7,
VariantArmV7Musl,
// https://github.com/golang/go/issues/58425 disabling arm builds until go issue is resolved
// VariantArmV6,
//VariantArmV7,
// VariantArmV7Musl,
VariantArm64,
VariantArm64Musl,
VariantDarwinAmd64,
@@ -83,7 +85,8 @@ var Versions = VersionMap{
Architectures: []Architecture{
ArchAMD64,
ArchARM64,
ArchARMv7, // GOARCH=ARM is used for both armv6 and armv7. They are differentiated by the GOARM variable.
// https://github.com/golang/go/issues/58425 disabling arm builds until go issue is resolved
// ArchARMv7, // GOARCH=ARM is used for both armv6 and armv7. They are differentiated by the GOARM variable.
},
Distribution: []Distribution{
Alpine,
@@ -171,9 +174,10 @@ var Versions = VersionMap{
},
Enterprise2Mode: {
Variants: []Variant{
VariantArmV6,
VariantArmV7,
VariantArmV7Musl,
// https://github.com/golang/go/issues/58425 disabling arm builds until go issue is resolved
// VariantArmV6,
// VariantArmV7,
// VariantArmV7Musl,
VariantArm64,
VariantArm64Musl,
VariantDarwinAmd64,
@@ -190,7 +194,8 @@ var Versions = VersionMap{
Architectures: []Architecture{
ArchAMD64,
ArchARM64,
ArchARMv7,
// https://github.com/golang/go/issues/58425 disabling arm builds until go issue is resolved
// ArchARMv7,
},
Distribution: []Distribution{
Alpine,
+1 -1
View File
@@ -74,7 +74,7 @@ func BuildImage(version string, arch config.Architecture, grafanaDir string, use
tagSuffix := ""
if useUbuntu {
libc = ""
baseImage = fmt.Sprintf("%subuntu:20.04", baseArch)
baseImage = fmt.Sprintf("%subuntu:22.04", baseArch)
tagSuffix = "-ubuntu"
}
+1 -1
View File
@@ -418,7 +418,7 @@ func GetLatestMainBuild(ctx context.Context, bucket *storage.BucketHandle, path
var latestVersion string
for i := 0; i < len(files); i++ {
captureVersion := regexp.MustCompile(`(\d+\.\d+\.\d+-\d+pre)`)
captureVersion := regexp.MustCompile(`(\d+\.\d+\.\d+-\d+)`)
if captureVersion.MatchString(files[i]) {
latestVersion = captureVersion.FindString(files[i])
break
+13
View File
@@ -15,3 +15,16 @@ func getGitSha() string {
}
return string(v)
}
func getGitEnterpriseSha() string {
// supporting the old way of dev setup
v, err := runError("git", "-C", "../grafana-enterprise", "rev-parse", "--short", "HEAD")
if err != nil {
// supporting the new way of dev setup
v, err = runError("git", "-C", "..", "rev-parse", "--short", "HEAD")
if err != nil {
return ""
}
}
return string(v)
}
+7 -1
View File
@@ -23,13 +23,19 @@ const (
)
func GrafanaLDFlags(version string, r config.Revision) []string {
return []string{
cmd := []string{
"-w",
fmt.Sprintf("-X main.version=%s", version),
fmt.Sprintf("-X main.commit=%s", r.SHA256),
fmt.Sprintf("-X main.buildstamp=%d", r.Timestamp),
fmt.Sprintf("-X main.buildBranch=%s", r.Branch),
}
if r.EnterpriseCommit != "" {
cmd = append(cmd, fmt.Sprintf("-X main.enterpriseCommit=%s", r.EnterpriseCommit))
}
return cmd
}
// BinaryFolder returns the path to where the Grafana binary is build given the provided arguments.
+1 -1
View File
@@ -47,7 +47,7 @@ func GetLernaVersion(grafanaDir string) (string, error) {
if err != nil {
return "", fmt.Errorf("failed to read %q: %w", lernaJSONPath, err)
}
pkgObj := map[string]interface{}{}
pkgObj := map[string]any{}
if err := json.Unmarshal(lernaJSONB, &pkgObj); err != nil {
return "", fmt.Errorf("failed decoding %q: %w", lernaJSONPath, err)
}
+1 -1
View File
@@ -21,11 +21,11 @@ const NpmArtifactDir = "./npm-artifacts"
var packages = []string{
"@grafana/ui",
"@grafana/data",
"@grafana/toolkit",
"@grafana/runtime",
"@grafana/e2e",
"@grafana/e2e-selectors",
"@grafana/schema",
"@grafana/flamegraph",
}
// PublishNpmPackages will publish local NPM packages to NPM registry.
+1 -1
View File
@@ -533,7 +533,7 @@ func copyPlugins(ctx context.Context, v config.Variant, grafanaDir, tmpDir strin
if err != nil {
return fmt.Errorf("failed to read %q: %w", filepath.Join(srcDir, "plugin.json"), err)
}
var plugJSON map[string]interface{}
var plugJSON map[string]any
if err := json.Unmarshal(jsonB, &plugJSON); err != nil {
return err
}