Skip to content

Commit 2c400ff

Browse files
committed
Fix: add initial tests content to guide
ENH: fixes from Jonny's review Fix: review edits from Jonny p2 Fix: typos and cleanup Fix: add example to tests ci page
1 parent 6d4f97a commit 2c400ff

File tree

13 files changed

+733
-3
lines changed

13 files changed

+733
-3
lines changed

_static/pyos.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,4 @@ td,
413413
th {
414414
border: 1px solid #ccc; /* Light gray border */
415415
padding: 8px; /* Add some padding for better readability */
416-
}
416+
}

_templates/header.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- custom head content-->
2+
<link rel="preconnect" href="https://fonts.googleapis.com">
3+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
4+
<link href="https://fonts.googleapis.com/css2?family=Itim&family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
5+
6+
<!-- END custom head content -->

ci-tests-data/ci.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# What is continuous integration?
2+
3+
When you’re ready to publish your code online, you can setup Continuous Integration (CI). CI is a platform that allows you to specify and run jobs or workflows that you define.
4+
These workflows include:
5+
6+
- Running your test suite
7+
- Running code checkers / linters / spellcheck
8+
- Building your documentation
9+
- Deploying your documentation to GitHub pages
10+
11+
CI also allows you to automate running workflows across a suite of environments including:
12+
13+
- environments containing different Python versions and
14+
- different operating systems (Mac, Linux, Unix).
15+
16+
### What is Continuous Deployment (CD)?
17+
18+
Continuous deployment (CD) extends the CI process by automating the deployment of code changes to production or staging environments. In the case of your open source tool, CD can be used to:
19+
20+
- Automate publishing to PyPI
21+
- Automate publishing your documentation to github pages or Read the Docs.
22+
23+
It is also used once your conda-forge recipe is set up to keep your package up to date on conda-forge.
24+
25+
### Why Use CI
26+
27+
CI can be configured to run a workflow on every commit pushed to GitHub and every pull request opened. This ensures that any changes made to your package are tested across environments before they are merged into the main branch of your code.
28+
29+
These checks are particularly useful if someone new is contributing to your code. Every change a contributor makes will be tested when it’s pushed to your code repository.
30+
31+
Together, CI and CD streamline the process of building, testing, and deploying code. They aim to improve the efficiency, quality, and reliability of software development and publication.
32+
33+
```{note}
34+
All pyOpenSci packages must use some form of continuous integration. Even if you are not planning to go through peer review, we strongly recommend that you use continuous integration too!
35+
```
36+
37+
In the case of GitHub actions (which we will focus on here), CI workflows are running on online servers that support GitHub.
38+
39+
## CI / CD Platforms
40+
41+
There are numerous platforms available for CI/CD. Here, we will focus on GitHub Actions (GHA) which is built into GitHub. GitHub is the most commonly used platform to store scientific open source software.
42+
43+
:::{note}
44+
If you are using GitLab CI/CD many of the principles described here will apply, however the workflow files may look different.
45+
:::
46+
47+
### If you aren't sure, use GitHub Actions
48+
49+
While you are welcome to use the continuous integration platform of your choice,
50+
we recommend Github actions because it is free-to-use and integrated tightly
51+
into the GitHub user interface. There is also an entire store of GitHub action
52+
templates that you can easily use and adapt to your own needs.
53+
54+
:::{admonition} Other platforms that you may run into
55+
:class: info
56+
57+
- [Appveyor:](https://www.appveyor.com/) used to be a goto for running tests on Windows operating systems until GitHub actions evolved to support Windows. AppVeyor has evolved to support other operating systems since Microsoft acquired GitHub.
58+
- [Travis CI:](https://www.travis-ci.com/) Used to be the most common CI platform used in our ecosystem until they dropped free support for open source.
59+
- [CircleCI:](https://circleci.com/) You will still see some people using CircleCI for specific tasks. CircleCi can be useful for automated builds of websites and documentation allowing you to preview the changes to that website in your browser.
60+
:::
61+
62+
## Embrace automation
63+
64+
By embracing CI/CD, you can ensure that your code runs as you expect it to across the diverse landscapes of user environments. Further you can
65+
automate certain checks (and in some cases code fixes) including linting and code style. You can even automate spell checking your documentation
66+
and docstrings!

ci-tests-data/code-cov.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Code coverage
2+
3+
Code coverage is the amount of your package's codebase that is run as a part of running your project's tests. A good rule of thumb is to ensure that every line of your code is run at least once during testing. However, note that good code coverage does not guarantee that your package is well-tested. For example, you may run all of your lines of code, but not account for many edge-cases that users may have. Ultimately, you should think carefully about the way your package will be used, and decide whether your tests adequately cover all of that usage.
4+
5+
A common service for analyzing code coverage is [codecov.io](https://codecov.io/). This project is free for open source tools, and will provide dashboards that tell you how much of your codebase is covered during your tests. We recommend setting up an account, and using codecov to keep track of your code coverage.
6+
7+
```{figure} ../images/code-cov-stravalib.png
8+
:height: 450px
9+
:alt: Screenshot of the code cov service - showing test coverage for the stravalib package. in this image you can see a list of package modules and the associated number of lines and % lines covered by tests. at the top of the image you can see what branch is being evaluated and the path to the repository being shown.
10+
11+
the Code cov platform is a useful tool if you wish to visually track code coverage. Using it you can not only get the same summary information that you can get with **pytest-cov** extension. You can also get a visual representation of what lines are covered by your tests and what lines are not covered. Code cove is mostly useful for evaluating unit tests and/or how much of your package code is "covered. It however will not evaluate things like integration tests and end-to-end workflows. b
12+
13+
```

ci-tests-data/data.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Data for packaging

ci-tests-data/index.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Tests and data for your Python package
2+
3+
In this section you will learn more about the importance of writing
4+
tests for you Python package.
5+
6+
::::{grid} 1 1 2 2
7+
:class-container: text-center
8+
:gutter: 3
9+
10+
:::{grid-item-card}
11+
:link: write-tests
12+
:link-type: doc
13+
14+
✨ Why write tests ✨
15+
^^^
16+
17+
Learn more about the art of writing tests for your Python package.
18+
Learn about why you should write tests and how they can help you and
19+
potential contributors to your project.
20+
:::
21+
22+
:::{grid-item-card}
23+
:link: test-types
24+
:link-type: doc
25+
26+
✨ Types of tests ✨
27+
^^^
28+
There are three general types of tests that you can write for your Python
29+
package: unit tests, integration tests and end-to-end (or functional) tests. Learn about all three.
30+
:::
31+
32+
:::{grid-item-card}
33+
:link: run-tests
34+
:link-type: doc
35+
36+
✨ How to Run Your Tests ✨
37+
^^^
38+
39+
Learn more about what tools you can use to run tests. And how to run your
40+
tests on different Python versions and different operating systems both on
41+
your computer and using continuous integration on GitHub (or in any other CI).
42+
:::
43+
44+
:::{grid-item-card}
45+
:link: data
46+
:link-type: doc
47+
48+
✨ Package data ✨
49+
^^^
50+
This section is current in progress... link coming soon
51+
:::
52+
53+
:::{grid-item-card}
54+
:link: ci
55+
:link-type: doc
56+
57+
✨ Continuous Integration ✨
58+
^^^
59+
Learn what Continuous Integration is and how you can set it up to run tests, build documentation and publish your package to PyPI.
60+
:::
61+
::::
62+
63+
```{toctree}
64+
:hidden:
65+
:maxdepth: 2
66+
:caption: Create & Run Tests
67+
68+
Intro <self>
69+
Write tests <write-tests>
70+
Test types <test-types>
71+
Run tests <run-tests>
72+
Code coverage <code-cov>
73+
74+
```
75+
76+
```{toctree}
77+
:hidden:
78+
:maxdepth: 2
79+
:caption: Continuous Integration
80+
81+
Intro to CI <ci>
82+
Run tests in CI <tests-ci>
83+
84+
```
85+
86+
```{toctree}
87+
:hidden:
88+
:maxdepth: 2
89+
:caption: Package data
90+
91+
Package data <data>
92+
93+
```

0 commit comments

Comments
 (0)