Skip to content

Improve CI gates: drift checks, coverage, CodeQL, PR analysis - #6

Draft
catalintomai wants to merge 1 commit into
masterfrom
improve-ci-gates
Draft

Improve CI gates: drift checks, coverage, CodeQL, PR analysis#6
catalintomai wants to merge 1 commit into
masterfrom
improve-ci-gates

Conversation

@catalintomai

@catalintomai catalintomai commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Expands ci.yml from a single delegated workflow call into explicit jobs: lint, test, build, coverage, delivery, and release
  • Adds drift checks for go.mod, plugin manifest, and i18n files in the lint job
  • Adds a coverage job that runs Go tests with a real Postgres and uploads results to Codecov (requires CODECOV_TOKEN repo secret)
  • Adds CodeQL analysis workflow (.github/workflows/codeql-analysis.yml) for Go and JavaScript security scanning
  • Adds PR test analysis workflows (pr-test-analysis.yml / pr-test-analysis-override.yml) matching the pattern used by sibling plugins (calls, agents)

Notes

  • The coverage job uses ${{ secrets.CODECOV_TOKEN }} — a CODECOV_TOKEN repository secret must be configured in repo settings for uploads to work
  • Delivery and release jobs retain the existing AWS OIDC role assumption pattern from the original workflow

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request replaces the shared CI workflow with explicit validation, coverage, delivery, and release jobs. It also adds CodeQL configuration and workflows for automated pull request test analysis and authorized overrides.

Changes

CI pipeline

Layer / File(s) Summary
Validation and coverage jobs
.github/workflows/ci.yml
Explicit lint, test, build, and coverage jobs run repository checks, Postgres-backed tests, builds, and Codecov uploads.
CI delivery and release distribution
.github/workflows/ci.yml
Master pushes and version tags download renamed artifacts and upload them to separate S3 prefixes using AWS OIDC credentials.

Analysis automation

Layer / File(s) Summary
CodeQL analysis configuration
.github/codeql/codeql-config.yml, .github/workflows/codeql-analysis.yml
CodeQL analyses Go and JavaScript on configured branches and schedules, with filtered queries and ignored test paths.
Pull request test analysis flows
.github/workflows/pr-test-analysis.yml, .github/workflows/pr-test-analysis-override.yml
Pull request events, manual dispatches, and authorized comments delegate test analysis through reusable workflows with concurrency controls and scoped secrets.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PullRequest
  participant GitHubActions
  participant MattermostCI
  participant Postgres14
  participant ArtifactStorage
  PullRequest->>GitHubActions: trigger CI workflow
  GitHubActions->>MattermostCI: run lint, test, and build jobs
  MattermostCI->>Postgres14: execute database-backed tests
  GitHubActions->>ArtifactStorage: deliver or release renamed artifacts
Loading
sequenceDiagram
  participant PullRequest
  participant GitHubActions
  participant TestAutomationToolkit
  PullRequest->>GitHubActions: trigger PR test analysis
  GitHubActions->>TestAutomationToolkit: delegate analysis with PR context
  PullRequest->>GitHubActions: submit authorized override comment
  GitHubActions->>TestAutomationToolkit: delegate override workflow
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main CI improvements: drift checks, coverage, CodeQL, and PR analysis.
Description check ✅ Passed The description is clearly related to the changeset and accurately outlines the added workflows and CI updates.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improve-ci-gates

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

16-214: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

No timeout-minutes set on any job.

All six jobs (lint, test, build, coverage, delivery, release) rely on the GitHub-wide default (360 minutes) rather than an explicit bound. A hung DB connection, network call, or external action could tie up a runner for hours instead of failing fast.

♻️ Example
   lint:
     if: ${{ github.repository_owner == 'mattermost' || github.event_name != 'schedule' }}
     runs-on: ubuntu-latest
+    timeout-minutes: 15
     permissions:
       contents: read
🤖 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 @.github/workflows/ci.yml around lines 16 - 214, Add explicit timeout-minutes
values to all six workflow jobs: lint, test, build, coverage, delivery, and
release. Choose reasonable bounds that allow normal database, build, coverage,
artifact, and upload operations while ensuring hung commands or external actions
fail promptly instead of using GitHub’s 360-minute default.
🤖 Prompt for all review comments with 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.

Inline comments:
In @.github/codeql/codeql-config.yml:
- Around line 3-9: Remove the global go/log-injection exclusion from the
query-filters in the CodeQL configuration. Keep the severity exclusions
unchanged, and do not replace the removed rule exclusion with another
repository-wide suppression; scope any necessary exception to the specific
finding only.

In @.github/workflows/codeql-analysis.yml:
- Around line 27-28: Update the actions/checkout step in the CodeQL workflow to
disable credential persistence by setting its persist-credentials option to
false, while preserving the pinned action version and existing checkout
behavior.
- Around line 16-18: Update the analyze job’s permissions block to include
contents: read alongside security-events: write, ensuring actions/checkout
retains repository read access while preserving CodeQL’s security-events
permission.

In @.github/workflows/pr-test-analysis.yml:
- Line 38: Pin all referenced reusable workflows and CodeQL actions to immutable
commit SHAs instead of the mutable main and v3.28.9 references: update
.github/workflows/pr-test-analysis.yml lines 38-38,
.github/workflows/codeql-analysis.yml lines 31-41 for init, autobuild, and
analyze, and .github/workflows/pr-test-analysis-override.yml lines 23-23.
Preserve the existing workflow and action versions while replacing each tag or
branch with its corresponding verified commit SHA.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 16-214: Add explicit timeout-minutes values to all six workflow
jobs: lint, test, build, coverage, delivery, and release. Choose reasonable
bounds that allow normal database, build, coverage, artifact, and upload
operations while ensuring hung commands or external actions fail promptly
instead of using GitHub’s 360-minute default.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 53a174d6-7a78-45b0-a8d5-295e6bc79c20

📥 Commits

Reviewing files that changed from the base of the PR and between 2d8b0b6 and aaf6856.

📒 Files selected for processing (5)
  • .github/codeql/codeql-config.yml
  • .github/workflows/ci.yml
  • .github/workflows/codeql-analysis.yml
  • .github/workflows/pr-test-analysis-override.yml
  • .github/workflows/pr-test-analysis.yml

Comment on lines +3 to +9
query-filters:
- exclude:
problem.severity:
- warning
- recommendation
- exclude:
id: go/log-injection

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Top-level files:\n'
git ls-files | sed -n '1,120p'

printf '\nCodeQL config:\n'
cat -n .github/codeql/codeql-config.yml

printf '\nGo files in repository:\n'
git ls-files '*.go' | sed -n '1,200p'

printf '\nSearch for log-related sinks / suppressions:\n'
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' 'go/log-injection|codeql|log-injection|logger|log\.' .

Repository: mattermost/mattermost-plugin-docs

Length of output: 2623


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Outline of Go files with logging-related names:\n'
ast-grep outline build/pluginctl/logs.go --view expanded || true
ast-grep outline server/main.go --view expanded || true
ast-grep outline server/plugin.go --view expanded || true
ast-grep outline server/api.go --view expanded || true
ast-grep outline server/job.go --view expanded || true

printf '\nLogging call sites:\n'
rg -n 'log\.|Printf|Println|Errorf|Infof|Warnf|logger|zap|slog' build/pluginctl server -g '*.go'

printf '\nRelevant snippets:\n'
sed -n '1,220p' build/pluginctl/logs.go
printf '\n--- server/main.go ---\n'
sed -n '1,220p' server/main.go
printf '\n--- server/plugin.go ---\n'
sed -n '1,260p' server/plugin.go
printf '\n--- server/api.go ---\n'
sed -n '1,240p' server/api.go
printf '\n--- server/job.go ---\n'
sed -n '1,240p' server/job.go

Repository: mattermost/mattermost-plugin-docs

Length of output: 13249


Remove the global go/log-injection exclusion in .github/codeql/codeql-config.yml:3-9. This disables CodeQL’s log-injection check across every Go file in the repo; keep it only with a documented repository-wide false-positive review, otherwise scope it to the specific finding.

🤖 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 @.github/codeql/codeql-config.yml around lines 3 - 9, Remove the global
go/log-injection exclusion from the query-filters in the CodeQL configuration.
Keep the severity exclusions unchanged, and do not replace the removed rule
exclusion with another repository-wide suppression; scope any necessary
exception to the specific finding only.

Comment on lines +16 to +18
permissions:
security-events: write
name: Analyze

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== .github/workflows/codeql-analysis.yml (outline) ==\n'
ast-grep outline .github/workflows/codeql-analysis.yml --view expanded || true

printf '\n== .github/workflows/codeql-analysis.yml (numbered, first 240 lines) ==\n'
cat -n .github/workflows/codeql-analysis.yml | sed -n '1,240p'

printf '\n== Search for permissions blocks in workflow files ==\n'
rg -n --glob '.github/workflows/*.yml' --glob '.github/workflows/*.yaml' 'permissions:|contents: read|security-events: write|actions/checkout|github/codeql-action' .github/workflows

Repository: mattermost/mattermost-plugin-docs

Length of output: 3583


🌐 Web query:

GitHub Actions job-level permissions override workflow-level permissions unspecified set to none contents read actions/checkout

💡 Result:

In GitHub Actions, when you define the permissions key at the job level, it completely overrides any permissions defined at the workflow level [1][2]. The permissions do not merge; the job-level configuration becomes the definitive set of permissions for that specific job [2]. When you explicitly use the permissions key—at either the workflow or job level—any permissions that you do not specify are automatically set to none (no access), with the sole exception of the metadata scope, which always retains read access [1][3][4]. For the actions/checkout action, the recommended configuration to ensure it can successfully check out your repository is to explicitly grant read access to the contents scope [5][6][7]: permissions: contents: read If you have a workflow-level permissions block but need to override it for a specific job while maintaining the actions/checkout functionality, you must include contents: read in that job's permissions block, as it will otherwise be reset to none [1][2].

Citations:


Add contents: read to the job permissions.
jobs.analyze.permissions replaces the workflow-level block, so actions/checkout loses repo read access here and can fail before CodeQL starts.

🤖 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 @.github/workflows/codeql-analysis.yml around lines 16 - 18, Update the
analyze job’s permissions block to include contents: read alongside
security-events: write, ensuring actions/checkout retains repository read access
while preserving CodeQL’s security-events permission.

Comment on lines +27 to +28
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Disable checkout credential persistence.

actions/checkout stores GITHUB_TOKEN in the local Git configuration by default. Later build or analysis tooling could expose that credential through an artefact.

       - name: Checkout repository
         uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+        with:
+          persist-credentials: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
🧰 Tools
🪛 zizmor (1.26.1)

[warning] 27-28: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🤖 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 @.github/workflows/codeql-analysis.yml around lines 27 - 28, Update the
actions/checkout step in the CodeQL workflow to disable credential persistence
by setting its persist-credentials option to false, while preserving the pinned
action version and existing checkout behavior.

Source: Linters/SAST tools

github.event_name == 'workflow_dispatch' ||
(github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == 'mattermost/mattermost-plugin-docs')
uses: mattermost/mattermost-test-automation-toolkit/.github/workflows/pr-test-analysis.yml@main

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

for f in .github/workflows/pr-test-analysis.yml .github/workflows/codeql-analysis.yml .github/workflows/pr-test-analysis-override.yml; do
  echo "===== $f ====="
  nl -ba "$f" | sed -n '1,120p'
  echo
done

Repository: mattermost/mattermost-plugin-docs

Length of output: 262


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for f in .github/workflows/pr-test-analysis.yml .github/workflows/codeql-analysis.yml .github/workflows/pr-test-analysis-override.yml; do
  echo "===== $f ====="
  sed -n '1,140p' "$f"
  echo
done

Repository: mattermost/mattermost-plugin-docs

Length of output: 3976


Pin reusable workflows and CodeQL actions to commit SHAs.

These references still use mutable tags/branches while running with repository permissions and secrets:

  • .github/workflows/pr-test-analysis.yml: mattermost/mattermost-test-automation-toolkit/.github/workflows/pr-test-analysis.yml@main
  • .github/workflows/codeql-analysis.yml: github/codeql-action/{init,autobuild,analyze}@v3.28.9``
  • .github/workflows/pr-test-analysis-override.yml: mattermost/mattermost-test-automation-toolkit/.github/workflows/pr-test-analysis-override.yml@main
📍 Affects 3 files
  • .github/workflows/pr-test-analysis.yml#L38-L38 (this comment)
  • .github/workflows/codeql-analysis.yml#L31-L41
  • .github/workflows/pr-test-analysis-override.yml#L23-L23
🤖 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 @.github/workflows/pr-test-analysis.yml at line 38, Pin all referenced
reusable workflows and CodeQL actions to immutable commit SHAs instead of the
mutable main and v3.28.9 references: update
.github/workflows/pr-test-analysis.yml lines 38-38,
.github/workflows/codeql-analysis.yml lines 31-41 for init, autobuild, and
analyze, and .github/workflows/pr-test-analysis-override.yml lines 23-23.
Preserve the existing workflow and action versions while replacing each tag or
branch with its corresponding verified commit SHA.

@catalintomai
catalintomai marked this pull request as draft July 15, 2026 13:35
@catalintomai catalintomai mentioned this pull request Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant