Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullsafe gql, gql_exec, gql_link #193

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bb7e93a
cats: null safety
micimize Feb 10, 2021
cbcf939
gql: null safety
micimize Feb 10, 2021
fa1edbb
applied quick fixes to ast.dart
micimize Feb 13, 2021
924352d
more suggestions and quickfixes
micimize Feb 13, 2021
a6805a8
suggestions and quickfixes for printer
micimize Feb 13, 2021
cb7349a
changed _peek(TokenKind.name) != null to _peek(TokenKind.name) in _pa…
micimize Feb 13, 2021
ff71970
fix lexer digit parsing
micimize Feb 13, 2021
691e0e3
fix gql pubspec
micimize Feb 13, 2021
848c74e
gql_exec dart migrate to nullsafety
micimize Feb 13, 2021
cf4e4a2
gql_exec dart migrate to nullsafety
micimize Feb 13, 2021
c1289f0
gql_link dart migrate to nullsafety
micimize Feb 13, 2021
b5e9b39
try and resolve issues for gql_exec and gql_link at least
micimize Feb 13, 2021
99a334d
depend on 2.12-beta for CI
micimize Feb 13, 2021
ee974f4
fix formatting of gql tests
micimize Feb 13, 2021
429d717
fix some lints in gql_link
micimize Feb 13, 2021
ffc032f
fix cats pubspec
micimize Feb 13, 2021
f9c9bb5
prefer const literals
micimize Feb 13, 2021
dd93c03
remove second gql_link from workflow
micimize Feb 13, 2021
118ad83
automatic migration
micimize Feb 14, 2021
8edfa3c
nullable parsedResponse
micimize Feb 14, 2021
da8fc71
nullable parsedResponse
micimize Feb 14, 2021
5aa8bb3
mockito migration for gql_http_link
micimize Feb 14, 2021
b792c30
mockito omck generation and test fixes
micimize Feb 14, 2021
64092c9
finally got tests to pass with generated mockito types
micimize Feb 14, 2021
72259a5
testing CI
micimize Feb 14, 2021
523465a
CI analysis issue
micimize Feb 14, 2021
0f1edb7
check only if no diff
micimize Feb 14, 2021
cf46960
hard override
micimize Feb 14, 2021
d50fadf
loosen gql_http_link build_runner constraint
micimize Feb 14, 2021
d0d08dc
attempt bumping build runner and analyzer
micimize Feb 14, 2021
e24bfc5
bump built value
micimize Feb 14, 2021
7874187
bump built value
micimize Feb 14, 2021
a7f17bc
bump built collectoi
micimize Feb 14, 2021
cdb37c5
ignore mockito build failure
micimize Feb 14, 2021
c880990
build runner as separate step
micimize Feb 14, 2021
3a2cb9f
gql_example_http_auth_link: bump http version
micimize Feb 14, 2021
03701f6
migrate dedupe_link
micimize Feb 15, 2021
0c055c0
cleanup unneeded mocklink codegen
micimize Feb 15, 2021
3617102
migrate transform link
micimize Feb 15, 2021
ddd20b2
migrate error link
micimize Feb 15, 2021
6885e14
move gql_example_http_auth_link to examples, add other examples
micimize Feb 15, 2021
756a08d
ignore lack of build runners in examples
micimize Feb 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/check_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#/bin/bash
micimize marked this conversation as resolved.
Show resolved Hide resolved

set -e

PACKAGE=$1

git diff --exit-code

clean_up () {
ARG=$?
git checkout .
exit $ARG
}

trap clean_up EXIT

# Check pubspec
multipack --only $PACKAGE pubspec clean
multipack --only $PACKAGE exec git diff --exit-code pubspec.yaml

# Override local dependencies
multipack pubspec hard_override

multipack --only $PACKAGE pub get

# Check formatting
echo ""
echo "A list of incorrectly formatted files may follow:"
echo ""
multipack --only $PACKAGE fmt -n . --set-exit-if-changed
echo ""

# Analyze package
multipack --only $PACKAGE analyze --version
multipack --only $PACKAGE analyze --fatal-warnings --no-hints .

# Run tests
# mockito requires build runner now
multipack --only $PACKAGE pub run build_runner build --delete-conflicting-outputs || true
multipack --only $PACKAGE exec [ ! -d ./test ] && exit 0
micimize marked this conversation as resolved.
Show resolved Hide resolved
multipack --only $PACKAGE pub run test

git checkout .
23 changes: 15 additions & 8 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: pull_request
jobs:
packages:
strategy:
fail-fast: false
matrix:
package:
- gql
Expand All @@ -16,13 +17,11 @@ jobs:
- gql_error_link
- gql_http_link
- gql_websocket_link
- gql_link
- gql_transform_link
- cats
- gql_example_http_auth_link
runs-on: ubuntu-latest
container:
image: google/dart:latest
image: google/dart:2.12-beta
name: Check ${{ matrix.package }}
env:
PACKAGE: ${{ matrix.package }}
Expand Down Expand Up @@ -50,6 +49,10 @@ jobs:
echo ""
multipack --only $PACKAGE fmt -n . --set-exit-if-changed
echo ""
- name: Run build_runner if necessary
run: |
multipack --only $PACKAGE pub run \
build_runner build --delete-conflicting-outputs || true
- name: Analyze package
run: |
multipack --only $PACKAGE analyze --version
Expand All @@ -65,9 +68,12 @@ jobs:
- gql_example_cli
- gql_example_cli_github
- gql_example_build
- gql_example_http_auth_link
- gql_example_dio_link
# gql_example_flutter would require flutter
runs-on: ubuntu-latest
container:
image: google/dart:latest
image: google/dart:2.12-beta
name: Check ${{ matrix.package }}
env:
PACKAGE: ${{ matrix.package }}
Expand All @@ -90,7 +96,8 @@ jobs:
multipack --only $PACKAGE pub get
- name: Run builders
run: |
multipack --only $PACKAGE pub run build_runner build --delete-conflicting-outputs
multipack --only $PACKAGE pub run \
build_runner build --delete-conflicting-outputs || true
- name: Check build diff
run: |
multipack --only $PACKAGE exec git diff --exit-code **/*.gql.dart
Expand All @@ -112,7 +119,7 @@ jobs:
- end_to_end_test
runs-on: ubuntu-latest
container:
image: google/dart:latest
image: google/dart:2.12-beta
name: Check ${{ matrix.package }}
env:
PACKAGE: ${{ matrix.package }}
Expand Down Expand Up @@ -158,7 +165,7 @@ jobs:
publish_dry_run:
runs-on: ubuntu-latest
container:
image: google/dart:latest
image: google/dart:2.12-beta
env:
PACKAGES: 'gql,gql_build,gql_code_builder,gql_dedupe_link,gql_dio_link,gql_exec,gql_http_link,gql_link,gql_pedantic,gql_transform_link,gql_error_link,gql_websocket_link'
PUB_ACCESS_TOKEN: ${{ secrets.PUB_ACCESS_TOKEN }}
Expand All @@ -183,7 +190,7 @@ jobs:
check_svg:
runs-on: ubuntu-latest
container:
image: google/dart:latest
image: google/dart:2.12-beta
steps:
- name: Clone repository
uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ doc/api/
.vscode/

**/*.iml

**/test/**/*.mocks.dart
14 changes: 7 additions & 7 deletions cats/lib/src/cat_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CatBuilder {
Scenario buildScenario(File file, Directory folder) {
var doc = loadYaml(
file.readAsStringSync(),
sourceUrl: file.path,
sourceUrl: Uri.parse(file.path),
);

var schema;
Expand Down Expand Up @@ -67,7 +67,7 @@ class CatBuilder {
);
}

Iterable<TestCase> buildTests(YamlNode node, Directory folder) {
Iterable<TestCase>? buildTests(YamlNode? node, Directory folder) {
if (node is YamlList) {
return node.map((n) => buildTest(n, folder));
}
Expand Down Expand Up @@ -110,7 +110,7 @@ class CatBuilder {
);
}

Action buildAction(YamlMap node) {
Action? buildAction(YamlMap node) {
if (node.containsKey('parse')) {
return ParsingAction();
}
Expand All @@ -135,7 +135,7 @@ class CatBuilder {
return null;
}

Iterable<Assertion> buildAssertions(YamlNode node) {
Iterable<Assertion?>? buildAssertions(YamlNode? node) {
if (node is YamlList) {
return node.map((n) => buildAssertion(n));
}
Expand All @@ -147,17 +147,17 @@ class CatBuilder {
return null;
}

Assertion buildAssertion(YamlNode node) {
Assertion? buildAssertion(YamlNode? node) {
if (node is YamlMap) {
if (node.containsKey('passes')) {
return PassesAssertion(
passes: node['passes'] as bool,
passes: node['passes'] as bool?,
);
}

if (node.containsKey('syntax-error')) {
return SyntaxErrorAssertion(
syntaxError: node['syntax-error'] as bool,
syntaxError: node['syntax-error'] as bool?,
);
}

Expand Down
82 changes: 41 additions & 41 deletions cats/lib/src/cat_model.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Suite {
Iterable<Scenario> scenarios;
Iterable<Scenario>? scenarios;

Map<String, ErrorDefinition> errorMapping;
Map<String, ErrorDefinition>? errorMapping;

Suite({
this.scenarios,
Expand All @@ -10,15 +10,15 @@ class Suite {
}

class Scenario {
String folder;
String file;
String? folder;
String? file;

String name;
String? name;

String schema;
Map<String, dynamic> testData;
String? schema;
Map<String, dynamic>? testData;

Iterable<TestCase> tests;
Iterable<TestCase>? tests;

Scenario({
this.folder,
Expand All @@ -31,19 +31,19 @@ class Scenario {
}

class TestCase {
String name;
String? name;

String query;
String schema;
Map<String, dynamic> testData;
String? schema;
Map<String, dynamic>? testData;

Action action;
Action? action;

Iterable<Assertion> assertions;
Iterable<Assertion?>? assertions;

TestCase({
this.name,
this.query,
required this.query,
this.schema,
this.testData,
this.action,
Expand All @@ -56,16 +56,16 @@ abstract class Action {}
class ParsingAction extends Action {}

class ValidationAction extends Action {
Iterable<String> validationRules;
Iterable<String?> validationRules;

ValidationAction(this.validationRules);
}

class ExecutionAction extends Action {
String operationName;
Map<String, dynamic> variables;
bool validateQuery;
String testValue;
String? operationName;
Map<String, dynamic>? variables;
bool? validateQuery;
String? testValue;

ExecutionAction({
this.operationName,
Expand All @@ -78,37 +78,37 @@ class ExecutionAction extends Action {
abstract class Assertion {}

class PassesAssertion extends Assertion {
bool passes;
bool? passes;

PassesAssertion({
this.passes,
});
}

class SyntaxErrorAssertion extends Assertion {
bool syntaxError;
bool? syntaxError;

SyntaxErrorAssertion({
this.syntaxError,
});
}

class DataAssertion extends Assertion {
Map<String, dynamic> data;
Map<String, dynamic>? data;
}

class ErrorCountAssertion extends Assertion {
int count;
int? count;

ErrorCountAssertion({
this.count,
});
}

class ErrorCodeAssertion extends Assertion {
String errorCode;
Map<String, String> args;
Iterable<Location> locations;
String? errorCode;
Map<String, String>? args;
Iterable<Location>? locations;

ErrorCodeAssertion({
this.errorCode,
Expand All @@ -118,38 +118,38 @@ class ErrorCodeAssertion extends Assertion {
}

class ErrorContainsAssertion extends Assertion {
String error;
Iterable<Location> locations;
String? error;
Iterable<Location>? locations;
}

class ErrorRegexAssertion extends Assertion {
String errorRegex;
Iterable<Location> locations;
String? errorRegex;
Iterable<Location>? locations;
}

class ExecutionExceptionContainsAssertion extends Assertion {
String exception;
String? exception;
}

class ExecutionExceptionRegexAssertion extends Assertion {
String errorRegex;
String? errorRegex;
}

class Location {
int line;
int column;
int? line;
int? column;
}

class ErrorDefinition {
String message;
String specReference;
String implementationReference;
String? message;
String? specReference;
String? implementationReference;
}

class DriverError {
String code;
String message;
Location location;
String? code;
String? message;
Location? location;

DriverError({
this.code,
Expand All @@ -159,5 +159,5 @@ class DriverError {
}

class DriverException {
String message;
String? message;
}
Loading