Skip to content

Commit

Permalink
Add PyPi Packaging (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
WibblyGhost authored Sep 17, 2022
1 parent 8745981 commit ea90e75
Show file tree
Hide file tree
Showing 30 changed files with 636 additions and 545 deletions.
11 changes: 0 additions & 11 deletions .coveragerc

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Auto detect text files and perform LF normalization
* text=auto
* text eol=lf
79 changes: 0 additions & 79 deletions .github/workflows/docker-publish.yml.disabled

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/pylint.yml.disabled

This file was deleted.

88 changes: 62 additions & 26 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,12 @@ name: Docker

on: [push]

# Unstable
# on:
# push:
# branches: [ "main" ]
# tags: [ 'v*.*.*' ]
# pull_request:
# branches: [ "main" ]
# paths:
# - '**.dockerfile'
# - '**.py'
# - '**.ps1'
# - '**.yml'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}


jobs:
lint:
PyLint:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -39,14 +25,38 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-test.txt
- name: Analysing the code with pylint
- name: Analysing the code with PyLint
run: |
pylint $(git ls-files '*.py')
isort --check $(git ls-files '*.py')
black --check $(git ls-files '*.py')
PyTest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-test.txt
- name: Analysing the code with PyTest
run: pytest


build:
Publish-Docker-Image:
runs-on: ubuntu-latest
needs: lint
needs: [PyLint, PyTest]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')

permissions:
contents: read
Expand All @@ -61,7 +71,6 @@ jobs:
id: vars
run: |
echo "::set-output name=image_path::${IMAGE_NAME,,}"
[ ${{ github.event_name }} == 'pull_request' ] && echo "::set-output name=tag_name::$(git rev-parse --short HEAD)" || echo "::set-output name=tag_name::latest"
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
Expand All @@ -81,13 +90,8 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ steps.vars.outputs.image_path }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
Expand All @@ -97,6 +101,38 @@ jobs:
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ steps.vars.outputs.image_path }}:${{ steps.vars.outputs.tag_name }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: solar-logger.dockerfile
target: solar-logger

Publish-PyPi-Package:
runs-on: ubuntu-latest
needs: [PyLint, PyTest]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build gitpython wheel
- name: Tag Version File
run: |
git fetch --tags -f
echo VERSION = "'$(git describe --tags)'" > __version__.py
- name: Build package
run: python setup.py sdist

- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ htmlcov/

# Docker Mappings
docker-solar-logger/
docker-influxdb/
docker-influxdb/

# Build Files
*.egg-info/
build
dist
11 changes: 0 additions & 11 deletions .pylintrc

This file was deleted.

2 changes: 2 additions & 0 deletions __version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# pylint: disable=missing-module-docstring
VERSION = "0.0.0"
Empty file added app/__init__.py
Empty file.
5 changes: 3 additions & 2 deletions influx_query.py → app/influx_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
https://docs.influxdata.com/influxdb/v2.0/api-guide/client-libraries/python/#query-data-from-influxdb-with-python
"""

from classes.common_classes import SecretStore
from classes.consts import INFLUX_DEBUG_CONFIG_TITLE, INFLUX_QUERY_CONFIG_TITLE
from classes.influx_classes import InfluxConnector
from classes.py_functions import SecretStore, read_query_settings, write_results_to_csv
from classes.py_functions import read_query_settings, write_results_to_csv
from classes.py_logger import create_logger
from classes.query_classes import QueryBuilder
from classes.consts import INFLUX_DEBUG_CONFIG_TITLE, INFLUX_QUERY_CONFIG_TITLE


class ParseQuery:
Expand Down
Loading

0 comments on commit ea90e75

Please sign in to comment.