Skip to content

ci(format): decide whether formatting warnings should fail validation #26

Closed

Description

@showxu

Summary

The CI Format step currently exits successfully even when swift-format reports style violations. The exact command reports 12 warnings and exits 0 at this revision; adding --strict makes the same check exit 1. Decide whether the step is advisory or an enforcing gate.

Code evidence at 5d4987b:

  • .github/workflows/ci.yml:26 names the Format step; :27 runs swift-format lint without --strict.
  • .swift-format:1 supplies the repository formatting configuration.
  • Sources/Core/Installer.swift:165 and Sources/Core/RuntimeService.swift:1013 are examples of current warning locations.

Use Case

Contributors and reviewers need a clear contract for whether a green Format step means formatting conforms to the checked-in rules.

Reproduction / current-state verification

Executed at 5d4987b.

Run in Bash after cd "<checkout>" && swift build, replacing <checkout> with the absolute path of the checkout at this revision. Use a fresh reproduction directory. The commands isolate HOME, agent configuration, and XDG_*, and remove their fixture root on exit.

set -eu
checkout="<checkout>"
skill_bin="$checkout/.build/debug/skill"
repro_root="$checkout/.build/issue-repro-lint"
mkdir -p "$repro_root/home" "$repro_root/tmp" "$repro_root/project"
trap 'rm -rf "$repro_root"' EXIT
isolated() {
  env -i PATH="$PATH" HOME="$repro_root/home" \
    CODEX_HOME="$repro_root/home/.codex" \
    CLAUDE_CONFIG_DIR="$repro_root/home/.claude" \
    XDG_CONFIG_HOME="$repro_root/home/.config" \
    XDG_STATE_HOME="$repro_root/home/.local/state" \
    XDG_CACHE_HOME="$repro_root/home/.cache" TMPDIR="$repro_root/tmp" \
    GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_GLOBAL=/dev/null \
    GIT_AUTHOR_NAME=Fixture [email protected] \
    GIT_COMMITTER_NAME=Fixture [email protected] \
    "$@"
}
skill() { isolated "$skill_bin" "$@"; }
cd "$repro_root/project"

cd "$checkout"
set +e
isolated xcrun swift-format lint --configuration .swift-format --recursive Package.swift Sources Tests > "$repro_root/lint.log" 2>&1
printf 'CI lint exit: %s\n' "$?"
isolated xcrun swift-format lint --strict --configuration .swift-format --recursive Package.swift Sources Tests > "$repro_root/strict.log" 2>&1
printf 'strict lint exit: %s\n' "$?"
head -3 "$repro_root/lint.log"
printf 'warning count: '
grep -c 'warning:' "$repro_root/lint.log"

Observed output (relevant lines; temporary paths shortened to <temp>):

CI lint exit: 0
strict lint exit: 1
Sources/Core/Installer.swift:165:1: warning: [Indentation] indent by 2 spaces
Sources/Core/Installer.swift:166:1: warning: [Indentation] indent by 2 spaces
Sources/Core/RuntimeService.swift:1013:26: warning: [AddLines] add 1 line break
warning count: 12

Environment: Apple Swift 6.4, macOS 27.0.1 (26A434), arm64; CLI 0.2.1; validation date 2026-10-17.

Proposed Behavior

Maintainer decision: choose enforcement or explicitly advisory linting. If enforcing, use --strict (or an equivalent supported error policy), establish a clean baseline, and document the required local command. If advisory, label/document the CI step so warnings are not mistaken for a required style pass.

Completion checks:

  • Verify the chosen exit policy with a small deliberate violation and with conforming code.
  • CI and contributor instructions use the same policy and formatter/toolchain expectations.
  • Handle existing warnings deliberately; do not introduce a broad suppression that hides new violations.

Tradeoffs

Strictness changes CI policy and requires addressing the existing warning baseline. An advisory step can still be useful; exit 0 on warnings is the formatter's documented local help behavior, not evidence of a malfunction.

Compatibility Notes

Executed with the Xcode formatter whose --version reports main; xcrun swift-format lint --help exposes --strict as treating findings as errors. Results may differ with another formatter version, so record/pin the supported toolchain when choosing the policy.

Related: PR #3, PR #11, and PR #12 report successful lint with existing warnings. None establishes an enforcement decision. No duplicate found.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions