Skip to content

Commit

Permalink
Create initial version of logki
Browse files Browse the repository at this point in the history
  • Loading branch information
tfiedor committed Apr 20, 2024
1 parent 6b771cd commit ed7aa05
Show file tree
Hide file tree
Showing 15 changed files with 1,460 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Setup Environment
description: Performs setup of Python and its dependencies
inputs:
python-version:
description: 'Python version to run'
required: true

runs:
using: 'composite'
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
cache: 'pip'

- name: Install Unix dependencies
shell: sh
run: |
sudo apt-get -qq update
- name: Upgrade pip and build dependencies
shell: sh
run: |
python -m pip install --upgrade pip setuptools
- name: Install Tox
shell: sh
run: |
pip install tox
86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Release

on:
pull_request:
types:
- closed
branches:
- devel

jobs:
release:
if: ${{ github.event.pull_request.merged == true && contains(github.head_ref, 'release') }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- name: Checkout latest version
uses: actions/checkout@v3
with:
ref: devel

- name: Setup Python, Ubuntu and Python environment
uses: ./.github/workflows/actions/setup
with:
python-version: ${{ matrix.python-version }}

- name: Install logki(to assure it is correctly installed) and try obtaining the version
run: |
make install
logki --version
- name: Set version
id: manual-tagger
run: echo "NEW_TAG=$(logki --version | cut -d' ' -f2)" >> "$GITHUB_OUTPUT"

- name: Tag the new version
uses: rickstaa/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.manual-tagger.outputs.NEW_TAG }}

build-and-deploy-to-pypi:
needs: release
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

steps:
- name: Checkout latest version
uses: actions/checkout@v3
with:
ref: devel

- name: Setup Python, Ubuntu and Python environment
uses: ./.github/workflows/actions/setup
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Ensure that dependencies are installed
run: |
# Install and upgrade pip
python3 -m pip install --upgrade pip
# Install dependencies for build and deploy
python3 -m pip install build wheel twine
- name: Build python release distribution package
run: |
make release
- name: Upload to TestPypi
run: |
python3 -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TESTPYPI_SECRET_TOKEN }}
TWINE_REPOSITORY: testpypi

- name: Upload to Pypi
run: |
python3 -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_SECRET_TOKEN }}
111 changes: 111 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Ubuntu (build-&-test)

on:
push:
branches:
- devel
pull_request:
branches:
- devel

jobs:
# Tests classic build using Tox for selected Python versions
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3

- name: Setup Python, Ubuntu and Python environment
uses: ./.github/workflows/actions/setup
with:
python-version: ${{ matrix.python-version }}

- name: Execute tests for Python ${{ matrix.python-version }} using Tox
run: tox -e py

- name: Generate docs for Python ${{ matrix.python-version }} using Tox
run: |
tox -e docs
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
flags: coverage-${{ matrix.python-version }}
verbose: true

# Tests that logki is buildable from distribution packages (this is precursor for pypi install).
# We limit the test to version 3.11 in order to have less clutter in Actions
build-from-dist:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v3

- name: Setup Python, Ubuntu and Python environment
uses: ./.github/workflows/actions/setup
with:
python-version: ${{ matrix.python-version }}

- name: Create tarball or wheel
run: |
pip3 install -q build
make release
- name: Install from dist (wheel)
run: |
pip3 install dist/*.whl
- name: Install from dist (tar.gz)
run: |
pip3 install dist/*.tar.gz
- name: Try running logki and getting help
run: |
logki --version
# Tests correctes of typing for all versions
typing:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3

- name: Setup Python, Ubuntu and Python environment
uses: ./.github/workflows/actions/setup
with:
python-version: ${{ matrix.python-version }}

- name: Check type correctness for Python ${{ matrix.python-version }} using Tox
run: |
tox -e typing
# Test linting only for the latest version of python
linting:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3

- name: Setup Python, Ubuntu and Python environment
uses: ./.github/workflows/actions/setup
with:
python-version: ${{ matrix.python-version }}

- name: Check lint correctness for Python ${{ matrix.python-version }} using Tox
run: |
tox -e lint || true
12 changes: 12 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

===============
Main Developers
===============

The following lists the authors (active ones are bold) that contributed to upstream (or to some fork) of logki:


* **Tomas Fiedor**: |github| `tfiedor <https://github.com/tfiedor>`_ |email| `[email protected] <mailto: [email protected]>`_ (original author)

.. |github| image:: ./figs/icon-github.svg
.. |email| image:: ./figs/icon-email.svg
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Changelog
=========

1.0 (2024-04-19)
-------------------

- Main version of logki
36 changes: 36 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Contributing
============

In case you run into some unexpected behaviour, error or anything suspicious, either contact us
directly through mail or [create a new Issue](https://github.com/Perfexionists/logki/issues/new).

If you'd like to contribute, please first fork our repository and create a new dedicated feature branch starting from
the `develop` branch. Pull requests are warmly welcome! We will surely review the contribution (possibly request
some changes). However, please follow these guidelines:

1. **Document your code properly**---refer to
[sphinx documentation](http://www.sphinx-doc.org/en/stable/domains.html#the-python-domain)
for the format compatible with our documentation.

2. **Test your code** within reasonable code coverage. The tests should be in the
<https://github.com/Perfexionists/logki/tree/develop/tests> directory and should achieve a suitable
amount of codecov coverage.

3. **Follow the project formatting**; we recommend using the [black](https://github.com/psf/black) formatter.

4. **Commit properly**: write meaningful commit messages; we recommend to write first short line as a short
description that can be included into the following template: "This commit will ___".

Before considering a merge of pull requests we want the feature branch to fulfill the following:

1. The branch must be compilable (i.e. Github Action checks are passing);
2. The tests cover reasonable proportion of code (i.e. codecov checks are passing);
3. The code has no issues checked by codacy;
4. At least one of the major maintainers has reviewed the code.

If you think your extension could help others, please [send us
PR](https://github.com/Perfexionists/logki/pull/new/develop), we will review the code and in case it is,
indeed, suitable for wider audience and maintainable, we will include it in our
[upstream](https://github.com/Perfexionists/logki).

*But, please be understanding; we cannot fix and merge everything.*
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
help:
@echo "Logki - Log Analysis Kit"
@echo ""
@echo "For best developer experience, make sure to use a virtual environment."
@echo "For more information about how to contribute, see the CONTRIBUTING file."
@echo ""
@echo "Main commands:"
@echo " dev Install all dependencies and set up an editable environment"
@echo " install Install the project"
@echo " lint Run linters (black, pylint)"
@echo " check Run static type checker (mypy)"
@echo " test Run tests with pytest"
@echo " release Generate sdist and wheel"

.PHONY: help dev install check lint test release docs docs-release docs-all docs-html docs-dirhtml docs-latex

# Base build requirements are not installed automatically.
# Inspired by https://meson-python.readthedocs.io/en/latest/how-to-guides/editable-installs.html
dev:
$(info [INFO] Make sure you're using a virtual environment for development)
python3 -m pip install --no-build-isolation --config-settings=editable-verbose=true --config-settings=setup-args=-Dbuildtype=debug --editable .[test,typing,lint,docs]

install:
pip3 install .

check:
python3 -m mypy ./logki/

lint:
python3 -m black -q ./logki/
python3 -m pylint --jobs 0 ./logki/ || true

test:
python3 -m pytest --durations=10 --cov=./ --cov-report term-missing:skip-covered ./tests/

# In the CI environemnt we want to see all the tests and want coverage report to be in XML
# because the results are being uploaded to Codecov.
test-ci:
python3 -m pytest --cov=./ --cov-report xml --cov-report term-missing:skip-covered ./tests/

release:
python3 -m build
Loading

0 comments on commit ed7aa05

Please sign in to comment.