Flutterプロジェクトのpubパッケージに対してGitHub Dependabotを使ってみた

2022.05.11

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

こんにちは、CX事業本部 IoT事業部の若槻です。

先月にGitHub Dependabotがpubパッケージのベータサポートを開始したとのことです。

そこで今回は、Flutterプロジェクトのpubパッケージに対してGitHub Dependabotを使ってみました。

※なお、Dependabotのpubサポートでは、ベータのためsecurity updatesをサポートしていないとのことです。

Support for pub is in beta, and thus, we are aware of some limitations. For example, security updates are not supported in this release but will be in the future.

この辺りも含めて動作を見てみたいと思います。

やってみる

準備

Flutterプロジェクトを作成します。

$ flutter create .

プロジェクト内にDependabot config fileを作成します。

$ mkdir .github
$ touch .github/dependabot.yml

Dependabot config fileを次のように記載します。package-ecosystem: "pub"を指定します。またpubはベータサポートなので、enable-beta-ecosystemstrueを指定します。

.github/dependabot.yml

version: 2
enable-beta-ecosystems: true
updates:
  - package-ecosystem: "pub"
    directory: "/"
    schedule:
      interval: "weekly"

GitHubにPushすると、GitHub上でpubに対してDependabotのチェックが開始されます。

チェックが完了しました。

pubspec.yamlpubspec.lockが監視対象となっています。

次に[Dependencies]でDependency Graphを有効化してみます。

しかし、有効化をしてもNo manifest files foundとなりDependency Graphは表示されませんでした。どうやらベータのパッケージではDependency Graphが使用できないようです。

ちなみに[Code security and analysis]を見るとこの時点で[Dependency graph]および[Dependabot alerts]は有効化されていました。

Dependabot Version Updatesの動作

まずDependabot Version Updatesの動作を確認してみます。これはベータでもサポートされているはずです。

pubspec.lockを編集して、パッケージcupertino_iconsを最新より古いバージョンに変更します。

pubspec.lock

  cupertino_icons:
    dependency: "direct main"
    description:
      name: cupertino_icons
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.0"
-     version: "1.0.4"
+     version: "1.0.0"

上記変更をGitHubにPushし、Dependabotのチェックを開始します。

しばらくしてチェックが完了すると、Dependabot Version Updatesによりcupertino_iconsをアップデートするためのPull Requestが作成されました!

Pull Requestの内容はこんな感じです。

Dependabot alertsの動作

次にDependabot alertsの動作を確認してみます。security updatesをサポートしていないとのことでしたが、どうなるでしょうか。

firebase_messagingのNull safetyをサポートしていないバージョンを導入します。

pubspec.lockを編集します。

pubspec.lock

  firebase_messaging: ^7.0.3

変更をPushしてDependabotのチェックを実施しましたが、alertは作成されませんでした。

どうやらDependabot security updatesだけでなくDependabot alertsもサポート外のようです。

まとめ

  • Dependabotではpubパッケージはベータサポート(2022年5月現在)
  • Dependabot Version Updatesは利用可能。
  • Dependabot Graphは表示されない。
  • Dependabot alertsおよびDependabot security updatesは利用不可。

pubにはnpm-auditのようなコマンド実行で脆弱性を監視できるツールも無いので、Dependabotでの早期の正式サポートが望まれますね。

以上