Skip to content

Commit

Permalink
Update template files
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Jan 10, 2024
1 parent a6414cb commit 1fe2329
Show file tree
Hide file tree
Showing 42 changed files with 734 additions and 199 deletions.
5 changes: 0 additions & 5 deletions .coveragerc

This file was deleted.

2 changes: 0 additions & 2 deletions .deprecated_files_ignore

This file was deleted.

2 changes: 0 additions & 2 deletions .description.md

This file was deleted.

2 changes: 1 addition & 1 deletion .devcontainer/dev_install
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cd /workspace
python -m pip install --upgrade pip

# install or upgrade dependencies for development and testing
pip install --no-deps -r requirements-dev.txt
pip install --no-deps -r ./lock/requirements-dev.txt

# install the package itself in edit mode:
pip install --no-deps -e .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_config_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v3
uses: ghga-de/gh-action-common@v4

- name: Check config docs
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_openapi_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v3
uses: ghga-de/gh-action-common@v4

- name: Check if openapi.yaml is up to date
run: |
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/check_pyproject.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check if the config schema and the example are up to date.

on: push

jobs:
static-code-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v4

- name: Check pyproject.toml
run: |
./scripts/update_pyproject.py --check
2 changes: 1 addition & 1 deletion .github/workflows/check_readme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v3
uses: ghga-de/gh-action-common@v4

- name: Check readme
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_workflow_dispatch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
fetch-tag:
runs-on: ubuntu-latest
if: ( github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'build') ) || ( github.event.action == 'labeled' && github.event.label.name == 'build' )
if: ( github.event.action == 'workflow_dispatch' || github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'build') ) || ( github.event.action == 'labeled' && github.event.label.name == 'build' )
steps:
- id: fetch-tag
uses: ghga-de/gh-action-fetch-tag@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v3
uses: ghga-de/gh-action-common@v4

- uses: pre-commit/[email protected]
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v3
uses: ghga-de/gh-action-common@v4

- id: pytest
run: |
Expand Down
2 changes: 0 additions & 2 deletions .mandatory_files_ignore

This file was deleted.

12 changes: 0 additions & 12 deletions .mypy.ini

This file was deleted.

29 changes: 29 additions & 0 deletions .pyproject_generation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
for the German Human Genome-Phenome Archive (GHGA)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Generating the pyproject.toml

The pyproject.toml of the service is generated by combining static configuration
captured in [`./pyproject_template.toml`](./pyproject_template.toml) and custom
package metadata specified in [`./pyproject_custom.toml`](./pyproject_custom.toml).

The `./pyproject_template.toml` is managed by the template, please do not edit manually.

You may specify properties in the `./pyproject_custom.toml` which are already specified
in the `./pyproject_template.toml`. In that case, the `./pyproject_custom.toml` takes
priority.
17 changes: 17 additions & 0 deletions .pyproject_generation/pyproject_custom.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[project]
name = "ars"
version = "1.1.0"
description = "Access Request Service"
dependencies = [
"ghga-event-schemas~=3.0.0",
"ghga-service-commons[api,auth]>=2.0.0",
"hexkit[mongodb,akafka]>=2.0.0",
"httpx>=0.25.2",
"typer>=0.9.0",
]

[project.urls]
Repository = "https://github.com/ghga-de/access-request-service"

[project.scripts]
ars = "ars.__main__:cli"
61 changes: 52 additions & 9 deletions .ruff.toml → ...roject_generation/pyproject_template.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
[build-system]
requires = ["setuptools>=67.7.2"]
build-backend = "setuptools.build_meta"

[project]
readme = "README.md"
authors = [
{ name = "German Human Genome Phenome Archive (GHGA)", email = "[email protected]" },
]
requires-python = ">=3.9"
license = { text = "Apache 2.0" }
classifiers = [
"Development Status :: 1 - Planning",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: Apache Software License",
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Software Development :: Libraries",
"Intended Audience :: Developers",
]

[tool.setuptools.packages.find]
where = ["src"]

[tool.ruff]
exclude = [
".git",
".devcontainer",
"__pycache__",
"build",
"dist",
]

ignore = [
"E", # pycodestyle errors
"W", # pycodestyle warnings - pycodestyle covered by black
Expand All @@ -23,9 +49,7 @@ ignore = [
"D206", # indent-with-spaces (ignored for formatter)
"D300", # triple-single-quotes (ignored for formatter)
]

line-length = 88

select = [
"C90", # McCabe Complexity
"F", # pyflakes codes
Expand All @@ -39,26 +63,45 @@ select = [
"SIM", # flake8-simplify
"D", # pydocstyle
]

fixable = [
"UP", # e.g. List -> list
"I", # sort imports
"D", # pydocstyle
]

src = ["src", "tests", "examples", "scripts"]

target-version = "py39"

[mccabe]
[tool.ruff.mccabe]
max-complexity = 10

[per-file-ignores]
[tool.ruff.per-file-ignores]
"scripts/*" = ["PL", "S", "SIM", "D"]
"tests/*" = ["S", "SIM", "PLR", "B011"]
".devcontainer/*" = ["S", "SIM", "D"]
"examples/*" = ["S", "D"]
"__init__.py" = ["D"]

[pydocstyle]
[tool.ruff.pydocstyle]
convention = "pep257"

[tool.mypy]
disable_error_code = "import"
show_error_codes = true
exclude = [
'build/lib/',
]
warn_redundant_casts = true
warn_unused_ignores = true
check_untyped_defs = true
no_site_packages = false

[tool.pytest.ini_options]
minversion = "7.1"
asyncio_mode = "strict"

[tool.coverage.paths]
source = [
"src",
"/workspace/src",
"**/lib/python*/site-packages",
]
22 changes: 11 additions & 11 deletions readme_generation.md → .readme_generation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@

# Readme Generation

The README file is generated by collecting information from different sources as
The Repository README is generated by collecting information from different sources as
outlined in the following.

- name: The full name of the package is derived from the remote origin Git repository.
- title: A title case representation of the name.
- shortname: An abbreviation of the full name. This is derived from the name mentioned
in the [`./pyproject.toml`](./pyproject.toml).
in the [`../pyproject.toml`](../pyproject.toml).
- summary: A short 1-2 sentence summary derived from the description in the
[`./pyproject.toml`](./pyproject.toml).
[`../pyproject.toml`](../pyproject.toml).
- version: The package version derived from the version specified in the
[`./pyproject.toml`](./pyproject.toml).
[`../pyproject.toml`](../pyproject.toml).
- description: A markdown-formatted description of the features and use cases of this
service or package. Obtained from the [`./.description.md`](./.description.md).
service or package. Obtained from the [`./description.md`](./description.md).
- design_description: A markdown-formatted description of the overall architecture and
design of the package. Obtained from the [`./.design.md`](./.design.md).
design of the package. Obtained from the [`./design.md`](./design.md).
- config_description: A markdown-formatted description of all config parameters.
This is autogenerated from the [`./config_schema.json`](./config_schema.json).
This is autogenerated from the [`../config_schema.json`](../config_schema.json).
- openapi_doc: A markdown-formatted description of the HTTP API. This is autogenerated
and links to the [`./openapi.yaml`](./openapi.yaml). If the openapi.yaml is not
and links to the [`../openapi.yaml`](../openapi.yaml). If the openapi.yaml is not
this documentation is empty.

The [`./.readme_template.md`](./.readme_template.md) serves as a template where the
The [`./readme_template.md`](./readme_template.md) serves as a template where the
above variable can be filled in using Pythons `string.Template` utility from the
standard library.

The [`./scripts/update_readme.py`] script can be used to collect all information and
fill it into the template to generate the README file.
The [`../scripts/update_readme.py`](../scripts/update_readme.py) script can be used to
collect all information and fill it into the template to generate the README file.
3 changes: 3 additions & 0 deletions .readme_generation/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- Please provide a short overview of the features of this service. -->

Here you should provide a short summary of the purpose of this microservice.
3 changes: 3 additions & 0 deletions .design.md → .readme_generation/design.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<!-- Please provide an overview of the architecture and design of the code base.
Mention anything that deviates from the standard triple hexagonal architecture and
the corresponding structure. -->

This is a Python-based service following the Triple Hexagonal Architecture pattern.
It uses protocol/provider pairs and dependency injection mechanisms provided by the
Expand Down
5 changes: 2 additions & 3 deletions .readme_template.md → .readme_generation/readme_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

[![tests](https://github.com/ghga-de/$name/actions/workflows/tests.yaml/badge.svg)](https://github.com/ghga-de/$name/actions/workflows/tests.yaml)
[![Coverage Status](https://coveralls.io/repos/github/ghga-de/$name/badge.svg?branch=main)](https://coveralls.io/github/ghga-de/$name?branch=main)
[![tests](https://github.com/ghga-de/$repo_name/actions/workflows/tests.yaml/badge.svg)](https://github.com/ghga-de/$repo_name/actions/workflows/tests.yaml)
[![Coverage Status](https://coveralls.io/repos/github/ghga-de/$repo_name/badge.svg?branch=main)](https://coveralls.io/github/ghga-de/$repo_name?branch=main)

# $title

Expand Down
2 changes: 0 additions & 2 deletions .static_files_ignore

This file was deleted.

47 changes: 47 additions & 0 deletions .template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--
Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
for the German Human Genome-Phenome Archive (GHGA)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Template File Lists

This directory contains multiple text files that are listing paths to other files
of this repository. The listed files are affected in different ways by template updates
as explained in the following.

## `static_files.txt`
The files listed here are synced with their counterparts in the template. They should
never be modified manually.

## `static_files_ignore.txt`
To opt out of template updates just for individual files declared as static
(e.g. because you would like manually modify them), you may add them to this list.

## `mandatory_files.txt`
The contents of the files listed here are not synced with the template, however, upon
every template update it is checked that the files exist. You should modify them
manually to the needs of your repository.

## `mandatory_files_ignore.txt`
To opt out of existence checks for individual files declared as mandatory, you may add
them to this list.

## `deprecated_files.txt`
Files listed here must not exist in your repository and are automatically deleted upon
a template update.

## `deprecated_files_ignore.txt`
If you would like to keep files declared as deprecated, you may add them to this list.
19 changes: 19 additions & 0 deletions .deprecated_files → .template/deprecated_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,26 @@ docs

setup.py
setup.cfg
requirements-dev-common.in
requirements-dev.in
requirements-dev.txt
requirements.txt
pytest.ini
readme_generation.md

.pylintrc
.flake8
.mypy.ini
.ruff.toml
.coveragerc
.editorconfig
.deprecated_files
.deprecated_files_ignore
.mandatory_files
.mandatory_files_ignore
.static_files
.static_files_ignore
.description.md
.design.md
.readme_template.md
.readme_generation.md
Loading

0 comments on commit 1fe2329

Please sign in to comment.