mkdir testrepo
cd testrepo
exec git init --initial-branch=main .

cp ../src/v1.yml rules.yml
cp ../src/.pint.hcl .
env GIT_AUTHOR_NAME=pint
env GIT_AUTHOR_EMAIL=pint@example.com
env GIT_COMMITTER_NAME=pint
env GIT_COMMITTER_EMAIL=pint@example.com
exec git add .
exec git commit -am 'import rules and config'

exec git checkout -b v2
cp ../src/v2.yml rules.yml
exec git commit -am 'v2'

exec pint -l debug --offline --no-color ci --checkstyle=checkstyle.xml
! stdout .
cmp checkstyle.xml ../checkstyle_expected.xml

-- src/v1.yml --
- alert: rule1
  expr: sum(foo) by(job)
- alert: rule2
  expr: sum(foo) by(job)
  for: 0s

-- src/v2.yml --
- alert: rule1
  expr: sum(foo) by(job)
  for: 0s
- alert: rule2
  expr: sum(foo) by(job)
  for: 0s

-- src/.pint.hcl --
ci {
  baseBranch = "main"
}
parser {
  relaxed = [".*"]
}

-- checkstyle_expected.xml --
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="4.3">
  <file name="rules.yml">
    <error line="2" severity="warning" message="always firing alert&#xA;Prometheus alerting rules will trigger an alert for each query that returns *any* result.&#xA;Unless you do want an alert to always fire you should write your query in a way that returns results only when some condition is met.&#xA;In most cases this can be achieved by having some condition in the query expression.&#xA;For example `up == 0` or `rate(error_total[2m]) &gt; 0`.&#xA;Be careful as some PromQL operations will cause the query to always return the results, for example using the [bool modifier](https://prometheus.io/docs/prometheus/latest/querying/operators/#comparison-binary-operators)." source="alerts/comparison"></error>
    <error line="3" severity="info" message="redundant field with default value" source="alerts/for"></error>
  </file>
</checkstyle>
