GitHub Actionsを使ってCI/CDを構築していく。初めてなのでGitHubのQuickstartページを参考に試してみる。コードのLintを実行するSuper-Linterというフローを追加する内容になっている。
まずはsuperlinter.ymlファイルを.github/workslowsディレクトリに作成。

“Propose new file” でPull Requestを作成

何個かエラーが出ているようだけど、ひとまずプルリクをマージ。

これでGitHub Actionsが有効になったはずなので、適当に別のプルリクを作ってみると、Super-Linterのチェックが自動で走っているのが分かる。

ただやはり何個かエラーが発生している模様。これがlintのエラーなのか別の何かのエラーなの確認が必要。そして結構時間がかかる。3分程かかっている。

余計なところまでlintが行われているようなので、superlinterのREADMEを見ながらKotlinだけをLint対象とするようにymlファイルを変更してみる。
################################
# Run Linter against code base #
################################
- name: Lint Code Base
uses: github/super-linter@v3
env:
VALIDATE_KOTLIN: true
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GitHub上のActionsタブからプルリクを選んで”Re-run jobs”で再度GitHub Actionを実行してみる。

ひとまずKotlinだけLintされるようになったので、Detailsのリンクで出力されているコンソールのエラー内容を確認しながら修正してコミットをPush。
再度Lintが行われて“All checks have passed”となった。

pushとpull_requestの2回superlintが走っているようなので、pushの時だけ実行されるように修正。
on: push
# on:
# push:
# branches-ignore: [master]
# # Remove the line above to run when pushing to master
# pull_request:
# branches: [master]
コメントを残す