Skip to content

Commit cff04ca

Browse files
JohnWeidnerclaude
andcommitted
fix: license_check failed on flutter pkgs
Closes #297 Allow callers to specify a `flutter_version` or `dart_sdk` to control which SDK is used for dependency resolution. When `flutter_version` is provided, the workflow installs Flutter and uses `flutter pub get`. Otherwise it defaults to the stable Dart SDK with `dart pub get`. - Add `flutter_version` input to license_check workflow - Route SDK setup and dependency install based on input - Warn when both `flutter_version` and `dart_sdk` are specified - Show notice when neither is specified, suggesting `flutter_version` for Flutter projects - Add CI jobs covering all four input combinations - Update docs site to document the new input Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6ec6b7a commit cff04ca

File tree

3 files changed

+80
-8
lines changed

3 files changed

+80
-8
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
with:
4747
modified_files_only: false
4848

49-
verify-license-check:
49+
verify-license-check-no-sdk:
5050
uses: ./.github/workflows/license_check.yml
5151
with:
5252
working_directory: examples/dart_package
@@ -55,6 +55,31 @@ jobs:
5555
forbidden: "unknown"
5656
skip_packages: "very_good_analysis"
5757

58+
verify-license-check-dart-only:
59+
uses: ./.github/workflows/license_check.yml
60+
with:
61+
working_directory: examples/dart_package
62+
dart_sdk: "stable"
63+
dependency_type: "direct-dev"
64+
allowed: ""
65+
forbidden: "unknown"
66+
skip_packages: "very_good_analysis"
67+
68+
verify-license-check-flutter-only:
69+
uses: ./.github/workflows/license_check.yml
70+
with:
71+
working_directory: examples/flutter_package
72+
flutter_version: "3.41.x"
73+
allowed: "MIT,BSD-3-Clause,BSD-2-Clause,Apache-2.0,Zlib"
74+
75+
verify-license-check-both:
76+
uses: ./.github/workflows/license_check.yml
77+
with:
78+
working_directory: examples/flutter_package
79+
flutter_version: "3.41.x"
80+
dart_sdk: "stable"
81+
allowed: "MIT,BSD-3-Clause,BSD-2-Clause,Apache-2.0,Zlib"
82+
5883
build:
5984
needs:
6085
[
@@ -64,7 +89,10 @@ jobs:
6489
verify-pana-flutter,
6590
verify-semantic-pull-request,
6691
verify-spell-check,
67-
verify-license-check,
92+
verify-license-check-no-sdk,
93+
verify-license-check-dart-only,
94+
verify-license-check-flutter-only,
95+
verify-license-check-both,
6896
]
6997

7098
runs-on: ubuntu-latest

.github/workflows/license_check.yml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ on:
1212
type: string
1313
default: "ubuntu-latest"
1414
dart_sdk:
15+
description: 'Dart SDK to use when no flutter_version is specified'
16+
required: false
17+
type: string
18+
flutter_version:
19+
description: 'Flutter SDK version to use'
1520
required: false
1621
type: string
17-
default: "stable"
1822
allowed:
1923
required: false
2024
type: string
@@ -46,15 +50,43 @@ jobs:
4650
working-directory: ${{inputs.working_directory}}
4751

4852
runs-on: ${{inputs.runs_on}}
53+
env:
54+
USE_FLUTTER: ${{ inputs.flutter_version != '' }}
55+
USE_DART: ${{ inputs.flutter_version == '' }}
56+
SHOW_DART_FLUTTER_WARNING: ${{ inputs.flutter_version != '' && inputs.dart_sdk != '' }}
57+
NO_SDK_SPECIFIED: ${{ inputs.flutter_version == '' && inputs.dart_sdk == '' }}
4958

5059
steps:
5160
- name: 📚 Git Checkout
5261
uses: actions/checkout@v6
5362

54-
- name: 🎯 Setup Dart
63+
- name: ℹ️ No SDK specified
64+
if: ${{ env.NO_SDK_SPECIFIED == 'true' }}
65+
run: echo "::notice::No 'flutter_version' or 'dart_sdk' was specified. Defaulting to the stable Dart SDK. If this is a Flutter project, specify 'flutter_version' to use 'flutter pub get' for dependency resolution."
66+
67+
- name: Show warning if conflicting SDK inputs
68+
if: ${{ env.SHOW_DART_FLUTTER_WARNING == 'true' }}
69+
run: echo "::warning::Both 'flutter_version' and 'dart_sdk' were specified. The workflow will proceed with the Flutter SDK setup."
70+
71+
- name: Set Dart SDK Version
72+
if: ${{ env.USE_DART == 'true' }}
73+
id: set_dart_version
74+
run: |
75+
echo "dart_sdk_version=${{ inputs.dart_sdk || 'stable' }}" >> $GITHUB_OUTPUT
76+
77+
- name: 🦋Set up Flutter
78+
if: ${{ env.USE_FLUTTER == 'true' }}
79+
uses: subosito/flutter-action@v2
80+
with:
81+
flutter-version: ${{inputs.flutter_version}}
82+
cache: true
83+
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
84+
85+
- name: 🎯 Set up Dart
86+
if: ${{ env.USE_DART == 'true' }}
5587
uses: dart-lang/setup-dart@v1
5688
with:
57-
sdk: ${{inputs.dart_sdk}}
89+
sdk: ${{steps.set_dart_version.outputs.dart_sdk_version}}
5890

5991
- name: 🤫 Set SSH Key
6092
env:
@@ -64,7 +96,12 @@ jobs:
6496
with:
6597
ssh-private-key: ${{secrets.ssh_key}}
6698

67-
- name: 📦 Install Dependencies
99+
- name: 📦 Install Dependencies for Flutter
100+
if: ${{ env.USE_FLUTTER == 'true' }}
101+
run: flutter pub get --no-example
102+
103+
- name: 📦 Install Dependencies for Dart
104+
if: ${{ env.USE_DART == 'true' }}
68105
run: dart pub get --no-example
69106

70107
- name: 👨‍⚖️ Check licenses

site/docs/workflows/license_check.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@ The License Check workflow consists of the following steps:
3535

3636
### `dart_sdk`
3737

38-
**Optional** Which Dart SDK version to use. It can be a version (e.g. `3.5.0`) or a channel (e.g. `stable`):
38+
**Optional** Which Dart SDK version to use. It can be a version (e.g. `3.5.0`) or a channel (e.g. `stable`). This parameter is ignored if a flutter_version is specified.
3939

4040
**Default** `"stable"`
4141

42+
### `flutter_version`
43+
44+
**Optional** Which Flutter SDK version to use.
45+
46+
**Default** `""`
47+
4248
### `allowed`
4349

4450
**Optional** Only allow the use of certain licenses. The expected format is a comma-separated list.
@@ -104,7 +110,8 @@ jobs:
104110
license_check:
105111
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/license_check.yml@v1
106112
with:
107-
allowed: 'MIT,BSD-3-Clause,BSD-2-Clause,Apache-2.0'
113+
flutter_version: '3.32.0'
114+
allowed: 'MIT,BSD-3-Clause,BSD-2-Clause,Apache-2.0,Zlib'
108115
```
109116
110117
The example [workflow file](https://docs.github.com/en/actions/quickstart#creating-your-first-workflow) will [trigger](https://docs.github.com/en/actions/using-workflows/triggering-a-workflow) the `license_check` job on every push to the `main` branch and on every pull request that modifies the `pubspec.yaml` or the `license_check.yaml` workflow file.

0 commit comments

Comments
 (0)