ワークフローのサードパーティーアクションのバージョンをコミットハッシュで固定する #981
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# cspell:ignore danielpalme dorny nologo targetdir reporttypes | |
name: azure-ad-b2c-auth-sample CI | |
permissions: | |
contents: read | |
on: | |
pull_request: | |
branches: [main] | |
paths: | |
- 'samples/AzureADB2CAuth/**' | |
- '.github/workflows/samples-azure-ad-b2c-auth-ci.yml' | |
workflow_dispatch: | |
env: | |
BACKEND_WORKING_DIRECTORY: samples/AzureADB2CAuth/auth-backend | |
FRONTEND_WORKING_DIRECTORY: samples/AzureADB2CAuth/auth-frontend | |
jobs: | |
build-frontend: | |
name: フロントエンドアプリケーションのビルド | |
runs-on: ubuntu-latest | |
env: | |
NO_COLOR: "1" # 文字化け防止のためカラーコードを出力しない | |
strategy: | |
matrix: | |
node-version: [20.x] | |
defaults: | |
run: | |
working-directory: ${{ env.FRONTEND_WORKING_DIRECTORY }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- uses: actions/cache@v4 | |
id: node_modules_cache_id | |
env: | |
cache-name: cache-node-modules-azure-ad-b2c-auth-frontend | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
- name: node パッケージのキャッシュ確認 | |
run: echo '${{ toJSON(steps.node_modules_cache_id.outputs) }}' | |
- name: node パッケージのインストール | |
if: ${{ steps.node_modules_cache_id.outputs.cache-hit != 'true' }} | |
run: npm ci | |
- id: run-lint | |
name: lintの実行 | |
run: npm run lint:ci:app >> /var/tmp/lint-result.txt 2>&1 | |
- id: run-type-check | |
name: TypeScript の型チェック | |
run: npm run type-check:app >> /var/tmp/type-check-result.txt 2>&1 | |
- id: application-build | |
name: アプリケーションのビルド | |
run: npm run build-only:dev:app >> /var/tmp/build-result.txt 2>&1 | |
- name: lintの結果出力 | |
if: ${{ success() || (failure() && steps.run-lint.conclusion == 'failure') }} | |
uses: ./.github/workflows/file-to-summary | |
with: | |
body: /var/tmp/lint-result.txt | |
header: 'lintの結果 :pen:' | |
- name: 型チェックの結果出力 | |
if: ${{ success() || (failure() && steps.run-type-check.conclusion == 'failure') }} | |
uses: ./.github/workflows/file-to-summary | |
with: | |
body: /var/tmp/type-check-result.txt | |
header: '型チェックの結果 :pencil2:' | |
- name: ビルドの結果出力 | |
if: ${{ success() || (failure() && steps.application-build.conclusion == 'failure') }} | |
uses: ./.github/workflows/file-to-summary | |
with: | |
body: /var/tmp/build-result.txt | |
header: 'ビルドの結果 :gear:' | |
build-backend: | |
name: バックエンドアプリケーションのビルド | |
runs-on: ubuntu-latest | |
env: | |
DOTNET_NOLOGO: true | |
BUILD_CONFIGURATION: Debug | |
BUILD_SUMMARY_FILE: BuildSummary.md | |
permissions: | |
checks: write | |
defaults: | |
run: | |
working-directory: ${{ env.BACKEND_WORKING_DIRECTORY }} | |
steps: | |
- name: ブランチのチェックアウト | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: .NET SDK のセットアップ | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.*' | |
- name: NuGet パッケージの復元 | |
run: dotnet restore | |
- id: application-build | |
name: アプリケーションのビルド | |
continue-on-error: true | |
run: | | |
echo '## Build Result :gear:' >> $GITHUB_STEP_SUMMARY | |
dotnet build --nologo --configuration ${{ env.BUILD_CONFIGURATION }} --verbosity minimal > build-result.txt | |
echo ':heavy_check_mark: アプリケーションのビルドに成功しました。' >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
cat build-result.txt >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
- name: ビルド失敗時の結果の表示 | |
shell: bash | |
if: ${{ steps.application-build.outcome == 'failure' }} | |
run: | | |
echo ':x: アプリケーションのビルドに失敗しました。 ' >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
cat build-result.txt >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
exit 1 | |
- id: run-tests | |
name: テストの実行 | |
continue-on-error: true | |
run: | | |
dotnet test --no-build --nologo --logger "trx;LogFileName=integration-test.trx" --logger:"console;verbosity=minimal" --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} --collect "XPlat Code Coverage" > integration-test-result.txt | |
- id: create-test-result-report | |
name: テスト結果ページの作成 | |
uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 # v1.9.1 | |
if: ${{ success() || (failure() && steps.run-tests.conclusion == 'failure') }} | |
with: | |
name: 'バックエンドのテスト結果' | |
path: '**/TestResults/*.trx' | |
path-replace-backslashes: 'true' | |
reporter: 'dotnet-trx' | |
only-summary: 'false' | |
list-suites: 'all' | |
list-tests: 'all' | |
max-annotations: '10' | |
fail-on-error: 'true' | |
- name: テスト結果のサマリー表示 | |
shell: bash | |
if: ${{ success() || (failure() && steps.run-tests.conclusion == 'failure') }} | |
run: | | |
echo '## Test Result :memo:' >> ${{ env.BUILD_SUMMARY_FILE }} | |
echo 'Test was a **${{ steps.create-test-result-report.outputs.conclusion }}**.' >> ${{ env.BUILD_SUMMARY_FILE }} | |
echo 'Completed in ${{ steps.create-test-result-report.outputs.time }}ms with **${{ steps.create-test-result-report.outputs.passed }}** passed, **${{ steps.create-test-result-report.outputs.failed }}** failed and ${{ steps.create-test-result-report.outputs.skipped }} skipped.' >> ${{ env.BUILD_SUMMARY_FILE }} | |
cat ${{ env.BUILD_SUMMARY_FILE }} >> $GITHUB_STEP_SUMMARY | |
- id: create-coverage-report | |
name: コードカバレッジレポートの解析と作成 | |
uses: danielpalme/ReportGenerator-GitHub-Action@c38c522d4b391c1b0da979cbb2e902c0a252a7dc # v5.4.3 | |
if: ${{ success() || (failure() && steps.run-tests.conclusion == 'failure') }} | |
with: | |
reports: '**/TestResults/*/coverage.cobertura.xml' | |
targetdir: '${{ env.BACKEND_WORKING_DIRECTORY }}/CoverageReport' | |
reporttypes: 'MarkdownSummaryGithub' | |
- name: コードカバレッジの結果表示 | |
shell: bash | |
if: ${{ success() || (failure() && steps.run-tests.conclusion == 'failure') }} | |
run: | | |
sed -i s/'# Summary'/'## Coverage :triangular_ruler:'/g CoverageReport/SummaryGithub.md | |
sed -i -e '/^## Coverage$/d' CoverageReport/SummaryGithub.md | |
cat CoverageReport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY | |
cat CoverageReport/SummaryGithub.md >> ${{ env.BUILD_SUMMARY_FILE }} |