主な機能
機能 | 概要 |
Pipline | パイプラインの実行時間などが見れる |
Test | ユニットテストなどの結果確認、Flakey Testの管理 |
Code Analysis | コードの静的解析、SBOMの作成 |
事前準備
まずは、MSが提供しているeShopOnWebのリポジトリをクローン or ダウンロードして自身のリポジトリに登録する。
※クローンした場合にはリポジトリをプライベートに変更できません。
Pipline
- Datadogの画面の指示に従って、GitHub Apps をインストールする。
- eShopOnWebの.github/workflows/eshoponweb-cicd.ymlをコピーして下記のように編集
name: eShopOnWeb Pipline Test
#Triggers (uncomment line below to use it)
on:
workflow_dispatch
#Environment variables https://docs.github.com/en/actions/learn-github-actions/environment-variables
env:
TEMPLATE-FILE: infra/webapp.bicep
jobs:
#Build, test and publish .net web project in repository
buildandtest:
runs-on: ubuntu-latest
steps:
#checkout the repository
- uses: actions/checkout@v4
#prepare runner for desired .net version SDK
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
include-prerelease: true
# Dontet Tools
- name: Check for package update
run: dotnet tool update -g dd-trace
#Build/Test/Publish the .net project
- name: Build with dotnet
run: dotnet build ./eShopOnWeb.sln --configuration Release
- name: Test with dotnet
run: |
dotnet test ./eShopOnWeb.sln --configuration Release
- name: dotnet publish
run: dotnet publish ./src/Web/Web.csproj -c Release -o ${{env.DOTNET_ROOT}}/myapp
# upload the published website code artifacts
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp
- GitHub Actions を動かす。
- 結果をPiplineで確認する。
Test
- DatadogのCI→Test画面で設定方法を確認する。
- eShopOnWebの.github/workflows/eshoponweb-cicd.ymlをコピーして下記のように編集
name: eShopOnWeb Unit test
#Triggers (uncomment line below to use it)
on:
workflow_dispatch
# Environment variables https://docs.github.com/en/actions/learn-github-actions/environment-variables
env:
TEMPLATE-FILE: infra/webapp.bicep
DD_API_KEY: ${{ secrets.DD_API_KEY }}
DD_CIVISIBILITY_AGENTLESS_ENABLED: true
DD_SITE: datadoghq.eu
jobs:
# Build, test and publish .net web project in repository
buildandtest:
runs-on: ubuntu-latest
steps:
#checkout the repository
- uses: actions/checkout@v4
# prepare runner for desired .net version SDK
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
include-prerelease: true
# Dontet Tools
- name: Check for package update
run: dotnet tool update -g dd-trace
# Build/Test/Publish the .net project
- name: Build with dotnet
run: dotnet build ./eShopOnWeb.sln --configuration Release
- name: Test with dotnet
run: |
dd-trace ci run --dd-service=my-dotnet-app --dd-env=ci -- dotnet test ./eShopOnWeb.sln
- name: dotnet publish
run: dotnet publish ./src/Web/Web.csproj -c Release -o ${{env.DOTNET_ROOT}}/myapp
# upload the published website code artifacts
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp
- GitHub Actions を動かす。
- Test結果が表示されることを確認する。
※表示されるまでに時間がかかる場合があります。
Code Analysis
- DatadogのCI→Code Quality画面で設定方法を確認する。
- Datadogの指示に従って、リポジトリのトップに「static-analysis.datadog.yml」を追加する。
rulesets:
- csharp-best-practices # ensure best practices are followed
- csharp-code-style # code-style enforcement for C#
- csharp-inclusive # ensure that we use inclusive wording in our codebase
- csharp-security # ensure your C# code is safe and secure
- ワークフローファイルを追加をする。(.github/workflows/dd-analysis.yml)
name: Datadog Static Analysis
#Triggers (uncomment line below to use it)
on:
workflow_dispatch
jobs:
static-analysis:
runs-on: ubuntu-latest
name: Datadog Static Analyzer
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check code meets quality and security standards
id: datadog-static-analysis
uses: DataDog/datadog-static-analyzer-github-action@v1
with:
dd_api_key: ${{ secrets.DD_API_KEY }}
dd_app_key: ${{ secrets.DD_APP_KEY }}
dd_service: my-app
dd_env: ci
dd_site: datadoghq.eu
cpu_count: 2
name: Datadog Static Analysis
#Triggers (uncomment line below to use it)
on:
workflow_dispatch
jobs:
static-analysis:
runs-on: ubuntu-latest
name: Datadog Static Analyzer
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check code meets quality and security standards
id: datadog-static-analysis
uses: DataDog/datadog-static-analyzer-github-action@v1
with:
dd_api_key: ${{ secrets.DD_API_KEY }}
dd_app_key: ${{ secrets.DD_APP_KEY }}
dd_service: my-app
dd_env: ci
dd_site: datadoghq.eu
cpu_count: 2
name: Datadog Static Analysis
#Triggers (uncomment line below to use it)
on:
workflow_dispatch
jobs:
static-analysis:
runs-on: ubuntu-latest
name: Datadog Static Analyzer
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check code meets quality and security standards
id: datadog-static-analysis
uses: DataDog/datadog-static-analyzer-github-action@v1
with:
dd_api_key: ${{ secrets.DD_API_KEY }}
dd_app_key: ${{ secrets.DD_APP_KEY }}
dd_service: my-app
dd_env: ci
dd_site: datadoghq.eu
cpu_count: 2
name: Datadog Static Analysis
#Triggers (uncomment line below to use it)
on:
workflow_dispatch
jobs:
static-analysis:
runs-on: ubuntu-latest
name: Datadog Static Analyzer
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check code meets quality and security standards
id: datadog-static-analysis
uses: DataDog/datadog-static-analyzer-github-action@v1
with:
dd_api_key: ${{ secrets.DD_API_KEY }}
dd_app_key: ${{ secrets.DD_APP_KEY }}
dd_service: my-app
dd_env: ci
dd_site: datadoghq.eu
cpu_count: 2


- GitHub Actionsを実行する。
- DatadogのCI→Code Qualityの画面で静的解析の結果が表示されることを確認する。
コメント