Skip to content

Commit 2a59797

Browse files
committed
Support analyzer 13 in gql codegen
1 parent 5d2850d commit 2a59797

5 files changed

Lines changed: 86 additions & 3 deletions

File tree

.github/workflows/dart.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,26 @@ jobs:
151151
run: melos analyze --scope $PACKAGE --fatal-warnings
152152

153153
- name: Run tests
154-
run: melos exec --scope $PACKAGE --dir-exists=test -- dart test
154+
run: melos exec --scope $PACKAGE --dir-exists=test -- dart test
155+
156+
min_dependencies:
157+
runs-on: ubuntu-latest
158+
container:
159+
image: dart:latest
160+
name: Verify minimum dependencies
161+
steps:
162+
- name: Configure Git for safe directory
163+
run: |
164+
git config --global --add safe.directory /__w/gql/gql
165+
git config --global --add safe.directory /__w/gql
166+
167+
- name: Checkout repository
168+
uses: actions/checkout@v4
169+
170+
- name: Install Melos
171+
run: |
172+
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
173+
dart pub global activate melos && dart pub get
174+
175+
- name: Verify minimum dependencies
176+
run: melos run verify-min-dependencies

codegen/gql_build/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repository: https://github.com/gql-dart/gql
55
environment:
66
sdk: '>=3.0.0 <4.0.0'
77
dependencies:
8-
analyzer: '>=9.0.0 <11.0.0'
8+
analyzer: '>=9.0.0 <14.0.0'
99
build: ^4.0.0
1010
built_collection: ^5.0.0
1111
built_value: ^8.0.6

codegen/gql_code_builder/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repository: https://github.com/gql-dart/gql
55
environment:
66
sdk: '>=3.0.0 <4.0.0'
77
dependencies:
8-
analyzer: '>=9.0.0 <11.0.0'
8+
analyzer: '>=9.0.0 <14.0.0'
99
built_collection: ^5.0.0
1010
built_value: ^8.0.6
1111
code_builder: ^4.7.0
@@ -16,6 +16,7 @@ dependencies:
1616
gql_tristate_value: ^1.1.0
1717
gql_code_builder_serializers: ^0.1.0+1
1818
dev_dependencies:
19+
frontend_server_client: ^4.0.0
1920
gql_pedantic: ^1.2.0
2021
test: ^1.16.8
2122
topics:

melos.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ scripts:
6464
packageFilters:
6565
dependsOn: build_runner
6666

67+
verify-min-dependencies:
68+
run: ./tool/verify_min_dependencies.sh
69+
description: Verify gql codegen packages against minimum supported dependency versions
70+
6771
bump-alpha:
6872
description: Bump all packages to next alpha version
6973
run: |

tool/verify_min_dependencies.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
work_dir="$(mktemp -d)"
6+
trap 'rm -rf "$work_dir"' EXIT
7+
8+
copy_package() {
9+
local package_path="$1"
10+
local package_name="$2"
11+
12+
cp -R "$repo_root/$package_path" "$work_dir/$package_name"
13+
rm -rf "$work_dir/$package_name/.dart_tool"
14+
rm -f "$work_dir/$package_name/pubspec_overrides.yaml"
15+
rm -f "$work_dir/$package_name/pubspec.lock"
16+
}
17+
18+
resolved_package_version() {
19+
local package_name="$1"
20+
local deps_output
21+
22+
deps_output="$(dart pub deps --style=list)"
23+
awk -v package_name="$package_name" '$2 == package_name {print $3; exit}' <<<"$deps_output"
24+
}
25+
26+
verify_package() {
27+
local package_dir="$1"
28+
local package_name="$2"
29+
30+
echo "Verifying $package_name with downgraded dependencies"
31+
(
32+
cd "$package_dir"
33+
dart pub downgrade
34+
35+
local analyzer_version
36+
analyzer_version="$(resolved_package_version analyzer)"
37+
echo "$package_name resolved analyzer $analyzer_version"
38+
39+
dart analyze --fatal-warnings
40+
41+
if [ -d test ]; then
42+
dart test
43+
fi
44+
)
45+
}
46+
47+
copy_package "codegen/gql_code_builder" "gql_code_builder"
48+
copy_package "codegen/gql_build" "gql_build"
49+
50+
perl -0pi -e 's/ gql_code_builder: \^[^\n]+/ gql_code_builder:\n path: ..\/gql_code_builder/' \
51+
"$work_dir/gql_build/pubspec.yaml"
52+
perl -0pi -e 's/name: gql_build\n/name: gql_build\npublish_to: none\n/' \
53+
"$work_dir/gql_build/pubspec.yaml"
54+
55+
verify_package "$work_dir/gql_code_builder" "gql_code_builder"
56+
verify_package "$work_dir/gql_build" "gql_build"

0 commit comments

Comments
 (0)