GitHub Actionsを使ってCI/CDを構築していく。初めてなのでGitHubのQuickstartページを参考に試してみる。コードのLintを実行するSuper-Linterというフローを追加する内容になっている。
まずはsuperlinter.ymlファイルを.github/workslowsディレクトリに作成。
![](https://littleengineer.jp/wp-content/uploads/2021/02/image-4-1024x365.png)
“Propose new file” でPull Requestを作成
![](https://littleengineer.jp/wp-content/uploads/2021/02/image-5-1024x433.png)
何個かエラーが出ているようだけど、ひとまずプルリクをマージ。
![](https://littleengineer.jp/wp-content/uploads/2021/02/image-6-1024x532.png)
これでGitHub Actionsが有効になったはずなので、適当に別のプルリクを作ってみると、Super-Linterのチェックが自動で走っているのが分かる。
![](https://littleengineer.jp/wp-content/uploads/2021/02/image-7-1024x355.png)
ただやはり何個かエラーが発生している模様。これがlintのエラーなのか別の何かのエラーなの確認が必要。そして結構時間がかかる。3分程かかっている。
![](https://littleengineer.jp/wp-content/uploads/2021/02/image-8-1024x548.png)
余計なところまで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を実行してみる。
![](https://littleengineer.jp/wp-content/uploads/2021/02/image-9-1024x377.png)
ひとまずKotlinだけLintされるようになったので、Detailsのリンクで出力されているコンソールのエラー内容を確認しながら修正してコミットをPush。
再度Lintが行われて“All checks have passed”となった。
![](https://littleengineer.jp/wp-content/uploads/2021/02/image-10-1024x283.png)
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]
コメントを残す