-
Notifications
You must be signed in to change notification settings - Fork 0
[] Create .github/workflows/ci.yml with path-filtered frontend and backend CI jobs, coverage gate, caching, and concurrency groups #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,26 +4,67 @@ on: | |
| push: | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| changes: | ||
| frontend-ci: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| backend: ${{ steps.filter.outputs.backend }} | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: dorny/paths-filter@v3 | ||
| id: filter | ||
| with: | ||
| filters: | | ||
| backend: | ||
| - 'backend/**' | ||
| - 'go.work' | ||
| - 'go.work.sum' | ||
| app: | ||
| - 'app/**' | ||
| - 'components/**' | ||
| - 'lib/**' | ||
| - 'middleware.ts' | ||
| - 'next.config.mjs' | ||
| - 'package.json' | ||
| - 'tsconfig.json' | ||
| - 'vitest.config.ts' | ||
| - '*.ts' | ||
| - '*.tsx' | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| if: steps.filter.outputs.app == 'true' || github.ref == 'refs/heads/main' | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - uses: actions/cache@v4 | ||
| if: steps.filter.outputs.app == 'true' || github.ref == 'refs/heads/main' | ||
| with: | ||
| path: ~/.npm | ||
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
|
|
||
| - name: Install dependencies | ||
| if: steps.filter.outputs.app == 'true' || github.ref == 'refs/heads/main' | ||
| run: npm ci | ||
|
|
||
| backend: | ||
| needs: changes | ||
| if: needs.changes.outputs.backend == 'true' | ||
| - name: Lint | ||
| if: steps.filter.outputs.app == 'true' || github.ref == 'refs/heads/main' | ||
| run: npm run lint | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [high] パスフィルタ ( frontend-ci:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
...
- uses: actions/setup-node@v4
if: steps.filter.outputs.app == 'true' || github.ref == 'refs/heads/main'これ自体は動作するが、
|
||
| - name: Typecheck | ||
| if: steps.filter.outputs.app == 'true' || github.ref == 'refs/heads/main' | ||
| run: npx tsc --noEmit | ||
|
|
||
| - name: Test | ||
| if: steps.filter.outputs.app == 'true' || github.ref == 'refs/heads/main' | ||
| run: npx vitest run | ||
|
|
||
| - name: Build | ||
| if: steps.filter.outputs.app == 'true' || github.ref == 'refs/heads/main' | ||
| run: npm run build | ||
|
|
||
| backend-ci: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| defaults: | ||
| run: | ||
| working-directory: backend | ||
|
|
@@ -41,34 +82,66 @@ jobs: | |
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: dorny/paths-filter@v3 | ||
| id: filter | ||
| with: | ||
| filters: | | ||
| backend: | ||
| - 'backend/**' | ||
| - '.golangci.yml' | ||
| - 'go.work' | ||
| - 'go.work.sum' | ||
|
|
||
| - uses: actions/setup-go@v5 | ||
| if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main' | ||
| with: | ||
| go-version: '1.25' | ||
| go-version: '1.24' | ||
|
|
||
| - uses: actions/cache@v4 | ||
| if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main' | ||
| with: | ||
| path: ~/go/pkg/mod | ||
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
|
||
| - name: Download dependencies | ||
| if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main' | ||
| run: go mod download | ||
|
|
||
| - name: Run SQLite unit tests | ||
| run: go test ./... -count=1 -timeout 60s | ||
|
|
||
| - name: Run PostgreSQL integration tests | ||
| run: go test -tags integration ./internal/infrastructure/... -count=1 -timeout 120s | ||
| env: | ||
| DB_TYPE: postgres | ||
| DB_DSN: postgres://postgres:postgres@localhost:5432/testdb?sslmode=disable | ||
| - name: Vet | ||
| if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main' | ||
| run: go vet ./... | ||
|
|
||
| - name: golangci-lint | ||
| if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main' | ||
| uses: golangci/golangci-lint-action@v6 | ||
| with: | ||
| version: v2.1 | ||
| working-directory: backend | ||
| args: --timeout=5m | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [high] Go バージョンが 1.25 から 1.24 にダウングレードされた 旧設定では - uses: actions/setup-go@v5
if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main'
with:
go-version: '1.24'リポジトリの
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [high] 旧 CI から引き継いだ - uses: actions/setup-go@v5
if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main'
with:
go-version: '1.25'タスク要件では @@ -110,3 +110,3 @@
with:
- go-version: '1.25'
+ go-version: '1.24'
|
||
| - name: Upload coverage artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: coverage | ||
| path: backend/coverage.out | ||
| - name: Test with race detector | ||
| if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [high] 外部スクリプトのパイプ実行による Supply Chain Attack リスク CWE-829: Inclusion of Functionality from Untrusted Control Sphere 該当箇所: run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.0
また、 推奨対応:
- name: golangci-lint
if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main'
uses: golangci/golangci-lint-action@v6
with:
version: v1.62.0
working-directory: backend
args: --timeout=5m
|
||
| run: go test -race -coverprofile=coverage.out -covermode=atomic ./... | ||
|
|
||
| - name: Run PostgreSQL integration tests | ||
| if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main' | ||
| run: go test -tags integration ./internal/infrastructure/... -count=1 -timeout 120s | ||
| env: | ||
| DB_TYPE: postgres | ||
| DB_DSN: postgres://postgres:postgres@localhost:5432/testdb?sslmode=disable | ||
|
|
||
| - name: Check coverage threshold | ||
| if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 [critical] golangci-lint を curl | sh でインストールしている — 公式 action を削除した回帰 削除前は - name: Install golangci-lint
if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main'
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.0問題点:
@@ -110,5 +110,6 @@
- - name: Install golangci-lint
- if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main'
- run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.0
-
- - name: golangci-lint
- if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main'
- run: golangci-lint run ./... --timeout=5m
+ - name: golangci-lint
+ if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main'
+ uses: golangci/golangci-lint-action@v6
+ with:
+ version: v1.62.0
+ args: --timeout=5m
|
||
| run: | | ||
| total=$(go tool cover -func=coverage.out | awk '/^total:/ {gsub(/%/,"",$3); print $3}') | ||
| awk -v total="$total" 'BEGIN { exit (total >= 60 ? 0 : 1) }' || { | ||
| echo "Coverage ${total}% below 60% threshold" | ||
| exit 1 | ||
| } | ||
|
|
||
| - name: Build | ||
| if: steps.filter.outputs.backend == 'true' || github.ref == 'refs/heads/main' | ||
| run: go build ./cmd/server | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛑 [blocker] 旧 CI に存在した以下の 2 ジョブが diff で丸ごと削除されており、今回の変更後は実行されない: - compat-tests:
- runs-on: ubuntu-latest
- steps:
- ...
- - name: Run compatibility tests
- run: cd backend && go test ./internal/compat/... -v ...- validate-dashboards:
- runs-on: ubuntu-latest
- steps:
- ...
- - run: node -e "...grafana dashboard validation..."タスク要件 (PR 本文) には
|
||
|
|
||
| compat-tests: | ||
| runs-on: ubuntu-latest | ||
|
|
@@ -77,7 +150,7 @@ jobs: | |
|
|
||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.25' | ||
| go-version: '1.24' | ||
|
|
||
| - name: Run compatibility tests | ||
| run: cd backend && go test ./internal/compat/... -v -count=1 -timeout 120s 2>&1 | tee compat-results.txt | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 [high] frontend-ci: paths-filter の出力を参照する前に checkout が不足している可能性がある (実際は別の問題: 後続ステップの if 条件が filter 結果を使うが filter ステップ自体は常に実行される設計は問題なし。ただし
working-directory未設定で npm コマンドが正しいディレクトリで動かない)frontend-ci ジョブ内の
npm ci/npm run lint/npx tsc等の各ステップにworking-directoryが指定されていない。タスク仕様には「frontend files are under
app/」とあり、リポジトリがモノレポ構成であればフロントエンドのルート (app/やfrontend/など) にpackage.jsonが存在する可能性が高い。working-directoryなしではnpm ciがリポジトリルートのpackage.jsonを参照し、存在しない場合は CI が即失敗する。該当箇所:
backend-ci ジョブには
defaults.run.working-directory: backendが設定されており、frontend-ci にも同等の設定が必要。code.ci.path_filter_step_ordering| confidence: 0.72