Skip to content

Commit

Permalink
add workflow for release + release v0.0.1 (#1)
Browse files Browse the repository at this point in the history
* add workflow for release

* add ci

* fix release

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* readme

* clean

* clean

* clean

* clean

* add example

* clean

* clean

* clean

* clean

* clean
  • Loading branch information
ysawa0 authored Nov 5, 2023
1 parent 0ff3e27 commit 2ff40cf
Show file tree
Hide file tree
Showing 22 changed files with 791 additions and 63 deletions.
13 changes: 8 additions & 5 deletions .cpa/flake8.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ exclude =
build,
dist,
htmlcov.*,

application-import-names = flake8 # List of application-specific import names.
import-order-style = google # Import statement format style.
max-complexity = 18 # The maximum McCabe complexity allowed.
max-line-length = 120 # The maximum allowed line length.
# List of application-specific import names.
application-import-names = flake8
# Import statement format style.
import-order-style = google
# The maximum McCabe complexity allowed.
max-complexity = 18
# The maximum allowed line length.
max-line-length = 120
# per-file-ignores = # Per-file-ignores setting can be used to ignore specific errors in specific files.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

####################################
# Start the job on all push and PR #
####################################
on:
pull_request:
branches: [master, main]
types: [synchronize, opened, reopened, ready_for_review]
# push:
# branches: [master, main]

jobs:
precommits:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install pre-commit
pre-commit install
- name: Install shfmt
run: |
SHFMT_VERSION="v3.7.0"
SHFMT_BIN="shfmt_${SHFMT_VERSION}_linux_amd64"
wget -O shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/${SHFMT_BIN}"
chmod +x shfmt
sudo mv shfmt /usr/local/bin/
- name: Run pre-commits
run: |
pre-commit run --all-files
# pre-commit run --from-ref origin/main --to-ref HEAD
# run: |
# BASE_COMMIT_ID=$(git rev-parse origin/main)
# pre-commit run --from-ref ${{ env.BASE_COMMIT_ID }} --to-ref HEAD
57 changes: 57 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Release

on:
push:
tags:
- "v*"
# pull_request:
# branches: [master, main]
# types: [synchronize, opened, reopened, ready_for_review]

jobs:
create-release:
name: Create Release
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create ${{ github.ref_name }} --generate-notes --title "Version ${{ github.ref_name }}"

upload-release:
name: Build and Release
permissions:
contents: write
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable

- name: Print Runner OS
run: echo "Runner OS is ${{ runner.os }}"

- name: Build Release
run: cargo build --release

- name: Archive Release Binary (Windows)
if: runner.os == 'Windows'
run: Compress-Archive -Path ./target/release/cpa.exe -DestinationPath cpa-Windows.zip
shell: pwsh

- name: Archive Release Binary (MacOS, Linux)
if: runner.os != 'Windows'
run: zip -j cpa-${{ runner.os }}.zip ./target/release/cpa

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.ref_name }} "cpa-${{ runner.os }}.zip" --clobber
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ repos:
- id: check-merge-conflict # Searches for merge conflict markers within files.
- id: check-symlinks # Detects broken symlinks.
- id: check-added-large-files # Blocks commits that add large files. Default limit is 500kB.
args: ["--maxkb=1300"]
# Can be configured with args, e.g., '--maxkb=1000' to change the limit.
# Files in 'your_dir/' can be excluded.
# exclude: 'your_dir/.*'
# args: ['--maxkb=5000']
- id: end-of-file-fixer # Ensures files end with a single newline or are empty.
- id: trailing-whitespace # Removes any trailing whitespace at the end of lines.

Expand Down Expand Up @@ -59,7 +59,7 @@ repos:
- id: isort # Sorts Python imports into sections and by alphabetical order
args:
- --settings-path
- .cpa/pyproject.toml
- pyproject.toml
types:
- python

Expand All @@ -69,7 +69,7 @@ repos:
- id: black # Formats Python code to conform to the Black code style
args:
- --config
- .cpa/pyproject.toml
- pyproject.toml
types:
- python

Expand Down Expand Up @@ -116,9 +116,9 @@ repos:
- markdown
exclude: templates/.pre-commit-config.yaml

##
#############################################################################
# Rust
##
#############################################################################
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
Expand Down
39 changes: 22 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
# CPA: Create-Python-App

## Overview

`cpa` is a cli tool designed to streamline the setup of new Python projects. It automates the creation of Python projects with commonly used configs and boilerplate.

## Goals

- **Speed up Project Creation**: Reduce the time spent on repetitive setup tasks
- **Best Practices**: Encourage best practices for code quality, formatting, and style by including configs for tools like `black`, `isort`, and `flake8`.
- **Automation**: Automate tasks such as generating `.gitignore` files, setting up pre-commit hooks, and configuring code linters and formatters.
![CPA Logo](cpa.png)

## Features
## Overview

- Provides pre-commit hook setup with hooks for checking merge conflicts, large files, and code styling.
`cpa` is a cli tool for ultra fast setup of new Python projects. It automates the creation of config files for style & lint checks, gitignore, a basic Dockerfile and dependency management configuration. An opinionated set of pre-commit hooks are included for enforcing best practices and reducing setup time.

## Installation

Download binary from Github
### MacOS, Linux

```bash
Download latest binary and install via provided `install.sh` script or get it from [Releases](https://github.com/ysawa0/create-python-app/releases)

```
sh install.sh
```

### Windows

Download latest binary from [Releases](https://github.com/ysawa0/create-python-app/releases) page

Building from source
### Building from source

```bash
# cd to project
Expand All @@ -34,19 +32,26 @@ cargo install --path .
To create a new project:

```bash
cpa create --name <project_name>
cpa create --name myproject
```

Optional params:

- `--preset`: Specifies a Python version for the project. Defaults to "python" which is mapped internally to "python3.10".
- `--preset`: Specifies a Python version for the project. Defaults to "python3.10"

Example:

```bash
cpa create --name my_project --preset python3.10
cpa create --name myproject --preset python3.10
```

## Goals

- **Speed up Project Creation**: Reduce the time spent on repetitive setup tasks
- **Best Practices**: Encourage best practices for code quality, formatting, and style by including configs for tools like `black`, `isort`, and `flake8`.
- **Automation**: Automate tasks such as generating `.gitignore` files, setting up pre-commit hooks, and configuring code linters and formatters.
- Golang, Rust support planned

## Contributions and Feedback

Users are welcome to contribute to the project by submitting pull requests or opening issues for bugs and feature requests. Feedback is also greatly appreciated to help improve the tool.
Binary file added cpa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions example/.cpa/flake8.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[flake8]
ignore =
# C901, # function is too complex. Ignored because max-complexity is set.
D100, # Missing docstring in public module.
D101, # Missing docstring in public class.
D102, # Missing docstring in public method.
D103, # Missing docstring in public function.
D104, # Missing docstring in public package.
D105, # Missing docstring in magic method.
D107, # Missing docstring in __init__.
D205, # 1 blank line required between summary line and description.
D400, # First line should end with a period.
E203, # whitespace before ':'. Conflicts with how Black formats slicing.
E231, # missing whitespace after ',', ';', or ':'. Conflicts with Black.
E266, # too many leading '#' for block comment.
E402, # module level import not at top of file.
E501, # line too long (82 > 79 characters). Ignored because max-line-length is set.
F841, # local variable is assigned to but never used.
I100, # Import statements are in the wrong order.
I201, # Missing newline between import groups.
I202, # Additional newline in a group of imports.
W503 # line break before binary operator. This is no longer PEP 8 compliant.

exclude =
.cache,
.coverage.*,
.env, # Environment directory used by some tools
.git, # Version control directory
.github, # GitHub metadata directory
.gradle,
.hg, # Mercurial directory
.mypy_cache, # MyPy cache directory
.pytest_cache, # PyTest cache directory
.svn, # Subversion directory
.tox,
.venv, # Common virtual environment directory
.vscode, # VS Code configuration directory
*__pycache__, # Python cache directory
*.egg-info,
*.pyc,
build,
dist,
htmlcov.*,

application-import-names = flake8 # List of application-specific import names.
import-order-style = google # Import statement format style.
max-complexity = 18 # The maximum McCabe complexity allowed.
max-line-length = 120 # The maximum allowed line length.
# per-file-ignores = # Per-file-ignores setting can be used to ignore specific errors in specific files.
7 changes: 7 additions & 0 deletions example/.cpa/prettier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"bracketSpacing": true,
"singleQuote": false,
"useTabs": false,
"tabWidth": 2,
"trailingComma": "all"
}
Loading

0 comments on commit 2ff40cf

Please sign in to comment.