Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc0548e

Browse files
Merge pull request #15761 from [BEAM-13008] Create gradle tasks 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 <[email protected]>
1 parent 9c8939b commit dc0548e

29 files changed

Lines changed: 1422 additions & 237 deletions

File tree

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,10 @@ website/www/site/code_samples
113113
website/www/site/_config_branch_repo.toml
114114
website/www/yarn-error.log
115115
!website/www/site/content
116+
117+
# Dart/Flutter
118+
**/.dart_tool
119+
**/.packages
120+
**/.flutter-plugins
121+
**/.flutter-plugins-dependencies
122+
**/generated_plugin_registrant.dart

build.gradle.kts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ tasks.rat {
124124
// Ignore Flutter autogenerated files for Playground
125125
"playground/frontend/.metadata",
126126
"playground/frontend/pubspec.lock",
127-
"playground/frontend/assets/**/*.svg",
128-
"playground/frontend/assets/**/*.png",
129-
"playground/frontend/assets/**/*.jpg",
127+
"playground/frontend/**/*.svg",
130128

131129
// Ignore .gitkeep file
132130
"**/.gitkeep"
@@ -249,6 +247,15 @@ task("goIntegrationTests") {
249247
dependsOn(":runners:google-cloud-dataflow-java:worker:shadowJar")
250248
}
251249

250+
task("playgroundPreCommit") {
251+
dependsOn(":playground:backend:tidy")
252+
dependsOn(":playground:backend:test")
253+
254+
dependsOn(":playground:frontend:pubGet")
255+
dependsOn(":playground:frontend:analyze")
256+
dependsOn(":playground:frontend:test")
257+
}
258+
252259
task("pythonPreCommit") {
253260
dependsOn(":sdks:python:test-suites:tox:pycommon:preCommitPyCommon")
254261
dependsOn(":sdks:python:test-suites:tox:py36:preCommitPy36")

playground/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# Playground
21+
22+
The Beam Playground is a web application to run Beam code snippets in a modern
23+
browser. This directory holds code to build, test, and deploy the frontend
24+
and backend services.
25+
26+
# Requirements
27+
28+
The following requirements are needed for development, testing, and deploying.
29+
30+
- [go 1.16+](https://golang.org)
31+
- [flutter](https://flutter.dev/)
32+
- Go protobuf dependencies (See [Go gRPC Quickstart](https://grpc.io/docs/languages/go/quickstart/))
33+
- Dart protobuf dependencies (See [Dart gRPC Quickstart](https://grpc.io/docs/languages/dart/))
34+
- [buf](https://docs.buf.build/installation)
35+
36+
# Available Gradle Tasks
37+
38+
## Perform overall pre-commit checks
39+
40+
```
41+
cd beam
42+
./gradlew playgroundPrecommit
43+
```
44+
45+
## To see available gradle tasks for playground:
46+
47+
```
48+
cd beam
49+
./gradlew playground:tasks
50+
```
51+
52+
## Re-generate protobuf
53+
54+
```
55+
cd beam
56+
./gradlew playground:generateProto
57+
```
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
*/
1818

1919
syntax = "proto3";
20+
option go_package = "beam.apache.org/playground/backend/internal;playground";
2021

21-
option go_package = "github.com/apache/beam/playground/v1;playground";
22-
package playground.v1;
22+
package api.v1;
2323

2424
enum Sdk {
2525
SDK_UNSPECIFIED = 0;
@@ -92,4 +92,4 @@ service PlaygroundService {
9292

9393
// Get the result of pipeline compilation.
9494
rpc GetCompileOutput(GetCompileOutputRequest) returns (GetCompileOutputResponse);
95-
}
95+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* License); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
description = "Apache Beam :: Playground :: Backend"
20+
21+
task("format") {
22+
group = "build"
23+
description = "Format backend go code"
24+
doLast {
25+
exec {
26+
executable("gofmt")
27+
args("-w", ".")
28+
}
29+
}
30+
}
31+
32+
task("tidy") {
33+
group = "build"
34+
description = "Run go mod tidy"
35+
doLast {
36+
exec {
37+
executable("go")
38+
args("mod", "tidy")
39+
}
40+
}
41+
}
42+
43+
task("test") {
44+
group = "verification"
45+
description = "Test the backend"
46+
doLast {
47+
exec {
48+
executable("go")
49+
args("test", "internal/...")
50+
}
51+
}
52+
}

playground/backend/cmd/server/controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
package main
1616

1717
import (
18-
pb "beam.apache.org/playground/backend/internal/api"
1918
"context"
19+
20+
pb "beam.apache.org/playground/backend/internal/api/v1"
2021
"github.com/google/uuid"
2122
)
2223

playground/backend/cmd/server/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package main
1616

1717
import (
18-
pb "beam.apache.org/playground/backend/internal/api"
18+
pb "beam.apache.org/playground/backend/internal/api/v1"
1919
"context"
2020
"github.com/google/uuid"
2121
"google.golang.org/grpc"

playground/backend/cmd/server/server.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
package main
1717

1818
import (
19-
pb "beam.apache.org/playground/backend/internal/api"
20-
"beam.apache.org/playground/backend/internal/environment"
2119
"context"
20+
"log"
21+
"os"
22+
23+
pb "beam.apache.org/playground/backend/internal/api/v1"
24+
"beam.apache.org/playground/backend/internal/environment"
2225
"github.com/improbable-eng/grpc-web/go/grpcweb"
2326
"google.golang.org/grpc"
2427
"google.golang.org/grpc/grpclog"
25-
"log"
26-
"os"
2728
)
2829

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

42-
go listenHttp(ctx, errChan, envService.ServerEnvs, handler)
43+
go listenHttp(ctx, errChan, envService, handler)
4344

4445
for {
4546
select {

0 commit comments

Comments
 (0)