Commit Graph

284 Commits

Author SHA1 Message Date
Sergey Gulin
1543744a0c
[#134] Add makefile
Problem: Most of our projects have a makefile for running common
tasks. We should add one to xrefcheck as well.

Solution: Add makefile.
2022-09-27 18:33:19 +10:00
Diogo Castro
54aa5415bf
Merge pull request #163 from serokell/diogo/#162-interrupt-io
[#162] Do not cancel the progress bar thread
2022-09-26 14:16:33 +01:00
Diogo Castro
25d73c3d09
[#162] Remove artificial delay in allowRewrite
Problem: `allowRewrite` uses `threadDelay (ms 100)` to "prevent our
output to interleave with further outputs".

It's not exactly what problem this is supposed to address, and how it's
supposed to fix it. This seems like it may have been an earlier attempt
to fix the issue addressed in the previous commit.

Solution: delete `threadDelay`.
2022-09-26 14:12:57 +01:00
Diogo Castro
1964f57280
[#162] Do not cancel the progress bar thread
Problem: The output of xrefcheck sometimes appears as a confusing mess,
see here for details and examples:
https://github.com/serokell/xrefcheck/issues/162

The culprit seems to be the `withAsync` used in `verifyRepo`. This
spawns a thread that prints and refreshes the progress bar, while the
main thread coordinates the verification of references.

The problem here is that, as the docs of `withAsync` explain, when the
main thread finishes/throws, the spawned thread will be cancelled with
`uninterruptibleCancel`.

If the thread is in the middle of updating the progress bar (printing
return carriages, writing over an existing line, printing control
characters to change the text color, etc), it'll be abruptly interrupted
and will not be given the chance to finish cleanly.

Solution: replace `withAsync` with `loopAsyncUntil`. This lets the
printer thread finish what it's currently doing.
2022-09-26 14:12:57 +01:00
Sorokin-Anton
3ee7649889
Merge pull request #158 from serokell/Sorokin-Anton/#155-footnotes-support
[#155] Footnote syntax support
2022-09-26 12:22:50 +03:00
Anton Sorokin
3df588ac8f
[#155] Footnote syntax support
Problem: we can wrongly report footnotes as broken links (#155),
because footnotes support is disabled by default in cmark-gfm

Solution: add `optFootnotes` to `commonMarkToNode`
(this option was recently added to cmark-gfm-hs,
so we need to temporarily pull it from github instead hackage)
2022-09-26 11:59:07 +03:00
Sorokin-Anton
31777f72cc
Merge pull request #145 from serokell/Sorokin-Anon/#140-unknown-key-errors
[#140] Unknown field errors
2022-09-25 20:05:06 +03:00
Anton Sorokin
0d983beada
[#140] Reject unknown fields in yaml config
Problem: during parsing yaml file, `fromJSON` instance is used,
and by default it ignores unknown field, and
we want to get errors instead (issue #140)

Solution: change `fromJSON` instance for `Config` and types inside it.
Luckily, they  and only they use `aesonConfigOption`
2022-09-25 20:03:57 +03:00
Anton Sorokin
e259d92261
Add hie.yaml to .gitignore
Problem: HLS need a hi.yaml file, but we don't want to see it in repo

Solution: add it to .gitignore, so anybody can create if needed
2022-09-25 19:33:11 +03:00
Sorokin-Anton
40e729b1e8
Merge pull request #153 from serokell/Sorokin-Anton/#149-replace-hspec-with-tasty
[#149] Replace hspec with tasty
2022-09-25 18:54:40 +03:00
Anton Sorokin
b412781020
[#149] Replace hspec with tasty
Problem: `hspec` and `tasty` are testing frameworks with
almost same functionality,
for historical reasons in xrefcheck we  used different frameworks
for tests and links-tests, and in Serokell we prefer `tasty` now.

Solution: use only `tasty`,
 rewrite code that use `hspec` using correspondance between
 - `testGroup` and `describe`
 -  `testCase` and `it`
 - `shouldBe` and `@?=`
2022-09-25 18:51:41 +03:00
Diogo Castro
955e0ea9cf
Merge pull request #161 from serokell/diogo/update-release-instructions
[Chore] Update release instructions
2022-09-24 18:22:08 +01:00
Diogo Castro
4eadd0198a
[Chore] Update release instructions
Problem: Turns out the release instructions are not entirely accurate.

In order for `xrefcheck-action` to work, the release page must have the
linux binary and the windows zip file attached.

Turns out the recommended way to do this is to edit the "auto-release"
page created by the "Create a pre-release" CI step, see the instructions
here:
https://raw.githubusercontent.com/serokell/scratch/release-binary/scripts/release-binary.sh

Solution: edit the release checklist to include these instructions.
2022-09-24 18:18:04 +01:00
Sereja313
4cf1f562f7
Merge pull request #146 from serokell/Sereja313/#133-refactor-golden-tests
[#133] Refactor golden tests
2022-09-24 23:53:00 +10:00
Sergey Gulin
95d5bad3cd
[#133] Refactor golden tests
Problem: We're using a common pattern in our bats tests:
  Run xrefcheck, redirect output to a temp file
  Check the temp file matches some .gold file using `diff`
  Delete temp file
We could encapsulate this pattern and make it easier to reuse.

Solution: In the `setup` function, create a temp directory. In the
`teardown` function, delete the temp directory. Create a `to_temp`
function that runs xrefcheck with desired options, pipes its output
through the `prepare` helper function and saves it in a file inside
the temp directory. Create a `assert_diff` function that reads the temp
file, and uses `diff` to compare it against some expected output.
2022-09-24 23:47:24 +10:00
Diogo Castro
08dd61bb9f
Merge pull request #160 from serokell/diogo/0.2.1-release
v0.2.1 release
2022-09-24 09:12:51 +01:00
Diogo Castro
0871e29907
v0.2.1 release 2022-09-24 08:30:53 +01:00
Diogo Castro
e4fc5d530e
Merge pull request #159 from serokell/Sereja313/#156-make-all-config-options-optional
[#156] Make all config options optional
2022-09-24 08:30:01 +01:00
Sergey Gulin
a99005d731
[#156] Make all config options optional
Problem: In #126 we made the `ignoreRefs` option required (to match the
other options). However, having it optional is better for
backwards-compatibility and to help users migrate to newer xrefcheck
versions.

Solution: Make all config options optional.
2022-09-24 05:51:39 +10:00
Sereja313
d3b1cb53f5
Merge pull request #141 from serokell/Sereja313/#56-dump-all-errors-from-files
[#56] Dump all the errors from different files
2022-09-23 17:17:48 +10:00
Sergey Gulin
c8d19a3f98
[#56] Dump all the errors from different files
Problem: Currently, xrefcheck fails immediately after the first
observed error because `die` is used right in `markdownScanner` What
we want is dumping all the errors from different markdowns and then
print them as a final xrefcheck's result together with the broken
links. Also, despite the fact that in the `makeError` function we have
4 error messages, 2 of them are not reported, and the test case that
should check this only checks that at least one of the four files
throws an error.

Solution: Make xrefcheck to report all errors. Add `ScanError` type
and propagate errors to report all of them, rather than failing
immediately after the first error is detected.
2022-09-23 17:13:50 +10:00
Diogo Castro
91483fcc9d
Merge pull request #154 from serokell/diogo/chore-fix-gh-templates
[Chore] Fix PR template
2022-09-21 11:29:14 +01:00
Diogo Castro
0a4b70f1e8
[Chore] Fix changelog
Problem: A `0.2.1` section was added to the changelog by mistake in #68,
even though no release was made. This was corrected and undone in #100.
It seems it was added back in again in #88, most likely due to a rebase
mixup.

Solution: Delete this section again.
2022-09-21 11:23:42 +01:00
Diogo Castro
bc9d77f17a
[Chore] Add release checklist to PR template 2022-09-21 11:23:41 +01:00
Diogo Castro
8d2f7c0ed4
[Chore] Fix broken links in PR template 2022-09-21 11:23:33 +01:00
Sereja313
162b678372
Merge pull request #136 from serokell/Sereja313/#76-add-tests-for-virtualFiles-glob-patterns
[#76] Add tests for `virtualFiles` glob patterns
2022-09-19 17:35:30 +10:00
Sergey Gulin
943d0c881b
[#76] Add tests for virtualFiles glob patterns
Problem: The `virtualFiles` config allows the user to use glob patterns
to specify files that do not physically exist in the repository but
should be treated as existing nevertheless. However, we do not yet
have any around our usage of glob patterns. We should write some to
1) ensure it behaves in a sensible way even in corner cases and 2)
document  the behaviour.

Solution: Add tests that document how the `virtualFiles` glob paterns work.
2022-09-19 17:32:24 +10:00
Sereja313
f4eb187f31
Merge pull request #142 from serokell/Sereja313/#137-remove-checkLocalhost-option
[#137] Remove `checkLocalhost` option
2022-09-16 03:09:39 +10:00
Sergey Gulin
db77aaa9e4
[#137] Remove checkLocalhost option
Problem: In #85, we added the `checkLocalhost` option to decide
whether to verify links to localhost. However, upon further
reflection, it seems like this could have been subsumed by the
existing `ignoreRefs` option instead.

Solution: Remove `check-localhost` CLI option and `checkLocalhost`
config option. Add a regex matching localhost links to the
`ignoreRefs` field of the default config.
2022-09-16 03:00:53 +10:00
Sereja313
1b0b8d5fdb
Merge pull request #131 from serokell/Sereja313/#77-add-glob-to-ignored-and-notScanned
[#77] Add support for glob patterns to `ignored` and `notScanned`
2022-09-08 22:52:56 +10:00
Sergey Gulin
332da5569e
[#77] Add support for glob patterns to ignored and notScanned
Problem: The `virtualFiles` config option supports glob patterns. On the
other hand, `ignored` only supports exact matches and `notScanned`
mathches on prefixes. There is also a bug where `ignored` does not
ignore files if they contain broken xrefcheck annotations.

Solution: Add support for glob patterns to `ignored` and
`notScanned`. Filter ignored files before parsing their contents.
2022-09-08 22:49:27 +10:00
Sereja313
fdf2ce27d2
Merge pull request #132 from serokell/Sereja313/#125-display-uri-parsing-errors
[#125] Display URL parsing errors
2022-09-08 22:34:37 +10:00
Sergey Gulin
a3f2d28216
[#125] Display URL parsing errors
Problem: We use a 2-step process to parse a URL: we use `parseURI` and
then `mkURIBs`. Both of these functions can fail. At the moment, we're
ignoring their errors and simply throwing a `ExternalResourceInvalidUri`,
and then displaying a generic error message to the user.

Solution: Catch errors from `parseUri` and `mkURIBs` and use them to
tell user why the URL was invalid.
2022-09-08 22:31:12 +10:00
Sereja313
391a5ea040
Merge pull request #130 from serokell/Sereja313/#120-fix-broken-anchor-checks
[#120] Fix bug with ignoring checks for relative anchors
2022-09-07 21:50:23 +10:00
Sergey Gulin
36a1da6473
[#120] Fix bug with ignoring checks for relative anchors
Problem: When a file contains a reference to another file, and that
reference contains an anchor, that anchor is not checked.

Solution: Normalise relative anchor links before check.
2022-09-07 21:48:13 +10:00
Sereja313
fd147e6856
Merge pull request #116 from serokell/breakerzirconia/#49-allow-brackets-in-URIs
[#49] Allow certain reserved characters in the URLs
2022-09-06 04:43:09 +10:00
Constantine Ter-Matevosian
80b5edd1c7
[#49] Allow certain reserved characters in the URLs
Problem: The current version of xrefcheck doesn't allow the square
brackets and some other special characters, like the angle brackets and
the curly brackets, to be present in the URLs, even in the query
strings, as they need to be percent-encoded first.

Solution: Allow some of the reserved characters, like the brackets, to
be present in the query strings of the URLs.
There exist two main standards of URL parsing: RFC 3986 and the Web
Hypertext Application Technology Working Group's URL standard. Ideally,
we want to be able to parse the URLs in accordance with the latter
standard, because it provides a much less ambiguous set of rules for
percent-encoding special characters, and is essentially a living
standard that gets updated constantly.
We allow these characters to be present in the query strings by using
the `parseURI` function from the `uri-bytestring` library with
`laxURIParseOptions`.
2022-09-06 04:39:40 +10:00
Nurlan Alkuatov
acb2394c9c
Merge pull request #127 from serokell/nalkuatov/#99-add-date-support-for-retry-after
[#99] Support `Retry-After` headers with dates
2022-09-05 13:19:30 +06:00
Nurlan Alkuatov
86e17eb3a4 [#99] Support Retry-After headers with dates
Problem: We currently support obtaining `Retry-After` header
values as seconds. However, the http specs state that the header
value can be also a date, e.g: `Wed, 21 Oct 2015 07:28:00 GMT`.

Solution: Support `Retry-After` headers with dates.
2022-09-05 13:17:05 +06:00
Sereja313
8a6490ba7f
Merge pull request #129 from serokell/Sereja313/#94-support-id-attribute-in-anchors
[#94] Add support for the `id` attribute in anchors
2022-08-29 19:07:36 +10:00
Sergey Gulin
ea88032a95
[#94] Changelog update: Add support for the id attribute in anchors
Problem: We added support for the `id` attribute in anchors. Since
this is "user-facing change", we should add an entry to `CHANGES.md`.

Solution: Add an entry to `CHANGES.md`.
2022-08-29 18:48:11 +10:00
Sergey Gulin
c4f0bfb9fc
[#94] Add support for the id attribute in anchors
Problem: The `name` attribute was deprecated, and web devs are now
encouraged to use the `id` attribute instead. We should add support
for the `id` attribute, while retaining support for the `name`
attribute.

Solution: Add support for the `id` attribute.
2022-08-29 18:41:20 +10:00
Sereja313
bf81311e43
Merge pull request #128 from serokell/Sereja313/#126-make-ignoreRefs-required
[#126] Make `ignoreRefs` a required parameter
2022-08-29 18:28:38 +10:00
Sergey Gulin
81ebde0d99
[#126] Changelog update: Make ignoreRefs a required parameter
Problem: We made `ignoreRefs` a required option. Since this
is "user-facing change", we should add an entry to `CHANGES.md`.

Solution: Add an entry to `CHANGES.md`.
2022-08-29 17:32:50 +10:00
Sergey Gulin
397f23c9da
[#126] Remove note ignoreRefs is optional from README
Problem: We made `ignoreRefs` a required option. But the `README.md`
still contains a note that `ignoreRefs` is optional.

Solution: Remove the note that says `ignoreRefs` is optional.
2022-08-29 17:26:35 +10:00
Sergey Gulin
114a6138a3
[#126] Remove note ignoreRefs is optional from config
Problem: We made `ignoreRefs` a required option. But the config file
generated with the `dump-config` option still contains a note that
`ignoreRefs` can be omitted.

Solution: Remove the note that says `ignoreRefs` can be omitted.
2022-08-27 04:54:56 +10:00
Sergey Gulin
f198777f57
[#126] Make ignoreRefs a required parameter
Problem: The `ignoreRefs` parameter, in the config file, was
optional. This is in stark contrast with all the other parameters, all
of which are required.

Solution: Make `ignoreRefs` a required parameter in the config file.
2022-08-26 21:48:33 +10:00
Nurlan Alkuatov
59727f44c8
Merge pull request #117 from serokell/nalkuatov/#90-forbid-verifying-single-file
[#90] Forbid verifying a single file
2022-07-24 19:03:40 +06:00
Nurlan Alkuatov
96960f7ebf [#90] Forbid verifying a single file
Problem: Verifying a single file using `-r` option missbehaves
when there are absolute links present in the file. Since `-r`
option expects a directory, we can just forbid verifying a single
file.

Solution: Fail with an error message when the user tries to
specify a file as the repository's root directory.
2022-07-24 18:59:53 +06:00
Diogo Castro
71a931b4eb
Merge pull request #124 from serokell/diogo/#121-mode-help-msg
[#121] Improve help message of `--mode` command line option
2022-07-24 07:51:51 +01:00