Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions .github/workflows/build_dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches: ["main"]

permissions:
contents: write

jobs:
Build-Dist:
Expand All @@ -19,28 +21,56 @@ jobs:

- name: Install dependencies
run: |
python -m venv ./venv
. ./venv/bin/activate
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install wheel
python -m pip install --upgrade build
pip install wheel build
pip install poetry
poetry install --with=dev --no-interaction --no-ansi

- name: Gather new package version
id: version
uses: anothrNick/github-tag-action@2.12.0
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
WITH_V: false
DEFAULT_BUMP: patch
DRY_RUN: true

- name: Bump package version in pyproject.toml
run: |
poetry version ${{steps.version.outputs.new_tag}}
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add pyproject.toml
git diff-index --quiet HEAD || git commit -m "Updating version of pyproject.toml [skip actions]"
git push

- name: Build dist
run: |
. ./venv/bin/activate
python -m build

- name: Commit
- name: Commit the new dist
run: |
git add -f dist
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m "Update dist"

- name: Push
- name: Push the new dist
uses: ad-m/github-push-action@master
with:
github_token: ${{secrets.GITHUB_TOKEN}}
branch: main
force: true
directory: dist

- name: Create Tag and Release
id: create_tag_and_release
uses: anothrNick/github-tag-action@2.12.0
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
WITH_V: false
DEFAULT_BUMP: patch
DRY_RUN: false
14 changes: 7 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ jobs:

- name: Install dependencies
run: |
python -m venv ./venv
. ./venv/bin/activate
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -U sphinx==6.2.1 docutils==0.18.1 sphinx_rtd_theme==1.2.2 sphinxcontrib-bibtex==2.5.0
pip install sphinx-theme
pip install groundwork-sphinx-theme
pip install karma_sphinx_theme
pip install sphinx-mdinclude
pip install wheel build
pip install poetry
poetry install --with=docs --no-interaction --no-ansi

- name: Build the sphinx docs
run: |
. ./venv/bin/activate
sphinx-apidoc -f -o ./sphinx/source ./src/<package_name>
make -C sphinx clean
python sphinx/clean_html_files.py
Expand All @@ -43,6 +42,7 @@ jobs:

- name: Copy build files to docs folder
run: |
. ./venv/bin/activate
cp -a sphinx/build/html/. docs/
python sphinx/make_html_files_list.py
rm -rf sphinx/build
Expand Down
53 changes: 30 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Tests

on:
push:
branches: [ "main" ]
branches: [ "main", "dev" ]
pull_request:
branches: [ "main" ]
branches: [ "*" ]

permissions:
contents: read
Expand All @@ -25,19 +25,30 @@ jobs:
python-version: "3.10"
- name: Install dependencies
run: |
python -m venv ./venv
. ./venv/bin/activate
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -U pytest-cov coverage-lcov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
pip install poetry
poetry install --with=dev --no-interaction --no-ansi
- name: Test Linting
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
. ./venv/bin/activate
black src --check --diff
black tests --check --diff
- name: Test Typing
run: |
python run_pytests.py tests --N_RANDOM_TESTS_PER_CASE=10 --run_slow=False
. ./venv/bin/activate
mypy src
mypy tests
- name: Test Notebooks
run: |
. ./venv/bin/activate
pytest --nbmake notebooks --nbmake-timeout=600 # 10 minutes timeout

- name: Test Unittests with pytest
run: |
. ./venv/bin/activate
python run_pytests.py tests --N_RANDOM_TESTS_PER_CASE=3 --run_slow=False

Run-tests-on-Windows:
name: Run tests on Windows-latest
Expand All @@ -51,16 +62,12 @@ jobs:
python-version: "3.10"
- name: Install dependencies
run: |
python -m venv ./venv
. ./venv/Scripts/activate
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt
pip install git+https://github.com/JeremieGince/PythonBasicTools
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
pip install poetry
poetry install --with=dev --no-interaction --no-ansi
- name: Test Unittests with pytest
run: |
python run_pytests.py tests --N_RANDOM_TESTS_PER_CASE=10 --run_slow=False
. ./venv/Scripts/activate
python run_pytests.py tests --N_RANDOM_TESTS_PER_CASE=3 --run_slow=False
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,33 @@ Then you can start developing your project by adding your code to the `src` dire

The project is constituted by the following parts:

- **.github**: This directory contains the GitHub Actions workflows that are responsible for
- **/.github**: This directory contains the GitHub Actions workflows that are responsible for
- running the tests: `.github/workflows/tests.yml`
- build the distribution: `.github/workflows/build_dist.yml`
- build the documentation: `.github/workflows/docs.yml`
- **data**: This directory will contain the data that will be used and generated by the project.
- **dist**: This directory will contain the distribution of the project.
- **docs**: This directory will contain the documentation of the project.
- **images**: This directory will contain the images that will be used in the README.md file or in the documentation.
- **sphinx**: This directory contains the configuration of the Sphinx documentation.
- **src**: This directory will contain the source code of the project. This is where you will add your own sauce.
- **tests**: This directory will contain the tests of the project.
- **docker_files**: This directory contains the scripts that will help you build the docker image and run the
- **/data**: This directory will contain the data that will be used and generated by the project.
- **/dist**: This directory will contain the distribution of the project.
- **/docs**: This directory will contain the documentation of the project.
- **/images**: This directory will contain the images that will be used in the README.md file or in the documentation.
- **/sphinx**: This directory contains the configuration of the Sphinx documentation.
- **/src**: This directory will contain the source code of the project. This is where you will add your own sauce.
- **/tests**: This directory will contain the tests of the project.
- **/docker_files**: This directory contains the scripts that will help you build the docker image and run the
project in a container.
- *Dockerfile*: This file is responsible for building the docker image of the project.
- *.gitattributes*: This file is responsible for setting the git attributes of the project.
- *.gitignore*: This file is responsible for ignoring the files that you don't want to commit to the repository.
- **Dockerfile**: This file is responsible for building the docker image of the project.
- **.gitattributes**: This file is responsible for setting the git attributes of the project.
- **.gitignore**: This file is responsible for ignoring the files that you don't want to commit to the repository.
A basic one is already provided and should be enough for most of the projects.
- *requirements.txt*: This file is responsible for listing the dependencies of the project.
- *pyproject.toml*: This file is responsible for listing the dependencies of the project and the
- **requirements.txt**: This file is responsible for listing the dependencies of the project.
- **pyproject.toml**: This file is responsible for listing the dependencies of the project and the
configuration of the project.
- *README.md*: This file is responsible for providing information about the project.
- **README.md**: This file is responsible for providing information about the project.
A basic structure is provided after this little introduction.
- *change_project_attributes.py*: This script is responsible for changing the attributes of the project.
- **change_project_attributes.py**: This script is responsible for changing the attributes of the project.
Feel free to remove it once you used it.
- *setup.py*: This file is responsible for setting up the project.
- *LICENSE*: This file is responsible for providing the license of the project.
- *run_pytests.py*: This script is used by the github actions to run the tests.
- **setup.py**: This file is responsible for setting up the project.
- **LICENSE**: This file is responsible for providing the license of the project.
- **run_pytests.py**: This script is used by the github actions to run the tests.

# README TEMPLATE

Expand Down Expand Up @@ -86,7 +86,7 @@ and to know the parameters you can use the help command:
python -m <package_name> --help
```

### Deployment
## Deployment
You will need to install Docker to run the trainings in a container.
You can install Docker by following the instructions [here](https://docs.docker.com/get-docker/).

Expand Down
37 changes: 37 additions & 0 deletions notebooks/notebook.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "initial_id",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
""
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading