Skip to content

Commit bbfb3a7

Browse files
authored
Merge pull request #1 from max-models/extend-the-ci
Extended the CI
2 parents 2299cc0 + e955c12 commit bbfb3a7

9 files changed

Lines changed: 203 additions & 33 deletions

File tree

.github/workflows/ci.yml

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
python -m venv env
4141
source env/bin/activate
4242
pip install --upgrade pip
43-
pip install .
43+
pip install ".[test]"
4444
4545
# Run a basic command to check installation
4646
- name: Check installation
@@ -55,42 +55,62 @@ jobs:
5555
pytest .
5656
env:
5757
CI: true
58-
59-
# Linting job
60-
lint:
61-
runs-on: ubuntu-latest
6258

59+
- name: Test docs build
60+
run: |
61+
pip install ".[docs]"
62+
sphinx-apidoc -o docs src/app
63+
cd docs
64+
make clean
65+
make html
66+
cd ..
67+
ls docs/_build/html/index.html
68+
69+
# Static analysis
70+
static-analysis:
71+
runs-on: ubuntu-latest
6372
steps:
64-
# Checkout the repository
65-
- name: Checkout code
66-
uses: actions/checkout@v3
73+
- name: Checkout the code
74+
uses: actions/checkout@v4
6775

68-
# Set up Python
69-
- name: Set up Python
70-
uses: actions/setup-python@v4
71-
with:
72-
python-version: '3.10'
76+
- name: Download and run cloc
77+
run: |
78+
curl -s https://raw.githubusercontent.com/AlDanial/cloc/master/cloc > cloc
79+
chmod +x cloc
80+
./cloc --version
81+
./cloc $(git ls-files)
7382
74-
# Cache pip dependencies
75-
- name: Cache pip
76-
uses: actions/cache@v3
77-
with:
78-
path: ~/.cache/pip
79-
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
80-
restore-keys: |
81-
${{ runner.os }}-pip-
83+
- name: Code formatting with black
84+
run: |
85+
pip install black
86+
pip install "black[jupyter]"
87+
black --check src/
8288
83-
# Install linting tools
84-
- name: Install linting tools
89+
- name: Code formatting with isort
8590
run: |
86-
python -m venv env
87-
source env/bin/activate
88-
pip install --upgrade pip
89-
pip install black isort
91+
pip install isort
92+
isort --check src/
9093
91-
# Code formatting check with black and isort
92-
- name: Run linters
94+
- name: Code formatting with prospector
95+
continue-on-error: true
9396
run: |
94-
source env/bin/activate
95-
black --check src/
96-
isort --check src/
97+
pip install mypy
98+
mypy src/
99+
100+
- name: Code formatting with prospector
101+
continue-on-error: true
102+
run: |
103+
pip install prospector
104+
prospector src/
105+
106+
- name: Code formatting with ruff
107+
continue-on-error: true
108+
run: |
109+
pip install ruff
110+
ruff check src/
111+
112+
- name: Code formatting with pylint
113+
continue-on-error: true
114+
run: |
115+
pip install pylint
116+
pylint src/

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
import os
6+
import sys
7+
8+
# sys.path.insert(0, os.path.abspath('..'))
9+
sys.path.insert(0, os.path.abspath("../src/app"))
10+
11+
12+
# -- Project information -----------------------------------------------------
13+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
14+
15+
project = "python-template"
16+
copyright = "2025, Max"
17+
author = "Max"
18+
19+
# The full version, including alpha/beta/rc tags
20+
release = "1.0.0"
21+
22+
23+
# -- General configuration ---------------------------------------------------
24+
25+
# Add any Sphinx extension module names here, as strings. They can be
26+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
27+
# ones.
28+
extensions = [
29+
"sphinx.ext.autodoc",
30+
"sphinx.ext.viewcode",
31+
"sphinx.ext.napoleon",
32+
# 'myst_parser',
33+
]
34+
35+
# Add any paths that contain templates here, relative to this directory.
36+
templates_path = ["_templates"]
37+
38+
# List of patterns, relative to source directory, that match files and
39+
# directories to ignore when looking for source files.
40+
# This pattern also affects html_static_path and html_extra_path.
41+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
42+
43+
44+
# -- Options for HTML output -------------------------------------------------
45+
46+
# The theme to use for HTML and HTML Help pages. See the documentation for
47+
# a list of builtin themes.
48+
#
49+
html_theme = "sphinx_rtd_theme"
50+
51+
# Add any paths that contain custom static files (such as style sheets) here,
52+
# relative to this directory. They are copied after the builtin static files,
53+
# so a file named "default.css" will overwrite the builtin "default.css".
54+
html_static_path = ["_static"]

docs/index.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.. python-template documentation master file, created by
2+
sphinx-quickstart on Sun Apr 20 11:40:45 2025.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
python-template documentation
7+
=============================
8+
9+
Add your content using ``reStructuredText`` syntax. See the
10+
`reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
11+
documentation for details.
12+
13+
14+
.. toctree::
15+
:maxdepth: 2
16+
:caption: Contents:
17+

docs/main.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
main module
2+
===========
3+
4+
.. automodule:: main
5+
:members:
6+
:show-inheritance:
7+
:undoc-members:

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/modules.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
app
2+
===
3+
4+
.. toctree::
5+
:maxdepth: 4
6+
7+
main

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ dev = [
2525
"black",
2626
"isort",
2727
"ruff",
28-
"pytest",
28+
]
29+
# https://medium.com/@pratikdomadiya123/build-project-documentation-quickly-with-the-sphinx-python-2a9732b66594
30+
docs = [
31+
"sphinx",
32+
"sphinx_rtd_theme",
2933
]
3034

3135
[project.urls]

src/app/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
"""
2+
Main module of the python package.
3+
"""
4+
5+
16
def main():
7+
"""Main method called from from the command line."""
28
print("Hello, world")

0 commit comments

Comments
 (0)