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:6248

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

cp ../src/v1/alert.yml .
cp ../src/v1/record.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/alert.yml .
cp ../src/v2/record.yml .
exec git commit -am 'v2'

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:6248
exec pint -l error --offline --no-color ci
! stdout .
cmp stderr ../stderr.txt
cmp github.got ../github.expected

-- stderr.txt --
Warning: rule results used by another rule (rule/dependency)
  ---> record.yml:6 (deleted) -> `up:sum`

-- src/v1/alert.yml --
groups:
- name: g1
  rules:
  - alert: Alert
    expr: 'up:sum == 0'
    annotations:
      summary: 'Service is down'
    labels:
      cluster: dev
  - alert: AlertBroken
    expr: 'up:sum == 0'
    annotations:
      summary: 'Service is down'
    labels:
      cluster: dev
-- src/v1/record.yml --
groups:
- name: g1
  rules:
  - record: unused:sum1
    expr: sum(up)
  - record: up:sum
    expr: sum(up)
  - record: unused:sum2
    expr: sum(up)
-- src/v2/alert.yml --
groups:
- name: g1
  rules:
  - alert: AlertBroken
    expr: 'up:sum == 0'
    annotations:
      summary: 'Service is down'
    labels:
      cluster: dev
-- src/v2/record.yml --
groups:
- name: g1
  rules:
  - record: unused:sum1
    expr: sum(up)
  - record: unused:sum2
    expr: sum(up)
-- src/.pint.hcl --
parser {
  include    = [".+.yml"]
}
prometheus "prom" {
  uri      = "http://127.0.0.1:7248"
  timeout  = "5s"
  required = true
}
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/) **rule/dependency** check.

    ------

    rule results used by another rule

    <details>
    <summary>More information</summary>
    If you remove the recording rule generating `up:sum`, and there is no other source of this metric, then any other rule depending on it will break.
    List of found rules that are using `up:sum`:

    - `AlertBroken` at `alert.yml:5`

    </details>

    ------

    :information_source: To see documentation covering this check and instructions on how to resolve it [click here](https://cloudflare.github.io/pint/checks/rule/dependency.html).
path: record.yml
line: 6
side: LEFT
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 | 5 |
    | Number of rules checked | 5 |
    | Number of problems found | 1 |
    | Number of offline checks | 2 |
    | Number of online checks | 0 |
    | Checks duration | 0 |

    </p>
    </details>

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

    ```
    Warning: rule results used by another rule (rule/dependency)
      ---> record.yml:6 (deleted) -> `up:sum`

    ```

    </p>
    </details>

event: COMMENT
--- END ---

