Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fea115a
Switch to Codecov
jacebrowning Mar 5, 2022
0c85daa
Enable XML coverage reports
jacebrowning Mar 5, 2022
a63afc6
Merge pull request #552 from doorstop-dev/codecov
jacebrowning Mar 5, 2022
7b516f7
Upgrade Markdown
jacebrowning Mar 5, 2022
a504163
Only upload coverage from Linux jobs
jacebrowning Mar 5, 2022
8a316b9
Only run the linter and demo on one OS
jacebrowning Mar 5, 2022
c0df734
Merge pull request #553 from doorstop-dev/update-markdown
jacebrowning Mar 5, 2022
79f31ec
Make the compile script executable
jacebrowning Mar 5, 2022
9962a6b
Add pytest-sugar
jacebrowning Mar 5, 2022
b14c66d
Merge pull request #554 from doorstop-dev/sugar
jacebrowning Mar 5, 2022
94da6b8
Added patch from urbasus
Mar 7, 2022
5b8ecb3
Added test for loading UTF-8 files and writing them back.
Mar 7, 2022
ff54ecb
Removed architecture since only x64 is used now.
Mar 7, 2022
14bb6e6
Only upload coverage for python 3.9
Mar 7, 2022
fe72d40
Do not upload coverage for forks.
Mar 7, 2022
6ede2ee
Merge pull request #556 from neerdoc/Simplify_CI
neerdoc Mar 7, 2022
4682c50
Wait for url response of server.
neerdoc Mar 7, 2022
d717791
Retry intermittently failing tests automatically.
neerdoc Mar 7, 2022
4f5471b
Merge pull request #559 from doorstop-dev/wait_for_server
neerdoc Mar 8, 2022
a578a98
Re-added run on PR.
Mar 8, 2022
5bb9def
Re-added for Windows and MacOS too.
Mar 8, 2022
6b7c7e8
Checkout of PR uses different naming convention. Test using action/ch…
Mar 8, 2022
e1c0528
Fixed typo.
Mar 8, 2022
258c831
Files are missing. Change copy command.
Mar 8, 2022
e32be36
Copy instead of move.
Mar 8, 2022
b82cde2
Show env and changed copy command.
Mar 8, 2022
17b60e1
Changed to backslash.
Mar 8, 2022
38cbc5c
Show what gets moved.
Mar 8, 2022
d0d832e
Show make doctor too.
Mar 8, 2022
fe57614
Only run single windows during debugging.
Mar 8, 2022
3406bd4
Show hidden files.
Mar 8, 2022
4fe5e92
Try moving .git folder too.
Mar 8, 2022
d299ec7
Cleaned up.
Mar 8, 2022
6f36d1f
Cleaned up even more.
Mar 8, 2022
2a50137
Merge remote-tracking branch 'origin/develop' into UTF-8
Mar 8, 2022
054bc92
Merge pull request #560 from neerdoc/CI_on_PR
neerdoc Mar 8, 2022
541f5b5
Merge pull request #526 from urbasus/urbasus-patch-1
jacebrowning Mar 9, 2022
613df32
Bump version to 3.0b3
jacebrowning Mar 9, 2022
73c1b4c
Merge branch 'develop' into UTF-8
Mar 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions .github/workflows/execute-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ name: Execute tests
on:
workflow_call:
inputs:
architecture:
required: true
type: string
basepath:
required: true
required: false
type: string
os:
required: true
Expand All @@ -29,24 +26,22 @@ jobs:
working-directory: ${{ inputs.workpath }}

steps:
- name: Checkout Unix
if: ${{ inputs.os != 'windows-latest' }}
run: |
mkdir -p ${{ inputs.workpath }}
git clone https://github.com/${{ github.repository }} ${{ inputs.workpath }} --depth 1 --branch $GITHUB_REF_NAME
- name: Checkout Windows
- name: Checkout
uses: actions/checkout@v2

- name: Change path on Windows
if: ${{ inputs.os == 'windows-latest' }}
# Cannot start powershell from a path that does not exist, so change
# working directory for this step only.
working-directory: ${{ inputs.basepath }}
if: ${{ inputs.os == 'windows-latest' }}
run: |
mkdir -p ${{ inputs.workpath }}
git clone https://github.com/${{ github.repository }} ${{ inputs.workpath }} --depth 1 --branch $env:GITHUB_REF_NAME
mv $env:GITHUB_WORKSPACE\* ${{ inputs.workpath }}\ -Force

- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ inputs.architecture }}
architecture: x64

- uses: Gr1N/setup-poetry@v7

Expand All @@ -61,11 +56,29 @@ jobs:
- name: Install project dependencies
run: make install

- name: Run tests
# Some tests fails intermittently, likely due to the public runners being
# very slow. Especially any client/server tests seems to be problematic.
# This is a simple attempt to re-run the tests up to three times if they
# fail. Does not add any execution time if successful.
- name: Run tests attempt 1
run: make test
- name: Run tests attempt 2
if: ${{ failure() }}
run: make test
- name: Run tests attempt 3
if: ${{ failure() }}
run: make test

- name: Upload coverage
uses: codecov/codecov-action@v1
if: ${{ inputs.os == 'ubuntu-latest' && matrix.python-version == '3.9' && github.repository == 'doorstop-dev/doorstop' }}
with:
fail_ci_if_error: true

- name: Run checks
run: make check
if: ${{ inputs.os == 'ubuntu-latest' }}

- name: Run demo
run: make demo
if: ${{ inputs.os == 'ubuntu-latest' }}
7 changes: 4 additions & 3 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Linux

on: push
on:
push:
pull_request:
branches: [ develop ]

jobs:
Test:
uses: ./.github/workflows/execute-tests.yml
with:
architecture: x64
basepath: "/home/runner/work"
os: "ubuntu-latest"
workpath: "/home/runner/work/doorstop/doorstop"
7 changes: 4 additions & 3 deletions .github/workflows/test-osx.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: macOS

on: push
on:
push:
pull_request:
branches: [ develop ]

jobs:
Test:
uses: ./.github/workflows/execute-tests.yml
with:
architecture: x64
basepath: "/Users/runner/work"
os: "macos-latest"
workpath: "/Users/runner/work/doorstop/doorstop"
8 changes: 4 additions & 4 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Windows

on: push
on:
push:
pull_request:
branches: [ develop ]

jobs:


Test:
uses: ./.github/workflows/execute-tests.yml
with:
architecture: x64
basepath: 'D:\'
os: "windows-latest"
workpath: 'C:\a\doorstop\doorstop'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Icon*
/site/
/*.html
/docs/*.png
texput.log

# Google Drive
*.gdoc
Expand All @@ -37,6 +38,7 @@ Icon*
/pyunit.xml
/tmp/
*.tmp
coverage.xml

# Build and release directories
/build/
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"choco",
"clevel",
"cname",
"codecov",
"codeql",
"cors",
"curr",
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- **BREAKING:** Dropped support for Python 3.6.
- **BREAKING:** Removed `--no-body-levels` option to `doorstop publish`.
- Fixed overriding default attributes with `doorstop add`. ([@tangoalx](https://github.com/doorstop-dev/doorstop/pull/544))
- Fixed encoding error with special characters on Windows. ([@urbasus](https://github.com/doorstop-dev/doorstop/pull/526))
- Add support for publishing to the LaTeX format. ([@neerdoc](https://github.com/doorstop-dev/doorstop/pull/545))

# 2.2 (2022-01-22)
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ PYTEST_OPTIONS := --doctest-modules
ifndef DISABLE_COVERAGE
PYTEST_OPTIONS += --cov=$(PACKAGE) --cov-report=html --cov-report=term-missing
endif
ifdef CI
PYTEST_OPTIONS += --cov-report=xml
endif

.PHONY: test
test: test-all ## Run unit and integration tests
Expand Down Expand Up @@ -147,7 +150,7 @@ DOORSTOP := poetry run doorstop
YAML := $(wildcard */*.yml */*/*.yml */*/*/*/*.yml)

.PHONY: reqs
reqs: doorstop reqs-html reqs-latex reqs-md reqs-txt
reqs: doorstop reqs-html reqs-latex reqs-md reqs-pdf reqs-txt

.PHONY: reqs-html
reqs-html: install docs/gen/*.html
Expand All @@ -164,6 +167,10 @@ reqs-md: install docs/gen/*.md
docs/gen/*.md: $(YAML)
$(DOORSTOP) publish all docs/gen --markdown

.PHONY: reqs-pdf
reqs-pdf: reqs-latex
cd docs/gen && ./compile.sh

.PHONY: reqs-txt
reqs-txt: install docs/gen/*.txt
docs/gen/*.txt: $(YAML)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Mac OS X Test](https://github.com/doorstop-dev/doorstop/actions/workflows/test-osx.yml/badge.svg)](https://github.com/doorstop-dev/doorstop/actions/workflows/test-osx.yml)
[![Windows Test](https://github.com/doorstop-dev/doorstop/actions/workflows/test-windows.yml/badge.svg)](https://github.com/doorstop-dev/doorstop/actions/workflows/test-windows.yml)
<br>
[![Coverage Status](http://img.shields.io/coveralls/doorstop-dev/doorstop/develop.svg)](https://coveralls.io/r/doorstop-dev/doorstop)
[![Coverage Status](https://img.shields.io/codecov/c/gh/doorstop-dev/doorstop)](https://codecov.io/gh/doorstop-dev/doorstop)
[![Scrutinizer Code Quality](http://img.shields.io/scrutinizer/g/doorstop-dev/doorstop.svg)](https://scrutinizer-ci.com/g/doorstop-dev/doorstop/?branch=develop)
[![PyPI Version](http://img.shields.io/pypi/v/Doorstop.svg)](https://pypi.org/project/Doorstop)
<br>
Expand Down
4 changes: 3 additions & 1 deletion doorstop/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def load_yaml(text, path, loader=yaml.SafeLoader):
return data


def write_lines(lines, path, end="\n", encoding="utf-8"):
def write_lines(lines, path, end="\n", encoding="utf-8", *, executable=False):
"""Write lines of text to a file.

:param lines: iterator of strings
Expand All @@ -159,6 +159,8 @@ def write_lines(lines, path, end="\n", encoding="utf-8"):
for line in lines:
data = (line + end).encode(encoding)
stream.write(data)
if executable and os.path.isfile(path):
os.chmod(path, 0o775)
return path


Expand Down
2 changes: 1 addition & 1 deletion doorstop/core/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def publish(
log.info("Copied assets from %s to %s", obj.assets, assets_dir)

if ext == ".tex":
common.write_lines(compile_files, compile_path)
common.write_lines(compile_files, compile_path, executable=True)
msg = "You can now execute the file 'compile.sh' twice in the exported folder to produce the PDFs!"
utilities.show(msg, flush=True)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
active: true
derived: false
header: |
UTF-8
level: 1.7.0
links: []
normative: true
ref: ''
reviewed: null
text: |
UTF-8 is supported. Verified by this file.

première is first
première is slightly different
Кириллица is Cyrillic
𐐀 am Deseret
19 changes: 19 additions & 0 deletions doorstop/core/tests/test_fixtures/002-utf8-characters/REQ-MIT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
active: true
derived: false
header: |
MIT licence
level: 1.7.1
links: []
normative: true
ref: ''
reviewed: null
text: |
Just verify that the MIT licence is typeset correctly.

Copyright © 2022 <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 changes: 28 additions & 0 deletions doorstop/core/tests/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,3 +1050,31 @@ def test_attributes_with_spec(self, mock_warning):
def test_stamp(self):
"""Verify an unknown item has no stamp."""
self.assertEqual(Stamp(None), self.item.stamp())


class TestUTF8(unittest.TestCase):
"""Unit tests for reading UTF8 formatted files."""

def test_load_cyrillic(self):
"""Verify that cyrillic and other UTF-8 characters are correltly loaded and written."""
ITEM = "doorstop/core/tests/test_fixtures/002-utf8-characters/REQ-CYRILLIC.yml"
backup = common.read_text(ITEM)
item = Item(None, ITEM)
item.load()
item.save()
text = common.read_text(ITEM)
self.maxDiff = None
common.write_text(backup, ITEM)
self.assertEqual(backup, text)

def test_load_mit(self):
"""Verify that an MIT licence is correltly loaded and written."""
ITEM = "doorstop/core/tests/test_fixtures/002-utf8-characters/REQ-MIT.yml"
backup = common.read_text(ITEM)
item = Item(None, ITEM)
item.load()
item.save()
text = common.read_text(ITEM)
self.maxDiff = None
common.write_text(backup, ITEM)
self.assertEqual(backup, text)
14 changes: 12 additions & 2 deletions doorstop/server/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from multiprocessing import Process
from unittest.mock import patch

import requests

from doorstop import server
from doorstop.server import main
from doorstop.server.tests import ENV, REASON
Expand All @@ -24,8 +26,16 @@ def setUpClass(cls):
if os.getenv(ENV):
cls.process = Process(target=main.main, kwargs={"args": []})
cls.process.start()
logging.info("delaying for the server to initialize...")
time.sleep(3)
logging.info("waiting for the server to initialize...")
# Check for response!
url = "http://localhost:7867/documents"
for _ in range(0, 29):
try:
_ = requests.head(url)
break
except requests.exceptions.RequestException:
time.sleep(1)
logging.info("server is answering!")
assert cls.process.is_alive()

@classmethod
Expand Down
Loading