Skip to content

Commit

Permalink
Merge pull request apache#15761 from [BEAM-13008] Create gradle tasks…
Browse files Browse the repository at this point in the history
… for the Beam Playground

* Implement Beam Playground gradle tasks

* Fix trailing whitespace

* Remove format from precommit

* Fix order of includes and add descriptions

* [BEAM-13008] add generated files and fix analysis issues (#2)

* Reconcile errors with playgroundPrecommit output

Co-authored-by: Aydar Farrakhov <stranniknm@gmail.com>
  • Loading branch information
damondouglas and ElessarST authored Oct 21, 2021
1 parent 9c8939b commit dc0548e
Show file tree
Hide file tree
Showing 29 changed files with 1,422 additions and 237 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,10 @@ website/www/site/code_samples
website/www/site/_config_branch_repo.toml
website/www/yarn-error.log
!website/www/site/content

# Dart/Flutter
**/.dart_tool
**/.packages
**/.flutter-plugins
**/.flutter-plugins-dependencies
**/generated_plugin_registrant.dart
13 changes: 10 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ tasks.rat {
// Ignore Flutter autogenerated files for Playground
"playground/frontend/.metadata",
"playground/frontend/pubspec.lock",
"playground/frontend/assets/**/*.svg",
"playground/frontend/assets/**/*.png",
"playground/frontend/assets/**/*.jpg",
"playground/frontend/**/*.svg",

// Ignore .gitkeep file
"**/.gitkeep"
Expand Down Expand Up @@ -249,6 +247,15 @@ task("goIntegrationTests") {
dependsOn(":runners:google-cloud-dataflow-java:worker:shadowJar")
}

task("playgroundPreCommit") {
dependsOn(":playground:backend:tidy")
dependsOn(":playground:backend:test")

dependsOn(":playground:frontend:pubGet")
dependsOn(":playground:frontend:analyze")
dependsOn(":playground:frontend:test")
}

task("pythonPreCommit") {
dependsOn(":sdks:python:test-suites:tox:pycommon:preCommitPyCommon")
dependsOn(":sdks:python:test-suites:tox:py36:preCommitPy36")
Expand Down
57 changes: 57 additions & 0 deletions playground/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# Playground

The Beam Playground is a web application to run Beam code snippets in a modern
browser. This directory holds code to build, test, and deploy the frontend
and backend services.

# Requirements

The following requirements are needed for development, testing, and deploying.

- [go 1.16+](https://golang.org)
- [flutter](https://flutter.dev/)
- Go protobuf dependencies (See [Go gRPC Quickstart](https://grpc.io/docs/languages/go/quickstart/))
- Dart protobuf dependencies (See [Dart gRPC Quickstart](https://grpc.io/docs/languages/dart/))
- [buf](https://docs.buf.build/installation)

# Available Gradle Tasks

## Perform overall pre-commit checks

```
cd beam
./gradlew playgroundPrecommit
```

## To see available gradle tasks for playground:

```
cd beam
./gradlew playground:tasks
```

## Re-generate protobuf

```
cd beam
./gradlew playground:generateProto
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/

syntax = "proto3";
option go_package = "beam.apache.org/playground/backend/internal;playground";

option go_package = "github.com/apache/beam/playground/v1;playground";
package playground.v1;
package api.v1;

enum Sdk {
SDK_UNSPECIFIED = 0;
Expand Down Expand Up @@ -92,4 +92,4 @@ service PlaygroundService {

// Get the result of pipeline compilation.
rpc GetCompileOutput(GetCompileOutputRequest) returns (GetCompileOutputResponse);
}
}
52 changes: 52 additions & 0 deletions playground/backend/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* License); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

description = "Apache Beam :: Playground :: Backend"

task("format") {
group = "build"
description = "Format backend go code"
doLast {
exec {
executable("gofmt")
args("-w", ".")
}
}
}

task("tidy") {
group = "build"
description = "Run go mod tidy"
doLast {
exec {
executable("go")
args("mod", "tidy")
}
}
}

task("test") {
group = "verification"
description = "Test the backend"
doLast {
exec {
executable("go")
args("test", "internal/...")
}
}
}
3 changes: 2 additions & 1 deletion playground/backend/cmd/server/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package main

import (
pb "beam.apache.org/playground/backend/internal/api"
"context"

pb "beam.apache.org/playground/backend/internal/api/v1"
"github.com/google/uuid"
)

Expand Down
2 changes: 1 addition & 1 deletion playground/backend/cmd/server/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package main

import (
pb "beam.apache.org/playground/backend/internal/api"
pb "beam.apache.org/playground/backend/internal/api/v1"
"context"
"github.com/google/uuid"
"google.golang.org/grpc"
Expand Down
11 changes: 6 additions & 5 deletions playground/backend/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
package main

import (
pb "beam.apache.org/playground/backend/internal/api"
"beam.apache.org/playground/backend/internal/environment"
"context"
"log"
"os"

pb "beam.apache.org/playground/backend/internal/api/v1"
"beam.apache.org/playground/backend/internal/environment"
"github.com/improbable-eng/grpc-web/go/grpcweb"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
"log"
"os"
)

// runServer is starting http server wrapped on grpc
Expand All @@ -39,7 +40,7 @@ func runServer() error {
handler := Wrap(grpcServer, getGrpcWebOptions())
errChan := make(chan error)

go listenHttp(ctx, errChan, envService.ServerEnvs, handler)
go listenHttp(ctx, errChan, envService, handler)

for {
select {
Expand Down
Loading

0 comments on commit dc0548e

Please sign in to comment.