Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

yashh1196/github-actions-cicd-example

Open more actions menu
 
 

Repository files navigation

CI/CD Practical

License: MIT Tests codecov Code Style: Black Checked with mypy Latest Documentation

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:

  1. Tests: Automatically unit test code using unittest from Python's standard library.
  2. 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.
  3. Lint and format code: Lint using pylint. Check code formatting using black. Check type hints using mypy.
  4. Check docs build: Check Sphinx docs build successfully.
  5. Deploy docs to GitHub pages: Automatically deploy docs to a GitHub Pages repo upon merges to main branch.
  6. 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.py working 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.

About

Example Python repo employing GitHub Actions for CI/CD

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.