mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-06 23:23:23 +09:00
The PR pipeline skipped build, Talos and E2E only when every changed path was under docs/. A pull request that touched README.md, GOVERNANCE.md, an issue template or LICENSE still built every image, booted a sandbox and ran the suite, for files nothing in that pipeline reads. Move the classifier into hack/code-changed.sh, the one source of truth for both lanes: the in-tree `plan` job feeds it the --no-renames merge diff and the fork `resolve` job feeds it the base-repo PR file list (filename and previous_filename, so a packages/… -> docs/… rename still reads as code). Non-code is the docs/ tree, Markdown outside packages/, img/, LICENSE and the GitHub and review-bot metadata. Markdown under packages/ stays code: Go controller tests read chart READMEs. TestDocs_StateTheTimingsTheBinaryAndTheChartUse checks packages/system/flux-plunger/README.md and runs only under make test-controllers, i.e. only when hack/code-changed.sh prints true, so a README-only PR there would skip the test and turn the next code PR on main red. The classifier uses awk rather than grep to express that exception. Other chart READMEs are generated by `make generate`, which pre-commit re-runs, and contract-tested by hack/*.bats, which the `checks` job still runs for every path except the two CI-only tools. The push triggers of build-main, build-release and CodeQL mirror the classifier so a docs-only merge no longer rebuilds main. They use a `paths` filter (`**`, one `!` glob per non-code path, then `packages/**.md`) because only `paths` documents re-including after a negation. hack/code-changed_test.bats checks that the three filters are equal, that every `!` glob is non-code, that every re-include is code, and that CodeQL's pull_request trigger carries no path filter at all: it is a required check on main. Over the 200 merged PRs returned by `gh pr list --state merged --limit 200` on 2026-11-18 the gate on main (docs/ plus the two CI-only tools) skipped 8, the new one 10 (#5168 and #5188 are newly skipped). Assisted-by: LLM Signed-off-by: Marian Koreniuk <moriarti@cp.if.ua>
122 lines
4.4 KiB
YAML
122 lines
4.4 KiB
YAML
name: CodeQL
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
# Mirrors hack/code-changed.sh; hack/code-changed_test.bats keeps them equal.
|
|
# `paths`, not `paths-ignore`: Markdown under packages/ is code (Go tests
|
|
# read chart READMEs), and only `paths` documents re-including after `!`.
|
|
paths:
|
|
- '**'
|
|
- '!docs/**'
|
|
- '!cmd/backport-batch/**'
|
|
- '!cmd/api-gate/**'
|
|
- '!img/**'
|
|
- '!.gemini/**'
|
|
- '!.github/ISSUE_TEMPLATE/**'
|
|
- '!.github/CODEOWNERS'
|
|
- '!.github/PULL_REQUEST_TEMPLATE.md'
|
|
- '!.github/labels.yml'
|
|
- '!.github/renovate.json'
|
|
- '!.coderabbit.yaml'
|
|
- '!security-insights.yml'
|
|
- '!LICENSE'
|
|
- '!**.md'
|
|
- 'packages/**.md'
|
|
pull_request:
|
|
branches: [main]
|
|
# No paths-ignore: CodeQL is a required check on main, and a path-filtered
|
|
# required workflow never reports, so the PR would wait on "Expected".
|
|
schedule:
|
|
# Weekly on Monday 03:27 UTC — off-peak and offset from the other
|
|
# scheduled jobs (scorecard 06:00 Mon, labels 04:17 Mon, stale 04:37
|
|
# daily).
|
|
- cron: '27 3 * * 1'
|
|
|
|
# Default to read-only; the analyze job opts into security-events: write.
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
analyze:
|
|
if: (github.event_name == 'pull_request' || github.repository == 'cozystack/cozystack')
|
|
name: Analyze (${{ matrix.language }})
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 120
|
|
env:
|
|
# The pipe falls back to direct on any proxy error (hack/common-envs.mk).
|
|
GOPROXY: "https://proxy.golang.org|direct"
|
|
permissions:
|
|
# Upload CodeQL results to the code-scanning dashboard. On pull_request
|
|
# this is also what lets CodeQL post new-alert annotations on the diff.
|
|
security-events: write
|
|
# Check out the repository.
|
|
contents: read
|
|
# Read workflow run metadata (required by codeql-action on private
|
|
# repos; harmless on a public repo).
|
|
actions: read
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
# Go uses build-mode: manual. The alternative, autobuild, runs `make`
|
|
# from the repo root, whose included hack/common-envs.mk does a
|
|
# `$(shell git fetch upstream --tags)` at parse time — a network call
|
|
# to a non-origin remote that has no bearing on the analysis and is a
|
|
# flake vector. Instead the "Build Go modules" step below compiles
|
|
# each first-party module explicitly. This keeps the same coverage
|
|
# autobuild aimed for — the root module, api/apps/v1alpha1, and the
|
|
# three nested image modules — while the _repos/* upstream clones are
|
|
# gitignored and absent on a clean checkout, so they are excluded for
|
|
# free. setup-go pins the toolchain to the root go.mod version.
|
|
- language: go
|
|
build-mode: manual
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: false
|
|
|
|
- name: Initialize CodeQL
|
|
uses: github/codeql-action/init@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
|
|
with:
|
|
languages: ${{ matrix.language }}
|
|
build-mode: ${{ matrix.build-mode }}
|
|
|
|
# CodeQL traces these compiler invocations to build its database. Each
|
|
# first-party module is a separate go.mod, so `go build ./...` from the
|
|
# root never reaches the nested ones — build each explicitly. No `make`,
|
|
# so no upstream fetch.
|
|
- name: Build Go modules
|
|
if: matrix.build-mode == 'manual'
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail
|
|
for mod in \
|
|
. \
|
|
api/apps/v1alpha1 \
|
|
packages/apps/kubernetes/images/kubevirt-csi-driver \
|
|
packages/system/dashboard/images/token-proxy \
|
|
packages/system/kubeovn-webhook/images/kubeovn-webhook; do
|
|
echo "::group::go build ${mod}"
|
|
( cd "${mod}" && go build ./... )
|
|
echo "::endgroup::"
|
|
done
|
|
|
|
- name: Perform CodeQL Analysis
|
|
uses: github/codeql-action/analyze@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
|
|
with:
|
|
category: "/language:${{ matrix.language }}"
|