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

Check the syntax of reStructuredText files during CI #112

Merged
merged 17 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6dd7a08
Adding a GitHub CI workflow to check the syntax of reStructuredText f…
rptb1 Jan 14, 2023
646436a
Suppress Travis CI on branch/2023-01-13/rst-check for faster testing …
rptb1 Jan 14, 2023
79fb554
Run checking steps even if other steps fail.
rptb1 Jan 14, 2023
a1c003d
Moving checking to its own script so it can be used at the command li…
rptb1 Jan 14, 2023
db63baf
Refining pruning rules for command-line use.
rptb1 Jan 14, 2023
5da9822
Fixing basic reStructuredText syntax and reference errors found by to…
rptb1 Jan 14, 2023
83c1230
Improving the naming so that results are clearer in GitHub output.
rptb1 Jan 14, 2023
b2ae297
Fixing warnings found by shellcheck.
rptb1 Jan 14, 2023
caa7a60
Fixing duplicate tag design.mps.config.var introduced in commit 533f4…
rptb1 Jan 14, 2023
1a1d265
Oops, forgot to fix up the RST ref in commit caa7a60
rptb1 Jan 14, 2023
d5d996d
Fixing duplicate tags introduced by e9841d23a0 as a consequence of b0…
rptb1 Jan 14, 2023
b8d1851
Fixing duplicate tag design.mps.arena.tract.field.base. Looks like a…
rptb1 Jan 14, 2023
dd6493a
Fixing duplicate tag design.mps.prmc.if.init.thread. Looks like a co…
rptb1 Jan 14, 2023
21ac667
Making script name more readable.
rptb1 Jan 15, 2023
2fb85a4
Enabling manual triggering of reStructuredText syntax check.
rptb1 Jan 15, 2023
15b3d00
Clarifying that this checks the MPS source tree, not the MPS. Signing.
rptb1 Jan 17, 2023
7c6b6aa
Linking comment about smushed document to GitHub issue 128 <https://g…
rptb1 Jan 25, 2023
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
23 changes: 23 additions & 0 deletions .github/workflows/rst-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# .github/workflows/rst-check.yml -- check syntax of reStructuredText files
#
# This is a GitHub CI workflow
# <https://docs.github.com/en/actions/using-workflows/about-workflows>
# to check the syntax of reStructuredText files.

name: reStructuredText syntax check

on:
# Run as part of CI checks on branch push and on merged pull request.
- push
- pull_request
- workflow_dispatch # allow manual triggering

jobs:
check-rst:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install docutils
run: sudo apt-get install -y docutils
- name: Check reStructuredText syntax
run: tool/check-rst
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Some branches don't need builds. Add them here to avoid using build
# resources and unnecessary build messages. See
# <https://docs.travis-ci.com/user/conditions-v1>.
if: NOT branch IN (branch/2023-01-07/pull-request-merge-procedure)
if: NOT branch IN (branch/2023-01-13/rst-check)

rptb1 marked this conversation as resolved.
Show resolved Hide resolved
# The main build matrix for POSIX-like systems.
language: c # see <https://docs.travis-ci.com/user/languages/c/>.
Expand Down
2 changes: 1 addition & 1 deletion design/arena.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ that the private representation can share a common prefix with
private representation whether such an object is allocated or not,
without requiring an extra field.

_`.tract.field.base`: The seg field is a pointer to the segment
_`.tract.field.seg`: The seg field is a pointer to the segment
containing the tract, or ``NULL`` if the tract is not contained in any
segment.

Expand Down
2 changes: 1 addition & 1 deletion design/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ predefined when compiling the module sources::

CONFIG_VAR_<variety-code>

_`.var`: The variety codes are as follows:
_`.var.codes`: The variety codes are as follows:

_`.var.hot`: ``HOT``

Expand Down
15 changes: 11 additions & 4 deletions design/poolamc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ AMC pool class
single: pool class; AMC design


Introduction
~~~~~~~~~~~~
Guide Introduction
~~~~~~~~~~~~~~~~~~

.. The intro and readership tags were found to be duplicated by
changelist 182116 / commit e9841d23a but not referenced. But that
was just a consequence of two documents being smushed together by
RHSK in changelist 168424 / commit b0433b3e9: a guide and a design.
It would be good to sort that out. See also
<https://github.com/Ravenbrook/mps/issues/128>. RB 2023-01-14

rptb1 marked this conversation as resolved.
Show resolved Hide resolved
_`.intro`: This document contains a guide (`.guide`_) to the MPS AMC
_`.guide.intro`: This document contains a guide (`.guide`_) to the MPS AMC
pool class, followed by the historical initial design
(`.initial-design`_).

_`.readership`: Any MPS developer.
_`.guide.readership`: Any MPS developer.


Guide
Expand Down
2 changes: 1 addition & 1 deletion design/poolawl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ segment sizes are rounded up to the arena grain size.

_`.fun.awlsegcreate.where`: The segment is allocated using a
generation preference, using the generation number stored in the
``AWLStruct`` (the ``gen`` field), see `.poolstruct.gen`_ above.
``AWLStruct`` (the ``gen`` field), see `.poolstruct`_ above.

``Res awlSegInit(Seg seg, Pool pool, Addr base, Size size, ArgList args)``

Expand Down
2 changes: 1 addition & 1 deletion design/prmc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ design.mps.check_.

``Res MutatorContextInitFault(MutatorContext context, ...)``

_`.if.init.thread`: Initialize with the context of the mutator at the
_`.if.init.fault`: Initialize with the context of the mutator at the
point where it was stopped by a protection fault. The arguments are
platform-specific and the return may be ``void`` instead of ``Res`` if
this always succeeds.
Expand Down
9 changes: 3 additions & 6 deletions design/protix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,9 @@ okay), the protection is set to ``PROT_READ|PROT_WRITE|PROT_EXEC``.
.. _design.mps.prot.if.set: prot#.if.set

_`.fun.set.assume.mprotect`: We assume that the call to ``mprotect()``
always succeeds.

_`.fun.set.assume.mprotect`: This is because we should always call the
function with valid arguments (aligned, references to mapped pages,
and with an access that is compatible with the access of the
underlying object).
always succeeds. We should always call the function with valid
arguments (aligned, references to mapped pages, and with an access
that is compatible with the access of the underlying object).

_`.fun.sync`: ``ProtSync()`` does nothing in this implementation as
``ProtSet()`` sets the protection without any delay.
Expand Down
2 changes: 1 addition & 1 deletion design/protocol.txt
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ following:
A function called by ``SomeClassGet()``. All the class
initialization code is actually in this function.

_`.impl.subclass`: The subclass test `.if.subclass`_ is implemented
_`.impl.subclass`: The subclass test `.if.is-subclass`_ is implemented
using an array of superclasses [Cohen_1991]_ giving a fast
constant-time test. (RB_ tried an approach using prime factors
[Gibbs_2004]_ but found that they overflowed in 32-bits too easily to
Expand Down
2 changes: 1 addition & 1 deletion design/shield.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ _`.proof.sync`: As the depth of a segment cannot be negative
| ⇒ all segments are synced (by `.inv.unsynced.depth`_)

_`.proof.access`: If the mutator is running then all segments must be
synced (`.inv.unsynced.suspend`_). Which means that the hardware
synced (`.inv.unsynced.suspended`_). Which means that the hardware
protection (protection mode) must reflect the software protection
(shield mode). Hence all shielded memory will be hardware protected
while the mutator is running. This ensures `.prop.mutator.access`_.
Expand Down
4 changes: 2 additions & 2 deletions design/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ _`.run`: Run these commands::

where ``<makefile>`` is the appropriate makefile for the platform (see
`manual/build.txt`_), ``<variety>`` is the variety (see
design.mps.config.var_) and ``<target>`` is the collection of tests
design.mps.config.var.codes_) and ``<target>`` is the collection of tests
(see `.target`_ below). For example::

make -f lii6ll VARIETY=cool testrun

If ``<variety>`` is omitted, tests are run in both the cool and hot
varieties.

.. _design.mps.config.var: config#.var
.. _design.mps.config.var.codes: config#.var.codes
.. _manual/build.txt: https://www.ravenbrook.com/project/mps/master/manual/build.txt


Expand Down
2 changes: 1 addition & 1 deletion procedure/release-build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ B. Document History
.. _NB: mailto:[email protected]
.. _RHSK: mailto:[email protected]
.. _GDR: mailto:[email protected]
.. _PNJ mailto:[email protected]
.. _PNJ: mailto:[email protected]

C. Copyright and License
------------------------
Expand Down
77 changes: 77 additions & 0 deletions tool/check-rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/sh
# tool/check-rst -- check syntax of reStructuredText in the MPS source tree
# Richard Brooksby, Ravenbrook Limited, 2023-01-13
#
# Copyright (c) 2023 Ravenbrook Limited. See end of file for license.
#
# This script finds reStructuredText files in the MPS tree and runs
# them through docutils to check for syntax errors.
#
# It can be invoked from the command line of from Continuous
# Integration scripts. See .github/workflows/rst-check.yml
#
# This script excludes manual/source because the reStructuredText
# there is in an extended Sphinx format that can't be checked by the
# basic docutils. It can be checked by building the manual. See
# manual/Makefile.

{
find . -path ./manual/source -prune -o \
-path ./manual/tool -prune -o \
-type f -name '*.rst' -print
find . -type f -name '*.txt' -print |
while read -r f; do
if head -1 -- "$f" | grep -F -q -e '-*- rst -*-'; then
echo "$f"
fi
done
} | {
code=0
while read -r f; do
if ! rst2html --report=2 --exit-status=2 "$f" > /dev/null; then
code=1
fi
done
exit "$code"
}

# A. REFERENCES
#
# [None]
#
#
# B. DOCUMENT HISTORY
#
# 2023-01-13 RB Created.
#
#
# C. COPYRIGHT AND LICENSE
#
# Copyright (C) 2023 Ravenbrook Limited <https://www.ravenbrook.com/>.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# $Id$