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

Set up tests and Github actions workflow #19

Closed
duncandewhurst opened this issue Aug 10, 2022 · 17 comments
Closed

Set up tests and Github actions workflow #19

duncandewhurst opened this issue Aug 10, 2022 · 17 comments
Assignees
Labels
Build This issue relates to the build process
Milestone

Comments

@duncandewhurst
Copy link
Collaborator

I don't know what is provided for in https://github.com/OpenDataServices/sphinx-base, but we should set up tests and a Github actions workflow to run them.

We can likely reuse some of the tests from OCDS, which are split across:

If I remember correctly, the reason for the separation is that some tests need to be run across multiple repos (extensions and profiles). For this project, I think we can put all the tests in this repository.

There's a lot of complexity in the OCDS tests relating to extensions, which doesn't need to be reproduced for this project.

@duncandewhurst duncandewhurst added the Build This issue relates to the build process label Aug 10, 2022
@lgs85 lgs85 self-assigned this Aug 10, 2022
@duncandewhurst duncandewhurst added this to the Alpha milestone Aug 12, 2022
@lgs85
Copy link
Contributor

lgs85 commented Aug 16, 2022

@Lathrisk is going to take a look at this in a couple of weeks, and I can help out/code review etc. I don't think the sphinx base involves any testing, so we'll need to write/borrow from other standards.

@lgs85
Copy link
Contributor

lgs85 commented Aug 17, 2022

To map this out in a little more detail, here is a suggested starting list for tests to add as Github actions (to be run on each push and pull request)

Generic tests

Schema specific tests

  • To be decided on completion of the schema. See this example from BODS

Others do please feel free to add/comment.

@Lathrisk in terms of timing, I think we can make a start on the generic tests in the first block of time, then depending on how far we get, finish these off in block two and get going with the schema specific tests?

@duncandewhurst
Copy link
Collaborator Author

Looks good to me.

  • Something to check that the sphinx documentation builds?

We should definitely have this, we don't want to merge PRs that break the docs build.

  • Something to check markdown formatting?

+1

OCDS has/had some extra tests that we can consider:

  • test_search
  • test_broken_links (I think that this test would need to result in a warning rather than a failure so that the build isn't overly dependent on externalities)

@jpmckinney
Copy link

jpmckinney commented Aug 23, 2022

If you run sphinx-build with -nW you'll enable nit-picky mode and turn warnings into errors, so you won't be able to deploy broken builds.

To check links, you can also run sphinx-build linkcheck. It accepts some options here: https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-the-linkcheck-builder

We don't use linkcheck for OCDS as it's too slow for the number of external links we have.

test_broken_links was removed from test_docs as it's unnecessary (it was only checking internal links, but those are already checked if you build with -nW). test_search only matters if you implement your own custom search page, instead of using the default provided by ReadTheDocs (which is quite better nowadays).

For Markdown formatting, I recommend setting up pre-commit with mdformat.

@duncandewhurst
Copy link
Collaborator Author

Thanks @jpmckinney!

@duncandewhurst
Copy link
Collaborator Author

Another test that would be useful is to check that the descriptions of related properties and codes are in sync:

  • Node.physicalInfrastructureProvider, Link.physicalInfrastructureProvider and 'physicalInfrastructureProvider' in organisationRole.csv
  • Node.networkProvider, Link.networkProvider and 'networkProvider' in organisationRole.csv
  • Phase.funder and 'funder' in organisationRole.csv

@duncandewhurst
Copy link
Collaborator Author

Tests for example data are mentioned in #57 (comment)

@duncandewhurst duncandewhurst modified the milestones: Alpha, Beta Sep 15, 2022
@odscjames
Copy link
Collaborator

Some Python functionality is now in ofdskit, in that case remove python from here.

@duncandewhurst
Copy link
Collaborator Author

Some Python functionality is now in ofdskit, in that case remove python from here.

We're still going to have a pre-commit Python script for updating derivative schema files and reference documentation so I think we want to have Python code checking as part of the tests.

@odscjames
Copy link
Collaborator

I think we want to have Python code checking as part of the tests.

Yes - if there is any large bits of Python in the repository we still want code checking.

I think my comment has been misunderstood - it was posted during our call and refers not to removing Python checking but to removing actual bits of Python code, if that code is now available in external libraries like ofdskit instead (and of course ofdskit does have Python checking!)

We're still going to have a pre-commit Python script for updating derivative schema files and reference documentation

No, this repository is going to have a pre-comit hook to do that. If it's suitable for that code to become a generic Python library in another repository that the hook can just call, we'll do that. Suitable in this case means: If the advantages of code-sharing across standards and/or different places outweigh the disadvantages of dealing with an extra repository. (I'm not saying that is in scope for this ticket, just trying to be clear about the option here that we should consider later!)

@duncandewhurst
Copy link
Collaborator Author

Yes, that all makes sense. I've created new issues.

odscjames pushed a commit that referenced this issue Dec 1, 2022
with nit-picky modeand turn warnings into errors

#19
@odscjames odscjames self-assigned this Dec 1, 2022
@odscjames
Copy link
Collaborator

I have started looking at this and the draft PR, taking functionality a bit at a time to new PR's to ensure things are merged as soon as they are ready.

odscjames pushed a commit that referenced this issue Dec 1, 2022
with nit-picky modeand turn warnings into errors

#19
odscjames pushed a commit that referenced this issue Dec 1, 2022
with nit-picky mode and turn warnings into errors

#19
odscjames added a commit that referenced this issue Dec 1, 2022
odscjames added a commit that referenced this issue Dec 7, 2022
#19

Commit 0a6f417 turned these from 2
decimal places into 1 and that was incorrect
@jpmckinney
Copy link

Another test we should have - run precommit as far as it is possible

You can use https://pre-commit.ci, which adds a check (which you can make mandatory or not).

odscjames pushed a commit that referenced this issue Dec 7, 2022
docs/reference/publication_formats/geojson: Updated link to libcoveofds

#213
#19
odscjames pushed a commit that referenced this issue Dec 7, 2022
odscjames pushed a commit that referenced this issue Dec 7, 2022
odscjames pushed a commit that referenced this issue Dec 7, 2022
docs/reference/publication_formats/geojson: Updated link to libcoveofds

#213
#19
odscjames pushed a commit that referenced this issue Dec 7, 2022
odscjames pushed a commit that referenced this issue Dec 7, 2022
odscjames pushed a commit that referenced this issue Dec 7, 2022
docs/reference/publication_formats/geojson: Updated link to libcoveofds

#213
#19
odscjames pushed a commit that referenced this issue Dec 7, 2022
docs/reference/publication_formats/geojson: Updated link to libcoveofds

#213
#19
odscjames pushed a commit that referenced this issue Dec 14, 2022
odscjames added a commit that referenced this issue Dec 14, 2022
#19

All JSON files were treated with this Python:

import json
from collections import OrderedDict

files = [
    'schema/network-schema.json',
    'examples/json/network-package-additional-checks.json',
    'examples/json/network-package.json',
    'examples/json/spans-endpoint.json',
    'examples/json/nodes-endpoint.json',
    'examples/json/network-separate-files.json',
    'examples/json/multiple-networks.json',
    'examples/json/api-response.json',
    'examples/json/network-embedded.json',
    'examples/json/network-package-invalid.json',
    'examples/json/network-separate-endpoints.json',
]

for f in files:
    print(f)
    with open(f) as fp:
        data = json.load(fp, object_pairs_hook=OrderedDict)
    with open(f, "w") as fp:
        json.dump(data, fp, ensure_ascii=False, indent=2)
        fp.write('\n')
odscjames pushed a commit that referenced this issue Dec 14, 2022
odscjames added a commit that referenced this issue Dec 14, 2022
#19

All JSON files were treated with this Python:

import json
from collections import OrderedDict

files = [
    'schema/network-schema.json',
    'examples/json/network-package-additional-checks.json',
    'examples/json/network-package.json',
    'examples/json/spans-endpoint.json',
    'examples/json/nodes-endpoint.json',
    'examples/json/network-separate-files.json',
    'examples/json/multiple-networks.json',
    'examples/json/api-response.json',
    'examples/json/network-embedded.json',
    'examples/json/network-package-invalid.json',
    'examples/json/network-separate-endpoints.json',
]

for f in files:
    print(f)
    with open(f) as fp:
        data = json.load(fp, object_pairs_hook=OrderedDict)
    with open(f, "w") as fp:
        json.dump(data, fp, ensure_ascii=False, indent=2)
        fp.write('\n')
@odscjames
Copy link
Collaborator

odscjames commented Dec 14, 2022

I think everything here has been done or moved to a new issue. Can we close this one?

@duncandewhurst
Copy link
Collaborator Author

Yep. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build This issue relates to the build process
Projects
None yet
Development

No branches or pull requests

5 participants