File tree Expand file tree Collapse file tree 13 files changed +228
-2
lines changed
Expand file tree Collapse file tree 13 files changed +228
-2
lines changed Original file line number Diff line number Diff line change 1+ name : Docker Tests
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ setup :
7+ required : false
8+ type : string
9+ default : " "
10+ test_directory :
11+ required : false
12+ type : string
13+ default : " e2e"
14+ working_directory :
15+ required : false
16+ type : string
17+ default : " ."
18+
19+ jobs :
20+ test :
21+ runs-on : ubuntu-latest
22+ defaults :
23+ run :
24+ working-directory : ${{inputs.working_directory}}
25+
26+ steps :
27+ - name : 📚 Git Checkout
28+ uses : actions/checkout@v3
29+
30+ - name : 🎯 Setup Dart
31+ uses : dart-lang/setup-dart@v1
32+
33+ - name : ⚙️ Run Setup
34+ if : " ${{inputs.setup != ''}}"
35+ run : ${{inputs.setup}}
36+
37+ - name : 📦 Install Dependencies
38+ run : dart pub get
39+
40+ - name : 🐸 Dart Frog Build
41+ run : dart_frog build
42+
43+ - name : 🐳 Build Docker Image
44+ run : docker build -q build -t e2e-image
45+
46+ - name : ⚡️ Run Docker Image
47+ run : docker run -d -p 8080:8080 --name e2e --rm e2e-image
48+
49+ - name : 🧪 Run Docker Tests
50+ run : dart test ${{inputs.test_directory}}
51+
52+ - name : 🧹 Docker Cleanup
53+ if : success() || failure()
54+ run : |
55+ docker stop e2e
56+ docker image rm e2e-image
Original file line number Diff line number Diff line change 1010 - " examples/counter/routes/**"
1111 - " examples/counter/lib/**"
1212 - " examples/counter/test/**"
13+ - " examples/counter/e2e/**"
1314 - " .github/workflows/examples_counter.yaml"
1415 - " packages/dart_frog/lib/**"
1516 - " packages/dart_frog/pubspec.yaml"
2324 working_directory : examples/counter
2425 analyze_directories : " routes test"
2526 report_on : " routes"
27+
28+ docker :
29+ uses : ./.github/workflows/.docker_tests.yaml
30+ with :
31+ setup : rm pubspec_overrides.yaml && dart pub global activate --source path ../../packages/dart_frog_cli
32+ working_directory : examples/counter
Original file line number Diff line number Diff line change 1010 - " examples/echo/routes/**"
1111 - " examples/echo/lib/**"
1212 - " examples/echo/test/**"
13+ - " examples/echo/e2e/**"
1314 - " .github/workflows/examples_echo.yaml"
1415 - " packages/dart_frog/lib/**"
1516 - " packages/dart_frog/pubspec.yaml"
2324 working_directory : examples/echo
2425 analyze_directories : " routes test"
2526 report_on : " routes"
27+
28+ docker :
29+ uses : ./.github/workflows/.docker_tests.yaml
30+ with :
31+ setup : rm pubspec_overrides.yaml && dart pub global activate --source path ../../packages/dart_frog_cli
32+ working_directory : examples/echo
Original file line number Diff line number Diff line change 1010 - " examples/hello_world/routes/**"
1111 - " examples/hello_world/lib/**"
1212 - " examples/hello_world/test/**"
13+ - " examples/hello_world/e2e/**"
1314 - " .github/workflows/examples_hello_world.yaml"
1415 - " packages/dart_frog/lib/**"
1516 - " packages/dart_frog/pubspec.yaml"
2324 working_directory : examples/hello_world
2425 analyze_directories : " routes test"
2526 report_on : " routes"
27+
28+ docker :
29+ uses : ./.github/workflows/.docker_tests.yaml
30+ with :
31+ setup : rm pubspec_overrides.yaml && dart pub global activate --source path ../../packages/dart_frog_cli
32+ working_directory : examples/hello_world
Original file line number Diff line number Diff line change 1212 - " examples/todos/test/**"
1313 - " examples/todos/packages/**/lib/**"
1414 - " examples/todos/packages/**/test/**"
15+ - " examples/todos/packages/**/e2e/**"
1516 - " .github/workflows/examples_todos.yaml"
1617 - " packages/dart_frog/lib/**"
1718 - " packages/dart_frog/pubspec.yaml"
2627 analyze_directories : " routes test"
2728 report_on : " routes"
2829
30+ docker :
31+ uses : ./.github/workflows/.docker_tests.yaml
32+ with :
33+ setup : rm pubspec_overrides.yaml && dart pub global activate --source path ../../packages/dart_frog_cli
34+ working_directory : examples/todos
35+
2936 todos_data_source :
3037 uses : VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1
3138 with :
Original file line number Diff line number Diff line change 1+ import 'dart:io' ;
2+
3+ import 'package:http/http.dart' as http;
4+ import 'package:test/test.dart' ;
5+
6+ void main () {
7+ group ('E2E' , () {
8+ test ('GET / increments the count on each request' , () async {
9+ const numRequests = 10 ;
10+ for (var i = 1 ; i <= numRequests; i++ ) {
11+ final response = await http.get (Uri .parse ('http://localhost:8080' ));
12+ expect (response.statusCode, equals (HttpStatus .ok));
13+ expect (
14+ response.body,
15+ equals ('You have requested this route $i time(s).' ),
16+ );
17+ }
18+ });
19+ });
20+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ dependencies:
1010 dart_frog : ^0.0.1-dev
1111
1212dev_dependencies :
13+ http : ^0.13.5
1314 mocktail : ^0.3.0
1415 test : ^1.19.2
1516 very_good_analysis : ^3.0.1
Original file line number Diff line number Diff line change 1+ import 'dart:io' ;
2+
3+ import 'package:http/http.dart' as http;
4+ import 'package:test/test.dart' ;
5+
6+ void main () {
7+ group ('E2E' , () {
8+ test ('GET /<message> echos back <message>' , () async {
9+ final messages = ['hello' , 'world' ];
10+ for (final message in messages) {
11+ final response = await http.get (
12+ Uri .parse ('http://localhost:8080/$message ' ),
13+ );
14+ expect (response.statusCode, equals (HttpStatus .ok));
15+ expect (response.body, equals (message));
16+ }
17+ });
18+ });
19+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ dependencies:
1010 dart_frog : ^0.0.1-dev
1111
1212dev_dependencies :
13+ http : ^0.13.5
1314 mocktail : ^0.3.0
1415 test : ^1.19.2
1516 very_good_analysis : ^3.0.1
Original file line number Diff line number Diff line change 1+ import 'dart:io' ;
2+
3+ import 'package:http/http.dart' as http;
4+ import 'package:test/test.dart' ;
5+
6+ void main () {
7+ group ('E2E' , () {
8+ test ('GET / responds with "Welcome to Dart Frog!"' , () async {
9+ final response = await http.get (Uri .parse ('http://localhost:8080' ));
10+ expect (response.statusCode, equals (HttpStatus .ok));
11+ expect (response.body, equals ('Welcome to Dart Frog!' ));
12+ });
13+
14+ test ('GET /favicon.ico responds with the favicon.cio' , () async {
15+ final response = await http.get (
16+ Uri .parse ('http://localhost:8080/favicon.ico' ),
17+ );
18+ expect (response.statusCode, equals (HttpStatus .ok));
19+ expect (response.body, isNotEmpty);
20+ });
21+ });
22+ }
You can’t perform that action at this time.
0 commit comments