-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add sample Python application with linting and CI setup (#1)
- Loading branch information
1 parent
afcfe06
commit 7694461
Showing
5 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[flake8] | ||
# Set the maximum line length to 88 characters (PEP 8 recommendation) | ||
max-line-length = 88 | ||
|
||
# Exclude directories or files from linting | ||
exclude = | ||
.git, | ||
__pycache__, | ||
venv, | ||
docs, | ||
old, | ||
build, | ||
dist | ||
|
||
# Ignore some specific linting errors | ||
# Visit the below link for complete list of Error codes | ||
# https://github.com/pycqa/flake8/blob/main/docs/source/user/error-codes.rst | ||
ignore = | ||
# E203: whitespace before ':' | ||
E203, | ||
# W503: line break before binary operator | ||
W503 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Python CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: [3.7, 3.8, 3.9] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install -r requirements.txt | ||
- name: Run linting | ||
run: | | ||
flake8 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,40 @@ | ||
# python-lint-workflow-guide | ||
|
||
# Sample Python Application with Linting and CI | ||
|
||
This repository contains a sample Python application with linting using Flake8 and Continuous Integration (CI) setup using GitHub Actions. | ||
|
||
## Contents | ||
- [Overview](#overview) | ||
- [Project Structure](#project-structure) | ||
- [Setup and Installation](#setup-and-installation) | ||
- [Running the Application](#running-the-application) | ||
- [Linting with Flake8](#linting-with-flake8) | ||
- [Continuous Integration](#continuous-integration) | ||
- [Contributing](#contributing) | ||
|
||
## Overview | ||
The project demonstrates a basic setup for a Python application, including code linting and automated CI pipelines. | ||
|
||
## Project Structure | ||
- `app.py`: A simple Python script with basic functionalities. | ||
- `.flake8`: Configuration file for Flake8 linting. | ||
- `.github/workflows/python-ci.yml`: GitHub Actions workflow for CI. | ||
|
||
## Setup and Installation | ||
To set up the project locally: | ||
1. Clone the repository. | ||
2. Install Python 3.8 or higher. | ||
3. (Optional) Set up a virtual environment. | ||
4. Install dependencies: `pip install -r requirements.txt` | ||
|
||
## Running the Application | ||
Run the application using the command: `python app.py` | ||
|
||
## Linting with Flake8 | ||
To lint the project, run: `flake8 app.py` | ||
|
||
## Continuous Integration | ||
The project uses GitHub Actions for CI, which runs linting on every push or pull request to the `main` branch. | ||
|
||
## Contributing | ||
Contributions to this project are welcome. Please ensure that your code adheres to the project's coding standards and passes all CI checks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
# app.py | ||
def add(a, b): | ||
return a + b | ||
|
||
def subtract(a, b): | ||
return a - b | ||
|
||
|
||
def mult(a, b): | ||
return a * b | ||
|
||
|
||
# Sample usage | ||
if __name__ == "__main__": | ||
print(add(5, 3)) | ||
print(subtract(5, 3)) | ||
print(mult(5, 3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# requirements.txt | ||
|
||
flake8==7.0.0 |