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

Devops: Various improvements to the package #3

Merged
merged 9 commits into from
Dec 22, 2023
10 changes: 5 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.8'

- name: Validate the tag version against the package version
run: python .github/workflows/validate_release_tag.py $GITHUB_REF
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.8'
cache: pip
cache-dependency-path: pyproject.toml

Expand All @@ -52,7 +52,7 @@ jobs:

strategy:
matrix:
python-version: ['3.7', '3.8']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

services:
rabbitmq:
Expand All @@ -74,7 +74,7 @@ jobs:
run: sudo apt update && sudo apt install postgresql

- name: Install Python dependencies
run: pip install -e .[dev] && reentry scan
run: pip install -e .[dev]

- name: Run pytest
run: pytest -sv tests
Expand All @@ -92,7 +92,7 @@ jobs:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.8'

- name: Install flit
run: pip install flit~=3.4
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.8'
cache: pip
cache-dependency-path: pyproject.toml

Expand All @@ -31,7 +31,7 @@ jobs:

strategy:
matrix:
python-version: ['3.7', '3.8']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

services:
rabbitmq:
Expand All @@ -53,7 +53,9 @@ jobs:
run: sudo apt update && sudo apt install postgresql

- name: Install Python package and dependencies
run: pip install -e .[dev] && reentry scan
run: pip install -e .[dev]

- name: Run pytest
env:
AIIDA_WARN_v3: true
run: pytest -sv tests
23 changes: 8 additions & 15 deletions .github/workflows/validate_release_tag.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Validate that the version in the tag label matches the version of the package."""
import argparse
import ast
Expand All @@ -13,32 +12,26 @@ def get_version_from_module(content: str) -> str:
try:
module = ast.parse(content)
except SyntaxError as exception:
raise IOError("Unable to parse module.") from exception
raise IOError('Unable to parse module.') from exception

try:
return next(
ast.literal_eval(statement.value)
for statement in module.body
if isinstance(statement, ast.Assign)
for target in statement.targets
if isinstance(target, ast.Name) and target.id == "__version__"
if isinstance(target, ast.Name) and target.id == '__version__'
)
except StopIteration as exception:
raise IOError("Unable to find the `__version__` attribute in the module.") from exception
raise IOError('Unable to find the `__version__` attribute in the module.') from exception


if __name__ == "__main__":
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("GITHUB_REF", help="The GITHUB_REF environmental variable")
parser.add_argument('GITHUB_REF', help='The GITHUB_REF environmental variable')
args = parser.parse_args()
assert args.GITHUB_REF.startswith(
"refs/tags/v"
), f'GITHUB_REF should start with "refs/tags/v": {args.GITHUB_REF}'
assert args.GITHUB_REF.startswith('refs/tags/v'), f'GITHUB_REF should start with "refs/tags/v": {args.GITHUB_REF}'
tag_version = args.GITHUB_REF[11:]
package_version = get_version_from_module(
Path("aiida_wien2k/__init__.py").read_text(encoding="utf-8")
)
error_message = (
f"The tag version `{tag_version}` is different from the package version `{package_version}`"
)
package_version = get_version_from_module(Path('src/aiida_wien2k/__init__.py').read_text(encoding='utf-8'))
error_message = f'The tag version `{tag_version}` is different from the package version `{package_version}`'
assert tag_version == package_version, error_message
27 changes: 19 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: check-yaml
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: fix-encoding-pragma
args: [--remove]
- id: mixed-line-ending
args: [--fix=lf]
- id: trailing-whitespace
exclude: >-
(?x)^(
tests/.*.*out|
tests/.*.in$
)$
- repo: https://github.com/pycqa/isort
rev: 5.11.5

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
hooks:
- id: isort
- repo: https://github.com/ambv/black
rev: 23.3.0
- id: ruff-format
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.11.0
hooks:
- id: black
language_version: python3.7
- id: pretty-format-toml
args: [--autofix]
- id: pretty-format-yaml
args: [--autofix]
3 changes: 0 additions & 3 deletions aiida_wien2k/__init__.py

This file was deleted.

220 changes: 0 additions & 220 deletions aiida_wien2k/calculations/run123_lapw.py

This file was deleted.

Loading
Loading