Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 30 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
with:
modified_files_only: false

verify-license-check:
verify-license-check-no-sdk:
uses: ./.github/workflows/license_check.yml
with:
working_directory: examples/dart_package
Expand All @@ -55,6 +55,31 @@ jobs:
forbidden: "unknown"
skip_packages: "very_good_analysis"

verify-license-check-dart-only:
uses: ./.github/workflows/license_check.yml
with:
working_directory: examples/dart_package
dart_sdk: "stable"
dependency_type: "direct-dev"
allowed: ""
forbidden: "unknown"
skip_packages: "very_good_analysis"

verify-license-check-flutter-only:
uses: ./.github/workflows/license_check.yml
with:
working_directory: examples/flutter_package
flutter_version: "3.41.x"
allowed: "MIT,BSD-3-Clause,BSD-2-Clause,Apache-2.0,Zlib"

verify-license-check-both:
uses: ./.github/workflows/license_check.yml
with:
working_directory: examples/flutter_package
flutter_version: "3.41.x"
dart_sdk: "stable"
allowed: "MIT,BSD-3-Clause,BSD-2-Clause,Apache-2.0,Zlib"

build:
needs:
[
Expand All @@ -64,7 +89,10 @@ jobs:
verify-pana-flutter,
verify-semantic-pull-request,
verify-spell-check,
verify-license-check,
verify-license-check-no-sdk,
verify-license-check-dart-only,
verify-license-check-flutter-only,
verify-license-check-both,
]

runs-on: ubuntu-latest
Expand Down
45 changes: 41 additions & 4 deletions .github/workflows/license_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ on:
type: string
default: "ubuntu-latest"
dart_sdk:
description: 'Dart SDK to use when no flutter_version is specified'
required: false
type: string
flutter_version:
description: 'Flutter SDK version to use'
required: false
type: string
default: "stable"
allowed:
required: false
type: string
Expand Down Expand Up @@ -46,15 +50,43 @@ jobs:
working-directory: ${{inputs.working_directory}}

runs-on: ${{inputs.runs_on}}
env:
USE_FLUTTER: ${{ inputs.flutter_version != '' }}
USE_DART: ${{ inputs.flutter_version == '' }}
SHOW_DART_FLUTTER_WARNING: ${{ inputs.flutter_version != '' && inputs.dart_sdk != '' }}
NO_SDK_SPECIFIED: ${{ inputs.flutter_version == '' && inputs.dart_sdk == '' }}

steps:
- name: 📚 Git Checkout
uses: actions/checkout@v6

- name: 🎯 Setup Dart
- name: ℹ️ No SDK specified
if: ${{ env.NO_SDK_SPECIFIED == 'true' }}
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."

- name: Show warning if conflicting SDK inputs
if: ${{ env.SHOW_DART_FLUTTER_WARNING == 'true' }}
run: echo "::warning::Both 'flutter_version' and 'dart_sdk' were specified. The workflow will proceed with the Flutter SDK setup."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also validate when none were specified right?


- name: Set Dart SDK Version
if: ${{ env.USE_DART == 'true' }}
id: set_dart_version
run: |
echo "dart_sdk_version=${{ inputs.dart_sdk || 'stable' }}" >> $GITHUB_OUTPUT

- name: 🦋Set up Flutter
if: ${{ env.USE_FLUTTER == 'true' }}
uses: subosito/flutter-action@v2
with:
flutter-version: ${{inputs.flutter_version}}
cache: true
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}

- name: 🎯 Set up Dart
if: ${{ env.USE_DART == 'true' }}
uses: dart-lang/setup-dart@v1
with:
sdk: ${{inputs.dart_sdk}}
sdk: ${{steps.set_dart_version.outputs.dart_sdk_version}}

- name: 🤫 Set SSH Key
env:
Expand All @@ -64,7 +96,12 @@ jobs:
with:
ssh-private-key: ${{secrets.ssh_key}}

- name: 📦 Install Dependencies
- name: 📦 Install Dependencies for Flutter
if: ${{ env.USE_FLUTTER == 'true' }}
run: flutter pub get --no-example

- name: 📦 Install Dependencies for Dart
if: ${{ env.USE_DART == 'true' }}
run: dart pub get --no-example

- name: 👨‍⚖️ Check licenses
Expand Down
11 changes: 9 additions & 2 deletions site/docs/workflows/license_check.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ The License Check workflow consists of the following steps:

### `dart_sdk`

**Optional** Which Dart SDK version to use. It can be a version (e.g. `3.5.0`) or a channel (e.g. `stable`):
**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.

**Default** `"stable"`

### `flutter_version`

**Optional** Which Flutter SDK version to use.

**Default** `""`

### `allowed`

**Optional** Only allow the use of certain licenses. The expected format is a comma-separated list.
Expand Down Expand Up @@ -104,7 +110,8 @@ jobs:
license_check:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/license_check.yml@v1
with:
allowed: 'MIT,BSD-3-Clause,BSD-2-Clause,Apache-2.0'
flutter_version: '3.32.0'
allowed: 'MIT,BSD-3-Clause,BSD-2-Clause,Apache-2.0,Zlib'
```

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.
Expand Down
Loading