http response prometheus /api/v1/metadata 200 {"status":"success","data":{}}
http response prometheus /api/v1/status/config 200 {"status":"success","data":{"yaml":"global:\n  scrape_interval: 30s\n"}}
http response prometheus /api/v1/status/flags 200 {"status":"success","data":{"storage.tsdb.retention.time": "1d"}}
http response prometheus /api/v1/query_range 200 {"status":"success","data":{"resultType":"matrix","result":[]}}
http response prometheus /api/v1/query 200 {"status":"success","data":{"resultType":"vector","result":[]}}
http start prometheus 127.0.0.1:7160

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

cp ../src/v0.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 v1
cp ../src/v1.yml rules.yml
exec git commit -am 'v1'
exec pint --no-color ci
cmp stderr ../stderrV1.txt

exec git checkout main
exec git merge v1

exec git checkout -b v2
cp ../src/v2.yml rules.yml
exec git commit -am 'v2'
! exec pint --no-color ci
! stdout .
cmp stderr ../stderrV2.txt

-- stderrV1.txt --
level=INFO msg="Loading configuration file" path=.pint.hcl
level=INFO msg="Finding all rules to check on current git branch" base=main
level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=[] include=[] exclude=[]
level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true
-- stderrV2.txt --
level=INFO msg="Loading configuration file" path=.pint.hcl
level=INFO msg="Finding all rules to check on current git branch" base=main
level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=[] include=[] exclude=[]
level=INFO msg="Checking Prometheus rules" entries=2 workers=10 online=true
level=WARN msg="No results for Prometheus uptime metric, you might have set uptime config option to a missing metric, please check your config" name=prom metric=up
level=WARN msg="Using dummy Prometheus uptime metric results with no gaps" name=prom metric=up
level=WARN msg="No results for Prometheus uptime metric, you might have set uptime config option to a missing metric, please check your config" name=prom metric=up
level=WARN msg="Using dummy Prometheus uptime metric results with no gaps" name=prom metric=up
level=INFO msg="Problems found" Bug=2 Warning=1
Warning: invalid comment (promql/series)
  ---> rules.yml:6 -> `DownAlert`
6 |     # pint disable promql/series(xxx)
                       ^^^^^^^^^^^^^^^^^^
                       pint disable comment `promql/series(xxx)` doesn't match any selector in this
                       query

Bug: query on nonexistent series (promql/series)
  ---> rules.yml:8 -> `DownAlert` [+1 duplicates]
8 |     expr: up == 0
              ^^
              `prom` Prometheus server at http://127.0.0.1:7160 didn't have any series for the `up`
              metric in the last 1w.

level=INFO msg="Some problems are duplicated between rules and all the duplicates were hidden, pass `--show-duplicates` to see them" total=3 duplicates=1 shown=2
level=ERROR msg="Execution completed with error(s)" err="problems found"
-- src/v0.yml --
groups:
- name: g1
  rules: []
-- src/v1.yml --
groups:
- name: g1
  rules:
  - alert: DownAlert
    # foo
    # pint disable promql/series(up)
    # bar
    expr: up == 0
    annotations:
      summary: 'Service is down'
    labels:
      cluster: dev
  - record: up:sum
    # foo
    # pint disable promql/series(up)
    # bar
    expr: up == 0
    labels:
      cluster: dev
-- src/v2.yml --
groups:
- name: g1
  rules:
  - alert: DownAlert
    # foo
    # pint disable promql/series(xxx)
    # bar
    expr: up == 0
    annotations:
      summary: 'Service is down'
    labels:
      cluster: dev
  - record: up:sum
    # foo
    # bar
    expr: up == 0
    labels:
      cluster: dev
-- src/.pint.hcl --
ci {
  baseBranch = "main"
}
parser {
  include    = [".+.yml"]
}
prometheus "prom" {
  uri     = "http://127.0.0.1:7160"
  timeout = "5s"
  required = true
}
