feat: extra CI jobs with mago#170
Open
tijsverkoyen wants to merge 3 commits into
Open
Conversation
Reviewer's GuideAdds Mago as a development dependency and wires multiple Mago-based code quality jobs into GitLab CI using a shared configuration file for formatting, linting, analysis, and structural guards. Flow diagram for new Mago CI code quality jobsflowchart LR
InstallDeps["Install dependencies and build assets"]
InstallDeps --> MagoFmtCheck["Mago - check code styling (fmt --check)"]
InstallDeps --> MagoLint["Mago - lint (allow_failure)"]
InstallDeps --> MagoAnalyse["Mago - analyse"]
InstallDeps --> MagoGuard["Mago - guard (allow_failure)"]
subgraph MagoContainer["Mago container image: ghcr.io/carthage-software/mago:1"]
MagoFmtCheck
MagoLint
MagoAnalyse
MagoGuard
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues, and left some high level feedback:
- The four Mago CI jobs repeat the same image, entrypoint, stage, needs, and tags; consider using YAML anchors or a shared template/extends to reduce duplication and ease future maintenance.
- The
reasonstring in theguard.structural.ruleshas a typo (extedinstead ofextend); updating this will make guard output clearer for developers. - All Mago jobs currently
needthe "Install dependencies and build assets" job even though they only operate on source files; you might want to drop that dependency (or split it) to shorten the pipeline when assets are not required.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The four Mago CI jobs repeat the same image, entrypoint, stage, needs, and tags; consider using YAML anchors or a shared template/extends to reduce duplication and ease future maintenance.
- The `reason` string in the `guard.structural.rules` has a typo (`exted` instead of `extend`); updating this will make guard output clearer for developers.
- All Mago jobs currently `need` the "Install dependencies and build assets" job even though they only operate on source files; you might want to drop that dependency (or split it) to shorten the pipeline when assets are not required.
## Individual Comments
### Comment 1
<location path=".gitlab-ci.yml" line_range="46" />
<code_context>
+ - mago --config=./mago.dist.toml --colors=always fmt --check
+ after_script:
+ - >
+ if [ $CI_JOB_STATUS != 'success' ]; then
+ mago --config=./mago.dist.toml --colors=always fmt --dry-run
+ fi
</code_context>
<issue_to_address>
**suggestion:** Quote CI_JOB_STATUS in the condition to avoid edge-case issues in the shell test.
Use `if [ "$CI_JOB_STATUS" != 'success' ]; then` so the condition still behaves correctly if the variable is unset or contains spaces/special characters.
```suggestion
if [ "$CI_JOB_STATUS" != 'success' ]; then
```
</issue_to_address>
### Comment 2
<location path=".gitlab-ci.yml" line_range="66-52" />
<code_context>
+ - docker
+ allow_failure: true
+
+Mago - analyse:
+ image:
+ name: ghcr.io/carthage-software/mago:1
+ entrypoint: [ '' ]
+ script:
+ - mago --config=./mago.dist.toml --colors=always analyse --reporting-format=rich --minimum-fail-level=warning
+ stage: code quality
+ needs: [ "Install dependencies and build assets" ]
+ tags:
+ - docker
+
+Mago - guard:
</code_context>
<issue_to_address>
**suggestion:** Consider deduplicating shared job configuration using YAML anchors or extends.
These four Mago jobs duplicate `image`, `entrypoint`, `stage`, `needs`, and `tags`. To simplify maintenance, factor the shared config into a YAML anchor or GitLab `extends` template and override only `script` (and `allow_failure`) per job so changes to the base config are made in one place.
Suggested implementation:
```
Mago - analyse:
extends: .mago-base-mago
script:
- mago --config=./mago.dist.toml --colors=always analyse --reporting-format=rich --minimum-fail-level=warning
```
```
Mago - guard:
extends: .mago-base-mago
script:
- mago --config=./mago.dist.toml --colors=always guard --reporting-format=rich --minimum-fail-level=warning
allow_failure: true
```
1. Add a hidden base job definition (anywhere near the top of your Mago jobs) that captures the shared configuration:
```yaml
.mago-base-mago:
image:
name: ghcr.io/carthage-software/mago:1
entrypoint: [ '' ]
stage: code quality
needs: [ "Install dependencies and build assets" ]
tags:
- docker
```
2. Update the `Mago - lint` (and any other Mago jobs not shown in the snippet) to also use `extends: .mago-base-mago`, keeping their specific `script` and `allow_failure` values, e.g.:
```yaml
Mago - lint:
extends: .mago-base-mago
script:
- mago --config=./mago.dist.toml --colors=always lint --reporting-format=rich --minimum-fail-level=warning
allow_failure: true
```
</issue_to_address>
### Comment 3
<location path="mago.dist.toml" line_range="101" />
<code_context>
+target = "class"
+must-be-named = "*Controller"
+must-extend = "Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController"
+reason = "Controllers must exted AbstractController and name should end with *Controller."
</code_context>
<issue_to_address>
**suggestion (typo):** Fix the typo in the `reason` string for clarity.
Specifically, update `exted` to `extend` in the `reason` string so it reads: `Controllers must extend AbstractController and name should end with *Controller.`
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
jonasdekeukelaere
approved these changes
Jun 3, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://next-app.activecollab.com/108877/projects/533/tasks/241804
Summary by Sourcery
Add Mago-based static analysis and formatting checks to the CI code quality stage and configure the tool for this project.
New Features:
Build:
Documentation:
Chores: