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
53 changes: 53 additions & 0 deletions standards/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# ─────────────────────────────────────────────────────────────────────────────
# SOURCE OF TRUTH: petry-projects/.github/standards/workflows/ci.yml
# Standard: petry-projects/.github/standards/ci-standards.md#1-ci-pipeline-ciyml
#
# ADOPTING THIS WORKFLOW:
# 1. This ships verbatim into repos created from petry-projects/repo-template.
# 2. It is a CUSTOMIZE-PER-STACK stub: it passes out of the box so a fresh repo
# is green on day 0. Replace the placeholder step with your stack's
# lint / format / typecheck / unit-test / coverage steps (see the standard).
# 3. The job name `build-and-test` is the required CI status check. Keep it — or,
# if you split into per-language jobs (e.g. TypeScript, Go, Python), update the
# repo's branch-protection required checks to match the new job names.
#
# CONVENTIONS (enforced by the standard):
# • permissions: {} at top, least-privilege per job (CI needs contents: read)
# • triggers: push + pull_request to main
# • concurrency keyed by ref+sha so a new push cancels the stale run

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Concurrency group keyed by sha defeats "cancel stale run" intent.

Including github.sha in the group key (ci-${{ github.ref }}-${{ github.sha }}) means every push gets a unique group, since sha differs per commit. This means cancel-in-progress: true can never actually cancel a previous in-flight run on the same branch — directly contradicting the doc comment at line 17 ("a new push to a branch cancels the stale run for the same ref"). The conventional pattern is to key only on workflow+ref so consecutive pushes to the same ref share a group.

🛠️ Proposed fix
 concurrency:
-  group: ci-${{ github.ref }}-${{ github.sha }}
+  group: ci-${{ github.ref }}
   cancel-in-progress: true

Also applies to: 30-32

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@standards/workflows/ci.yml` at line 17, The CI concurrency setup in the
workflow is keyed with github.sha, which makes every run unique and prevents
cancel-in-progress from stopping stale branch runs. Update the concurrency group
in the CI workflow to use a stable key based on the workflow and ref only, and
make sure the same change is applied everywhere this group is defined so
consecutive pushes to the same branch share the same cancellation group.

# • SHA-pin every third-party action (never a tag/branch)
# ─────────────────────────────────────────────────────────────────────────────
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions: {}

concurrency:
group: ci-${{ github.ref }}-${{ github.sha }}
cancel-in-progress: true

jobs:
build-and-test:
name: build-and-test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

# ── Replace the step below with your stack's checks ───────────────────────
# Standard CI stages: lint, format check, type check, unit tests, coverage
# (plus integration / e2e / build where applicable). For example, a Node repo:
# - uses: actions/setup-node@<sha> # vX (with node-version + cache)
# - run: npm ci
# - run: npm run lint && npm run typecheck && npm test
# See BOOTSTRAP.md and the CI standard. Until you add real steps, the
# placeholder below keeps the required `build-and-test` check green.
- name: Placeholder — replace with real build/test steps
run: echo "CI stub — add your stack's lint/format/typecheck/test/coverage steps; see BOOTSTRAP.md."
51 changes: 51 additions & 0 deletions standards/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# ─────────────────────────────────────────────────────────────────────────────
# SOURCE OF TRUTH: petry-projects/.github/standards/workflows/sonarcloud.yml
# Standard: petry-projects/.github/standards/ci-standards.md#3-sonarcloud-analysis
#
# ADOPTING THIS WORKFLOW:
# 1. This ships verbatim into repos created from petry-projects/repo-template.
# 2. Set sonar.projectKey / sonar.organization in sonar-project.properties to
# match your repo (see BOOTSTRAP.md), and add the SONAR_TOKEN repo secret.
# 3. The job name `SonarCloud` is the required status check — keep it.
# 4. The scan is guarded on SONAR_TOKEN, so the job is a green no-op until the
# secret is set — a fresh repo is not blocked on day 0.
#
# CONVENTIONS (enforced by the standard):
# • permissions: {} at top, least-privilege per job (contents + pull-requests: read)
# • triggers: push + pull_request to main; checkout with fetch-depth: 0
# • first scan is continue-on-error with a single retry (SonarCloud's analysis
# endpoint is occasionally flaky)
# • SHA-pin every third-party action (never a tag/branch)
# ─────────────────────────────────────────────────────────────────────────────
name: SonarCloud Analysis

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions: {}

jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: SonarCloud Scan
id: sonar
if: env.SONAR_TOKEN != ''
uses: SonarSource/sonarqube-scan-action@713881670b6b3676cda39549040e2d88c70d582e # v8.2.0
continue-on-error: true
- name: SonarCloud Scan (retry)
if: env.SONAR_TOKEN != '' && steps.sonar.outcome == 'failure'
uses: SonarSource/sonarqube-scan-action@713881670b6b3676cda39549040e2d88c70d582e # v8.2.0
Loading