Skip to content

Commit

Permalink
empty project
Browse files Browse the repository at this point in the history
  • Loading branch information
andreisorokin-astrazeneca committed Dec 14, 2023
0 parents commit c4afc70
Show file tree
Hide file tree
Showing 35 changed files with 1,004 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[run]
relative_files = true
omit =
*/tests/*
*/*_check.py
*/__init__.py
*/conftest.py
*/.tox/*
*/.venv/*
*/.eggs/*
*/docs/*
*/build/*
*/dist/*
*/.git/*
*/.github/*
*/.vscode/*
*/.pytest_cache/*
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
ignore = F401,F403,W503,E203,E402
max-line-length = 99
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
#
name: ci

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

strategy:
matrix:
python-version: [3.8, 3.9, "3.10", 3.11]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.dev.txt
python -m pip install -e .
- name: Test with pytest
run: |
python -m pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=src tests/
- name: Upload Coverage to Codecov
if: ${{ matrix.python-version == 3.11 && matrix.platform == 'ubuntu-latest' }}
uses: codecov/codecov-action@v2

- name: Coverage comment
id: coverage_comment
if: ${{ matrix.python-version == 3.11 && matrix.platform == 'ubuntu-latest' }}
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
MINIMUM_GREEN: 85
MINIMUM_ORANGE: 70

- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v3
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
# If you use a different name, update COMMENT_ARTIFACT_NAME accordingly
name: python-coverage-comment-action
# If you use a different name, update COMMENT_FILENAME accordingly
path: python-coverage-comment-action.txt
33 changes: 33 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# build docs from docstrings and markdown-file in folder docs
# publish them as github pages
#
#note for myself
#
# Do not forget to set git branch `gh-pages` as source for github pages.
# This branch auto-updated by `mkdocs gh-deploy`
#
name: docs
on:
push:
branches:
- main
- master

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: '3.11'
- run: |
pip install -r requirements.dev.txt
pip install ghp-import
python -m pip install -e .
- run: ./scripts/build-docs.sh
- run: |
ghp-import --no-jekyll --push --force site
60 changes: 60 additions & 0 deletions .github/workflows/pip_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This workflows will upload a Python Package when a version tag is pushed using build system from pyproject.toml
# To publish new version use `scripts/verup.sh`
# Put you pypi credentials (PYPI_USERNAME, PYPI_PASSWORD) into the github repository secrets

name: Upload Python Package

on:
push:
tags:
- 'v*.*.*'

permissions:
contents: write

jobs:
publish:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set version var
run: |
echo "RELEASE_VERSION=$(echo ${GITHUB_REF#refs/*/} | sed 's/^v//')" >> $GITHUB_ENV
echo $RELEASE_VERSION
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: |
python -m build
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
packages_dir: dist

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
release_name: Release ${{ env.RELEASE_VERSION }}
body: https://pypi.org/project/opensearch-log/${{ env.RELEASE_VERSION }}/
draft: false
prerelease: false
27 changes: 27 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# build docs from docstrings and markdown-file in folder docs
# publish them as github pages
#
#note for myself
#
# Do not forget to set git branch `gh-pages` as source for github pages.
# This branch auto-updated by `mkdocs gh-deploy`
#
name: static source code checks
on:
push:
branches:
- main
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.11'
- run: |
python -m pip install --upgrade pip
pip install -r requirements.dev.txt
python -m pip install -e .
- run: pre-commit run --verbose --all-files
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
site
.mypy_cache
**/api-reference/
.idea/
**/__pycache__
**/.pytest_cache
**/*.egg-info
pytest.xml
.coverage
.dmypy.json
pytest-coverage.txt
*.py-e
2 changes: 2 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
ignore_missing_imports = True
100 changes: 100 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
exclude: |
(?x)(
tests/|
site/|
docs/|
pyproject.toml|
__about__.py
)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args: ["--unsafe"]
- id: check-added-large-files

- repo: https://github.com/myint/autoflake
rev: v2.2.1
hooks:
- id: autoflake
name: Cleanup imports
args:
- --in-place
- --remove-all-unused-imports
- --expand-star-imports
- --ignore-init-module-imports

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
name: Sorts imports
args: [
# Align isort with black formatting
"--multi-line=3",
"--trailing-comma",
"--force-grid-wrap=0",
"--use-parentheses",
"--line-width=99",
]

- repo: https://github.com/psf/black
rev: 23.12.0
hooks:
- id: black
name: Fixes formatting
language_version: python3
args: ["--line-length=99"]

- repo: https://github.com/pycqa/flake8.git
rev: 6.1.0
hooks:
- id: flake8
name: Checks pep8 style
args:
- --max-line-length=99
# F405 - init imports * from module
# F401 - ignore imports used in init
# F403 - import * used in init
- --exclude=__init__.py
# ignore long comments (E501), as long lines are formatted by black
# ignore Whitespace before ':' (E203)
# ignore Line break occurred before a binary operator (W503)
# ignore module level import not at top of file (E402) to skip tests with uninstalled modules (pytest.importorskip)
- --ignore=E501,E203,W503,E402

- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
name: docstrings
entry: pydocstyle
language: python
args:
- --ignore=D100,D203,D405,D407,D213,D413

- repo: local
hooks:
- id: mypy
name: mypy
entry: |
mypy
--ignore-missing-imports
--install-types
--non-interactive
--strict
--implicit-reexport
--warn-unused-ignores
--cache-fine-grained
--no-namespace-packages
files: \.py$
language: python

- id: pylint
name: Pylint
entry: pylint --max-line-length=99 --ignore-imports=yes
files: \.py$
language: python
19 changes: 19 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2021 Andrey Sorokin <andrey@sorokin.engineer>

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.
46 changes: 46 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!make
VERSION := $(shell grep '__version__' src/opensearch_log/__about__.py | cut -d '"' -f2)
export VERSION

.HELP: version ## Show the current version
version:
echo ${VERSION}

.HELP: ver-bug ## Bump the version for a bug
ver-bug:
bash ./scripts/verup.sh bug

.HELP: ver-feature ## Bump the version for a feature
ver-feature:
bash ./scripts/verup.sh feature

.HELP: ver-release ## Bump the version for a release
ver-release:
bash ./scripts/verup.sh release

.HELP: reqs ## Upgrade requirements including pre-commit
reqs:
pre-commit autoupdate
bash ./scripts/compile_requirements.sh
pip install -r requirements.txt
pip install -r requirements.dev.txt

.PHONY: docs # mark as phony so it always runs even we have a docs folder
.HELP: docs ## Docs preview English
docs:
./scripts/docstrings.sh
open -a "Google Chrome" http://127.0.0.1:8000/opensearch-log/
mkdocs serve -f docs/mkdocs-en.yml

.HELP: docs-ru ## Docs preview Russian
docs-ru:
./scripts/docstrings.sh
open -a "Google Chrome" http://127.0.0.1:8000/opensearch-log/
mkdocs serve -f docs/mkdocs-ru.yml

.HELP: help ## Display this message
help:
@grep -E \
'^.HELP: .*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ".HELP: |## "}; {printf "\033[36m%-19s\033[0m %s\n", $$2, $$3}'
Loading

0 comments on commit c4afc70

Please sign in to comment.