Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 29 additions & 0 deletions .github/workflows/test-committed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Automated Serverpod Cloud deploy

on:
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Flutter SDK
uses: subosito/flutter-action@v2

- name: Activate serverpod command
run: dart pub global activate serverpod_cli

- uses: ./ # Directly use the action
with:
token: ${{ secrets.MY_SERVERPOD_CLOUD_ACCESS_TOKEN }}
working_directory: ./test/committed/committed_server
43 changes: 43 additions & 0 deletions .github/workflows/test-non-committed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Automated Serverpod Cloud generate & deploy
description: >
Checks out the repository, sets up Flutter, runs serverpod generate,
and deploys to Serverpod Cloud.

on:
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:

permissions:
contents: read

env:
# Change these values according to your project
PROJECT_ID: test-action-non-committed-proj
SERVER_DIR: ./test/non_committed/non_committed_server
CLOUD_TOKEN: ${{ secrets.MY_SERVERPOD_CLOUD_ACCESS_TOKEN }}

jobs:
generate-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Flutter SDK
uses: subosito/flutter-action@v2

- name: Run serverpod generate
working-directory: ${{ env.SERVER_DIR }}
run: |
dart pub get
dart pub global activate serverpod_cli 3.1.1
serverpod generate

- uses: ./ # Directly use the action
with:
token: ${{ env.CLOUD_TOKEN }}
project_id: ${{ env.PROJECT_ID }}
project_dir: ${{ env.SERVER_DIR }}
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@v1
- name: Setup Flutter SDK
uses: subosito/flutter-action@v2

- uses: serverpod/serverpod-cloud-deploy@v0.3
- name: Activate serverpod command
run: dart pub global activate serverpod_cli

- uses: serverpod/serverpod-cloud-deploy@v1
with:
token: ${{ secrets.MY_SERVERPOD_CLOUD_ACCESS_TOKEN }}
```
Expand Down Expand Up @@ -80,7 +84,6 @@ description: >
on:
push:
branches: ["main"]
workflow_dispatch:

permissions:
contents: read
Expand All @@ -99,17 +102,15 @@ jobs:

- name: Setup Flutter SDK
uses: subosito/flutter-action@v2
with:
# Picks the latest stable version. Some may want to pin the version instead.
channel: stable
cache: true

- name: Run serverpod generate
working-directory: ${{ env.SERVER_DIR }}
# Automatically picks the used Serverpod version from dependencies
run: dart run serverpod_cli generate
run: |
dart pub get
dart pub global activate serverpod_cli
serverpod generate

- uses: serverpod/serverpod_cloud_deploy@v0.3
- uses: serverpod/serverpod_cloud_deploy@v1
with:
token: ${{ env.CLOUD_TOKEN }}
project_id: ${{ env.PROJECT_ID }}
Expand Down
13 changes: 13 additions & 0 deletions test/committed/committed_client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Files and directories created by pub
.dart_tool/
.packages

# Omit committing pubspec.lock for library packages:
# https://dart.dev/guides/libraries/private-files#pubspeclock
pubspec.lock

# Conventional directory for build outputs
build/

# Directory created by dartdoc
doc/api/
3 changes: 3 additions & 0 deletions test/committed/committed_client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial version, created by Stagehand
5 changes: 5 additions & 0 deletions test/committed/committed_client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# committed_client

This is your Serverpod client. The code in here is mostly generated by
Serverpod, but you may want to make changes if you are adding modules to your
project.
16 changes: 16 additions & 0 deletions test/committed/committed_client/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Defines a default set of lint rules enforced for
# projects at Google. For details and rationale,
# see https://github.com/dart-lang/pedantic#enabled-lints.

# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
# Uncomment to specify additional rules.
# linter:
# rules:
# - camel_case_types

analyzer:
exclude:
- lib/src/protocol/**

formatter:
trailing_commas: preserve
5 changes: 5 additions & 0 deletions test/committed/committed_client/dartdoc_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dartdoc:
categories:
"Endpoint":
markdown: doc/endpoint.md
name: Endpoint
15 changes: 15 additions & 0 deletions test/committed/committed_client/doc/endpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Callable endpoints

Each class contains callable methods that will call a method on the server side. These are normally defined in the `endpoint` directory in your server project. This client sends requests to these endpoints and returns the result.

Example usage:

```dart
// How to use GreetingEndpoint.
client.greeting.hello("world!");

// Generic format.
client.<endpoint>.<method>(...);
```

Please see the full official documentation [here](https://docs.serverpod.dev)
2 changes: 2 additions & 0 deletions test/committed/committed_client/lib/committed_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'src/protocol/protocol.dart';
export 'package:serverpod_client/serverpod_client.dart';
75 changes: 75 additions & 0 deletions test/committed/committed_client/lib/src/protocol/client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */

// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_client/serverpod_client.dart' as _i1;
import 'dart:async' as _i2;
import 'package:committed_client/src/protocol/greetings/greeting.dart' as _i3;
import 'protocol.dart' as _i4;

/// This is an example endpoint that returns a greeting message through
/// its [hello] method.
/// {@category Endpoint}
class EndpointGreeting extends _i1.EndpointRef {
EndpointGreeting(_i1.EndpointCaller caller) : super(caller);

@override
String get name => 'greeting';

/// Returns a personalized greeting message: "Hello {name}".
_i2.Future<_i3.Greeting> hello(String name) =>
caller.callServerEndpoint<_i3.Greeting>(
'greeting',
'hello',
{'name': name},
);
}

class Client extends _i1.ServerpodClientShared {
Client(
String host, {
dynamic securityContext,
@Deprecated(
'Use authKeyProvider instead. This will be removed in future releases.',
)
super.authenticationKeyManager,
Duration? streamingConnectionTimeout,
Duration? connectionTimeout,
Function(
_i1.MethodCallContext,
Object,
StackTrace,
)?
onFailedCall,
Function(_i1.MethodCallContext)? onSucceededCall,
bool? disconnectStreamsOnLostInternetConnection,
}) : super(
host,
_i4.Protocol(),
securityContext: securityContext,
streamingConnectionTimeout: streamingConnectionTimeout,
connectionTimeout: connectionTimeout,
onFailedCall: onFailedCall,
onSucceededCall: onSucceededCall,
disconnectStreamsOnLostInternetConnection:
disconnectStreamsOnLostInternetConnection,
) {
greeting = EndpointGreeting(this);
}

late final EndpointGreeting greeting;

@override
Map<String, _i1.EndpointRef> get endpointRefLookup => {'greeting': greeting};

@override
Map<String, _i1.ModuleEndpointCaller> get moduleLookup => {};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */

// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_client/serverpod_client.dart' as _i1;

/// A greeting message which can be sent to or from the server.
abstract class Greeting implements _i1.SerializableModel {
Greeting._({
required this.message,
required this.author,
required this.timestamp,
});

factory Greeting({
required String message,
required String author,
required DateTime timestamp,
}) = _GreetingImpl;

factory Greeting.fromJson(Map<String, dynamic> jsonSerialization) {
return Greeting(
message: jsonSerialization['message'] as String,
author: jsonSerialization['author'] as String,
timestamp: _i1.DateTimeJsonExtension.fromJson(
jsonSerialization['timestamp'],
),
);
}

/// The greeting message.
String message;

/// The author of the greeting message.
String author;

/// The time when the message was created.
DateTime timestamp;

/// Returns a shallow copy of this [Greeting]
/// with some or all fields replaced by the given arguments.
@_i1.useResult
Greeting copyWith({
String? message,
String? author,
DateTime? timestamp,
});
@override
Map<String, dynamic> toJson() {
return {
'__className__': 'Greeting',
'message': message,
'author': author,
'timestamp': timestamp.toJson(),
};
}

@override
String toString() {
return _i1.SerializationManager.encode(this);
}
}

class _GreetingImpl extends Greeting {
_GreetingImpl({
required String message,
required String author,
required DateTime timestamp,
}) : super._(
message: message,
author: author,
timestamp: timestamp,
);

/// Returns a shallow copy of this [Greeting]
/// with some or all fields replaced by the given arguments.
@_i1.useResult
@override
Greeting copyWith({
String? message,
String? author,
DateTime? timestamp,
}) {
return Greeting(
message: message ?? this.message,
author: author ?? this.author,
timestamp: timestamp ?? this.timestamp,
);
}
}
Loading