Skip to content

Commit 249bf56

Browse files
committed
Merge branch 'devel' into add-publish-job
2 parents 9b745bb + 7d3ae79 commit 249bf56

20 files changed

Lines changed: 552 additions & 229 deletions

.github/workflows/ci.yml

Lines changed: 0 additions & 116 deletions
This file was deleted.

.github/workflows/docs.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Deploy docs to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: ["devel", "main"] # TODO: Set to main only after release
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build-and-deploy:
19+
runs-on: ubuntu-latest
20+
environment:
21+
name: github-pages
22+
url: ${{ steps.deployment.outputs.page_url }}
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Install pandoc
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y pandoc
32+
33+
- name: Install Python dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install ".[docs]"
37+
38+
- name: Build Sphinx docs
39+
run: |
40+
cd docs
41+
make html
42+
43+
- name: Setup Pages
44+
uses: actions/configure-pages@v5
45+
46+
- name: Upload built docs
47+
uses: actions/upload-pages-artifact@v3
48+
with:
49+
path: docs/build/html/
50+
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v4
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Static analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- devel
8+
pull_request:
9+
branches:
10+
- main
11+
- devel
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
jobs:
18+
cloc:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout the code
22+
uses: actions/checkout@v4
23+
24+
- name: Download and run cloc
25+
run: |
26+
curl -s https://raw.githubusercontent.com/AlDanial/cloc/master/cloc > cloc
27+
chmod +x cloc
28+
./cloc --version
29+
./cloc $(git ls-files)
30+
31+
black:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout the code
35+
uses: actions/checkout@v4
36+
37+
- name: Code formatting with black
38+
run: |
39+
pip install black "black[jupyter]"
40+
black --check src/
41+
black --check tutorials/
42+
43+
isort:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout the code
47+
uses: actions/checkout@v4
48+
49+
- name: Code formatting with isort
50+
run: |
51+
pip install isort
52+
isort --check src/
53+
isort --check tutorials/
54+
55+
mypy:
56+
runs-on: ubuntu-latest
57+
continue-on-error: true
58+
steps:
59+
- name: Checkout the code
60+
uses: actions/checkout@v4
61+
62+
- name: Type checking with mypy
63+
run: |
64+
pip install mypy
65+
mypy src/ || true
66+
67+
prospector:
68+
runs-on: ubuntu-latest
69+
continue-on-error: true
70+
steps:
71+
- name: Checkout the code
72+
uses: actions/checkout@v4
73+
74+
- name: Code analysis with prospector
75+
run: |
76+
pip install prospector
77+
prospector src/ || true
78+
79+
ruff:
80+
runs-on: ubuntu-latest
81+
continue-on-error: true
82+
steps:
83+
- name: Checkout the code
84+
uses: actions/checkout@v4
85+
86+
- name: Linting with ruff
87+
run: |
88+
pip install ruff
89+
ruff check src/ || true
90+
91+
pylint:
92+
runs-on: ubuntu-latest
93+
continue-on-error: true
94+
steps:
95+
- name: Checkout the code
96+
uses: actions/checkout@v4
97+
98+
- name: Linting with pylint
99+
run: |
100+
pip install pylint
101+
pylint src/ || true

.github/workflows/testing.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- devel
8+
pull_request:
9+
branches:
10+
- main
11+
- devel
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
# Checkout the repository
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
# Set up Python
23+
- name: Set up Python
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: '3.10' # Adjust as needed
27+
28+
# Cache pip dependencies
29+
- name: Cache pip
30+
uses: actions/cache@v3
31+
with:
32+
path: ~/.cache/pip
33+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
34+
restore-keys: |
35+
${{ runner.os }}-pip-
36+
37+
- name: Install dependencies
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y pandoc
41+
42+
- name: Install project
43+
run: |
44+
pip install --upgrade pip
45+
pip install ".[dev]"
46+
47+
- name: Check installation
48+
run: |
49+
template-python
50+
51+
- name: Run tests
52+
run: |
53+
pytest .
54+
55+
- name: Test tutorials
56+
run: |
57+
jupyter nbconvert --to notebook --execute tutorials/*.ipynb --output-dir=/tmp --ExecutePreprocessor.timeout=300
58+
59+
- name: Test docs build
60+
run: |
61+
pip install ".[docs]"
62+
cd docs
63+
make clean
64+
make html
65+
cd ..
66+
ls docs/build/html/index.html

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ instance/
7171

7272
# Sphinx documentation
7373
docs/_build/
74+
docs/source/tutorials/
7475

7576
# PyBuilder
7677
.pybuilder/

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0 # Use the latest stable version
4+
hooks:
5+
- id: check-added-large-files # Prevent giant files from being committed.
6+
args: ["--maxkb=1000"]
7+
- id: check-merge-conflict # Check for files that contain merge conflict strings.
8+
- id: check-toml # Attempts to load all TOML files to verify syntax.
9+
- id: check-yaml # Attempts to load all yaml files to verify syntax.
10+
args: ["--unsafe"]
11+
12+
- repo: https://github.com/kynan/nbstripout
13+
rev: 0.8.1
14+
hooks:
15+
- id: nbstripout # remove jupyter notebook cell output

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# template-python
2+
23
Template repository for python projects
34

5+
Documentation: https://max-models.github.io/template-python/
6+
47
# Install
58

69
Create and activate python environment
@@ -21,4 +24,13 @@ Run the code with
2124

2225
```
2326
template-python
24-
```
27+
```
28+
29+
# Build docs
30+
31+
32+
```
33+
make html
34+
cd ../
35+
open docs/_build/html/index.html
36+
```

0 commit comments

Comments
 (0)