Skip to content

Commit b761664

Browse files
authored
Merge pull request #194 from gql-dart/nullsafety
Null Safety
2 parents d3780d5 + a1728dc commit b761664

File tree

268 files changed

+13517
-12607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+13517
-12607
lines changed

.github/check_package.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#/bin/bash
2+
3+
# NOTE:
4+
# This is a temporary utility script to help mitigate the need for github action
5+
# troubleshooting, and will be deleted either pre-merge or when melos replaces it
6+
# (https://github.com/gql-dart/gql/pull/192)
7+
8+
set -e
9+
10+
PACKAGE=$1
11+
12+
git diff --exit-code
13+
14+
clean_up () {
15+
ARG=$?
16+
git checkout .
17+
exit $ARG
18+
}
19+
20+
trap clean_up EXIT
21+
22+
# Check pubspec
23+
multipack --only $PACKAGE pubspec clean
24+
multipack --only $PACKAGE exec git diff --exit-code pubspec.yaml
25+
26+
# Override local dependencies
27+
multipack pubspec hard_override
28+
29+
multipack --only $PACKAGE pub get
30+
31+
# Check formatting
32+
echo ""
33+
echo "A list of incorrectly formatted files may follow:"
34+
echo ""
35+
multipack --only $PACKAGE fmt -n . --set-exit-if-changed
36+
echo ""
37+
38+
# Analyze package
39+
multipack --only $PACKAGE analyze --version
40+
multipack --only $PACKAGE analyze --fatal-warnings --no-hints .
41+
42+
# Run tests
43+
# mockito requires build runner now
44+
multipack --only $PACKAGE pub run build_runner build --delete-conflicting-outputs || true
45+
multipack --only $PACKAGE exec [ -d ./test ] || exit 0
46+
multipack --only $PACKAGE pub run test
47+
48+
git checkout .

.github/workflows/dart.yml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on: pull_request
44
jobs:
55
packages:
66
strategy:
7+
fail-fast: false
78
matrix:
89
package:
910
- gql
@@ -16,13 +17,11 @@ jobs:
1617
- gql_error_link
1718
- gql_http_link
1819
- gql_websocket_link
19-
- gql_link
2020
- gql_transform_link
2121
- cats
22-
- gql_example_http_auth_link
2322
runs-on: ubuntu-latest
2423
container:
25-
image: google/dart:latest
24+
image: google/dart
2625
name: Check ${{ matrix.package }}
2726
env:
2827
PACKAGE: ${{ matrix.package }}
@@ -50,24 +49,32 @@ jobs:
5049
echo ""
5150
multipack --only $PACKAGE fmt -n . --set-exit-if-changed
5251
echo ""
52+
- name: Run build_runner if necessary
53+
run: |
54+
multipack --only $PACKAGE pub run \
55+
build_runner build --delete-conflicting-outputs || true
5356
- name: Analyze package
5457
run: |
5558
multipack --only $PACKAGE analyze --version
5659
multipack --only $PACKAGE analyze --fatal-warnings --no-hints .
5760
- name: Run tests
5861
run: |
59-
multipack --only $PACKAGE exec [ ! -d ./test ] && exit 0
62+
multipack --only $PACKAGE exec [ -d ./test ] || exit 0
6063
multipack --only $PACKAGE pub run test
6164
examples:
6265
strategy:
66+
fail-fast: false
6367
matrix:
6468
package:
6569
- gql_example_cli
6670
- gql_example_cli_github
6771
- gql_example_build
72+
- gql_example_http_auth_link
73+
- gql_example_dio_link
74+
# gql_example_flutter would require flutter
6875
runs-on: ubuntu-latest
6976
container:
70-
image: google/dart:latest
77+
image: google/dart
7178
name: Check ${{ matrix.package }}
7279
env:
7380
PACKAGE: ${{ matrix.package }}
@@ -90,7 +97,8 @@ jobs:
9097
multipack --only $PACKAGE pub get
9198
- name: Run builders
9299
run: |
93-
multipack --only $PACKAGE pub run build_runner build --delete-conflicting-outputs
100+
multipack --only $PACKAGE pub run \
101+
build_runner build --delete-conflicting-outputs || true
94102
- name: Check build diff
95103
run: |
96104
multipack --only $PACKAGE exec git diff --exit-code **/*.gql.dart
@@ -112,7 +120,7 @@ jobs:
112120
- end_to_end_test
113121
runs-on: ubuntu-latest
114122
container:
115-
image: google/dart:latest
123+
image: google/dart
116124
name: Check ${{ matrix.package }}
117125
env:
118126
PACKAGE: ${{ matrix.package }}
@@ -152,13 +160,13 @@ jobs:
152160
multipack --only $PACKAGE analyze --fatal-warnings --no-hints .
153161
- name: Run tests
154162
run: |
155-
multipack --only $PACKAGE exec [ ! -d ./test ] && exit 0
163+
multipack --only $PACKAGE exec [ -d ./test ] || exit 0
156164
multipack --only $PACKAGE pub run test
157165
158166
publish_dry_run:
159167
runs-on: ubuntu-latest
160168
container:
161-
image: google/dart:latest
169+
image: google/dart
162170
env:
163171
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'
164172
PUB_ACCESS_TOKEN: ${{ secrets.PUB_ACCESS_TOKEN }}
@@ -177,13 +185,26 @@ jobs:
177185
run: |
178186
multipack --only $PACKAGES pubspec sync-versions
179187
- name: Publish packages
188+
shell: bash
189+
continue-on-error: true
180190
run: |
181191
echo "{\"accessToken\":\"$PUB_ACCESS_TOKEN\",\"refreshToken\":\"$PUB_REFRESH_TOKEN\",\"idToken\":null,\"tokenEndpoint\":\"https://accounts.google.com/o/oauth2/token\",\"scopes\":[\"openid\",\"https://www.googleapis.com/auth/userinfo.email\"],\"expiration\":1588334512218}" > $HOME/.pub-cache/credentials.json
182-
multipack --only $PACKAGES pub publish --dry-run
192+
193+
## BEGIN TEMPORARY WORKAROUND FOR https://github.com/google/built_value.dart/issues/1032
194+
## See dry_run_workaround_helpers.sh for more details
195+
source .github/workflows/dry_run_workaround_helpers.sh
196+
197+
multipack --only $PACKAGES exec 'pub publish --dry-run 2>&1' | cap
198+
199+
ignore_err_when_stdout_contains \
200+
'Publishing gql_build' \
201+
'Package has 1 warning' \
202+
'package:built_value_generator/built_value_generator.dart is opting out of null safety' \
203+
183204
check_svg:
184205
runs-on: ubuntu-latest
185206
container:
186-
image: google/dart:latest
207+
image: google/dart
187208
steps:
188209
- name: Clone repository
189210
uses: actions/checkout@v2
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
##
4+
## TEMPORARY WORKAROUND HELPERS FOR https://github.com/google/built_value.dart/issues/1032
5+
##
6+
## once built_value_generator is implemented nullsafe this can be deleted
7+
## and the workflow can be reset to just:
8+
## `multipack --only $PACKAGES pub publish --dry-run`
9+
##
10+
11+
# capture the output of a command so it can be retrieved with ret
12+
cap () { tee /tmp/capture.out; }
13+
14+
# return the output of the most recent command that was captured by cap
15+
ret () { cat /tmp/capture.out; }
16+
17+
# ignore err when stdout contains all of the given strings
18+
ignore_err_when_stdout_contains() {
19+
code=$?
20+
if [[ "$code" == "0" ]]; then
21+
return 0
22+
fi
23+
output=`ret`
24+
for search in $@
25+
do
26+
if [[ "$output" != *"$search"* ]]; then
27+
return $code
28+
fi
29+
done
30+
}
31+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ doc/api/
1515
.vscode/
1616

1717
**/*.iml
18+
19+
**/test/**/*.mocks.dart

cats/lib/src/cat_builder.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class CatBuilder {
6767
);
6868
}
6969

70-
Iterable<TestCase> buildTests(YamlNode node, Directory folder) {
70+
Iterable<TestCase>? buildTests(YamlNode? node, Directory folder) {
7171
if (node is YamlList) {
7272
return node.map((n) => buildTest(n, folder));
7373
}
@@ -110,7 +110,7 @@ class CatBuilder {
110110
);
111111
}
112112

113-
Action buildAction(YamlMap node) {
113+
Action? buildAction(YamlMap node) {
114114
if (node.containsKey('parse')) {
115115
return ParsingAction();
116116
}
@@ -135,7 +135,7 @@ class CatBuilder {
135135
return null;
136136
}
137137

138-
Iterable<Assertion> buildAssertions(YamlNode node) {
138+
Iterable<Assertion?>? buildAssertions(YamlNode? node) {
139139
if (node is YamlList) {
140140
return node.map((n) => buildAssertion(n));
141141
}
@@ -147,17 +147,17 @@ class CatBuilder {
147147
return null;
148148
}
149149

150-
Assertion buildAssertion(YamlNode node) {
150+
Assertion? buildAssertion(YamlNode? node) {
151151
if (node is YamlMap) {
152152
if (node.containsKey('passes')) {
153153
return PassesAssertion(
154-
passes: node['passes'] as bool,
154+
passes: node['passes'] as bool?,
155155
);
156156
}
157157

158158
if (node.containsKey('syntax-error')) {
159159
return SyntaxErrorAssertion(
160-
syntaxError: node['syntax-error'] as bool,
160+
syntaxError: node['syntax-error'] as bool?,
161161
);
162162
}
163163

0 commit comments

Comments
 (0)