Automating Python Unit Tests, Linting, and Wheel Packaging with GitHub Actions

Added:

Setup Overview
Local Coding
Testing Setup
Lint and Build
Package Test
Push Code
CI Workflow
Run Checks
Fail Test
Build Artifact

Setup Overview

0:00
Playing Section
  • 1

    Initiates an empty GitHub repository for local development.

  • 2

    Plans to implement continuous integration with automated tasks.

Basic Python programming and familiarity with unit testing frameworks such as 'unittest' or 'pytest'.
Fundamental Git concepts including repositories, commits, branching, and pushing code to GitHub.
An understanding of Python code linting, formatting concepts, and PEP 8 style standards.
The basics of Python packaging, including the purpose of 'setup.py', 'pyproject.toml', and wheel distribution files.
A conceptual understanding of Continuous Integration (CI) and familiarity with YAML syntax used for configuration files.
Automating Continuous Delivery (CD) to securely publish built wheel packages to PyPI or private package registries.
Configuring matrix builds in GitHub Actions to run unit tests across multiple Python versions and operating systems simultaneously.
Integrating advanced security auditing, static application security testing (SAST), and dependency vulnerability scanning using tools like Bandit or Dependabot.
Implementing automated code coverage reporting and quality gates using tools like Coverage.py or Codecov.
Designing complex environment-specific deployment pipelines (e.g., Dev, Staging, Production) with manual approval steps in GitHub Actions.
694 views26likes27:12@codersbringchangeOriginal Release: 2024-11-11

This tutorial demonstrates how to set up a Continuous Integration (CI) pipeline using GitHub Actions to automatically test Python code and build wheel packages. The process involves creating a Python package structure with test files, configuring pytest and flake8 for testing and linting, building wheel packages using the build module, and defining a GitHub Actions workflow that triggers on code pushes to automatically run tests, linting, and package building. The workflow can be configured to run on specific Python versions and store the resulting wheel packages as artifacts for download.