diff --git a/.github/workflows/dev.workflow.yml b/.github/workflows/dev.workflow.yml new file mode 100644 index 0000000..a1470ec --- /dev/null +++ b/.github/workflows/dev.workflow.yml @@ -0,0 +1,167 @@ +name: Integration workflow - validation & testing + +run-name: ${{github.event_name}} by ${{github.actor}} + +on: + pull_request: + branches: + - main + - master + +env: + PIP_CACHE_DIR: ${{github.workspace}}/.cache/pip + PRE_COMMIT_HOME: ${{github.workspace}}/.cache/pre-commit + +jobs: + validate: + runs-on: ubuntu-latest + container: python:3.8.5 + env: + TARGET_BRANCH: ${{ github.base_ref }} + HEAD_BRANCH: ${{ github.head_ref }} + steps: + - uses: actions/checkout@v3 + - name: New Version Check + run: | + pip install packaging + git fetch origin $HEAD_BRANCH + git fetch origin $TARGET_BRANCH + lib_ver=$(git diff origin/$HEAD_BRANCH origin/$TARGET_BRANCH -- soam/__init__.py | grep __version__ | cut -d = -f 2 | xargs) + python -c "import sys; from packaging import version; exit(not version.parse(sys.argv[1]) > version.parse(sys.argv[2]))" $lib_ver + + - name: Check changelog + run: | + git fetch origin $HEAD_BRANCH + git fetch origin $TARGET_BRANCH + added_lines=$(git diff --numstat origin/$TARGET_BRANCH origin/$HEAD_BRANCH -- CHANGELOG.md | awk '{print $1}') + if [ -z $added_lines ] || [ $added_lines -eq 0 ]; then echo "Changelog has not been modified" && exit 1; else echo "Changelog has been modified" && exit 0; fi; + + + test_stage: + runs-on: ubuntu-latest + needs: validate + container: + image: python:3.8.5 + options: --user root + services: + postgres: + image: postgres + env: + POSTGRES_DB: soam_db + POSTGRES_USER: soam_usr + POSTGRES_PASSWORD: soam_pass + + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - uses: actions/checkout@v3 + + - name: Installing sudo package + run: apt update && apt install sudo + + - name: Installing Nox + run: pip install -U nox + + - name: Lint + run: | + sudo apt-get install libffi-dev + sudo apt-get install -y texlive-xetex texlive-fonts-recommended libpoppler-cpp-dev libpoppler-dev poppler-utils + pip install --upgrade pre-commit + nox --sessions lint + + + - name: Tests + env: + POSTGRES_HOST: localhost + POSTGRES_PORT: 5432 + TEST_DB_CONNSTR: "postgresql://soam_usr:soam_pass@postgres:5432/soam_db" + run: | + pip install pdftotext + nox --sessions tests + + - name: DocString Coverage + run: | + pip install interrogate + interrogate soam -c pyproject.toml -vv + + - name: Bandit + run: nox --sessions bandit + + - name: Pyreverse + run: | + apt-get -qq update + apt-get -qq install -y graphviz + nox --sessions pyreverse + + # version_stage: + # runs-on: ubuntu-latest + # container: python:3.8.5 + # steps: + + # script: + # - echo "TAG=v$(grep __version__ ./soam/__init__.py | cut -d "'" -f 2)" >> variables.env + # artifacts: + # reports: + # dotenv: variables.env + # before_script: + # - '' + # only: + # refs: + # - master + + release_stage: + name: Release Stage + runs-on: ubuntu-latest + needs: test_stage + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: | + Adding Github Workflows + draft: false + prerelease: false + + # pages: + # stage: deploy_stage + # script: + # - pip install .[dev] + # - cd documentation + # - sphinx-apidoc -f -o source ../soam + # - make html + # - cd .. + # - mv documentation/build/html/ public/ + # artifacts: + # paths: + # - public + # only: + # refs: + # - master + + # Deploy from master to package registry +# If PYPI_USERNAME/PYPI_PASSWORD are not set, defaults to gitlab +# package registry, thus using the required variables to do so +# The package will be uploaded to PYPI_URL, which can be overrided +# not to upload to gitlab's PYPI +# deploy: +# stage: deploy_stage +# script: +# - pip install twine +# - python setup.py sdist bdist_wheel +# - export TWINE_USERNAME=${PYPI_USERNAME:=gitlab-ci-token} +# - export TWINE_PASSWORD=${PYPI_PASSWORD:=$CI_JOB_TOKEN} +# - export PYPI_REPO=${PYPI_URL:=https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi} +# - python -m twine upload --verbose --repository-url ${PYPI_REPO} dist/* +# only: +# refs: +# - master \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 66c2147..232cb98 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: templates/.+|notebook/.+ repos: -- repo: git://github.com/pre-commit/pre-commit-hooks - rev: v2.5.0 +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 hooks: - id: trailing-whitespace - id: requirements-txt-fixer @@ -13,16 +13,15 @@ repos: # args: [--max-line-length=88] # exclude: templates/* notebook/* - repo: https://github.com/timothycrosley/isort - rev: 4.3.21 + rev: 5.10.1 hooks: - id: isort name: isort entry: isort - language: system types: [python] exclude: templates/.+|notebook/.+ - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.10.0 hooks: - id: black name: black @@ -32,7 +31,7 @@ repos: args: [--skip-string-normalization] exclude: templates/.+|notebook/.+ - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.761 + rev: v0.982 hooks: - id: mypy name: mypy @@ -42,7 +41,7 @@ repos: files: \.py$ exclude: templates/.+|notebook/.+ - repo: https://github.com/pre-commit/mirrors-pylint - rev: v2.4.4 + rev: v3.0.0a5 hooks: - id: pylint name: pylint @@ -60,3 +59,59 @@ repos: types: [file] files: 'README.md' require_serial: true + +# exclude: templates/.+|notebook/.+ +# repos: +# - repo: https://github.com/pre-commit/pre-commit-hooks.git +# rev: v4.3.0 +# hooks: +# - id: trailing-whitespace +# - id: requirements-txt-fixer +# - repo: https://github.com/timothycrosley/isort +# rev: 5.10.1 +# hooks: +# - id: isort +# name: isort +# entry: isort +# language: system +# types: [python] +# exclude: templates/.+|notebook/.+ +# - repo: https://github.com/psf/black +# rev: 22.10.0 +# hooks: +# - id: black +# name: black +# entry: black +# language: python +# types: [python] +# args: [--skip-string-normalization] +# exclude: templates/.+|notebook/.+ +# - repo: https://github.com/pre-commit/mirrors-mypy +# rev: v0.982 +# hooks: +# - id: mypy +# name: mypy +# entry: mypy +# language: system +# types: [python] +# files: \.py$ +# exclude: templates/.+|notebook/.+ +# - repo: https://github.com/pre-commit/mirrors-pylint +# rev: v3.0.0a5 +# hooks: +# - id: pylint +# name: pylint +# entry: pylint +# language: system +# exclude: templates/.+|notebook/.+ +# files: \.py$ +# types: [python] +# - repo: https://github.com/MuttData/gfm-diagram +# rev: v0.3.0 +# hooks: +# - id: gfmd +# name: gfmd +# entry: gfmd +# types: [file] +# files: 'README.md' +# require_serial: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d2d6a9..a63c241 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.10.2- 2022-10-18] +- Added Github Workflow + ## [0.10.1- 2022-02-14] ### Fixed diff --git a/setup.py b/setup.py index a45f8d2..8ab633c 100644 --- a/setup.py +++ b/setup.py @@ -43,9 +43,10 @@ 'slack': ["slackclient>=2.0.0"], 'orbit': ['orbit-ml==1.0.13'], 'prophet': ["pystan==2.19.1.1", "fbprophet==0.7.1", "holidays>=0.10.2"], - 'pdf_report': ["jupytext==1.10.2", "papermill==2.3.2", "nbconvert==5.6",], + 'pdf_report': ["jupytext==1.10.2", "papermill==2.3.2", "nbconvert==5.6","ipython_genutils"], 'gsheets_report': ["gspread_pandas", "muttlib[gsheets]>=1.0,<2"], 'statsmodels': ["statsmodels<0.12,>=0.11"], + 'protobuf': ["protobuf~=3.2"], 'mlflow': ["mlflow==1.17.0"], } @@ -84,7 +85,7 @@ tests_require=["pytest", "pytest-cov", "pytest-html", "betamax"], test_suite='test', install_requires=[ - "jinja2", + "Jinja2>=2.11.3,<3.1.0", "pandas>=1.0.0,<1.3.0", "Cython<0.29.18,>=0.29", "sqlalchemy<1.4.0,>=1.3.0", diff --git a/soam/__init__.py b/soam/__init__.py index e7ade49..85a9795 100644 --- a/soam/__init__.py +++ b/soam/__init__.py @@ -1,3 +1,3 @@ """Version.""" -__version__ = '0.10.1' +__version__ = '0.10.2'