Commit graph

819 commits

Author SHA1 Message Date
Tomas Janousek
7b67d510cc cache: Get markup_syntax from vimwiki, drop g:taskwiki_markup_syntax
I don't see the point of forcing the user to select this manually in
both vimwiki and taskwiki.
2020-09-18 11:31:49 -04:00
Tomas Janousek
5807945a40 cache: Drop unnecessary decode_bytes invocations
These were made redundant in 61d0d89be9
but never dropped. It's time.
2020-09-18 11:31:49 -04:00
Tomas Janousek
92785f10f7 ftplugin: Minor cleanup 2020-09-18 11:28:39 -04:00
Tomas Janousek
94fe6ed8e8 ftplugin: Postpone initial refresh to better preserve folds
Vim preserves folds by writing line jumps into the view script, so it's
better to load this script with the original file contents and only then
refresh from taskwarrior. The folding is still often broken when the
buffer is updated, but that can now be considered a vim bug and may
perhaps one day be fixed (or even worked around, if one is persistent
enough). Loading the view after modifying the buffer is simply wrong,
that can never ever work.
2020-09-18 11:28:39 -04:00
Tomas Janousek
f3fe7aca21 ftplugin: Only load the python plugin once
This makes opening wiki pages significantly faster and also prevents
clearing the entire cache every time.
2020-09-18 11:28:39 -04:00
Tomas Janousek
b722c29f9e ftplugin: Make commands buffer-local
Consistency with vimwiki, less confusion/clutter.
2020-09-18 11:28:39 -04:00
Tomas Janousek
2942ba776d ftplugin: Use buffer local autocmds
* simplifies code a bit
* avoids triggering autocmds on *.wiki files outside of registered vimwiki
* prevents reordering of autocmds when switching wiki pages

The last bit is my main motivation: I need to add a BufEnter autocmd (to
~/.vim/after, not to taskwiki itself) and I'd love to rely on
`cache.load_current()` having been called already.
2020-09-18 11:28:39 -04:00
Tomas Janousek
d00234b60d ci: Don't hash TASK_DEVEL_SHA for tags (reuses old docker images)
This isn't really necessary but it seems cleaner anyway. :-)
2020-09-18 11:26:08 -04:00
Tomas Janousek
3498c51a46 ci: Simplify getting branch HEAD commit hash
This is simpler and more reliable/predictable:

"git ls-remote 'heads/'" doesn't return anything, while "grep 'heads/'"
returns all branches, so a taskwarrior push causes most docker images
(those that don't have any TASK_VERSION and fallback to the Dockerfile
default) to be rebuilt, not just the one that needs to be.
2020-09-18 11:26:08 -04:00
Tomas Babej
36652d1f9b
ci: Consider the HEAD commit hash for our cache test image tag
For the development branches of taskwarrior, caching 2.5.2 or 2.6.0 is
not sufficient since HEAD is still moving.

Build the tag hash based on the HEAD hash of the development branch in
question.
2020-09-18 02:19:40 -04:00
Tomas Babej
8353170200
util: Use tasklib.__version__ to determine module version
Importing pkg_resources module is notoriously slow, see [1,2]. Tasklib
module now provides __version__ attribute for an easy method of version
checking.

[1] https://github.com/pypa/setuptools/issues/510
[2] https://github.com/pypa/setuptools/issues/926
2020-09-17 23:04:33 -04:00
Tomas Babej
5032d0d74f
requirements: Bump required tasklib version 2020-09-17 23:04:32 -04:00
Tomas Janousek
a9af18203b tests: Fix build of psutil (required by pytest-xdist 2.0)
77e5fdfef9
2020-09-17 22:11:42 -04:00
Tomas Janousek
4b8ef36e69 README: Update GitHub URIs (fixes Coveralls badge)
Coveralls doesn't know that tools-life/taskwiki is the same repo as
tbabej/taskwiki so we need to update this. The rest redirects
automatically and is updated just for consistency.

Gitter room is still called tbabej/taskwiki.
landscape.io is probably dead but the badge still works so I'm not
touching that one either.
2020-09-17 21:58:54 -04:00
Tomas Babej
7a2b0d9ad1
docs: Add a note about spaces being mandatory around modstring operator 2020-08-02 18:17:43 -04:00
Tomas Janousek
29adb30f00 vwtask: Require spaces around --
There's -- in Google Drive URLs which I sometimes add to my task
descriptions.
2020-08-02 18:14:00 -04:00
Tomas Janousek
9d7d90192b syntax: Highlight priority in TaskWikTask{Active,Completed,…} as well
The more straightforward `containedin=@TaskWikiTaskContains`
unfortunately doesn't work as it actually means
`containedin=VimwikiListTodo,VimwikiTag,VimwikiEmoticons,…` and that
isn't what we want.
2020-08-02 17:56:21 -04:00
Tomas Janousek
8a8d22cd7a syntax: Allow regular vimwiki syntax in TaskWikTask{Active,…} as well 2020-08-02 17:56:21 -04:00
Tomas Janousek
30058188ac vwtask: Refactor apply_defaults
5bf0c89ae8 left a misleading comment in
the code:

                # If port was detected, break the search

            break

Refactor the code to make it clearer what's going on: we're looking for
the first parent header/preset/viewport of this task, and therefore we
always break. By separating the search and processing of the found
header/preset/viewport, we avoid the confusion.

Related: https://github.com/tools-life/taskwiki/pull/288
2020-08-02 17:52:55 -04:00
Tomas Janousek
13ee57540e tests: Refactor Dockerfile to multi-stage (more caching during development)
The previous refactor traded build step caching for smaller image size,
which in turn made fast caching of built images possible, and allowed us
to speed up CI builds. But almost any change in Dockerfile required full
rebuild of everything (vim & taskwarrior), so changes to the Dockerfile
became more painful.

This commit refactors the Dockerfile to use multi-stage builds, which
brings build caching back: vim & taskwarrior are built in separate
stages, which are cached step by step, and then the build artifacts are
copied into the main tests image and runtime dependencies are installed.

There's a catch, of course: --cache-from doesn't work with multi-stage
images unless the experimental BuildKit backend and its inline cache
export are enabled. This requires docker 19.03, which shouldn't be hard
to obtain but isn't installed by default on Travis CI.
2020-08-02 17:24:20 -04:00
Tomas Janousek
ae588783c1 tests: Cache the docker image on GitHub Packages
This speeds up the workflow from cca 9 minutes to less than 4 minutes,
as the 5 minute docker build is replaced with a 10 second docker pull.
2020-08-02 17:24:20 -04:00
Tomas Janousek
8e69ea52fb tests: Update test matrix (varying versions of vim, vimwiki, python)
(taskwarrior 2.5.2 branch fails a few tests, will investigate later)
2020-08-02 17:24:20 -04:00
Tomas Janousek
f2d1c162e2 tests: Fix "Different tests were collected" in python 3.5
pytest-xdist requires all subprocesses to collect the tests in the same
order. Python 3.5, however, randomizes order of dict keys.
2020-08-02 17:24:20 -04:00
Tomas Janousek
bc471ec94a tests: Refactor Dockerfile
* Switch from Fedora to Alpine. This makes it possible to have smaller
  docker images (Alpine is smaller by itself; apk add --virtual makes it
  feasible to correctly remove build dependencies) which will be useful
  for caching the images somewhere instead of building them in CI again
  and again. This is expected to cut the CI test time in half.

* Make versions of python, vim and vimwiki configurable via docker build
  args to enable testing of additional environments. This makes the
  build slower, but we will fix that by caching.

Unfortunate consequence of doing all the installs in one RUN step is
that docker build doesn't cache the intermediate steps and therefore
modifying the Dockerfile and testing those modifications locally is now
slower than it used to be. This can likely be improved by using
multi-stage builds (and using BuildKit and its inline cache export to
not break the caching we're about to add a few commits later).
2020-08-02 17:24:20 -04:00
Tomas Janousek
4e8b01e6e2 tests: Switch from Travis to GitHub Actions (faster)
Primary motivation for this is speed: GitHub Actions doesn't limit the
number of concurrent jobs to 4, and also provides a docker registry
(GitHub Packages) that we can use to cache the image (building the image
takes cca 5 minutes, fetching it would take less than 10 seconds). This
is done in another commit.

The workflow definition is a bit more complicated because coveralls
support for GitHub Actions is less mature than for Travis CI, so we need
to manually tell coveralls that all parallel builds have finished and
that it can publish the combined result.
2020-08-02 17:24:20 -04:00
Tomas Janousek
3b72535707 settings: Remember cursor position in the view
Commit 9f3a52e73b meant to only disable remembering options, but it
ended up disabling remembering of cursor position as well. The cursor is
still restored by last-position-jump (see usr_05.txt) if one has that in
their vimrc, but whenever there are any folds in the view, restoring
these folds resets the cursor again.

Not disabling saving of cursor position fixes this in the default
configuration and lets the user tweak viewoptions however they like.
2020-08-02 17:20:32 -04:00
Xyank
9565f1f30e Fix priority field in sort order
Did not actually change the code. Instead changed the docs referring to
the "priority" field incorrectly as "pri", and changed `constants.py` to
reflect the correct name for it.
2020-07-12 09:54:58 -04:00
Nikolaos Kakouros
79f086aef4 Adds missing doc for waiting-task marker 2020-07-08 21:37:34 -04:00
Tomas Janousek
58af37436e tests: Really move command from docker-compose.yml to Makefile
This makes it easier to understand the interaction between the outer and
inner make, as one doesn't need to dig through docker-compose.yml and
possibly Dockerfile to find what command will be run.

It does break the ability to run `docker-compose run --rm tests` but
that's a good thing I believe: I only ever use that when I need a shell
in the container for debugging purposes.
2020-07-08 21:36:52 -04:00
Tomas Janousek
15ce16f24c Revert "tests: Use explicit coverage tracking"
This reverts commit b00e886142.

This fixes reporting of coverage by the few tests that run outside of
vim.

The commit that is being reverted doesn't explain why it was committed,
and the git history suggests it was reverted once and then reintroduced
later again. None of those commits explains the why. I can only guess
that the last time this was committed was an attempt to fix coverage
reporting to outside of docker, which it didn't, and additionally it
made coverage gathering less robust (see previous commit). So this is
yet another fix for the inaccurate coverage reporting.

Or maybe it was because `--cov` without `=taskwiki` an argument reports
coverage for tests instead of taskwiki code? Nevermind, I guess, now it
works well.
2020-07-08 21:36:52 -04:00
Tomas Janousek
aa6c0deb00 tests: More robust (and simpler) coverage tracking
Let coverage.py handle generating the filename and saving data at exit.
This is more robust: it adds a random suffix as well so if one process
creates two Coverage objects, they don't write to the same file like we
did. This is another way to fix the inaccurate coverage reporting.

From my experiments it seems that the first Coverage object started (and
thus the last that saves its data) only covers the loading of modules
(defs, classes, etc.) whereas the second one, whose data is overwritten
by the first, contains the actual coverage generated by running the
tests.
2020-07-08 21:36:52 -04:00
Tomas Janousek
7d5b902c89 tests: Do not load vimwiki/taskwiki twice
Since c8c3cc9a00, vimwiki filetype is set
automatically by :edit, and `set filetype=vimwiki` loads everything
again.

One consequence of loading taskwiki twice is that
taskwiki/testcoverage.py is sourced twice, the Coverage object is
initialized, started, stopped and saved twice (with the same data
filename!) and the coverage report is inaccurate as two trackers write
into the same file.
2020-07-08 21:36:52 -04:00
Tomas Janousek
1b439fee9e docs: Update test instructions 2020-07-08 21:36:52 -04:00
Tomas Janousek
14c0268438 tests: Upgrade vimrunner and drop the now unnecessary hacks
This makes the tests less brittle and potentially also faster.
2020-07-02 09:51:56 -04:00
Tomas Janousek
4efe2c83d6 tests: Refactor the self.tasks resetting hack 2020-07-02 09:51:56 -04:00
Tomas Janousek
7f47669e0c tests: Run tests in parallel using pytest-xdist 2020-07-02 09:51:56 -04:00
Tomas Janousek
2c22bb2645 tests: Drop sudo, language: python from .travis.yml
These shouldn't be necessary, drop it to speed things up.
2020-07-02 09:51:56 -04:00
Tomas Janousek
625c26d59f regexp: Fix empty viewport filters in markdown
In markdown, there's no ' =' after '|', so the '+' in the filter regex
doesn't match. Let's allow filter to be empty and distinguish between
viewports and presets using negative look-ahead.

This fixes the failing TestViewportsTaskGenerationEmptyFilter test.
2020-07-02 09:51:56 -04:00
Tomas Janousek
7663a58793 tests: Fix coverage reporting
Coverage reporting wasn't migrated into the docker container and
therefore did nothing at all.
2020-07-02 09:51:56 -04:00
Tomas Janousek
f0cc8b3ba8 tests: Move command from docker-compose.yml to Makefile
This is a preparation for adding additional commands to the test, like
postprocessing the coverage data, which needs to be processed in the
container (unless we somehow copy the data out of it; but then, we
already install coverage and coveralls inside it, so...).

Additionally, this makes it a bit easier to run the tests locally, which
is helpful when investigating errors. Just a tiny bit, though: it still
requires setting up a fake home with a reasonably minimal .vim and a
python environment with vimrunner.
2020-07-02 09:51:56 -04:00
Tomas Janousek
45d448bda6 tests: Invoke using docker-compose run instead of up
Doesn't leave stopped containers around and feels more like running
locally (terminal size and CTRL-C is passed to pytest).
2020-07-02 09:51:56 -04:00
Tomas Janousek
d7167d9a50 meta: Use tasklib from PyPI in requirements
Current git already dropped support for Python 2, so let's stick with
1.3 until we drop it as well. We don't need bleeding edge any more.
2020-07-02 09:51:56 -04:00
Tomas Janousek
ae924a2afc tests: Drop unnecessary markup_syntax from MockCache 2020-07-02 09:51:56 -04:00
Tomas Janousek
6dd4d81aec tests: Use "default" syntax instead of "mediawiki" (for consistency) 2020-07-02 09:51:56 -04:00
Tomas Janousek
698e2448f3 tests: Fix vimwiki loading errors
Not only can we stop ignoring the errors, this also fixes
TestInfoActionNotTriggeredByEnterOnLink which would otherwise cause vim
to complain about g:vimwiki_wikilocal_vars not being available.
2020-07-02 09:51:56 -04:00
Tomas Janousek
789d04f488 tests: Catch vim errors in read_buffer
Without this, TestInfoActionNotTriggeredByEnterOnLink would pass because
it asserts that the buffer is empty, which is what read_buffer returned
if vim was stuck showing an error message. With `PYTEST_FLAGS=-s`, it
would additionally log

    E449: Invalid expression received: Send expression failed.

but that's easy to miss.
2020-07-02 09:51:56 -04:00
Tomas Janousek
9457b509cf tests: Simplify MultiSyntaxIntegrationTest.test_execute
Remove duplicated code.
2020-07-02 09:51:56 -04:00
Tomas Janousek
4e40a969f0 tests: Quit vim more reliably
`TestSuppressedMapping` leaves vim in visual mode and
`vimrunner.Client.quit()` fails with "E481: No range allowed" resulting
in

    Vim: Caught deadly signal TERM
    Vim: Finished.

This is probably harmless as the `quit()` is followed by `pkill`, but
let's do it the right way anyway.
2020-07-02 09:51:56 -04:00
Tomas Janousek
78105f4aca tests: Fix setting vim up twice
Since 8d8fd2c20b, the first `setup`
invocation sets g:taskwiki_markup_syntax="None" which is then detected
in `check_sanity` and vim is restarted, this time with correct
g:taskwiki_markup_syntax. This is wasteful and weird, but makes a bit of
sense as a hack to make `MultiSyntaxIntegrationTest` work as the
test_syntax fixture is not available in `setup`.

To fix this:

 * make `teardown` idempotent
 * let `check_sanity` fail early if the client is not set up yet
 * disable `setup` in `MultiSyntaxIntegrationTest`
 * let the sanity check and restart logic handle the setup in
   `MultiSyntaxIntegrationTest` once `markup` is available
2020-07-02 09:51:56 -04:00
Tomas Janousek
5037e18937 regexp: Fix DeprecationWarning: invalid escape sequence 2020-07-02 09:51:56 -04:00