Skip to content

Commit fbf098c

Browse files
authored
enh: add task runner page to guide (#596)
1 parent 585cfae commit fbf098c

File tree

8 files changed

+614
-100
lines changed

8 files changed

+614
-100
lines changed

continuous-integration/ci.md

Lines changed: 0 additions & 84 deletions
This file was deleted.

continuous-integration/index.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,6 @@ Tests <tests/index>
324324
:hidden:
325325
:caption: Continuous Integration
326326

327-
CI/CD <continuous-integration/index>
327+
Maintain <maintain-automate/index>
328328

329329
:::

maintain-automate/ci.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
(ci-cd)=
2+
# Continuous Integration and Continuous Deployment (CI/CD) For Python Packages
3+
4+
When you develop, work on, and contribute to software, there is more
5+
to consider than just writing code. Having tests and checks ensures
6+
that your code runs reliably and follows a consistent format is also
7+
important. You can use **Continuous Integration (CI)** and
8+
**Continuous Deployment (CD)** to run tests and checks on your code
9+
every time someone suggests a change online in a platform like GitHub
10+
or GitLab.
11+
12+
* **Continuous Integration (CI):** Automates the process of running
13+
tests, code checks, and other workflows each time code is updated.
14+
* **Continuous Deployment (CD):** Extends CI by allowing you to
15+
automate publishing your package to PyPI, publishing your
16+
documentation, and more.
17+
18+
CI and CD streamline software development by automating repetitive
19+
tasks and ensuring code quality and consistency. Having CI setup also
20+
makes it easier for new contributors to contribute to your code base
21+
without setting up all your test suites and other local checks.
22+
23+
## What is continuous integration?
24+
25+
When you're ready to publish your code online, you can set up Continuous Integration (CI). CI is a platform that allows you to specify and run jobs or workflows you define.
26+
These workflows include:
27+
28+
* Running your test suite
29+
* Running code checkers / linters / spellcheck
30+
* Building your documentation
31+
32+
CI allows you to automate running workflows across a suite of environments, including:
33+
34+
* environments containing different Python versions and
35+
* different operating systems (Mac, Linux, Windows).
36+
37+
## What is continuous deployment (CD)?
38+
39+
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:
40+
41+
* Automate publishing to PyPI
42+
* Automate publishing your documentation to GitHub Pages or Read the Docs.
43+
44+
It is also used once your conda-forge recipe is set up to keep your
45+
package up to date on conda-forge.
46+
47+
### Why use CI?
48+
49+
CI can be configured to run a workflow on every commit pushed to
50+
GitHub and every pull request opened. This ensures that any changes
51+
made to your package are tested across environments before merging into
52+
the main branch of your code.
53+
54+
These checks are particularly useful if someone new is contributing to
55+
your code. Every contributor's change will be tested when pushed to
56+
your code repository.
57+
58+
Together, CI and CD streamline the process of building, testing, and
59+
deploying code. They aim to improve software development and
60+
publication efficiency, quality, and reliability.
61+
62+
```{note}
63+
All pyOpenSci packages must use some form of continuous integration.
64+
Even if you are not planning to go through peer review, we strongly
65+
recommend that you use continuous integration, too!
66+
```
67+
68+
In the case of GitHub actions (which we will focus on here), CI
69+
workflows are running on online servers that support GitHub.
70+
71+
## CI/CD platforms
72+
73+
There are numerous platforms available for CI/CD. Here, we will focus
74+
on GitHub Actions (GHA), built into GitHub. GitHub is the most commonly
75+
used platform to store scientific open-source software.
76+
77+
:::{note}
78+
If you use [GitLab](https://about.gitlab.com/) CI/CD, many of the
79+
principles described here will apply. However, the workflow files may
80+
look different.
81+
:::
82+
83+
### If you aren't sure, use GitHub Actions
84+
85+
While you are welcome to use the continuous integration platform of
86+
your choice, we recommend GitHub Actions because it is free-to-use and
87+
integrated tightly into the GitHub user interface. There is also an
88+
entire store of GitHub action templates that you can easily use and
89+
adapt to your own needs.
90+
91+
:::{admonition} Other platforms that you may run into
92+
:class: info
93+
94+
* [Appveyor:](https://www.appveyor.com/): Supports running tests on
95+
Windows operating systems and predated the release of GitHub Actions.
96+
Today, AppVeyor supports operating systems beyond Windows.
97+
* [Travis CI:](https://www.travis-ci.com/) had been a common CI
98+
platform choice in our ecosystem. Usage dropped after Travis CI ended
99+
free support for open-source projects.
100+
* [CircleCI:](https://circleci.com/) CircleCI can be useful for
101+
automated builds of websites and documentation since it offers a
102+
preview of the PR changes.
103+
:::
104+
105+
## Embrace automation
106+
107+
By embracing CI/CD, you can ensure that your code runs as you expect
108+
it to across the diverse landscapes of user environments. Further, you
109+
can automate certain checks (and, in some cases, code fixes), including
110+
linting and code style. You can even automate spell-checking your
111+
documentation and docstrings!

maintain-automate/index.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
(maintain-intro)=
2+
# Automate Workflows and Maintain Your Package
3+
4+
Once you've [created your package](create-pure-python-package),
5+
[published it](publish-pypi-tutorial), and set up a repository for it, the next
6+
step is to automate development and maintenance workflows. Automation
7+
makes maintaining your package easier, more robust, and more secure. It
8+
also helps new contributors get started quickly without having to
9+
manually set up complex development environments and testing workflows.
10+
11+
## Why automate?
12+
13+
When you automate repetitive tasks like running tests, checking code
14+
style, and building documentation, you ensure that these important steps
15+
happen consistently every time. This consistency helps you catch bugs
16+
early, maintain code quality, and make it easier for others to
17+
contribute to your package. Automation also saves you time—instead of
18+
remembering and typing long command sequences, you can run everything
19+
with simple commands or have workflows run automatically when you push
20+
code to GitHub.
21+
22+
## What you'll learn
23+
24+
This section will walk you through two key automation strategies for
25+
Python packages:
26+
27+
[**Task runners**](task-runners-intro) help you automate common development tasks locally—
28+
things like running tests, building documentation, formatting code, and
29+
checking for errors. Instead of typing out long command sequences every
30+
time, you define tasks once and run them with simple commands. Task
31+
runners like Hatch and Nox also manage isolated environments for
32+
different workflows, ensuring you have the right dependencies for each
33+
task.
34+
35+
[**Continuous Integration (CI)**](ci-cd) takes automation further by running your
36+
tests and checks automatically every time code is pushed to GitHub or
37+
when someone opens a pull request. CI ensures that all changes are
38+
tested across different Python versions and operating systems before
39+
they're merged. You can also use Continuous Deployment (CD) to automate
40+
publishing your package to PyPI and deploying your documentation.
41+
42+
Together, task runners and CI/CD create a robust development workflow
43+
that makes your package easier to maintain and more welcoming to
44+
contributors.
45+
46+
:::{toctree}
47+
:caption: Maintain & Automate
48+
:hidden: true
49+
50+
Task runners <task-runners.md>
51+
What is CI? <ci.md>
52+
:::

0 commit comments

Comments
 (0)