Skip to content

Commit

Permalink
feat: flutter/dart license checker (#248)
Browse files Browse the repository at this point in the history
* feat: update flutter, dart docs

* wip

* feat: add flutter example

* wip

* chore: wip

* feat: add bootstrap

* chore: wip

* chore: wip

* Update Earthfile

* Update Earthfile

* Update Earthfile

* Update Earthfile

* Update Earthfile

* Update Earthfile

* Update Earthfile

* Update Earthfile

* Update Earthfile

* feat: add license checker

* fix: file name

* feat: add sample dart project

* fix: remove unnecessary files

* fix: typo

* feat: add pub get

* chore: update docs

* fix: remove dart example and use flutter instead

* fix: update license checker yaml

* fix: remove dart folder

* feat: add licnese checker in flutter

* Update examples/flutter/example/Earthfile

Co-authored-by: Steven Johnson <stevenj@users.noreply.github.com>

* Update earthly/flutter/Earthfile

Co-authored-by: Steven Johnson <stevenj@users.noreply.github.com>

* chore: update browser scripts

* feat: update example and docs

* feat: add install-flutter

* chore: wip

* wip

* Build fixes (#253)

* fix(cat-ci): ignore build artifacts

* fix(cat-ci): Dont use FROM in Flutter functions because it changes the docker container and setup is lost.

* fix(cat-ci): Use a relative import for flutter-ci, fix doc comments and default the WORKDIR if not set

* chore: update Earthfiles

* Update Earthfile

* Update README.md

* chore: ci fixes

* Update cspell.json

* fix: rewrite browser installer as FUNCTION (#251)

* fix: rewrite flutter sh file as FUNCTION

* fix: delete sh files

* fix: add test host

* fix: chrome installer to specific version

* fix: loop apt

* fix: edge installer to specific version

* fix: firefox installer to specific version

* fix: cleanup installer

* fix: typo

* fix: readme

* fix: typo

* fix: cspell

---------

Co-authored-by: Oleksandr Prokhorenko <djminikin@gmail.com>

* chore: bump flutter version

* fix: move license checker target

* fix: add word dic

* fix: license checker yaml file

* fix: license checker

* fix: cspell

* fix: flutter version

* fix: revert flutter version

* fix: docs

* fix: typo

---------

Co-authored-by: minikin <djminikin@gmail.com>
Co-authored-by: Steven Johnson <stevenj@users.noreply.github.com>
  • Loading branch information
3 people authored May 30, 2024
1 parent b30ce2b commit 17106cf
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 3 deletions.
1 change: 1 addition & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ penwidth
pkeyopt
pkgs
projectcatalyst
pubspec
pubout
pymdownx
PYTHONDONTWRITEBYTECODE
Expand Down
26 changes: 25 additions & 1 deletion docs/src/guides/languages/flutter.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:3.0.3 AS flutter-c
# Set up the CI environment for Flutter app.
builder:
DO flutter-ci+SETUP
COPY --dir . .
```

### Running Bootstrap
Expand Down Expand Up @@ -106,7 +107,7 @@ unit-tests:
DO flutter-ci+UNIT_TEST
```

### Build FLutter app for Web
### Build Flutter app for Web

An finally we build the Flutter app for Web (atm the only supported platform by Catalyst).

Expand All @@ -126,6 +127,29 @@ You can run it like this:
earthly +build-web --WORKDIR=path/to/flutter/app/ --TARGET=lib/main.dart
```

### Running checks

In addition to setting up a Flutter-based project, it is highly recommended to run a check to
ensure the project is clean and well-defined.
The example below illustrates how to implement a
[license_checker](https://pub.dev/packages/license_checker), allowing you to configure the
licenses of dependencies to permit, reject, or approve using the license_checker package.
This configuration can be managed through a `YAML` configuration file.

```Earthfile
check-license:
FROM flutter-ci+license-checker-base
COPY . .
DO flutter-ci+LICENSE_CHECK --license_checker_file=license_checker.yaml
```

To prevent the unintended approval of a package, a template `license_checker.yaml`
is included within the `earthly/flutter/Earthfile`.
This template will be compared with the provided `YAML` file
specified by the `--license_checker_file` argument.
If the files do not match, the program will return an error.

### Release and publish

To prepare a release artifact and publish it to some external container registries
Expand Down
19 changes: 17 additions & 2 deletions earthly/flutter/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ VERSION 0.8
IMPORT ./installer AS installer

# Installs flutter.

install-flutter:
FROM scratch
ARG version=3.22.1
Expand Down Expand Up @@ -35,7 +34,7 @@ flutter-base:
RUN dart pub global activate melos
RUN dart pub global activate junitreport
RUN dart pub global activate coverage

flutter-base-all-hosts:
BUILD --platform=linux/amd64 --platform=linux/arm64 +flutter-base

Expand Down Expand Up @@ -147,3 +146,19 @@ BUILD_WEB:
SAVE ARTIFACT web /web AS LOCAL web
END

license-checker-base:
DO +SETUP
COPY ./license_checker.yaml ./base/license_checker.yaml

LICENSE_CHECK:
FUNCTION

# Argument for the name of license checker config file
ARG license_checker_file="license_checker.yaml"
# Check whether the license config files are the same
RUN diff ${license_checker_file} ./base/license_checker.yaml
# Install license_checker
RUN dart pub global activate license_checker
# Generate pubspec.yaml file
RUN flutter pub get
RUN lic_ck check-licenses --config ${license_checker_file} -i
35 changes: 35 additions & 0 deletions earthly/flutter/license_checker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# cspell: words rxdart

permittedLicenses:
- MIT
- Apache-2.0
- Unicode-DFS-2016
- BSD-3-Clause
- BSD-2-Clause
- BlueOak-1.0.0
- Apache-2.0 WITH LLVM-exception
- CC0-1.0

packageLicenseOverride:
fuchsia_remote_debug_protocol: BSD-3-Clause
flutter_driver: BSD-3-Clause
flutter_localizations: BSD-3-Clause
flutter_test: BSD-3-Clause
flutter_web_plugins: BSD-3-Clause
integration_test: BSD-3-Clause
rxdart: Apache-2.0
vector_math: Apache-2.0
sky_engine: Apache-2.0
flutter_gen: MIT

packageSourceOverride:
fuchsia_remote_debug_protocol: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
flutter_driver: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
flutter_localizations: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
flutter_test: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
flutter_web_plugins: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
integration_test: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
rxdart: https://github.com/ReactiveX/rxdart/blob/0.27.7/LICENSE
vector_math: https://github.com/google/vector_math.dart/blob/v2.1.4/LICENSE
sky_engine: https://github.com/flutter/engine/blob/3.22.0/sky/packages/sky_engine/LICENSE
flutter_gen: https://github.com/FlutterGen/flutter_gen/blob/v5.4.0/LICENSE
7 changes: 7 additions & 0 deletions examples/flutter/example/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@ build-web:
ARG --required TARGET

DO flutter-ci+BUILD_WEB --WORKDIR=$WORKDIR --TARGET=$TARGET

# check-license - Check the licenses of the Flutter dependencies.
check-license:
FROM flutter-ci+license-checker-base

COPY . .
DO flutter-ci+LICENSE_CHECK --license_checker_file=license_checker.yaml
35 changes: 35 additions & 0 deletions examples/flutter/example/license_checker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# cspell: words rxdart

permittedLicenses:
- MIT
- Apache-2.0
- Unicode-DFS-2016
- BSD-3-Clause
- BSD-2-Clause
- BlueOak-1.0.0
- Apache-2.0 WITH LLVM-exception
- CC0-1.0

packageLicenseOverride:
fuchsia_remote_debug_protocol: BSD-3-Clause
flutter_driver: BSD-3-Clause
flutter_localizations: BSD-3-Clause
flutter_test: BSD-3-Clause
flutter_web_plugins: BSD-3-Clause
integration_test: BSD-3-Clause
rxdart: Apache-2.0
vector_math: Apache-2.0
sky_engine: Apache-2.0
flutter_gen: MIT

packageSourceOverride:
fuchsia_remote_debug_protocol: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
flutter_driver: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
flutter_localizations: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
flutter_test: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
flutter_web_plugins: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
integration_test: https://github.com/flutter/flutter/blob/3.19.5/LICENSE
rxdart: https://github.com/ReactiveX/rxdart/blob/0.27.7/LICENSE
vector_math: https://github.com/google/vector_math.dart/blob/v2.1.4/LICENSE
sky_engine: https://github.com/flutter/engine/blob/3.22.0/sky/packages/sky_engine/LICENSE
flutter_gen: https://github.com/FlutterGen/flutter_gen/blob/v5.4.0/LICENSE

0 comments on commit 17106cf

Please sign in to comment.