fix(ci): repair failing lint and test jobs#14
Merged
Conversation
The previous refactor (00b1ee8) broke CI in two ways: - tests: spec_helper required a "vendored" webmock under lib/ that is gitignored and never committed, and was not a declared dependency, so CI's clean `shards install` could not find it. Add webmock as a proper development_dependency and require it normally. - lint: the refactor enforced ameba (removed continue-on-error) without cleaning up existing violations or adding config. Add a principled .ameba.yml that disables only rules conflicting with deliberate project conventions (camelCase vars mirroring the Jules API JSON, short block params, CLI dispatcher complexity, not_nil! on closure-captured flags), and fix the remaining real issues in code (RedundantBegin, VerboseBlock, negated unless, lines.each -> each_line, sort -> sort!, the x.not_nil!.foo if x pattern, and getter -> getter? for quit_early?). Also pin the CI lint job to the ameba version locked in shard.lock (bin/ameba) instead of @master, so local `just lint` and CI agree and an upstream ameba rule change can no longer break CI without a code change. Verified locally: shards build, bin/ameba (0 failures), crystal spec (97 examples, 0 failures), crystal tool format --check all pass.
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.
Why
CI on
mainhas been failing on both the lint and tests jobs since the refactor in00b1ee8.Root cause
spec/spec_helper.crrequired../lib/webmock/src/webmock, described as "vendored... committed in tree". Butlib/is gitignored, webmock was never committed, and it wasn't a declared dependency — so CI's cleanshards installonly fetched ameba and spec compilation failed withcan't find file '../lib/webmock/...'.continue-on-error: true, but never cleaned up the ~184 pre-existing violations and added no config.What changed
Tests
webmockas a properdevelopment_dependency(shard.yml/shard.lock).spec_helper.cr; drop the misleading comment and the unusedrequire_webmock!helper.Lint
.ameba.ymlthat disables only rules conflicting with deliberate project conventions, each with a rationale:Naming/VariableNames— camelCase vars (createTime,gitPatch, …) mirror the Jules REST API JSON fields 1:1.Naming/BlockParameterName— short block params used idiomatically.Metrics/CyclomaticComplexity— CLI dispatcher / flag parsers are inherently branch-heavy.Lint/NotNil— flag values are captured in OptionParser closures, where Crystal flow typing can't narrow andnot_nil!is the idiomatic guard (plus spec fixtures).RedundantBegin,VerboseBlock, negatedunless,lines.each→each_line,.sort→.sort!, thex.not_nil!.foo if xpattern →if x = ..., andgetter quit_early→getter? quit_early?.Robustness (prevents recurrence)
shard.lock(bin/ameba) instead ofcrystal-ameba/github-action@master. The@masteraction always runs bleeding-edge ameba, so a new upstream rule (e.g. theSignal::INT.trapone that fires on master but not local 1.6.4) could break CI with no code change. Now localjust lint== CI.Verification (local)