3. Continuous integration#
What is CI?#
Continuous Integration (CI) refers to checks and tests that are triggered by events that occur within a GitHub repository such as pushing a commit, opening a pull request, and merging a pull request. In the pyOpenSci organization, each commit that is pushed to a GitHub repository triggers at least one or more automated CI workflows. For the pyOpenSci website repository and our online books such as the Python packaging guidebook, this build will:
Build the live rendered version of the online content with any changes added in the current commit(s) or pull requests.
Check the text for spelling issues,
Check images for missing alt tags, incorrect image paths and more.
If the repository has code, it will check for code style.
Having a CI setup on each pyOpenSci GitHub repository ensures that we detect issues such as bad links or broken code before they’re merged into the main repository.
What do the green and red checks mean?#
The green and red checks in the CI block indicate the status of these automated checks:
Green checks: These indicate that the code has passed the CI checks. This means the code meets the project’s standards and is likely free from errors or issues related to the specific checks that have passed.
Red X’s: These indicate that the code has failed the associated CI checks. This means there are issues that need to be addressed before the code can be merged. The issues could be related to code style, formatting, tests, or other criteria specified by the CI configuration.
If a CI check is red#
Click on “Details” next to the failed check to get more information about the failure.
Review the logs or output provided to understand what went wrong.
Make the necessary changes to fix the issue.
Push the updated code to the pull request to trigger the CI checks again.
If something isn’t working as expected or you are having a hard time understanding why CI is failing (we’ve all been there!), please ping someone else in the organization for help. As a pyOpenSci community, we are always here to help each other.
If all CI checks are green, you are good to go. Ping a pyOpenSci repository owner on GitHub to review your pull request. The pull request can be merged once you have approval from another repository owner.
If you don’t know who to ping, no worries. Someone from the pyOpenSci organization will see your pull request and get back to you.
Note
Generally, we require a single passing approval to merge a pull request. However, in some cases, if you are a pyOpenSci staff member or community member with admin/write access, it could be the case that you need to merge something immediately (i.e., fixing a small piece of breaking code, a spelling error, or adding a new piece of content that has already been agreed upon).
CI and outside contributors#
If someone from outside of the pyOpenSci organization submits a pull request, then someone within the organization needs to approve and run CI. If you have those superpowers, please go ahead and allow CI to run for new contributors. You can’t break anything by running CI, so always feel confident in our repos when you click that button, assuming that the PR is legitimate and submitted from a valid user!
Next to each CI step that was run, there is a details button. If you click on that link, it will give you more information about what has run/not run as expected in the build.
Website CI checks#
All of our website repositories have several CI builds, including:
A link checker.
htmlproofer
, which checks both links and alt tags, as well as images.A CI build that shows you what the rendered site looks like when built online. Currently, we are using CircleCI for a live rendered build, as CircleCI allows for in-browser website build checks. GitHub requires you to download, unzip, and view an archive with the build site locally.
About the Pre-Commit CI Bot#
The Pre-commit CI bot is a continuous integration service that automatically runs pre-commit hooks on each pull request. This helps maintain code quality and consistency without requiring developers to run pre-commit locally.
To run the bot on a PR, add the following command to a standalone comment:
pre-commit autofix
When you do this, the bot will run all of the hooks that it can, adding a new commit to the pull request for you.
What the bot can fix#
The bot can in-place fix many linting and style issues in our content, including:
What the bot can’t fix#
The bot can’t fix some things, such as:
Logical errors or bugs in the code.
Issues that require human judgment, such as resolving complex merge conflicts or making design decisions.
Spelling errors.
If the bot finds errors that it can’t fix, you will need to make those changes locally.
Using the bot instead of pre-commit hooks#
pyOpenSci contributors may prefer not to set up pre-commit locally. In that case, we can rely on the pre-commit.ci bot to fix things as needed.
Bot setup#
To set up the bot in a new repository:
Enable pre-commit.ci on your repository through the pre-commit.ci website.
The pre-commit.ci bot will automatically run checks and apply fixes on pull requests.
Review the bot’s output and ensure all checks pass before merging your code.
This approach ensures that all contributions meet our pyOpenSci code and text quality standards without requiring each contributor to install and run pre-commit locally.