Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template updates (GSI613) #18

Merged
merged 4 commits into from
Feb 7, 2024
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
5 changes: 0 additions & 5 deletions .coveragerc

This file was deleted.

2 changes: 0 additions & 2 deletions .deprecated_files_ignore

This file was deleted.

1 change: 0 additions & 1 deletion .devcontainer/.dev_config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
host: 127.0.0.1
port: 8080
log_level: info
workers: 1
auto_reload: true
cors_allowed_origins: []
Expand Down
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.

4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ repos:
- id: debug-statements
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
rev: v0.2.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
rev: v1.8.0
hooks:
- id: mypy
args: [--no-warn-unused-ignores]
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.
16 changes: 16 additions & 0 deletions .pyproject_generation/pyproject_custom.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[project]
name = "wps"
version = "1.0.1"
description = "Work Package Service"
dependencies = [
"ghga-event-schemas~=3.0.0",
"ghga-service-commons[api,auth,crypt]>=2, <3",
"hexkit[akafka,mongodb]>=2.1.0",
"typer>=0.9.0",
]

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

[project.scripts]
wps = "wps.__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.
File renamed without changes.
File renamed without changes.
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.
Loading
Loading