Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmichel80 committed Sep 3, 2024
0 parents commit 207a2ed
Show file tree
Hide file tree
Showing 27 changed files with 1,419 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kcalc/_version.py export-subst
49 changes: 49 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Bug report
description: Create a bug report
labels: ["bug"]
body:

- type: textarea
id: context
attributes:
label: Context
description: >-
Optional context about what you are / were trying to do when you found this
bug. You can leave this field empty if the context is not relevant.
- type: textarea
id: description
attributes:
label: Description
description: >-
A clear and concise description of what the bug is.
validations:
required: true

- type: textarea
id: reproduction
attributes:
label: Reproduction
description: >-
A minimal runnable example that showcases the bug.
validations:
required: true

- type: textarea
id: output
attributes:
label: Output
description: >-
The logs / error message(s) that you are seeing, if any. The more verbose the better!
validations:
required: false

- type: textarea
id: version
attributes:
label: Version
description: >-
The version (either a git commit hash or the release version) of the package
that you are using.
validations:
required: true
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Feature request
description: Request a new feature
labels: ["enhancement"]
body:

- type: textarea
id: context
attributes:
label: Context
description: >-
Optional context about what you are trying to do.
validations:
required: true

- type: textarea
id: description
attributes:
label: Description
description: >-
A clear and concise description of the feature you would like to see.
validations:
required: true

- type: textarea
id: alternatives
attributes:
label: Alternatives
description: >-
Alternatives or workarounds you've considered.
validations:
required: true

- type: textarea
id: additional-context
attributes:
label: Additional Context
description: >-
Any other context or screenshots about the feature request that might be relevant.
validations:
required: false
6 changes: 6 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Description

<!--- Provide a brief description of the PR's purpose here. -->

## Status
- [ ] Ready to go
35 changes: 35 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

on:
push: { branches: [ "main" ] }
pull_request: { branches: [ "main" ] }

jobs:
test:

runs-on: ubuntu-latest
container: condaforge/mambaforge:latest

steps:
- uses: actions/[email protected]

- name: Run CI
run: |
apt update && apt install -y git make
make env
make lint
make test
make docs-build
- name: CodeCov
uses: codecov/[email protected]
with:
file: ./coverage.xml
flags: unittests
47 changes: 47 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish Documentation

on:
push:
branches: ["main"]
tags: ["*"]

jobs:
deploy-docs:

runs-on: ubuntu-latest
container: condaforge/mambaforge:latest

steps:
- name: Prepare container
run: |
apt update && apt install -y git make
- name: Checkout
uses: actions/[email protected]

- name: Determine Version
shell: bash
run: |
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
echo "VERSION=latest" >> $GITHUB_ENV
elif [ "${GITHUB_REF#refs/tags/}" != "$GITHUB_REF" ]; then
VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\///')
echo "VERSION=$VERSION stable" >> $GITHUB_ENV
else
echo "Invalid ref: $GITHUB_REF"
exit 1
fi
- name: Build and Deploy Documentation
env:
INSIDER_DOCS_TOKEN: ${{ secrets.INSIDER_DOCS_TOKEN }}
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git config --global --add safe.directory "$PWD"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git fetch --all --prune
make env
make docs-deploy VERSION="$VERSION"
115 changes: 115 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
.pytest_cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# profraw files from LLVM? Unclear exactly what triggers this
# There are reports this comes from LLVM profiling, but also Xcode 9.
*profraw

# PyCharm
.idea

# OSX
.DS_Store

# Linters
.ruff_cache
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: local
hooks:
- id: ruff
name: Autoformat python code
language: system
entry: ruff
args: [check]
files: \.py$
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

MIT License

Copyright (c) 2024 Julien

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global-exclude *.py[cod] __pycache__ *.so
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
PACKAGE_NAME := kcalc
PACKAGE_DIR := kcalc

CONDA_ENV_RUN = conda run --no-capture-output --name $(PACKAGE_NAME)

TEST_ARGS := -v --cov=$(PACKAGE_NAME) --cov-report=term --cov-report=xml --junitxml=unit.xml --color=yes

.PHONY: env lint format test docs-build docs-deploy

env:
mamba create --name $(PACKAGE_NAME)
mamba env update --name $(PACKAGE_NAME) --file devtools/envs/base.yaml
$(CONDA_ENV_RUN) pip install --no-deps -e .
$(CONDA_ENV_RUN) pre-commit install || true

lint:
$(CONDA_ENV_RUN) ruff check $(PACKAGE_DIR)

format:
$(CONDA_ENV_RUN) ruff format $(PACKAGE_DIR)
$(CONDA_ENV_RUN) ruff check --fix --select I $(PACKAGE_DIR)

test:
$(CONDA_ENV_RUN) pytest -v $(TEST_ARGS) $(PACKAGE_DIR)/tests/

docs-build:
$(CONDA_ENV_RUN) mkdocs build

docs-deploy:
ifndef VERSION
$(error VERSION is not set)
endif
$(CONDA_ENV_RUN) mike deploy --push --update-aliases $(VERSION)


Loading

0 comments on commit 207a2ed

Please sign in to comment.