Skip to content

Commit

Permalink
Applying latest changes from aieng-template
Browse files Browse the repository at this point in the history
  • Loading branch information
lotif committed Feb 21, 2024
1 parent a955128 commit 966dde3
Show file tree
Hide file tree
Showing 23 changed files with 3,051 additions and 141 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/docs_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: docs (build)

on:
pull_request:
branches:
- main
paths:
- .pre-commit-config.yaml
- .github/workflows/docs_build.yml
- '**.py'
- '**.ipynb'
- poetry.lock
- pyproject.toml
- '**.rst'
- '**.md'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Install dependencies, build docs and coverage report
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/[email protected]
with:
python-version: '3.9'
cache: 'poetry'
- run: |
python3 -m pip install --upgrade pip && python3 -m pip install poetry
poetry env use '3.9'
source $(poetry env info --path)/bin/activate
poetry install --with docs,test
cd docs && rm -rf source/reference/api/_autosummary && make html
cd .. && coverage run -m pytest -m "not integration_test" && coverage xml && coverage report -m
- name: Upload coverage to Codecov
uses: Wandalen/[email protected]
with:
action: codecov/[email protected]
with: |
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
name: codecov-umbrella
fail_ci_if_error: true
attempt_limit: 5
attempt_delay: 30000
55 changes: 55 additions & 0 deletions .github/workflows/docs_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: docs

on:
push:
branches:
- main
paths:
- .pre-commit-config.yaml
- .github/workflows/code_checks.yml
- .github/workflows/docs_build.yml
- .github/workflows/docs_deploy.yml
- .github/workflows/integration_tests.yml
- '**.py'
- '**.ipynb'
- poetry.lock
- pyproject.toml
- '**.rst'
- '**.md'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
submodules: 'true'
- name: Install dependencies, build docs and coverage report
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/[email protected]
with:
python-version: '3.9'
cache: 'poetry'
- run: |
python3 -m pip install --upgrade pip && python3 -m pip install poetry
poetry env use '3.9'
source $(poetry env info --path)/bin/activate
poetry install --with docs,test
cd docs && rm -rf source/reference/api/_autosummary && make html
cd .. && coverage run -m pytest -m "not integration_test" && coverage xml && coverage report -m
- name: Upload coverage to Codecov
uses: Wandalen/[email protected]
with:
action: codecov/[email protected]
with: |
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
name: codecov-umbrella
fail_ci_if_error: true
attempt_limit: 5
attempt_delay: 30000
- name: Deploy to Github pages
uses: JamesIves/[email protected]
with:
branch: github_pages
folder: docs/build/html
61 changes: 61 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: integration tests

on:
push:
branches:
- main
paths:
- .pre-commit-config.yaml
- .github/workflows/code_checks.yml
- .github/workflows/docs_build.yml
- .github/workflows/docs_deploy.yml
- .github/workflows/integration_tests.yml
- '**.py'
- '**.ipynb'
- poetry.lock
- pyproject.toml
- '**.rst'
- '**.md'
pull_request:
branches:
- main
paths:
- .pre-commit-config.yaml
- .github/workflows/code_checks.yml
- .github/workflows/docs_build.yml
- .github/workflows/docs_deploy.yml
- .github/workflows/integration_tests.yml
- '**.py'
- '**.ipynb'
- poetry.lock
- pyproject.toml
- '**.rst'
- '**.md'

jobs:
integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Install poetry
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/[email protected]
with:
python-version: '3.9'
- name: Install dependencies and check code
run: |
poetry env use '3.9'
source $(poetry env info --path)/bin/activate
poetry install --with docs,test
coverage run -m pytest -m integration_test && coverage xml && coverage report -m
- name: Upload coverage to Codecov
uses: Wandalen/[email protected]
with:
action: codecov/[email protected]
with: |
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
name: codecov-umbrella
fail_ci_if_error: true
attempt_limit: 5
attempt_delay: 30000
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: publish package

on:
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install apt dependencies
run: |
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev libssl-dev
- uses: actions/[email protected]
- name: Install poetry
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/[email protected]
with:
python-version: '3.9'
- name: Build package
run: poetry build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
54 changes: 28 additions & 26 deletions .github/workflows/static_code_checks.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
# only has to pass for python 3.9
name: Static code checks
name: code checks

on:
push:
branches:
main
- main
paths:
- .pre-commit-config.yaml
- .github/workflows/code_checks.yml
- '**.py'
- poetry.lock
- pyproject.toml
- '**.ipynb'
pull_request:
branches:
main
- main
paths:
- .pre-commit-config.yaml
- .github/workflows/code_checks.yml
- '**.py'
- poetry.lock
- pyproject.toml
- '**.ipynb'

jobs:
run-code-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v3
- uses: actions/[email protected]
- name: Install poetry
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/setup-python@v5.0.0
with:
python-version: 3.9
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Set up cache
uses: actions/cache@v2
id: cached-poetry-dependencies
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install --with "dev, test"
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Pre-commit Checks
python-version: '3.9'
cache: 'poetry'
- name: Install dependencies and check code
run: |
source .venv/bin/activate
poetry env use '3.9'
source $(poetry env info --path)/bin/activate
poetry install --with test --all-extras
pre-commit run --all-files
- name: pip-audit (gh-action-pip-audit)
uses: pypa/[email protected]
with:
virtual-environment: .venv/
virtual-environment: $(poetry env info --path)/
67 changes: 35 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # Use the ref you want to point at
rev: v4.4.0 # Use the ref you want to point at
hooks:
- id: trailing-whitespace
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=lf]
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: check-yaml
- id: trailing-whitespace
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=lf]
- id: requirements-txt-fixer
- id: check-yaml
- id: check-toml

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.2.2'
hooks:
- id: flake8

- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, jupyter]
- id: ruff-format
types_or: [python, jupyter]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
- id: mypy
entry: python3 -m mypy --config-file pyproject.toml
language: system
types: [python]
exclude: "tests"

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.1
hooks:
- id: nbqa-black
- id: nbqa-isort
- id: nbqa-check-ast
- id: nbqa-flake8
- id: nbqa-mypy
- id: nbqa-ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: local
hooks:
- id: doctest
name: doctest
entry: python3 -m doctest -o NORMALIZE_WHITESPACE
files: "^aieng_template/"
language: system
Loading

0 comments on commit 966dde3

Please sign in to comment.