Skip to content

Commit 647e8c1

Browse files
Merge pull request #9 from EcoExtreML/use_python_template
Use python template to restructure the repo
2 parents 2767265 + 3ddb272 commit 647e8c1

32 files changed

Lines changed: 1116 additions & 5 deletions

.bumpversion.cfg

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[bumpversion]
2+
current_version = 0.1.0
3+
4+
[comment]
5+
comment = The contents of this file cannot be merged with that of setup.cfg until https://github.com/c4urself/bump2version/issues/185 is resolved
6+
7+
[bumpversion:file:PyStemmusScope/__init__.py]
8+
search = __version__ = "{current_version}"
9+
replace = __version__ = "{new_version}"
10+
11+
[bumpversion:file:setup.cfg]
12+
search = version = {current_version}
13+
replace = version = {new_version}
14+
15+
[bumpversion:file:CITATION.cff]
16+
search = version: "{current_version}"
17+
replace = version: "{new_version}"
18+
19+
[bumpversion:file:docs/conf.py]
20+
search = version = "{current_version}"
21+
replace = version = "{new_version}"

.editorconfig

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
charset = utf-8
12+
13+
# 4 space indentation
14+
[*.{py,java,r,R}]
15+
indent_style = space
16+
indent_size = 4
17+
18+
# 2 space indentation
19+
[*.{js,json,y{a,}ml,html,cwl}]
20+
indent_style = space
21+
indent_size = 2
22+
23+
[*.{md,Rmd,rst}]
24+
trim_trailing_whitespace = false
25+
indent_style = space
26+
indent_size = 2

.githooks/pre-commit

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
echo "Script $0 triggered ..."
4+
5+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
6+
echo "Starting prospector analysis using configuration from .prospector.yml..."
7+
8+
# quietly run prospector
9+
prospector 1>/dev/null
10+
11+
# use return code to abort commit if necessary
12+
if [ $? != "0" ]; then
13+
echo "Commit aborted. Run 'prospector' to see the errors."
14+
exit 1
15+
fi
16+
17+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
18+
echo "Starting isort analysis using configuration from setup.cfg..."
19+
20+
# recursively run isort on PyStemmusScope/ directory, don't try to automatically fix anything
21+
isort --recursive --check-only PyStemmusScope
22+
23+
if [ $? != "0" ]; then
24+
echo "Commit aborted."
25+
echo " Run 'isort --recursive --check-only --diff PyStemmusScope' to see what's wrong."
26+
echo " Run 'isort --recursive PyStemmusScope' to let isort fix problems automatically."
27+
exit 1
28+
fi
29+
30+
echo "Pre-commit checks completed successfully."
31+
exit 0

.github/workflows/build.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Python package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
13+
build:
14+
name: Build for (${{ matrix.python-version }}, ${{ matrix.os }})
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
20+
python-version: ['3.7', '3.8', '3.9']
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v3
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Python info
28+
shell: bash -l {0}
29+
run: |
30+
which python3
31+
python3 --version
32+
- name: Upgrade pip and install dependencies
33+
run: |
34+
python3 -m pip install --upgrade pip setuptools
35+
python3 -m pip install .[dev,publishing]
36+
- name: Run unit tests
37+
run: pytest -v
38+
- name: Verify that we can build the package
39+
run: python3 setup.py sdist bdist_wheel
40+
41+
lint:
42+
name: Linting build
43+
runs-on: ubuntu-latest
44+
strategy:
45+
fail-fast: false
46+
steps:
47+
- uses: actions/checkout@v3
48+
- name: Set up Python 3.9
49+
uses: actions/setup-python@v3
50+
with:
51+
python-version: 3.9
52+
- name: Python info
53+
shell: bash -l {0}
54+
run: |
55+
which python3
56+
python3 --version
57+
- name: Upgrade pip and install dependencies
58+
run: |
59+
python3 -m pip install --upgrade pip setuptools
60+
python3 -m pip install .[dev,publishing]
61+
- name: Check style against standards using prospector
62+
run: prospector
63+
- name: Check import order
64+
run: isort --check-only PyStemmusScope --diff

.github/workflows/cffconvert.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: cffconvert
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
13+
verify:
14+
name: "cffconvert"
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
name: Check out a copy of the repository
19+
20+
- uses: citation-file-format/cffconvert-github-action@main
21+
name: Check whether the citation metadata from CITATION.cff is equivalent to that in .zenodo.json
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build-documentation:
13+
name: Build documentation
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python 3.9
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.9
23+
- name: Python info
24+
shell: bash -l {0}
25+
run: |
26+
which python3
27+
python3 --version
28+
- name: Upgrade pip and install dependencies
29+
run: |
30+
python3 -m pip install --upgrade pip setuptools
31+
python3 -m pip install .[dev,publishing]
32+
- name: Install pandoc using apt
33+
run: sudo apt install pandoc
34+
- name: Build documentation
35+
run: make coverage doctest html
36+
working-directory: docs
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: markdown-link-check
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
13+
markdown-link-check:
14+
name: Check markdown links
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: gaurav-nelson/github-action-markdown-link-check@v1
19+
with:
20+
config-file: '.mlc-config.json'

.github/workflows/sonarcloud.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: sonarcloud
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
branches:
10+
- main
11+
12+
jobs:
13+
14+
sonarcloud:
15+
name: SonarCloud
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
21+
- name: Set up Python
22+
uses: actions/setup-python@v3
23+
with:
24+
python-version: 3.9
25+
- name: Python info
26+
shell: bash -l {0}
27+
run: |
28+
which python3
29+
python3 --version
30+
- name: Install dependencies
31+
run: python3 -m pip install .[dev]
32+
- name: Check style against standards using prospector
33+
run: prospector --zero-exit --output-format grouped --output-format pylint:pylint-report.txt
34+
- name: Run unit tests with coverage
35+
run: pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml tests/
36+
- name: Correct coverage paths
37+
run: sed -i "s+$PWD/++g" coverage.xml
38+
- name: SonarCloud Scan
39+
uses: SonarSource/sonarcloud-github-action@master
40+
env:
41+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
42+
SONAR_TOKEN: ${{secrets.SONAR_TOKEN }}

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# output file
2-
out/
31
# Byte-compiled / optimized / DLL files
42
__pycache__/
53
*.py[cod]

.mlc-config.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"_comment": "Markdown Link Checker configuration, see https://github.com/gaurav-nelson/github-action-markdown-link-check and https://github.com/tcort/markdown-link-check",
3+
"ignorePatterns": [
4+
{
5+
"pattern": "^http://localhost"
6+
},
7+
{
8+
"pattern": "^https://doi.org/<replace-with-created-DOI>"
9+
},
10+
{
11+
"pattern": "^https://github.com/.*/settings/secrets/actions$"
12+
},
13+
{
14+
"pattern": "^https://github.com/organizations/.*/repositories/new"
15+
},
16+
{
17+
"pattern": "^https://test.pypi.org"
18+
},
19+
{
20+
"pattern": "^https://bestpractices.coreinfrastructure.org/projects/<replace-with-created-project-identifier>"
21+
},
22+
{
23+
"pattern": "^https://readthedocs.org/dashboard/import.*"
24+
}
25+
],
26+
"replacementPatterns": [
27+
],
28+
"retryOn429": true,
29+
"timeout": "20s"
30+
}

0 commit comments

Comments
 (0)