Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status.rs: Make json output more verbose #1367

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

Asiderr
Copy link
Contributor

@Asiderr Asiderr commented Jan 30, 2024

Currently if the status response has no status code, json output contains only a text field which gives no real information about the cause of the problem. The patch adds field with more detailed information when the status response contains some details.

Currently if the status response has no status code, json output
contains only a text field which gives no real information about
the cause of the problem. The patch adds field with more detailed
information when the status response contains some details.

Signed-off-by: Norbert Kamiński <norbert.kaminski@3mdeb.com>
@mre
Copy link
Member

mre commented Jan 30, 2024

Nice.
Do you have an example of how the output looks like?
Can it be added as an integration test, similar to this?

#[test]
fn test_exclude_all_private() -> Result<()> {
test_json_output!(
"TEST_ALL_PRIVATE.md",
MockResponseStats {
total: 7,
excludes: 7,
..MockResponseStats::default()
},
"--exclude-all-private"
)
}

@Asiderr
Copy link
Contributor Author

Asiderr commented Jan 30, 2024

Yes, I have. Currently it looks like this:

{
  "total": 77,
  "successful": 36,
  "unknown": 0,
  "unsupported": 0,
  "timeouts": 0,
  "redirects": 0,
  "excludes": 39,
  "errors": 2,
  "cached": 0,
  "success_map": {},
  "fail_map": {
    "./themes/dasharo/layouts/partials/essentials/style.html": [
      {
        "url": "https://use.fontawesome.com/",
        "status": {
          "text": "Failed: Network error",
          "code": 404
        }
      },
      {
        "url": "https://expired.badssl.com/",
        "status": {
          "text": "Failed: Network error",
          "details": "error:0A000086:SSL routines:tls_post_process_server_certificate:certificate verify failed:../ssl/statem/statem_clnt.c:1883: (certificate has expired)"
        }
      }
    ]
  },
  "suggestion_map": {},
  "excluded_map": {},
  "duration_secs": 3,
  "detailed_stats": false
}

And this is how it looks without this patch (latest stable):

{
  "total": 77,
  "successful": 36,
  "unknown": 0,
  "unsupported": 0,
  "timeouts": 0,
  "redirects": 0,
  "excludes": 39,
  "errors": 2,
  "cached": 0,
  "success_map": {},
  "fail_map": {
    "./themes/dasharo/layouts/partials/essentials/style.html": [
      {
        "url": "https://use.fontawesome.com/",
        "status": {
          "text": "Failed: Network error",
          "code": 404
        }
      },
      {
        "url": "https://expired.badssl.com/",
        "status": {
          "text": "Failed: Network error"
        }
      }
    ]
  },
  "suggestion_map": {},
  "excluded_map": {},
  "duration_secs": 3,
  "detailed_stats": false
}

Can it be added as an integration test, similar to this?

I'll try to do this in a moment.

Some network error such as SSL has no status code but it can be
identified by error status details. This patch adds a test case to
verify if the error details are parsed properly in the json format.

Signed-off-by: Norbert Kamiński <norbert.kaminski@3mdeb.com>
@Asiderr
Copy link
Contributor Author

Asiderr commented Jan 30, 2024

@mre Test added in the ca14655.

@mre
Copy link
Member

mre commented Jan 30, 2024

Looking great! Thanks a lot @Asiderr 😃

@mre mre merged commit 2a95944 into lycheeverse:master Jan 30, 2024
7 checks passed
renovate bot added a commit to woodpecker-ci/woodpecker that referenced this pull request Feb 24, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [lycheeverse/lychee](https://togithub.com/lycheeverse/lychee) | patch
| `0.14.0` -> `0.14.3` |

---

### Release Notes

<details>
<summary>lycheeverse/lychee (lycheeverse/lychee)</summary>

###
[`v0.14.3`](https://togithub.com/lycheeverse/lychee/releases/tag/v0.14.3):
Version 0.14.3

[Compare
Source](https://togithub.com/lycheeverse/lychee/compare/v0.14.0...v0.14.3)

<!-- Release notes generated using configuration in .github/release.yml
at master -->

#### What's Changed

##### Miscellaneous and Others 🔔

- fix(tests): update the expected output in cli tests by
[@&#8203;orhun](https://togithub.com/orhun) in
[lycheeverse/lychee#1362
- status.rs: Make json output more verbose by
[@&#8203;Asiderr](https://togithub.com/Asiderr) in
[lycheeverse/lychee#1367
- Set URI to HTTPS for ErrorKind::InsecureURL by
[@&#8203;Elkiwa](https://togithub.com/Elkiwa) in
[lycheeverse/lychee#1369
- Fixed fragment generation for headings with inline code by
[@&#8203;HU90m](https://togithub.com/HU90m) in
[lycheeverse/lychee#1370
- Move to workspace versioning by
[@&#8203;mre](https://togithub.com/mre) in
[lycheeverse/lychee#1372

#### New Contributors

- [@&#8203;Asiderr](https://togithub.com/Asiderr) made their first
contribution in
[lycheeverse/lychee#1367
- [@&#8203;Elkiwa](https://togithub.com/Elkiwa) made their first
contribution in
[lycheeverse/lychee#1369

**Full Changelog**:
lycheeverse/lychee@v0.14.2...v0.14.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "every weekend" (UTC), Automerge -
"before 4am" (UTC).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/woodpecker-ci/woodpecker).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMDAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIwMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants