Skip to content

Commit

Permalink
CI: Move verify-storybook command from grabpl (#59928)
Browse files Browse the repository at this point in the history
* Move verify-storybook from grabpl

* Remove zerolog
  • Loading branch information
dsotirakis committed Dec 7, 2022
1 parent 440d8a3 commit 0801fce
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
10 changes: 5 additions & 5 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ steps:
- failure
- commands:
- yarn storybook:build
- ./bin/grabpl verify-storybook
- ./bin/build verify-storybook
depends_on:
- build-frontend
- build-frontend-packages
Expand Down Expand Up @@ -1430,7 +1430,7 @@ steps:
- failure
- commands:
- yarn storybook:build
- ./bin/grabpl verify-storybook
- ./bin/build verify-storybook
depends_on:
- build-frontend
- build-frontend-packages
Expand Down Expand Up @@ -2155,7 +2155,7 @@ steps:
- failure
- commands:
- yarn storybook:build
- ./bin/grabpl verify-storybook
- ./bin/build verify-storybook
depends_on:
- build-frontend
- build-frontend-packages
Expand Down Expand Up @@ -4699,7 +4699,7 @@ steps:
- failure
- commands:
- yarn storybook:build
- ./bin/grabpl verify-storybook
- ./bin/build verify-storybook
depends_on:
- build-frontend
- build-frontend-packages
Expand Down Expand Up @@ -6318,6 +6318,6 @@ kind: secret
name: packages_secret_access_key
---
kind: signature
hmac: efffc2eb55bbfa1cebe950585df1f3f81d2f2a38311e2854f3ce08d1eec16fe3
hmac: dcf24226fae30872050cdc031430374d811e6bbe13158ce0fbf234c90c1d83f9

...
7 changes: 6 additions & 1 deletion pkg/build/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func main() {
},
{
Name: "store-storybook",
Usage: "Integrity check for storybook build",
Usage: "Stores storybook to GCS buckets",
Action: StoreStorybook,
Flags: []cli.Flag{
&cli.StringFlag{
Expand All @@ -161,6 +161,11 @@ func main() {
},
},
},
{
Name: "verify-storybook",
Usage: "Integrity check for storybook build",
Action: VerifyStorybook,
},
{
Name: "upload-packages",
Usage: "Upload Grafana packages",
Expand Down
32 changes: 32 additions & 0 deletions pkg/build/cmd/verifystorybook.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Package verifystorybook contains the sub-command "verify-storybook".
package main

import (
"fmt"
"log"
"path/filepath"

"github.com/grafana/grafana/pkg/infra/fs"
"github.com/urfave/cli/v2"
)

// VerifyStorybook Action implements the sub-command "verify-storybook".
func VerifyStorybook(c *cli.Context) error {
const grafanaDir = "."

paths := []string{
"packages/grafana-ui/dist/storybook/index.html",
"packages/grafana-ui/dist/storybook/iframe.html"}
for _, p := range paths {
exists, err := fs.Exists(filepath.Join(grafanaDir, p))
if err != nil {
return cli.NewExitError(fmt.Sprintf("failed to verify Storybook build: %s", err), 1)
}
if !exists {
return fmt.Errorf("failed to verify Storybook build, missing %q", p)
}
}

log.Printf("Successfully verified Storybook integrity")
return nil
}
2 changes: 1 addition & 1 deletion scripts/drone/steps/lib.star
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def build_storybook_step(ver_mode):
},
'commands': [
'yarn storybook:build',
'./bin/grabpl verify-storybook',
'./bin/build verify-storybook',
],
'when': get_trigger_storybook(ver_mode),
}
Expand Down

0 comments on commit 0801fce

Please sign in to comment.