Skip to content

Commit

Permalink
Merge pull request #6 from buildbarn/mmj/workflow
Browse files Browse the repository at this point in the history
Regenerate workflows and enable CI
  • Loading branch information
mortenmj authored Sep 29, 2024
2 parents 2327139 + 2811b08 commit 5390c8d
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 39 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
},
{
"name": "Protobuf generation",
"run": "find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true\nbazel build $(bazel query --output=label 'kind(\"go_proto_library\", //...)')\nfind bazel-bin/pkg/proto -name '*.pb.go' | while read f; do\n cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|')\ndone\n"
"run": "if [ -d bazel-bin/pkg/proto ]; then\n find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true\n bazel build $(bazel query --output=label 'kind(\"go_proto_library\", //...)')\n find bazel-bin/pkg/proto -name '*.pb.go' | while read f; do\n cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|')\n done\nfi\n"
},
{
"name": "Embedded asset generation",
"run": "bazel build $(git grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |//\\1:|' | sort -u)\ngit grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |\\1/|' | while read o; do\n if [ -e \"bazel-bin/$o\" ]; then\n rm -rf \"$o\"\n cp -r \"bazel-bin/$o\" \"$o\"\n find \"$o\" -type f -exec chmod -x {} +\n fi\ndone\n"
"run": "bazel build $(git grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |//\\1:|; s|\"||g; s| .*||' | sort -u)\ngit grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |\\1/|' | while read o; do\n if [ -e \"bazel-bin/$o\" ]; then\n rm -rf \"$o\"\n cp -r \"bazel-bin/$o\" \"$o\"\n find \"$o\" -type f -exec chmod -x {} +\n fi\ndone\n"
},
{
"name": "Test style conformance",
Expand Down Expand Up @@ -197,6 +197,7 @@
"on": {
"push": {
"branches": [
"main",
"master"
]
}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pull-requests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
},
{
"name": "Protobuf generation",
"run": "find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true\nbazel build $(bazel query --output=label 'kind(\"go_proto_library\", //...)')\nfind bazel-bin/pkg/proto -name '*.pb.go' | while read f; do\n cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|')\ndone\n"
"run": "if [ -d bazel-bin/pkg/proto ]; then\n find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true\n bazel build $(bazel query --output=label 'kind(\"go_proto_library\", //...)')\n find bazel-bin/pkg/proto -name '*.pb.go' | while read f; do\n cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|')\n done\nfi\n"
},
{
"name": "Embedded asset generation",
"run": "bazel build $(git grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |//\\1:|' | sort -u)\ngit grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |\\1/|' | while read o; do\n if [ -e \"bazel-bin/$o\" ]; then\n rm -rf \"$o\"\n cp -r \"bazel-bin/$o\" \"$o\"\n find \"$o\" -type f -exec chmod -x {} +\n fi\ndone\n"
"run": "bazel build $(git grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |//\\1:|; s|\"||g; s| .*||' | sort -u)\ngit grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |\\1/|' | while read o; do\n if [ -e \"bazel-bin/$o\" ]; then\n rm -rf \"$o\"\n cp -r \"bazel-bin/$o\" \"$o\"\n find \"$o\" -type f -exec chmod -x {} +\n fi\ndone\n"
},
{
"name": "Test style conformance",
Expand Down Expand Up @@ -90,6 +90,7 @@
"on": {
"pull_request": {
"branches": [
"main",
"master"
]
}
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ git_override(

git_override(
module_name = "com_github_buildbarn_bb_storage",
commit = "256ec6c483a05f1aeefff6fc57a2044f746c5a08",
commit = "8abbcfab01bcde294b20c2070baba9fd242bab7f",
remote = "https://github.com/buildbarn/bb-storage.git",
)

Expand Down
75 changes: 75 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/bb_portal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

const (
readHeaderTimeout = 3 * time.Second
folderPermission = 0750
folderPermission = 0o750
)

var (
Expand Down
2 changes: 1 addition & 1 deletion internal/api/grpc/bes/bes.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (b BES) PublishBuildToolEventStream(stream build.PublishBuildEvent_PublishB
slog.ErrorContext(stream.Context(), "Recv failed", "err", err)
return err
}
//slog.InfoContext(stream.Context(), "Received ordered build event", "event", protojson.Format(req))
// slog.InfoContext(stream.Context(), "Received ordered build event", "event", protojson.Format(req))

if streamID == nil {
streamID = req.GetOrderedBuildEvent().GetStreamId()
Expand Down
8 changes: 5 additions & 3 deletions internal/graphql/custom.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions internal/graphql/ent.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions internal/graphql/graphql_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import (
"github.com/buildbarn/bb-portal/internal/graphql"
)

var (
update = flag.Bool("update-golden", false, "update golden (.out.json) files")
)
var update = flag.Bool("update-golden", false, "update golden (.out.json) files")

type setupFuncEnt func(ctx context.Context, client *ent.Client)

Expand Down Expand Up @@ -68,7 +66,7 @@ func newMockServer(t *testing.T, entDataSource string) *mockServer {
Server: server,
URL: server.URL,
ctx: ctx,
//ctrl: ctrl,
// ctrl: ctrl,
client: client,
}
t.Cleanup(func() {
Expand Down
1 change: 0 additions & 1 deletion pkg/events/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ func (it *BuildEventIterator) Next() (*BuildEvent, error) {
}

lineBytes, err := it.scanner.Bytes(), it.scanner.Err()

if err != nil {
return nil, fmt.Errorf("failed to read a line from build event file: %w", err)
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/processing/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import (
"github.com/buildbarn/bb-portal/pkg/summary/detectors"
)

var (
errNoArchiver = errors.New("no archiver registered")
)
var errNoArchiver = errors.New("no archiver registered")

type BlobArchiver interface {
ArchiveBlob(ctx context.Context, blobURI detectors.BlobURI) ent.Blob
Expand Down
3 changes: 1 addition & 2 deletions pkg/processing/summarize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"github.com/buildbarn/bb-portal/pkg/summary"
)

type SummarizeActor struct {
}
type SummarizeActor struct{}

func (SummarizeActor) Summarize(ctx context.Context, eventFileURL string) (*summary.Summary, error) {
return summary.Summarize(ctx, eventFileURL)
Expand Down
5 changes: 3 additions & 2 deletions pkg/testkit/golden.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ type CompareOptions struct {
// goldenDir defines the directory that holds golden files.
// testName is the name of the test, which will be sluggified to determine the golden file to use
// update is a flag that determines if we should update the golden file.
func CheckAgainstGoldenFile(t *testing.T, got map[string]interface{}, goldenDir string, testName string, update *bool, opts *CompareOptions) {
func CheckAgainstGoldenFile(t *testing.T, got map[string]interface{}, goldenDir, testName string, update *bool, opts *CompareOptions) {
testSlug := strings.ReplaceAll(testName, " ", "-")
golden := filepath.Join(goldenDir, fmt.Sprintf("%s.golden.json", testSlug))

if *update {
dir := filepath.Dir(golden)
require.NoError(t, os.MkdirAll(dir, os.ModePerm))
require.NoError(t, os.WriteFile(golden, prettyJSON(got), 0640))
require.NoError(t, os.WriteFile(golden, prettyJSON(got), 0o640))
}

// get golden file
Expand Down Expand Up @@ -94,6 +94,7 @@ func replaceTimes(str string) (string, error) {

return lastModifiedPattern.ReplaceAllString(res, `Mon, 01 Jan 0001 00:00:00 GMT`), nil
}

func prettyJSON(data interface{}) []byte {
jsonText, err := json.MarshalIndent(data, "", " ")
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions pkg/testkit/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type QueryRegistry struct {
entries map[string]*registryEntry
}

func LoadQueryRegistry(t *testing.T, queryDir string, consumerContractFile string) *QueryRegistry {
func LoadQueryRegistry(t *testing.T, queryDir, consumerContractFile string) *QueryRegistry {
reg := QueryRegistry{entries: make(map[string]*registryEntry)}

queryFiles, err := os.ReadDir(queryDir)
Expand Down Expand Up @@ -96,8 +96,10 @@ type ConsumerContract struct {
Operations map[string]Operation `yaml:"operations"`
}

type Document string
type Variables map[string]interface{}
type (
Document string
Variables map[string]interface{}
)

type Operation struct {
Document Document `yaml:"document"`
Expand Down
4 changes: 1 addition & 3 deletions pkg/uuidgql/uuidgql.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import (
"github.com/google/uuid"
)

var (
errExpectedString = errors.New("expected string")
)
var errExpectedString = errors.New("expected string")

func MarshalUUID(u uuid.UUID) graphql.Marshaler {
return graphql.WriterFunc(func(w io.Writer) {
Expand Down

0 comments on commit 5390c8d

Please sign in to comment.