【Github Actions】SonarCloud と連携させる(2019/09/15現在)
概要
- Github Actions(2019/09/15現在のβ版)と SonarCloud を連携させたサンプルを作成する。
- TSLint + Jest実行後に Github Actions上でSonarCloud Scan を実行して、SonarCloud側に保存する。
参考URL
参考過去記事
実行環境
- Github Actions
- SonarCloud
- yarn
使用ライブラリ
- jest - 24.9.x
- ts-jest - 24.0.x
- tslint - 5.20.x
サンプルソース
.github/workflows/ci.yml
name: CI on: [push] jobs: check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: yarn install run: sudo apt-get update && sudo apt-get install yarn - name: package install run: yarn - name: lint run: yarn lint:output - name: test run: yarn test:cov - name: SonarCloudScan uses: sonarsource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
sonar-project.properties
sonar.host.url=https://sonarcloud.io sonar.organization=yasu-s sonar.projectKey=github-actions-and-sonarcloud
- organization/projectKey は各環境ごとの値を設定してください。
SONAR_TOKENについて
- SonarCloudの
MyAccount
->Security
->Generate Tokens
からトークンを発行する。 - Githubの該当リポジトリの
Settings
->Secrets
のAdd a new secret
からSONAR_TOKEN
を登録しておく。
実行結果
https://sonarcloud.io/dashboard?id=github-actions-and-sonarcloud
サンプルソース一式
Github Actionsについて
- 気軽にCIを始めるには簡単なので良いかと思います。
- メトリクス周りをレポート化したい場合は、現状は他のサービスと連携する必要があるのがネックです。
- CIがスロー問題の解決をどうしていこう・・・。Bazelでビルド結果をリモートキャッシュとかを検討した方がいいのかな・・・