Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/coverage-to-markdown/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: coverage-to-markdown
description: Vitest の テストカバレッジファイル coverage-summary.json を jq で加工し、Markdown 形式の表に整形します。

inputs:
coverage_json:
description: "入力となる coverage-summary.json のパス"
required: true
output_md:
description: "整形した Markdown を出力するファイルパス"
required: true
prefix:
description: "ファイル名のプレフィックス"
required: false
default: ""


outputs:
markdown_path:
description: "生成された Markdown ファイルのパス"
value: ${{ steps.set-outputs.outputs.markdown_path }}

runs:
using: "composite"
steps:
- id: coverage-to-md-by-jq
name: jq で Markdown を生成
shell: bash
run: |
set -euo pipefail # エラーが出たら即終了、未定義変数の参照禁止、パイプライン中のエラー検知を設定します。

COV_JSON="${{ inputs.coverage_json }}"
OUT_MD="${{ inputs.output_md }}"
PREFIX="${{ inputs.prefix }}"

mkdir -p "$(dirname "$OUT_MD")" # 出力対象ディレクトリが存在していなければ作成

{
echo ""
echo "### サマリー"
echo "| 項目 | Covered/Total | % |"
echo "|---|---:|---:|"
jq -r '
.total as $t
| ["lines","branches","functions","statements"]
| map(select($t[.] != null))
| .[]
| "| \(.) | \($t[.].covered)/\($t[.].total) | \(($t[.].pct // 0))% |"
' "$COV_JSON"
echo ""
echo "### ファイルごとの詳細"
echo "| ファイル | Lines (c/t, %) | Branches (c/t, %) | Functions (c/t, %) | Statements (c/t, %) |"
echo "|---|---:|---:|---:|---:|"
jq -r --arg prefix "$PREFIX" '
to_entries
| map(select(.key != "total"))
| sort_by(.key)
| .[]
| .key as $file
| .value as $v
| "| \(
$file
| gsub("^" + $prefix; "") # ファイル名が長くなるので prefix を除去します。
)"
+ " | \($v.lines.covered)/\($v.lines.total), \(($v.lines.pct // 0))%"
+ " | \($v.branches.covered)/\($v.branches.total), \(($v.branches.pct // 0))%"
+ " | \($v.functions.covered)/\($v.functions.total), \(($v.functions.pct // 0))%"
+ " | \($v.statements.covered)/\($v.statements.total), \(($v.statements.pct // 0))% |"
' "$COV_JSON"
} > "$OUT_MD"
- id: set-outputs
name: 出力変数名をセット
shell: bash
run: |
echo "markdown_path=${{ inputs.output_md }}" >> "$GITHUB_OUTPUT"
3 changes: 2 additions & 1 deletion .github/workflows/lint-documents/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ runs:
using: "composite"
steps:
- name: Node.js のセットアップ
Comment thread
rnakagawa16 marked this conversation as resolved.
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: lts/*
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
cache: npm

- name: npm パッケージのインストール
shell: bash
Expand Down
23 changes: 11 additions & 12 deletions .github/workflows/samples-azure-ad-b2c-auth-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,15 @@ jobs:
with:
node-version: lts/*
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
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) }}'
cache: npm

- name: node パッケージのインストール
if: ${{ steps.node_modules_cache_id.outputs.cache-hit != 'true' }}
run: npm ci

- id: run-format-root
name: ルート直下の format の実行
run: npm run format:ci:root >> /var/tmp/format-root-result.txt 2>&1

- id: run-lint
name: lintの実行
run: npm run lint:ci:app >> /var/tmp/lint-result.txt 2>&1
Expand All @@ -68,6 +61,12 @@ jobs:
- id: run-unit-tests
name: 単体テストの実行
run: npm run test:unit:app >> /var/tmp/unit-test-result.txt 2>&1
- name: formatの結果出力
if: ${{ success() || (failure() && steps.run-format-root.conclusion == 'failure') }}
uses: ./.github/workflows/file-to-summary
with:
body: /var/tmp/format-root-result.txt
header: 'formatの結果 :pen:'
- name: lintの結果出力
if: ${{ success() || (failure() && steps.run-lint.conclusion == 'failure') }}
uses: ./.github/workflows/file-to-summary
Expand Down
36 changes: 21 additions & 15 deletions .github/workflows/samples-dressca-admin-frontend.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,8 @@ jobs:
with:
node-version: lts/*
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: node_modules_cache_id
env:
cache-name: cache-node-modules
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) }}'

cache: npm
- name: node パッケージのインストール
if: ${{ steps.node_modules_cache_id.outputs.cache-hit != 'true' }}
run: npm ci

- id: run-lint
Expand All @@ -60,8 +49,14 @@ jobs:

- id: run-unit-tests
name: 単体テストの実行
run: npm run test:unit:admin >> /var/tmp/unit-test-result.txt 2>&1

run: npm run test:coverage:admin >> /var/tmp/unit-test-result.txt 2>&1
- id: format-coverage
name: 単体テストのカバレッジ整形
uses: ./.github/workflows/coverage-to-markdown
with:
coverage_json: ./samples/Dressca/dressca-frontend/admin/coverage/coverage-summary.json
output_md: /var/tmp/coverage/admin.md
prefix: /home/runner/work/maris/maris/samples/Dressca/dressca-frontend/admin/
- name: lintの結果出力
if: ${{ success() || (failure() && steps.run-lint.conclusion == 'failure') }}
uses: ./.github/workflows/file-to-summary
Expand All @@ -88,4 +83,15 @@ jobs:
uses: ./.github/workflows/file-to-summary
with:
body: /var/tmp/unit-test-result.txt
header: '単体テストの結果 :memo:'
header: '単体テストの結果 :memo:'
- name: 単体テストのカバレッジ出力
if: ${{ success() || (failure() && steps.format-coverage.conclusion == 'failure') }}
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const fs = require('fs/promises')
const body = await fs.readFile('${{ steps.format-coverage.outputs.markdown_path }}', 'utf8')
await core.summary
.addHeading('単体テストのカバレッジ :memo:', 2)
.addRaw(body)
.write()
36 changes: 22 additions & 14 deletions .github/workflows/samples-dressca-consumer-frontend.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,8 @@ jobs:
with:
node-version: lts/*
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: node_modules_cache_id
env:
cache-name: cache-node-modules
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) }}'

cache: npm
- name: node パッケージのインストール
if: ${{ steps.node_modules_cache_id.outputs.cache-hit != 'true' }}
run: npm ci

- id: run-lint
Expand All @@ -60,7 +49,15 @@ jobs:

- id: run-unit-tests
name: 単体テストの実行
run: npm run test:unit:consumer >> /var/tmp/unit-test-result.txt 2>&1
run: npm run test:coverage:consumer >> /var/tmp/unit-test-result.txt 2>&1

- id: format-coverage
name: 単体テストのカバレッジ整形
uses: ./.github/workflows/coverage-to-markdown
with:
coverage_json: ./samples/Dressca/dressca-frontend/consumer/coverage/coverage-summary.json
output_md: /var/tmp/coverage/consumer.md
prefix: /home/runner/work/maris/maris/samples/Dressca/dressca-frontend/consumer

- name: lintの結果出力
if: ${{ success() || (failure() && steps.run-lint.conclusion == 'failure') }}
Expand Down Expand Up @@ -88,4 +85,15 @@ jobs:
uses: ./.github/workflows/file-to-summary
with:
body: /var/tmp/unit-test-result.txt
header: '単体テストの結果 :memo:'
header: '単体テストの結果 :memo:'
- name: 単体テストのカバレッジ出力
if: ${{ success() || (failure() && steps.format-coverage.conclusion == 'failure') }}
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const fs = require('fs/promises')
const body = await fs.readFile('${{ steps.format-coverage.outputs.markdown_path }}', 'utf8')
await core.summary
.addHeading('単体テストのカバレッジ :memo:', 2)
.addRaw(body)
.write()
45 changes: 45 additions & 0 deletions .github/workflows/samples-dressca-root-frontend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---

name: dressca-root-frontend CI

permissions:
contents: read

on:
pull_request:
branches: [main]
paths:
- 'samples/Dressca/dressca-frontend/*.*'
- '.github/workflows/samples-dressca-root-frontend-ci.yml'
workflow_dispatch:

defaults:
run:
working-directory: samples/Dressca/dressca-frontend/

jobs:
check:
name: Dressca モノレポのルートプロジェクトのチェック
runs-on: ubuntu-latest
env:
NO_COLOR: "1" # 文字化け防止のためカラーコードを出力しない
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Use Node.js LTS
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: lts/*
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
cache: npm
- name: node パッケージのインストール
run: npm ci
- id: run-format
name: format の実行
run: npm run format:ci:root >> /var/tmp/format-result.txt 2>&1

- name: format の結果出力
if: ${{ success() || (failure() && steps.run-format.conclusion == 'failure') }}
uses: ./.github/workflows/file-to-summary
with:
body: /var/tmp/format-result.txt
header: 'format の結果 :pen:'