Skip to content

Commit

Permalink
build: setup of initial files for ci linting packaging docs and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Vasconez committed May 31, 2024
1 parent 4618f0f commit 73d02f5
Show file tree
Hide file tree
Showing 19 changed files with 855 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
omit = */tests/*
source = src/baec
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
# just stop shouting as black decides line lengths.
max-line-length = 180
# E203, W504: due to black fmt
ignore = E203,W503
exclude = ["test*"]
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
33 changes: 33 additions & 0 deletions .github/workflows/deploy_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# name: deploy docs

# on:
# push:
# branches:
# - main

# jobs:
# deploy_docs:
# name: Deploy docs
# runs-on: ubuntu-20.04
# steps:
# - uses: actions/checkout@v3

# - name: Install python 3.9
# uses: actions/setup-python@v4
# with:
# python-version: 3.9

# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip setuptools
# pip install -r requirements.txt
# pip install .

# - name: Build docs
# run: sphinx-build -b html docs public

# - name: Publish docs
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./public
107 changes: 107 additions & 0 deletions .github/workflows/lint_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Test

on:
push:
paths-ignore:
- "docs/**"
- "**.md"
pull_request:
paths-ignore:
- "docs/**"
- "**.md"
workflow_call:

jobs:
test:
name: Unit test
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v3

- name: Install python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
# shellcheck disable=SC2102
pip install -e .[test]
- name: Test
run: coverage run -m pytest

- name: Post coverage results
uses: coverallsapp/github-action@v2
with:
flag-name: run-${{ matrix.python-version }}
parallel: true

finish:
needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true

lint:
name: Formatting check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed test_files within `super-linter`
fetch-depth: 0

- name: Lint
uses: github/super-linter@v5
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
FILTER_REGEX_EXCLUDE: .*tests/.*

VALIDATE_JSCPD: false
VALIDATE_CSS: false
VALIDATE_BASH: false
VALIDATE_YAML: false
VALIDATE_PYTHON_PYLINT: false
VALIDATE_NATURAL_LANGUAGE: false
VALIDATE_MARKDOWN: false

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

LINTER_RULES_PATH: /
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
PYTHON_ISORT_CONFIG_FILE: pyproject.toml
PYTHON_MYPY_CONFIG_FILE: pyproject.toml
PYTHON_FLAKE8_CONFIG_FILE: .flake8

test_docs:
name: Test docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install .
- name: Build docs
run: sphinx-build -b html docs public
39 changes: 39 additions & 0 deletions .github/workflows/release_pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# name: Release

# on:
# push:
# tags: ['*']

# jobs:
# deploy:
# runs-on: ubuntu-latest

# environment:
# name: release

# # Mandatory permission for trusted publishing to PyPi
# permissions:
# id-token: write

# steps:
# - uses: actions/checkout@v3
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: "3.11"

# - name: Install dependencies
# run: |
# pip install setuptools build

# - name: Build a binary wheel and a source tarball
# run: python3 -m build

# - name: Store the distribution packages
# uses: actions/upload-artifact@v3
# with:
# name: python-package-distributions
# path: dist/

# - name: Publish distribution 📦 to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
.idea/*

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -70,13 +71,15 @@ instance/

# Sphinx documentation
docs/_build/
public/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints
notebooks/*.pdf

# IPython
profile_default/
Expand Down Expand Up @@ -127,6 +130,7 @@ venv/
ENV/
env.bak/
venv.bak/
.ENV

# Spyder project settings
.spyderproject
Expand Down Expand Up @@ -158,3 +162,9 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# VS-Code
.vscode

# Other
tmp.*
106 changes: 105 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,105 @@
# BAEC
# BAEC Model Generator SDK
Python SDK to create Model Generators and add them into the BAEC platform.

[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Coverage Status](https://coveralls.io/repos/github/cemsbv/py-pilecore/badge.svg)](https://coveralls.io/github/cemsbv/py-pilecore)


This repository is created by [CEMS BV](https://cemsbv.nl/).

# Installation

To install a package in this repository run:

`$ pip install baec`


## ENV VARS

To use `baec` with `FitCore` to fit and predict settlements, add the follow ENV vars to your environment. Or provide them when asked.

```
* NUCLEI_TOKEN
- Your NUCLEI user token
```

You can obtain your `NUCLEI_TOKEN` on [NUCLEI](https://nuclei.cemsbv.io/#/).
Go to `personal-access-tokens` and create a new user token.

# Contribution

## Environment

We recommend developing in Python3.10 with a clean virtual environment (using `virtualenv` or `conda`), installing the requirements from the requirements.txt file:

Example using `virtualenv` and `pip` to install the dependencies in a new environment .env on Linux:

```bash
python -m venv .env
source .env/bin/activate
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install -e .
```

## Documentation

Build the docs:

```bash
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install .

sphinx-build -b html docs public
```

## Format

We format our code with black and isort.

```bash
black --config "pyproject.toml" src/baec tests notebooks
isort --settings-path "pyproject.toml" src/baec tests notebooks
```

## Lint

To maintain code quality we use the GitHub super-linter.

To run the linters locally, run the `run_super_linters.sh` bash script from the root directory.

## UnitTest

Test the software with the use of coverage:

```bash
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install -e .
coverage run -m pytest
```

## Requirements

Requirements are autogenerated by the `pip-compile` command with python 3.10

Install pip-tools with:

```bash
pip install pip-tools
```

Generate requirements.txt file with:

```bash
pip-compile --extra=test --extra=lint --extra=docs --output-file=requirements.txt pyproject.toml
```

Update the requirements within the defined ranges with:

```bash
pip-compile --upgrade --extra=test --extra=lint --extra=docs --output-file=requirements.txt pyproject.toml
```
Loading

0 comments on commit 73d02f5

Please sign in to comment.