Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
samupl committed Mar 20, 2023
0 parents commit 44a536f
Show file tree
Hide file tree
Showing 17 changed files with 752 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"template": "https://github.com/radix-ai/poetry-cookiecutter",
"commit": "9e5572055a98241f97c4d2ae2bfe45fd7cf5c051",
"checkout": null,
"context": {
"cookiecutter": {
"package_name": "ksef",
"package_description": "Python interface for the KSEF API",
"package_url": "https://github.com/samupl/python-ksef",
"author_name": "Jakub Szafrański",
"author_email": "[email protected]",
"python_version": "3.8",
"development_environment": "strict",
"with_conventional_commits": "1",
"with_fastapi_api": "0",
"with_jupyter_lab": "0",
"with_pydantic_typing": "1",
"with_sentry_logging": "0",
"with_streamlit_app": "0",
"with_typer_cli": "0",
"continuous_integration": "GitHub",
"docstring_style": "NumPy",
"private_package_repository_name": "",
"private_package_repository_url": "",
"__package_name_kebab_case": "ksef",
"__package_name_snake_case": "ksef",
"_template": "https://github.com/radix-ai/poetry-cookiecutter"
}
},
"directory": null
}
51 changes: 51 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "ksef",
"dockerComposeFile": "../docker-compose.yml",
"service": "devcontainer",
"workspaceFolder": "/workspaces/ksef/",
"remoteUser": "user",
"overrideCommand": true,
"initializeCommand": ".devcontainer/init",
"postStartCommand": "cp --update /opt/build/poetry/poetry.lock /workspaces/ksef/ && mkdir -p /workspaces/ksef/.git/hooks/ && cp --update /opt/build/git/* /workspaces/ksef/.git/hooks/",
"customizations": {
"vscode": {
"extensions": [
"charliermarsh.ruff",
"ms-python.python",
"ryanluker.vscode-coverage-gutters",
"tamasfe.even-better-toml",
"visualstudioexptteam.vscodeintellicode"
],
"settings": {
"coverage-gutters.coverageFileNames": [
"reports/coverage.xml"
],
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"editor.formatOnSave": true,
"[toml]": {
"editor.formatOnSave": false
},
"editor.rulers": [
100
],
"files.autoSave": "onFocusChange",
"python.defaultInterpreterPath": "/opt/ksef-env/bin/python",
"python.formatting.provider": "black",
"python.linting.mypyEnabled": true,
"python.terminal.activateEnvironment": false,
"python.testing.pytestEnabled": true,
"ruff.importStrategy": "fromEnvironment",
"ruff.logLevel": "warn",
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
}
}
}
}
}
}
25 changes: 25 additions & 0 deletions .devcontainer/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# This script runs on the host before the Dev Container is created to support both bind mount and
# volume mount workspaces [1]. If a volume mount workspace is detected, a .env file is generated
# that tells docker-compose.yml to use the container volume as the workspace source.
#
# [1] https://github.com/microsoft/vscode-remote-release/issues/6561

CONTAINER_ID="$(hostname)"
# shellcheck disable=SC2016
WORKSPACE_MOUNT_SOURCE_FMT='{{- $source := "" }}{{- range .HostConfig.Mounts }}{{- if (and (eq .Type "volume") (eq .Target "/workspaces")) }}{{- $source = .Source }}{{- end }}{{- end }}{{- $source }}'
WORKSPACE_CONTAINER_VOLUME_SOURCE=$(docker container inspect "$CONTAINER_ID" --format="$WORKSPACE_MOUNT_SOURCE_FMT" 2>/dev/null)

if [ -z "$WORKSPACE_CONTAINER_VOLUME_SOURCE" ]; then
exit
fi

cat << EOF > .env
# The following variables are used by docker-compose.yml to mount the workspace from a Docker volume.
WORKSPACE_SOURCE=devcontainer-volume
WORKSPACE_TARGET=/workspaces/
WORKSPACE_CONTAINER_VOLUME_SOURCE=$WORKSPACE_CONTAINER_VOLUME_SOURCE
WORKSPACE_IS_CONTAINER_VOLUME=true
EOF
cat .env
Empty file added .devcontainer/init.cmd
Empty file.
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2

updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
commit-message:
prefix: "ci"
prefix-development: "ci"
include: "scope"
- package-ecosystem: pip
directory: /
schedule:
interval: monthly
commit-message:
prefix: "build"
prefix-development: "build"
include: "scope"
versioning-strategy: lockfile-only
allow:
- dependency-type: "all"
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish

on:
release:
types:
- created

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Install Poetry
run: pip install --no-input poetry

- name: Publish package
run: |
poetry config pypi-token.pypi "${{ secrets.POETRY_PYPI_TOKEN_PYPI }}"
poetry publish --build
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test

on:
push:
branches:
- main
- master
pull_request:

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ["3.8"]

name: Python ${{ matrix.python-version }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install @devcontainers/cli
run: npm install --location=global @devcontainers/[email protected]

- name: Start Dev Container
env:
DOCKER_BUILDKIT: 1
run: |
git config --global init.defaultBranch main
PYTHON_VERSION=${{ matrix.python-version }} devcontainer up --workspace-folder .
- name: Lint package
run: devcontainer exec --workspace-folder . poe lint

- name: Test package
run: devcontainer exec --workspace-folder . poe test

- name: Upload coverage
uses: codecov/codecov-action@v3
with:
files: reports/coverage.xml
64 changes: 64 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Coverage.py
htmlcov/
reports/

# cruft
*.rej

# Data
*.csv*
*.dat*
*.pickle*
*.xls*
*.zip*
data/

# direnv
.envrc

# dotenv
.env

# Hypothesis
.hypothesis/

# Jupyter
*.ipynb
.ipynb_checkpoints/
notebooks/

# macOS
.DS_Store

# mypy
.dmypy.json
.mypy_cache/

# Node.js
node_modules/

# Poetry
.venv/
dist/

# PyCharm
.idea/

# pyenv
.python-version

# pytest
.pytest_cache/

# Python
__pycache__/
*.py[cdo]

# Ruff
.ruff_cache/

# Terraform
.terraform/

# VS Code
.vscode/
96 changes: 96 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# https://pre-commit.com
default_install_hook_types: [commit-msg, pre-commit]
default_stages: [commit, manual]
fail_fast: true
repos:
- repo: meta
hooks:
- id: check-useless-excludes
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-mock-methods
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
types: [python]
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: name-tests-test
args: [--pytest-test-first]
- id: no-commit-to-branch
- id: trailing-whitespace
types: [python]
- repo: local
hooks:
- id: commitizen
name: commitizen
entry: cz check
args: [--commit-msg-file]
require_serial: true
language: system
stages: [commit-msg]
- id: absolufy-imports
name: absolufy-imports
entry: absolufy-imports
require_serial: true
language: system
types: [python]
- id: ruff
name: ruff
entry: ruff
args: ["--fixable=ERA001,F401,F841,T201,T203"]
require_serial: true
language: system
types: [python]
- id: black
name: black
entry: black
require_serial: true
language: system
types: [python]
- id: shellcheck
name: shellcheck
entry: shellcheck
args: [--check-sourced]
language: system
types: [shell]
- id: poetry-check
name: poetry check
entry: poetry check
language: system
files: pyproject.toml
pass_filenames: false
- id: poetry-lock-check
name: poetry lock check
entry: poetry lock
args: [--check]
language: system
pass_filenames: false
- id: mypy
name: mypy
entry: mypy
language: system
types: [python]
Loading

0 comments on commit 44a536f

Please sign in to comment.