Example repo: using GitHub Actions for CI/CD for a Python project
This is a minimal repo demonstrating the use of GitHub Actions for Continuous Integration (CI) & Continous Deployment (CD) for a Python project.
The GitHub Actions are:
- Tests: Automatically unit test code using
unittestfrom Python's standard library. - Code coverage: Generate code coverage reports using coverage.py. The reports are automatically uploaded to codecov. The @codecov-commenter bot adds a comment to PR on code coverage status.
- Lint and format code: Lint using pylint. Check code formatting using black. Check type hints using mypy.
- Check docs build: Check Sphinx docs build successfully.
- Deploy docs to GitHub pages: Automatically deploy docs to a
GitHub Pages repo upon
merges to
mainbranch. - Upload release to PyPI: Publish the latest version of the package on PyPI when a new GitHub Release is created.
Each of these actions is stored in a YAML file in the .github/workflows directory.
File system structure
TBA...
Push Token for Deploying Docs
Action #5 requires setting up a Personal Access Token with full repo access via
the Developer Settings page. Store this token as an Actions secret under the
name PUSH_TOKEN in the main repo (i.e. the repo where the docs source code is
held). See more here.
Useful resources on the topic
- mCoding's YouTube video on using GitHub actions for automated testing (see associated code repo).
- Alex Damiani's YouTube videos on automated testing [1], [2] & [3] and associated code repos: [1] [2], & [3].
- librosa is a real-world example of
pyproject.toml,setup.cfg&setup.pyworking together. - Pharmpy uses Actions for building docs then deploying them to a separate GitHub Pages repo.
- Vinod Kurup's blog post on automating PyPI releases with GitHub Actions.
Metadata
Release files for github-actions-cicd-example 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| github-actions-cicd-example-0.0.1.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| github_actions_cicd_example-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.1 kB
Release files / github-actions-cicd-example-0.0.1.tar.gz
| Download URL | github-actions-cicd-example-0.0.1.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb9a20406d6b6199051d6ad2d8a48480779d1067a5ca4ad10011d958174847ed
|
|
BLAKE2b-256 checksum How to use checksums |
3bee3065f14dfe950f5a1b7aa3f204141778ff5828bbf507df341152af31e829
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
|
Release files / github_actions_cicd_example-0.0.1-py3-none-any.whl
| Download URL | github_actions_cicd_example-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
226076c44b529dcf689c64c0b91fe00cbda58bd59d19db98135db70dbbe9e422
|
|
BLAKE2b-256 checksum How to use checksums |
2e303c0895f01f4307b3d5648b7be7123984341f647e116a4e1122d05252d103
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
|