http method github GET /api/v3/repos/foo/bar/pulls/123/reviews 200 []
http method github POST /api/v3/repos/foo/bar/pulls/123/reviews 200 {}
http method github GET /api/v3/repos/foo/bar/pulls/123/comments 200 []
http method github GET /api/v3/repos/foo/bar/issues/123/comments 200 []
http method github POST /api/v3/repos/foo/bar/pulls/123/comments 200 {}
http start github 127.0.0.1:6246

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

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 config'

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

env GITHUB_AUTH_TOKEN=12345
env GITHUB_ACTION=YES
env GITHUB_EVENT_NAME=pull_request
env GITHUB_REF=refs/pull/123/merge
env GITHUB_BASE_REF=main
env GITHUB_REPOSITORY=foo/bar
env GITHUB_API_URL=http://127.0.0.1:6246
exec pint -l debug --offline --no-color ci
! stdout .
stderr 'level=INFO msg="Pull request review created" status="200 OK"'
cmp github.got ../github.expected

-- src/rules.yml --
groups:
- name: foo
  rules:
  - alert: rule1
    expr: sum(foo) by(job)

-- src/.pint.hcl --
repository {}

-- github.expected --
GET /api/v3/repos/foo/bar/pulls/123/comments
  Accept: application/vnd.github.squirrel-girl-preview, application/vnd.github.comfort-fade-preview+json
  Accept-Encoding: gzip
  Authorization: Bearer 12345
  X-Github-Api-Version: 2022-11-28

GET /api/v3/repos/foo/bar/issues/123/comments
  Accept: application/vnd.github.squirrel-girl-preview
  Accept-Encoding: gzip
  Authorization: Bearer 12345
  X-Github-Api-Version: 2022-11-28

POST /api/v3/repos/foo/bar/pulls/123/comments
  Accept: application/vnd.github.squirrel-girl-preview, application/vnd.github.comfort-fade-preview+json
  Accept-Encoding: gzip
  Authorization: Bearer 12345
  Content-Type: application/json
  X-Github-Api-Version: 2022-11-28
--- BODY ---
body: |
  :warning: **Warning** reported by [pint](https://cloudflare.github.io/pint/) **alerts/comparison** check.

  <details>
  <summary>always firing alert</summary>

  ```yaml
  5 |     expr: sum(foo) by(job)
                    ^^^
  ```

  This query doesn't have any condition and so this alert will always fire if it matches anything.

  Prometheus alerting rules will trigger an alert for each query that returns *any* result.
  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.
  In most cases this can be achieved by having some condition in the query expression.
  For example `up == 0` or `rate(error_total[2m]) > 0`.
  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).

  </details>

  ------

  :information_source: To see documentation covering this check and instructions on how to resolve it [click here](https://cloudflare.github.io/pint/checks/alerts/comparison.html).
path: rules.yml
line: 5
side: RIGHT
commit_id: <COMMIT ID>
--- END ---

GET /api/v3/repos/foo/bar/pulls/123/reviews
  Accept: application/vnd.github.v3+json
  Accept-Encoding: gzip
  Authorization: Bearer 12345
  X-Github-Api-Version: 2022-11-28

POST /api/v3/repos/foo/bar/pulls/123/reviews
  Accept: application/vnd.github.v3+json
  Accept-Encoding: gzip
  Authorization: Bearer 12345
  Content-Type: application/json
  X-Github-Api-Version: 2022-11-28
--- BODY ---
commit_id: <COMMIT ID>
body: |+
  ### This pull request was validated by [pint](https://github.com/cloudflare/pint).
  :heavy_exclamation_mark:	Problems found.
  | Severity | Number of problems |
  | --- | --- |
  | Warning | 1 |
  <details><summary>Stats</summary>
  <p>

  | Stat | Value |
  | --- | --- |
  | Version | unknown |
  | Number of rules parsed | 1 |
  | Number of rules checked | 1 |
  | Number of problems found | 1 |
  | Number of offline checks | 9 |
  | Number of online checks | 0 |
  | Checks duration | 0 |

  </p>
  </details>

  <details><summary>Problems</summary>
  <p>

  ```
  Warning: always firing alert (alerts/comparison)
    ---> rules.yml:5 -> `rule1`
  5 |     expr: sum(foo) by(job)
                    ^^^
                    This query doesn't have any condition and so this alert will always fire if it matches
                    anything.

  ```

  </p>
  </details>

event: COMMENT
--- END ---

