Skip to content
Open
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
43 changes: 38 additions & 5 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,39 @@ 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 != '' }}

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

- name: 🎯 Setup Dart
- 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
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,10 +92,15 @@ 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
run: |
dart pub global activate very_good_cli
dart pub global run very_good_cli:very_good packages check licenses --skip-packages=${{inputs.skip_packages}} --dependency-type=${{inputs.dependency_type}} ${{(inputs.ignore_retrieval_failures && '--ignore-retrieval-failures') || ''}} --allowed=${{inputs.allowed}} --forbidden=${{inputs.forbidden}}
dart pub global run very_good_cli:very_good packages check licenses --skip-packages=${{inputs.skip_packages}} --dependency-type=${{inputs.dependency_type}} ${{(inputs.ignore_retrieval_failures && '--ignore-retrieval-failures') || ''}} --allowed=${{inputs.allowed}} --forbidden=${{inputs.forbidden}}
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