diff --git a/.config/dictionaries/project.dic b/.config/dictionaries/project.dic index 5c1a1709e..4f507faa1 100644 --- a/.config/dictionaries/project.dic +++ b/.config/dictionaries/project.dic @@ -68,6 +68,7 @@ penwidth pkeyopt pkgs projectcatalyst +pubspec pubout pymdownx PYTHONDONTWRITEBYTECODE diff --git a/docs/src/guides/languages/flutter.md b/docs/src/guides/languages/flutter.md index b9acb4f50..819e91152 100644 --- a/docs/src/guides/languages/flutter.md +++ b/docs/src/guides/languages/flutter.md @@ -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 @@ -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). @@ -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 diff --git a/earthly/flutter/Earthfile b/earthly/flutter/Earthfile index 78ab62f93..c662cd812 100644 --- a/earthly/flutter/Earthfile +++ b/earthly/flutter/Earthfile @@ -3,7 +3,6 @@ VERSION 0.8 IMPORT ./installer AS installer # Installs flutter. - install-flutter: FROM scratch ARG version=3.22.1 @@ -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 @@ -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 diff --git a/earthly/flutter/license_checker.yaml b/earthly/flutter/license_checker.yaml new file mode 100644 index 000000000..f84f7d1ad --- /dev/null +++ b/earthly/flutter/license_checker.yaml @@ -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 diff --git a/examples/flutter/example/Earthfile b/examples/flutter/example/Earthfile index 50c5653e4..5a9c483df 100644 --- a/examples/flutter/example/Earthfile +++ b/examples/flutter/example/Earthfile @@ -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 \ No newline at end of file diff --git a/examples/flutter/example/license_checker.yaml b/examples/flutter/example/license_checker.yaml new file mode 100644 index 000000000..f84f7d1ad --- /dev/null +++ b/examples/flutter/example/license_checker.yaml @@ -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