Repository navigation
chore(standards): add canonical ci.yml + sonarcloud.yml inline workflow templates (#966) #564
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7f4bc4f
chore(standards): add canonical ci.yml inline workflow template (#966)
don-petry 7965953
chore(standards): add canonical sonarcloud.yml inline workflow templa…
don-petry baeedd3
fix(reviews): address review comments [skip ci-relay]
donpetry-bot 9311ddc
Merge branch 'main' into chore/add-ci-sonarcloud-inline-standards-966
donpetry-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| 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 | ||
| # • 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." | ||
This file contains hidden or 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
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Concurrency group keyed by sha defeats "cancel stale run" intent.
Including
github.shain the group key (ci-${{ github.ref }}-${{ github.sha }}) means every push gets a unique group, sinceshadiffers per commit. This meanscancel-in-progress: truecan 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 onworkflow+refso consecutive pushes to the same ref share a group.🛠️ Proposed fix
Also applies to: 30-32
🤖 Prompt for AI Agents