Commit Graph

379 Commits

Author SHA1 Message Date
Adrián Enríquez
978afec64a
[Chore] Allow Style tags 2022-12-22 16:50:39 +01:00
Adrián Enríquez
0886062500
[#197] Canonicalize filepaths
Problem: the current usage of filepaths is error-prone and can be
simplified.

Solution: canonicalize filepaths at the boundaries, so their management
will be safer and will simplify the codebase.
2022-12-22 16:29:23 +01:00
Adrián Enríquez
a13910d433
[Style] Fix indentation
Problem: our code contains a where statement with a 5-space indentation.

Solution: indent it with 6 spaces instead.
2022-12-22 16:29:05 +01:00
Adrián Enríquez
3c16b90bdf
[Chore] Fix CI danger checks
Problem: the danger checks were failing because it was configured to
fetch only and partially the current PR branch.

Solution: force the danger checks CI to get all the repository branches.
2022-12-20 16:50:54 +01:00
Konstantin Ivanov
96dba5f076
Merge pull request #252 from serokell/martoon/chore-add-danger-checks
[Chore] Add danger checks
2022-12-20 05:11:49 +03:00
martoon
59edcf439e
[Chore] Add license file
Problem: the danger checks that we copied had a license header, and
REUSE now complains that those headers refer to unknown licences.

Solution: copy the license file.
2022-12-20 04:55:54 +03:00
martoon
d259a3c7e2
[Chore] Add danger checks
Problem: it would be helpful to have checks for common rules on styling
commits and stuff, to avoid checking those manually every time.

Solution: add Danger checks, mostly the same we had in Morley.
2022-12-20 04:55:54 +03:00
Adrián Enríquez
50e4e3bd62
Merge pull request #231 from serokell/aeqz/#211-case_insensitive_anchors
[#211] Case insensitive anchors
2022-12-13 13:23:46 +01:00
Adrián Enríquez
dd52970029
[#211] Avoid warning on case-insensitive systems
Problem: There is currently some problem in stack or cabal
that produces a warning when building this project on
case-insensitive systems.

Solution: The current workaroud for it is to add the GHC
option '-optP-Wno-nonportable-include-path'.
2022-12-13 12:59:58 +01:00
Adrián Enríquez
7457a6b109
[#211] Specify language in a golden test
Problem: We have a Golden test that expects an output in English
and fails if a different language is configured.

Solution: Configure explicitly the language before running the
corresponding test.
2022-12-13 10:20:59 +01:00
Adrián Enríquez
e8d79e7f14
[#211] Case insensitive anchors
Problem: Some Markdown flavours such as the GitHub one are case
insensitive regarding anchors, but our analysis is currently
case sensitive and it produces false positives.

Solution: Support case-insensitivity depending on the configured
Markdown flavour. Apply this also to ambiguous and similar anchors
detection.
2022-12-13 10:20:32 +01:00
Adrián Enríquez
2b9bf2564e
Merge pull request #233 from serokell/aeqz/#25-#218-redirect-links-management
[#218] Change redirects default behaviour
2022-12-12 10:32:54 +01:00
Adrián Enríquez
9c5f5f82b7
[#218] Change redirects default behaviour
Problem: Xrefcheck currently always follows redirect links.

Solution: We are changing its default behaviour regarding redirect
links to fail and report permanent redirects, and to pass for temporary
redirects. Further PRs will allow the user to configure other policies.
2022-12-12 10:19:01 +01:00
YuriRomanowski
997c43833e
[#227] Add .xrefcheck.yaml config to repo (#232)
Problem: Currently, there are some invalid links in the repository,
mostly for tests, so one has to add some CLI options
for `xrefcheck` to succeed.

Solution: Added a new minimal `.xrefcheck.yaml` config file
such that `xrefcheck` succeeded without any options.
2022-12-06 23:24:58 +05:00
Adrián Enríquez
8b2b04652f
Merge pull request #229 from serokell/aeqz/#228-rename_local_file_reference_tag
[#228] Rename local file reference tag
2022-12-01 20:15:20 +01:00
Adrián Enríquez
5ff63f342a
[#228] Changelog entry 2022-12-01 12:00:49 +01:00
Adrián Enríquez
347f0eecd1
[#228] Rename local file reference tag
Problem: We have found that the current tag for local file references, current file, may lead to ambiguities.

Solution: Rename the tag that we use for local file references to be file-local instead.
2022-12-01 11:54:32 +01:00
Adrián Enríquez
1953238da1
Merge pull request #224 from serokell/aeqz/#202-avoid_exotic_unicode_symbols
[#202] Remove poorly supported unicode symbols from the program output
2022-12-01 09:58:27 +01:00
Adrián Enríquez
d41a07e7bc
[#202] Remove poorly supported unicode symbols from the program output
Problem: We are using unicode symbols as visual clues in the program output that are not commonly supported and are therefore not always displayed as intended.

Solution: Remove the usage of these symbols, as the program output is already using other visual clues and the result will remain understandable for the user.
2022-12-01 09:47:51 +01:00
Sorokin-Anton
64158281f2
Merge pull request #191 from serokell/Sorokin-Anton/#164-ci-windows-tests
[#164] Improve Windows support
2022-11-30 21:11:40 +02:00
Anton Sorokin
fb77575b0b
[#164] Add workflow for running Windows tests on CI
Problem: we are not testing behavior of xrefcheck on Windows

Solution: and add workflow to run
golden and tasty tests on CI
via github-actions windows runner
Some subproblems appear:

1.
Problem: CI build fails beacuse it needs `pcre` package
Solution: add it (somehow), see `install pacman dependencies`
in ci.yml

2.
Problem: Network errors displayed different on different platforms
Solution: collect output from both and use
`assert_diff expected_linux.gold || assert_diff expected_windows.gold`

3:
Problem: "Config matches" test is failing because checkout action
clone files with CRLF, and test assert equality of two ByteStrings
Solution: manually remove CR
2022-11-30 21:00:58 +02:00
Anton Sorokin
aba295b478
[#164] Use only '/' as path separator
Problem: in markdown links, '/' should always be used as path separator ,
e.g. GitHub renderer is not threating link `[x](a\b.md)` as a link
to file in dir `a`
We use OS-dependent file separators everywhere, so
e.g. `canonizeLocalRef "./a.md"="./a.md`"` on Windows

Solution: replace '\' to '/' while constructing repo tree if needed
and then use only '/', preferring functions from `System.FilePath.Posix`.
We can do this, since 'a/b' and `a\b` are equivalent paths on Windows
2022-11-29 19:35:17 +02:00
Anton Sorokin
09783e0213
[#164] Use utf8-compatible codepage on Windows
Problem: xrefcheck uses utf8 symbols in reports, which are not supported
on most of Windows shells by default.
Sometimes they are printed as question marks (and it cause golden tests to fail)
and sometimes printing of them raise an error.

Solution: use function `withCP65001` from `code-page` package which
sets correct codepage on Windows and do nothing on other OSs
2022-11-29 19:35:16 +02:00
Sorokin-Anton
a2404e8c2f
Merge pull request #225 from serokell/Sorokin-Anton/#223-nyan-defConfigText
[#223] Use nyan-interpolation for `defConfigText`
2022-11-29 18:02:15 +02:00
Anton Sorokin
7115c657ea
[#223] Use nyan-interpolation for defConfigText
Problem:
We have a function `defConfigText :: Flavor -> ByteString` that
uses  `fillHoles` to modify `defConfigUnfilled`.
This is a bit error-prone and very complicated way to have a
`ByteString` with parametric blocks. Also using `ByteString`
instead of `Text` to store text leads to CRLF-related issues when
launched on Windows.

Solution:
Remove `fillHoles` and `defConfigUnfilled`,
`defConfigText` creates a `Text` using `nyan-interpolation`.
2022-11-29 16:52:13 +02:00
Diogo Castro
a534c5fcd2
Merge pull request #216 from serokell/diogo/#147-update-readme
[#147] Update readme
2022-11-18 11:42:17 +00:00
Diogo Castro
2fd11bfeb1
[#147] Improve readme
Improved the readme and fixed several problems:
* Mention support for GitLab - this is important and wasn't mentioned
  anywhere.
* Add a FAQ clarifying how xrefcheck behaves in some important
  situations.
* We don't need to get into a lot of detail about the syntax of the
  `xrefcheck: ignore` annotations, where they're allowed and where
  they're not. A general idea and a couple of examples are more than
  enough.
* Added the backlink `[↑](#xrefcheck)` where it was missing.
* Fixed inconsistent level headers: we we're using `###` where we should
  be using `##`
* `nix run` should now be `nix shell`
* Add a link to `tests/configs/github-config.yaml` which contains a list
  of all supported config options.
* Instead of mentioning GitHub Actions in the "usage" section and nix in
  a separate section, mention everything in the "usage" section.
* Fixed link to `stack2cabal`
* Fixed typos and rephrased some bits.
2022-11-18 11:39:02 +00:00
Diogo Castro
247f12ad3e
[Chore] Fix dockerhub tags
Problem: We have a pipeline step to tag docker images on dockerhub
whenever a new version is released:
7dd5c4c3c9/.buildkite/pipeline.yml (L51-L56)

However, this doesn't seem to be working, dockerhub only contains the
`latest` tag: https://hub.docker.com/r/serokell/xrefcheck/tags

The problem *seems* to be that the CI step is only triggered when it
builds a branch with a name matching the regex `/^v[0-9]+.*/`. But we
never use that format for branch names, so it's never triggered.

Solution:
1. Change the CI step to trigger when it detects a tag with a version
   number
2. Enable the "Build tags" option in buildkite:
   https://buildkite.com/serokell/xrefcheck/settings/repository
2022-11-18 11:36:46 +00:00
Sorokin-Anton
68a909899d
Merge pull request #215 from serokell/Sorokin-Anton/#200-untracked-files-hints
[#200] Warnings about files that weren't added to git yet
2022-11-17 15:49:48 +02:00
Anton Sorokin
1c0fbfef95
[#200] Add --include-untracked CLI option
Problem: xrefcheck checks only files that are tracked by Git,
but sometimes we want to run xrefcheck on
files without adding them to Git, e.g. when we want to
test some generator of markdown files or when we actively
create markdown files during development.

Solution: add option to treat files that were neither
added to git nor ignored as existing.
2022-11-17 15:38:42 +02:00
Anton Sorokin
da25917fa6
[#200] Warnings about files that weren't added to git yet
Problem: after 0.2.2 release, xrefcheck cares only about files
that were added to Git. That can be confusing for users (see #200)

Solution:
If a scannable (currently it means markdown) file is not ignored
(by git or via config) and not tracked by git, print a warning to
stderr while scanning repo.

If a link target such file, change error message from "file not exists"
to `Link target is not tracked by Git`

Suggest user to run "git add" before running xrefcheck in both cases.

To do this, I've changed the `RepoInfo` type, so it also contains
information about untracked files now.
2022-11-17 15:32:02 +02:00
Sorokin-Anton
2d83165a0b
Merge pull request #209 from serokell/Sorokin-Anton/#89-handle-interrupts
[#89] Handle user interrupts
2022-11-16 15:19:40 +02:00
Anton Sorokin
4782c360ae
fixup! fixup! fixup! fixup! [#89] Handle user interrupts 2022-11-16 00:22:05 +02:00
Anton Sorokin
8e5f76e210
fixup! fixup! fixup! [#89] Handle user interrupts 2022-11-10 16:20:12 +02:00
Anton Sorokin
7b7f0a640e
fixup! fixup! [#89] Handle user interrupts 2022-11-10 15:49:27 +02:00
Anton Sorokin
63a317b88e
fixup! [#89] Handle user interrupts 2022-11-10 15:49:25 +02:00
Anton Sorokin
db430a6a61
[#89] Handle user interrupts
Currently, if xrefcheck is interrupted, it's not displaying any
`VerifyError`s, even if it has already found some.
When we found error, we are notifying user via progress bar, but he must
wait checking of all references to see it
(and it can be long enough).

Solution: when xrefcheck is interrupted, display all errors
we have already found and a number of
checked references.
To do this, we need to modify `forConcurrentlyCaching`
behaviour on exceptions.
2022-11-10 15:47:57 +02:00
Sorokin-Anton
c45f1ecc63
Merge pull request #214 from serokell/Sorokin-Anton/#213-remove-trailing-spaces
[#213] Do not print trailing whitespaces
2022-11-10 15:16:35 +02:00
Anton Sorokin
8012dc94d3
[#213] Do not print trailing whitespaces
Problem: bats tests are not space sensetive
Solution: remove trailing spaces from xrefcheck output
(see next problems), remove `--ignore-trailing-space`
from `assert_diff`

Problem: there are lines containing only spaces in
xrefcheck's output, because `Fmt.indentF` "indents"
empty lines too.
Solution: add `Xrefcheck.Util.Interpolate.interpolateIndentF`
function that is not indenting empty lines.
Same for `Fmt.blockListF` and `Fmt.blockListF'`.
Those functions are not adding trailing newlines, so it's
easier to use it in interpolation blocks.

Problem: when there is a current file link `[a](#b)`, it is
printed like
```
- text: "a"
- link: (trailing space here)
- anchor: b
```
Solution: like with anchors, print `link: -` instead
2022-11-10 15:10:59 +02:00
Sorokin-Anton
7dd5c4c3c9
Merge pull request #212 from serokell/Sorokin-Anton/#208-remove-exessive-newlines
[#208] Remove exessive newlines from output
2022-11-04 17:41:12 +02:00
Anton Sorokin
1476bd3435
[#208] Remove exessive newlines from output
Problem: xrefcheck's output contains many redundant newlines, so
it takes more display space than it could.
For list of places where such newlines appear, see #208

Solution: don't print redundant newlines, so output is more compact.
Since tests are newline-sensetive, I've checked that now there
are no extra  (e.g. 2 ajacent) blank lines in `expected` part of tests.
2022-11-04 14:27:19 +02:00
Sorokin-Anton
b49865014c
Merge pull request #204 from serokell/Sorokin-Anton/#201-nyan-interpolation
[#201] Use nyan-interpolation for building error messages
2022-11-03 17:42:24 +02:00
Anton Sorokin
82bf996615
[#201] Use nyan-interpolation for building error messages
Problem:
We often need to create large strings, and we use different
fmt tools for this (by-hand concatenation, unlinesF, etc).
Sometimes it is unclear or too heavy, and it always can
be called error-prone

Solution: use `int` quasiquoter to build large strings and
have nice-looking and easy-to-read code
2022-11-03 17:39:10 +02:00
Diogo Castro
543749ad78
Merge pull request #207 from serokell/diogo/#206-whitespace-tests
[#206] Make bats tests space-sensitive
2022-10-26 14:35:43 +01:00
Diogo Castro
e93a21e18a
[#206] Make bats tests space-sensitive
Problem: Right now, our bats tests ignore empty lines and
leading/trailing whitespace differences between the expected output and
the actual output.

However, this could lead to accidental bugs in xrefcheck's output.

Trailing whitespace isn't very concerning (except when it's excessive
and it causes the terminal to line-wrap), but additional/missing empty
lines and leading whitespace can lead to significant changes.

Solution: Let's make these tests sensitive to empty lines and leading
whitespace.
2022-10-26 13:14:45 +01:00
Sorokin-Anton
59cb36cb38
[Chore] Fix changelog entry (#205) 2022-10-26 13:30:47 +03:00
Sorokin-Anton
2f2fce5dab
Merge pull request #199 from serokell/Sorokin-Anton/#169-rename-ignore-file-annotation
[#169] Rename `ignore file` annotation to `ignore all`
2022-10-26 11:40:35 +03:00
Anton Sorokin
23b52729b1
[#169] Rename ignore file annotation to ignore all
Problem: as in #169, `ignore file` annotation is ignoring
not file itself but all links at file, which is not obvious

Solution: rename it to `ignore all`

Also renamed `IMFile :: IgnoreMode` and `IMSFile :: IgnoreModeState`
to `IMAll` and `IMSAll`
2022-10-26 11:31:52 +03:00
Sereja313
eafff47c60
Merge pull request #183 from serokell/Sereja313/#92-add-support-for-image-links
[#92] Add support for image links
2022-10-26 09:41:58 +10:00
Sergey Gulin
1740be676a
[#92] Add support for image links
Problem: We should add support for image links.

Solution: Extract image links as regular links.
2022-10-26 09:37:56 +10:00