[release-11.3.5] CI: Remove unused release_publisher scripts (#101156)

CI: Remove unused release_publisher scripts (#101019)

* Remove the unused `release_publisher` script.
* Remove the "whats new check" in Drone.
* Automatically set the What's New URL in releases based on the tagged version.

(cherry picked from commit 49e5f77dd1)
pull/100818/head
Kevin Minehart 5 months ago committed by GitHub
parent 739ac52c3e
commit dd15c5dc95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 47
      .drone.yml
  2. 6
      package.json
  3. 41
      pkg/build/cmd/grafanacom.go
  4. 24
      pkg/build/cmd/grafanacom_test.go
  5. 6
      pkg/build/versions/parse.go
  6. 18
      scripts/build/publish.sh
  7. 71
      scripts/build/release_publisher/externalrelease.go
  8. 80
      scripts/build/release_publisher/main.go
  9. 312
      scripts/build/release_publisher/publisher.go
  10. 201
      scripts/build/release_publisher/publisher_test.go
  11. 0
      scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.linux-amd64.tar.gz
  12. 1
      scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.linux-amd64.tar.gz.sha256
  13. 0
      scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.msi
  14. 1
      scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.msi.sha256
  15. 0
      scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.zip
  16. 1
      scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.windows-amd64.zip.sha256
  17. 0
      scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.x86_64.rpm
  18. 1
      scripts/build/release_publisher/testdata/grafana-enterprise-5.4.0-123pre1.x86_64.rpm.sha256
  19. 0
      scripts/build/release_publisher/testdata/grafana-enterprise_5.4.0-123pre1_amd64.deb
  20. 1
      scripts/build/release_publisher/testdata/grafana-enterprise_5.4.0-123pre1_amd64.deb.sha256
  21. 42
      scripts/drone/pipelines/whats_new_checker.star
  22. 5
      scripts/drone/rgm.star

@ -4210,51 +4210,6 @@ volumes:
path: /var/run/docker.sock
name: docker
---
clone:
retries: 3
depends_on: []
environment:
EDITION: oss
image_pull_secrets:
- gcr
- gar
kind: pipeline
name: release-whatsnew-checker
node:
type: no-parallel
platform:
arch: amd64
os: linux
services: []
steps:
- commands:
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
depends_on: []
environment:
CGO_ENABLED: 0
image: golang:1.23.5-alpine
name: compile-build-cmd
- commands:
- ./bin/build whatsnew-checker
depends_on:
- compile-build-cmd
image: golang:1.23.5-alpine
name: whats-new-checker
trigger:
event:
exclude:
- promote
ref:
exclude:
- refs/tags/*-cloud*
include:
- refs/tags/v*
type: docker
volumes:
- host:
path: /var/run/docker.sock
name: docker
---
clone:
retries: 3
depends_on:
@ -5733,6 +5688,6 @@ kind: secret
name: gcr_credentials
---
kind: signature
hmac: 7210382290a72f0ce411fd3f463d72c2dd9a1b062c7238cad35908bf2cca1794
hmac: 7938c034ff11ec8129ef6f4874d13d32ba1b34b209715ebe8dc7ee0c3b9808bd
...

@ -65,7 +65,7 @@
"generate-apis": "rtk-query-codegen-openapi ./scripts/generate-rtk-apis.ts"
},
"grafana": {
"whatsNewUrl": "https://grafana.com/docs/grafana/next/whatsnew/whats-new-in-v11-3/",
"whatsNewUrl": "https://grafana.com/docs/grafana/next/whatsnew/whats-new-in-v%[1]s-%[2]s/",
"releaseNotesUrl": "https://grafana.com/docs/grafana/next/release-notes/"
},
"devDependencies": {
@ -448,8 +448,6 @@
}
},
"msw": {
"workerDirectory": [
"public"
]
"workerDirectory": ["public"]
}
}

@ -21,6 +21,7 @@ import (
"github.com/grafana/grafana/pkg/build/gcloud/storage"
"github.com/grafana/grafana/pkg/build/gcom"
"github.com/grafana/grafana/pkg/build/packaging"
"github.com/grafana/grafana/pkg/build/versions"
)
const grafanaAPI = "https://grafana.com/api"
@ -45,6 +46,7 @@ func GrafanaCom(c *cli.Context) error {
}
version := metadata.GrafanaVersion
semver := versions.ParseSemver(version)
if releaseMode.Mode == config.Cronjob {
gcs, err := storage.New()
if err != nil {
@ -69,7 +71,13 @@ func GrafanaCom(c *cli.Context) error {
if grafanaAPIKey == "" {
return cli.Exit("the environment variable GRAFANA_COM_API_KEY must be set", 1)
}
whatsNewURL, releaseNotesURL, err := getReleaseURLs()
pkgjson, err := getPackageJSON()
if err != nil {
return cli.Exit(err.Error(), 1)
}
whatsNewURL, releaseNotesURL, err := getReleaseURLs(semver, pkgjson)
if err != nil {
return cli.Exit(err.Error(), 1)
}
@ -97,25 +105,32 @@ func GrafanaCom(c *cli.Context) error {
return nil
}
func getReleaseURLs() (string, string, error) {
type grafanaConf struct {
WhatsNewURL string `json:"whatsNewUrl"`
ReleaseNotesURL string `json:"releaseNotesUrl"`
}
type packageConf struct {
Grafana grafanaConf `json:"grafana"`
}
type grafanaConf struct {
WhatsNewURL string `json:"whatsNewUrl"`
ReleaseNotesURL string `json:"releaseNotesUrl"`
}
type packageConf struct {
Grafana grafanaConf `json:"grafana"`
}
func getPackageJSON() (*packageConf, error) {
pkgB, err := os.ReadFile("package.json")
if err != nil {
return "", "", fmt.Errorf("failed to read package.json: %w", err)
return nil, fmt.Errorf("failed to read package.json: %w", err)
}
var pconf packageConf
if err := json.Unmarshal(pkgB, &pconf); err != nil {
return "", "", fmt.Errorf("failed to decode package.json: %w", err)
return nil, fmt.Errorf("failed to decode package.json: %w", err)
}
if _, err := url.ParseRequestURI(pconf.Grafana.WhatsNewURL); err != nil {
return &pconf, nil
}
func getReleaseURLs(semver versions.Semver, pconf *packageConf) (string, string, error) {
u := fmt.Sprintf(pconf.Grafana.WhatsNewURL, semver.Major, semver.Minor, semver.Patch)
if _, err := url.ParseRequestURI(u); err != nil {
return "", "", fmt.Errorf("grafana.whatsNewUrl is invalid in package.json: %q", pconf.Grafana.WhatsNewURL)
}
if _, err := url.ParseRequestURI(pconf.Grafana.ReleaseNotesURL); err != nil {
@ -123,7 +138,7 @@ func getReleaseURLs() (string, string, error) {
pconf.Grafana.ReleaseNotesURL)
}
return pconf.Grafana.WhatsNewURL, pconf.Grafana.ReleaseNotesURL, nil
return u, pconf.Grafana.ReleaseNotesURL, nil
}
func Builds(baseURL *url.URL, grafana, version string, packages []packaging.BuildArtifact) ([]GCOMPackage, error) {

@ -7,6 +7,7 @@ import (
"testing"
"github.com/grafana/grafana/pkg/build/packaging"
"github.com/grafana/grafana/pkg/build/versions"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -258,3 +259,26 @@ func TestBuildsWithPlus(t *testing.T) {
})
}
}
func TestReleaseURLs(t *testing.T) {
f := "https://grafana.com/whats-new-in-v%[1]s-%[2]s"
smv := versions.Semver{
Major: "1",
Minor: "2",
Patch: "3",
}
conf := packageConf{
Grafana: grafanaConf{
WhatsNewURL: f,
ReleaseNotesURL: "https://example.com",
},
}
expect := "https://grafana.com/whats-new-in-v1-2"
a, _, err := getReleaseURLs(smv, &conf)
require.NoError(t, err)
require.Equal(t, expect, a)
}

@ -1,6 +1,9 @@
package versions
import "regexp"
import (
"regexp"
"strings"
)
var semverRegex = regexp.MustCompile(`^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`)
@ -13,6 +16,7 @@ type Semver struct {
}
func ParseSemver(version string) Semver {
version = strings.TrimPrefix(version, "v")
matches := semverRegex.FindStringSubmatch(version)
results := make(map[string]string)
for i, name := range semverRegex.SubexpNames() {

@ -1,18 +0,0 @@
#!/bin/sh
# no relation to publish.go
# shellcheck disable=SC2124
EXTRA_OPTS="$@"
# Right now we hack this in into the publish script.
# Eventually we might want to keep a list of all previous releases somewhere.
_releaseNoteUrl="https://community.grafana.com/t/release-notes-v7-0-x/29381"
_whatsNewUrl="https://grafana.com/docs/grafana/latest/guides/whats-new-in-v7-0/"
./scripts/build/release_publisher/release_publisher \
--wn "${_whatsNewUrl}" \
--rn "${_releaseNoteUrl}" \
--version "${CIRCLE_TAG}" \
--apikey "${GRAFANA_COM_API_KEY}" "${EXTRA_OPTS}"

@ -1,71 +0,0 @@
package main
import (
"fmt"
"io"
"net/http"
"strings"
"time"
)
type releaseFromExternalContent struct {
getter urlGetter
rawVersion string
artifactConfigurations []buildArtifact
}
func (re releaseFromExternalContent) prepareRelease(baseArchiveURL, whatsNewURL string, releaseNotesURL string, nightly bool) (*release, error) {
version := re.rawVersion[1:]
beta := strings.Contains(version, "beta")
var rt releaseType
if beta {
rt = BETA
} else if nightly {
rt = NIGHTLY
} else {
rt = STABLE
}
builds := []build{}
for _, ba := range re.artifactConfigurations {
url := ba.getURL(baseArchiveURL, version, rt)
sha256, err := re.getter.getContents(fmt.Sprintf("%s.sha256", url))
if err != nil {
return nil, err
}
builds = append(builds, newBuild(url, ba, sha256))
}
r := release{
Version: version,
ReleaseDate: time.Now().UTC(),
Stable: rt.stable(),
Beta: rt.beta(),
Nightly: rt.nightly(),
WhatsNewURL: whatsNewURL,
ReleaseNotesURL: releaseNotesURL,
Builds: builds,
}
return &r, nil
}
type urlGetter interface {
getContents(url string) (string, error)
}
type getHTTPContents struct{}
func (getHTTPContents) getContents(url string) (string, error) {
response, err := http.Get(url)
if err != nil {
return "", err
}
defer response.Body.Close()
all, err := io.ReadAll(response.Body)
if err != nil {
return "", err
}
return string(all), nil
}

@ -1,80 +0,0 @@
package main
import (
"flag"
"fmt"
"log"
"os"
)
func main() {
var version string
var whatsNewURL string
var releaseNotesURL string
var dryRun bool
var enterprise bool
var nightly bool
var apiKey string
flag.StringVar(&version, "version", "", "Grafana version (ex: --version v5.2.0-beta1)")
flag.StringVar(&whatsNewURL, "wn", "", "What's new url (ex: --wn http://docs.grafana.org/guides/whats-new-in-v5-2/)")
flag.StringVar(&releaseNotesURL, "rn", "", "Grafana version (ex: --rn https://community.grafana.com/t/release-notes-v5-2-x/7894)")
flag.StringVar(&apiKey, "apikey", "", "Grafana.com API key (ex: --apikey ABCDEF)")
flag.BoolVar(&dryRun, "dry-run", false, "--dry-run")
flag.BoolVar(&enterprise, "enterprise", false, "--enterprise")
flag.BoolVar(&nightly, "nightly", false, "--nightly (default: false)")
flag.Parse()
if len(os.Args) == 1 {
fmt.Println("Usage: go run publisher.go main.go --version <v> --wn <what's new url> --rn <release notes url> --apikey <api key> --dry-run false --enterprise false --nightly false")
fmt.Println("example: go run publisher.go main.go --version v5.2.0-beta2 --wn http://docs.grafana.org/guides/whats-new-in-v5-2/ --rn https://community.grafana.com/t/release-notes-v5-2-x/7894 --apikey ASDF123 --dry-run --enterprise")
os.Exit(1)
}
if dryRun {
log.Println("Dry-run has been enabled.")
}
var baseURL string
var builder releaseBuilder
var product string
archiveProviderRoot := "https://dl.grafana.com"
buildArtifacts := completeBuildArtifactConfigurations
if enterprise {
product = "grafana-enterprise"
baseURL = createBaseURL(archiveProviderRoot, "enterprise", product, nightly)
} else {
product = "grafana"
baseURL = createBaseURL(archiveProviderRoot, "oss", product, nightly)
}
builder = releaseFromExternalContent{
getter: getHTTPContents{},
rawVersion: version,
artifactConfigurations: buildArtifacts,
}
p := publisher{
apiKey: apiKey,
apiURI: "https://grafana.com/api",
product: product,
dryRun: dryRun,
enterprise: enterprise,
baseArchiveURL: baseURL,
builder: builder,
}
if err := p.doRelease(whatsNewURL, releaseNotesURL, nightly); err != nil {
log.Fatalf("error: %v", err)
}
}
func createBaseURL(root string, bucketName string, product string, nightly bool) string {
var subPath string
if nightly {
subPath = "main"
} else {
subPath = "release"
}
return fmt.Sprintf("%s/%s/%s/%s", root, bucketName, subPath, product)
}

@ -1,312 +0,0 @@
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"strings"
"time"
)
type publisher struct {
apiKey string
apiURI string
product string
dryRun bool
enterprise bool
baseArchiveURL string
builder releaseBuilder
}
type releaseBuilder interface {
prepareRelease(baseArchiveURL, whatsNewURL string, releaseNotesURL string, nightly bool) (*release, error)
}
func (p *publisher) doRelease(whatsNewURL string, releaseNotesURL string, nightly bool) error {
currentRelease, err := p.builder.prepareRelease(p.baseArchiveURL, whatsNewURL, releaseNotesURL, nightly)
if err != nil {
return err
}
if err := p.postRelease(currentRelease); err != nil {
return err
}
return nil
}
func (p *publisher) postRelease(r *release) error {
err := p.postRequest("/versions", r, fmt.Sprintf("Create Release %s", r.Version))
if err != nil {
return err
}
err = p.postRequest("/versions/"+r.Version, r, fmt.Sprintf("Update Release %s", r.Version))
if err != nil {
return err
}
for _, b := range r.Builds {
err = p.postRequest(fmt.Sprintf("/versions/%s/packages", r.Version), b, fmt.Sprintf("Create Build %s %s", b.Os, b.Arch))
if err != nil {
return err
}
err = p.postRequest(fmt.Sprintf("/versions/%s/packages/%s/%s", r.Version, b.Arch, b.Os), b, fmt.Sprintf("Update Build %s %s", b.Os, b.Arch))
if err != nil {
return err
}
}
return nil
}
type releaseType int
const (
// STABLE is a release type constant
STABLE releaseType = iota + 1
// BETA is a release type constant
BETA
// NIGHTLY is a release type constant
NIGHTLY
)
func (rt releaseType) beta() bool {
return rt == BETA
}
func (rt releaseType) stable() bool {
return rt == STABLE
}
func (rt releaseType) nightly() bool {
return rt == NIGHTLY
}
type buildArtifact struct {
os string
arch string
urlPostfix string
packagePostfix string
}
func (t buildArtifact) getURL(baseArchiveURL, version string, releaseType releaseType) string {
prefix := "-"
rev := ""
if t.os == "deb" {
prefix = "_"
}
if t.os == "rhel" {
rev = "-1"
}
verComponents := strings.Split(version, "-")
if len(verComponents) > 2 {
panic(fmt.Sprintf("Version string contains more than one hyphen: %q", version))
}
switch t.os {
case "deb", "rhel":
if len(verComponents) > 1 {
// With Debian and RPM packages, it's customary to prefix any pre-release component with a ~, since this
// is considered of lower lexical value than the empty character, and this way pre-release versions are
// considered to be of a lower version than the final version (which lacks this suffix).
version = fmt.Sprintf("%s~%s", verComponents[0], verComponents[1])
}
}
url := fmt.Sprintf("%s%s%s%s%s%s", baseArchiveURL, t.packagePostfix, prefix, version, rev, t.urlPostfix)
return url
}
var completeBuildArtifactConfigurations = []buildArtifact{
{
os: "deb",
arch: "arm64",
urlPostfix: "_arm64.deb",
},
{
os: "rhel",
arch: "arm64",
urlPostfix: ".aarch64.rpm",
},
{
os: "linux",
arch: "arm64",
urlPostfix: ".linux-arm64.tar.gz",
},
{
os: "deb",
arch: "armv7",
urlPostfix: "_armhf.deb",
},
{
os: "deb",
arch: "armv6",
packagePostfix: "-rpi",
urlPostfix: "_armhf.deb",
},
{
os: "rhel",
arch: "armv7",
urlPostfix: ".armhfp.rpm",
},
{
os: "linux",
arch: "armv6",
urlPostfix: ".linux-armv6.tar.gz",
},
{
os: "linux",
arch: "armv7",
urlPostfix: ".linux-armv7.tar.gz",
},
{
os: "darwin",
arch: "amd64",
urlPostfix: ".darwin-amd64.tar.gz",
},
{
os: "deb",
arch: "amd64",
urlPostfix: "_amd64.deb",
},
{
os: "rhel",
arch: "amd64",
urlPostfix: ".x86_64.rpm",
},
{
os: "linux",
arch: "amd64",
urlPostfix: ".linux-amd64.tar.gz",
},
{
os: "win",
arch: "amd64",
urlPostfix: ".windows-amd64.zip",
},
{
os: "win-installer",
arch: "amd64",
urlPostfix: ".windows-amd64.msi",
},
}
type artifactFilter struct {
os string
arch string
}
type filterType string
const (
Add filterType = "add"
Remove filterType = "remove"
)
func filterBuildArtifacts(filterFrom []buildArtifact, ft filterType, filters []artifactFilter) ([]buildArtifact, error) {
var artifacts []buildArtifact
for _, a := range filterFrom {
matched := false
var match buildArtifact
for _, f := range filters {
if f.os == a.os && f.arch == a.arch {
match = a
matched = true
break
}
}
if matched && ft == Add {
artifacts = append(artifacts, match)
} else if !matched && ft == Remove {
artifacts = append(artifacts, a)
}
}
return artifacts, nil
}
func newBuild(url string, ba buildArtifact, sha256 string) build {
return build{
Os: ba.os,
URL: url,
Sha256: sha256,
Arch: ba.arch,
}
}
func (p *publisher) apiURL(url string) string {
return fmt.Sprintf("%s/%s%s", p.apiURI, p.product, url)
}
func (p *publisher) postRequest(url string, obj any, desc string) error {
jsonBytes, err := json.Marshal(obj)
if err != nil {
return err
}
if p.dryRun {
log.Printf("POST to %s:\n", p.apiURL(url))
log.Println(string(jsonBytes))
return nil
}
req, err := http.NewRequest(http.MethodPost, p.apiURL(url), bytes.NewReader(jsonBytes))
if err != nil {
return err
}
req.Header.Add("Authorization", "Bearer "+p.apiKey)
req.Header.Add("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
if res.StatusCode == http.StatusOK {
log.Printf("Action: %s \t OK", desc)
return nil
}
if res.Body != nil {
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
return err
}
if strings.Contains(string(body), "already exists") || strings.Contains(string(body), "Nothing to update") {
log.Printf("Action: %s \t Already exists", desc)
} else {
log.Printf("Action: %s \t Failed - Status: %v", desc, res.Status)
log.Printf("Resp: %s", body)
log.Fatalf("Quitting")
}
}
return nil
}
type release struct {
Version string `json:"version"`
ReleaseDate time.Time `json:"releaseDate"`
Stable bool `json:"stable"`
Beta bool `json:"beta"`
Nightly bool `json:"nightly"`
WhatsNewURL string `json:"whatsNewUrl"`
ReleaseNotesURL string `json:"releaseNotesUrl"`
Builds []build `json:"-"`
}
type build struct {
Os string `json:"os"`
URL string `json:"url"`
Sha256 string `json:"sha256"`
Arch string `json:"arch"`
}

@ -1,201 +0,0 @@
package main
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestPreparingReleaseFromRemote(t *testing.T) {
cases := []struct {
version string
expectedVersion string
whatsNewURL string
relNotesURL string
nightly bool
expectedBeta bool
expectedStable bool
expectedArch string
expectedOs string
expectedURL string
baseArchiveURL string
buildArtifacts []buildArtifact
}{
{
version: "v5.2.0-beta1",
expectedVersion: "5.2.0-beta1",
whatsNewURL: "https://whatsnews.foo/",
relNotesURL: "https://relnotes.foo/",
nightly: false,
expectedBeta: true,
expectedStable: false,
expectedArch: "amd64",
expectedOs: "linux",
expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.0-beta1.linux-amd64.tar.gz",
baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana",
buildArtifacts: []buildArtifact{{"linux", "amd64", ".linux-amd64.tar.gz", ""}},
},
{
version: "v5.2.3",
expectedVersion: "5.2.3",
whatsNewURL: "https://whatsnews.foo/",
relNotesURL: "https://relnotes.foo/",
nightly: false,
expectedBeta: false,
expectedStable: true,
expectedArch: "amd64",
expectedOs: "rhel",
expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.3-1.x86_64.rpm",
baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana",
buildArtifacts: []buildArtifact{{"rhel", "amd64", ".x86_64.rpm", ""}},
},
{
version: "v5.4.0-pre1asdf",
expectedVersion: "5.4.0-pre1asdf",
whatsNewURL: "https://whatsnews.foo/",
relNotesURL: "https://relnotes.foo/",
nightly: true,
expectedBeta: false,
expectedStable: false,
expectedArch: "amd64",
expectedOs: "rhel",
expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.4.0~pre1asdf-1.x86_64.rpm",
baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana",
buildArtifacts: []buildArtifact{{"rhel", "amd64", ".x86_64.rpm", ""}},
},
{
version: "v5.4.0-pre1asdf",
expectedVersion: "5.4.0-pre1asdf",
whatsNewURL: "https://whatsnews.foo/",
relNotesURL: "https://relnotes.foo/",
nightly: true,
expectedBeta: false,
expectedStable: false,
expectedArch: "armv6",
expectedOs: "deb",
expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-rpi_5.4.0~pre1asdf_armhf.deb",
baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana",
buildArtifacts: []buildArtifact{
{os: "deb", arch: "armv6", urlPostfix: "_armhf.deb", packagePostfix: "-rpi"},
},
},
{
version: "v5.4.0-pre1asdf",
expectedVersion: "5.4.0-pre1asdf",
whatsNewURL: "https://whatsnews.foo/",
relNotesURL: "https://relnotes.foo/",
nightly: true,
expectedBeta: false,
expectedStable: false,
expectedArch: "amd64",
expectedOs: "win-installer",
expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.4.0-pre1asdf.windows-amd64.msi",
baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana",
buildArtifacts: []buildArtifact{{"win-installer", "amd64", ".windows-amd64.msi", ""}},
},
{
version: "v5.4.0-pre1asdf",
expectedVersion: "5.4.0-pre1asdf",
whatsNewURL: "https://whatsnews.foo/",
relNotesURL: "https://relnotes.foo/",
nightly: true,
expectedBeta: false,
expectedStable: false,
expectedArch: "amd64",
expectedOs: "win",
expectedURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.4.0-pre1asdf.windows-amd64.zip",
baseArchiveURL: "https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana",
buildArtifacts: []buildArtifact{{"win", "amd64", ".windows-amd64.zip", ""}},
},
}
for _, test := range cases {
builder := releaseFromExternalContent{
getter: mockHTTPGetter{},
rawVersion: test.version,
artifactConfigurations: test.buildArtifacts,
}
t.Log("Preparing release", "baseArchiveURL", test.baseArchiveURL, "nightly", test.nightly)
rel, err := builder.prepareRelease(test.baseArchiveURL, test.whatsNewURL, test.relNotesURL, test.nightly)
require.NoError(t, err)
assert.Equal(t, test.expectedBeta, rel.Beta)
assert.Equal(t, test.expectedStable, rel.Stable)
assert.Equal(t, test.expectedVersion, rel.Version)
assert.Len(t, rel.Builds, len(test.buildArtifacts))
build := rel.Builds[0]
assert.Equal(t, test.expectedArch, build.Arch)
assert.Equal(t, test.expectedOs, build.Os)
assert.Equal(t, test.expectedURL, build.URL)
}
}
type mockHTTPGetter struct{}
func (mockHTTPGetter) getContents(url string) (string, error) {
return url, nil
}
func TestFilterBuildArtifacts(t *testing.T) {
buildArtifacts, _ := filterBuildArtifacts(completeBuildArtifactConfigurations, Add, []artifactFilter{
{os: "deb", arch: "amd64"},
{os: "rhel", arch: "amd64"},
{os: "linux", arch: "amd64"},
{os: "win", arch: "amd64"},
})
if len(buildArtifacts) != 4 {
t.Errorf("Expected 4 build artifacts after filtering, but was %v", len(buildArtifacts))
}
buildArtifacts, err := filterBuildArtifacts([]buildArtifact{
{
os: "linux",
arch: "amd64",
},
{
os: "arm",
arch: "amd64",
},
{
os: "darwin",
arch: "amd64",
},
}, Remove, []artifactFilter{
{os: "darwin", arch: "amd64"},
})
if err != nil {
t.Error()
}
if len(buildArtifacts) != 2 {
t.Errorf("Expected 2 artifacts, was %v", len(buildArtifacts))
}
for _, ba := range buildArtifacts {
if ba.arch == "amd64" && ba.os == "darwin" {
t.Errorf("darwin/amd64 should be gone due to filtering")
}
}
left := []buildArtifact{
{
os: "linux",
arch: "amd64",
},
{
os: "arm",
arch: "amd64",
},
}
if !reflect.DeepEqual(left, buildArtifacts) {
t.Errorf("Lists should have been equal but was, expected=%v, actual=%v", left, buildArtifacts)
}
}

@ -1 +0,0 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

@ -1 +0,0 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

@ -1 +0,0 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

@ -1 +0,0 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

@ -1 +0,0 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

@ -1,42 +0,0 @@
"""
This module contains logic for checking if the package.json whats new url matches with the in-flight tag.
"""
load(
"scripts/drone/steps/lib.star",
"compile_build_cmd",
)
load(
"scripts/drone/utils/images.star",
"images",
)
load(
"scripts/drone/utils/utils.star",
"pipeline",
)
def whats_new_checker_step():
return {
"name": "whats-new-checker",
"image": images["go"],
"depends_on": [
"compile-build-cmd",
],
"commands": [
"./bin/build whatsnew-checker",
],
}
def whats_new_checker_pipeline(trigger):
environment = {"EDITION": "oss"}
steps = [
compile_build_cmd(),
whats_new_checker_step(),
]
return pipeline(
name = "release-whatsnew-checker",
trigger = trigger,
services = [],
steps = steps,
environment = environment,
)

@ -16,10 +16,6 @@ load(
"scripts/drone/pipelines/test_frontend.star",
"test_frontend",
)
load(
"scripts/drone/pipelines/whats_new_checker.star",
"whats_new_checker_pipeline",
)
load(
"scripts/drone/steps/github.star",
"github_app_generate_token_step",
@ -291,7 +287,6 @@ def rgm_tag_pipeline():
return [
build,
whats_new_checker_pipeline(tag_trigger),
verify_release_pipeline(
trigger = tag_trigger,
name = "rgm-tag-verify-prerelease-assets",

Loading…
Cancel
Save