Skip to content

Commit

Permalink
build: restructure project with escience center python template
Browse files Browse the repository at this point in the history
eScience Center python template is used to restructure the project.
  • Loading branch information
CunliangGeng committed Jul 21, 2022
1 parent 1e5bc0a commit 8d97b99
Show file tree
Hide file tree
Showing 45 changed files with 5,499 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[bumpversion]
current_version = 0.1.0

[bumpversion:file:nplinker/main.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

[bumpversion:file:CITATION.cff]
search = version: "{current_version}"
replace = version: "{new_version}"
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.bumpversion.cfg
.editorconfig
.git
.github
.gitignore
.mlc-config.json
.prospector.yml
.vscode
run_nplinker_docker.sh
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

# 4 space indentation
[*.{py,java,r,R,sh}]
indent_style = space
indent_size = 4

# 2 space indentation
[*.{js,json,y{a,}ml,html,cwl}]
indent_style = space
indent_size = 2

[*.{md,Rmd,rst}]
trim_trailing_whitespace = false
indent_style = space
indent_size = 2
25 changes: 25 additions & 0 deletions .github/workflows/cffconvert.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: cffconvert

on:
push:
branches:
- main
paths:
- CITATION.cff
pull_request:
branches:
- main
paths:
- CITATION.cff

jobs:

verify:
name: "cffconvert"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Check out a copy of the repository

- uses: citation-file-format/cffconvert-github-action@main
name: Check whether the citation metadata from CITATION.cff is equivalent to that in .zenodo.json
37 changes: 37 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Check code style

on:
push:
branches:
- main
paths:
- '**.py'
pull_request:
branches:
- main
paths:
- '**.py'

jobs:

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Python info
shell: bash -l {0}
run: |
which python3
python3 --version
- name: Upgrade pip and install dependencies
run: |
python3 -m pip install --upgrade pip setuptools
pip install "prospector[with_pyroma]" isort
- name: Check style against standards using prospector
run: prospector
- name: Check import order
run: isort --check-only . --diff
24 changes: 24 additions & 0 deletions .github/workflows/markdown-link-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: markdown-link-check

on:
push:
branches:
- main
paths:
- '**.md'
pull_request:
branches:
- main
paths:
- '**.md'

jobs:

markdown-link-check:
name: Check markdown links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
config-file: '.mlc-config.json'
73 changes: 73 additions & 0 deletions .github/workflows/publish_gh_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Draft or publish Github release
# this action will automatically create a tag for the latest commit

on:
workflow_dispatch:
inputs:
current_version:
description: 'Current version'
default: '0.0.1'
type: string
required: true
new_version:
description: 'New version to release, used for tag name and release title'
default: '0.0.1'
type: string
required: true
mode:
description: 'Draft or publish Github release'
default: "Draft"
required: true
type: choice
options:
- draft
- publish

env:
REPO_NAME: nplinker-webapp
CHANGELOG_FILE: CHANGELOG.md
RELEASE_NOTES_FILE: release_notes.md

jobs:
release:
runs-on: ubuntu-latest
if: ${{ inputs.current_version != inputs.new_version }}
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Upgrade pip and install dependencies
run: |
python3 -m pip install --upgrade pip
pip install bump2version
- name: Update package version and change log
run: |
bumpversion --current-version ${{ inputs.current_version }} --new-version ${{ inputs.new_version }} part
docker run --rm -v "$(pwd)":/usr/local/src/your-app \
githubchangeloggenerator/github-changelog-generator \
-u ${{ github.repository_owner }} \
-p $REPO_NAME \
--future-release=v${{ inputs.new_version }} \
-o $CHANGELOG_FILE \
-t ${{ secrets.GITHUB_TOKEN }}
- name: Commit and push the changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update version to ${{ inputs.new_version }}
- name: Generate release notes
run: |
awk '/^## \[v${{ inputs.new_version }}/{flag=1; next}/^##/{flag=0}flag' $CHANGELOG_FILE > $RELEASE_NOTES_FILE
- name: Draft a Github release
if: ${{ inputs.mode == 'draft' }}
run: |
gh release create v${{ inputs.new_version }} --draft --title v${{ inputs.new_version }} -F $RELEASE_NOTES_FILE
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTION_TOKEN }}
- name: Publish a Github release
if: ${{ inputs.mode == 'publish' }}
run: |
gh release create v${{ inputs.new_version }} --title v${{ inputs.new_version }} -F $RELEASE_NOTES_FILE
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTION_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.pyc
36 changes: 36 additions & 0 deletions .mlc-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"_comment": "Markdown Link Checker configuration, see https://github.com/gaurav-nelson/github-action-markdown-link-check and https://github.com/tcort/markdown-link-check",
"ignorePatterns": [
{
"pattern": "^http://localhost"
},
{
"pattern": "^https://doi.org/<replace-with-created-DOI>"
},
{
"pattern": "^https://github.com/.*/settings/secrets/actions$"
},
{
"pattern": "^https://github.com/organizations/.*/repositories/new"
},
{
"pattern": "^https://help.github.com/.*"
},
{
"pattern": "^https://docs.github.com/.*"
},
{
"pattern": "^https://test.pypi.org"
},
{
"pattern": "^https://bestpractices.coreinfrastructure.org/projects/<replace-with-created-project-identifier>"
},
{
"pattern": "^https://readthedocs.org/dashboard/import.*"
}
],
"replacementPatterns": [
],
"retryOn429": true,
"timeout": "20s"
}
30 changes: 30 additions & 0 deletions .prospector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# prospector configuration file

---

output-format: grouped

strictness: medium
doc-warnings: false
test-warnings: true
member-warnings: false

ignore-paths:
- docs
- notebooks

pyroma:
run: true

pycodestyle:
full: true

pydocstyle:
disable: [
# Disable because not part of PEP257 official convention:
# see http://pep257.readthedocs.io/en/latest/error_codes.html
D203, # 1 blank line required before class docstring
D212, # Multi-line docstring summary should start at the first line
D213, # Multi-line docstring summary should start at the second line
D404, # First word of the docstring should not be This
]
29 changes: 29 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"editor.rulers": [
72,
79
],

// python
"[python]": {
"editor.defaultFormatter": "ms-python.python"
},
"python.analysis.completeFunctionParens": true,
"python.autoComplete.addBrackets": true,
"python.defaultInterpreterPath": "",
"python.languageServer": "Pylance",
// formatting and linting
"python.formatting.provider": "yapf",
"python.linting.enabled": true,
"python.linting.prospectorEnabled": true,
"python.linting.pylintEnabled": false,
// python docstring
"autoDocstring.docstringFormat": "google",
"autoDocstring.customTemplatePath": ".vscode/vscode_docstring_google_adapted.mustache",

// Jupyter
"jupyter.sendSelectionToInteractiveWindow": true,
"jupyter.askForKernelRestart": false,
"notebook.lineNumbers": "on",
"notebook.diff.ignoreMetadata": true
}
32 changes: 32 additions & 0 deletions .vscode/vscode_docstring_google_adapted.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{! Google Docstring Template}}
{{summaryPlaceholder}}

{{extendedSummaryPlaceholder}}

{{ # parametersExist}}
Args:
{{ # args}}
{{var}}({{typePlaceholder}}): {{descriptionPlaceholder}}
{{/args}}
{{ # kwargs}}
{{var}} ({{typePlaceholder}}, optional): {{descriptionPlaceholder}}. Defaults to {{& default}}.
{{/kwargs}}
{{/parametersExist}}

{{ # exceptionsExist}}
Raises:
{{ # exceptions}}
{{type}}: {{descriptionPlaceholder}}
{{/exceptions}}
{{/exceptionsExist}}

{{ # returnsExist}}
Returns:
{{ # returns}}
{{typePlaceholder}}: {{descriptionPlaceholder}}
{{/returns}}
{{/returnsExist}}

Examples:
>>> {{#placeholder}}
{{/placeholder}}
Loading

0 comments on commit 8d97b99

Please sign in to comment.