Skip to content

Commit

Permalink
Fix errors produced by formatter and linter migration
Browse files Browse the repository at this point in the history
This commit is mainly the result of running `pre-commit run --all-files`
with the previous changes in the formatter and linter. There is some
additional manual changes to fix linebreaks.
  • Loading branch information
agoscinski committed Nov 20, 2024
1 parent bf53b22 commit 11d8aad
Show file tree
Hide file tree
Showing 57 changed files with 1,350 additions and 1,603 deletions.
66 changes: 33 additions & 33 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
name: cd

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*

jobs:

validate-release-tag:
validate-release-tag:

if: github.repository == 'aiidateam/aiida-restapi'
runs-on: ubuntu-latest
if: github.repository == 'aiidateam/aiida-restapi'
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v2
steps:
- name: Checkout source
uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Validate the tag version against the package version
run: python .github/workflows/validate_release_tag.py $GITHUB_REF
- name: Validate the tag version against the package version
run: python .github/workflows/validate_release_tag.py $GITHUB_REF

publish:
publish:

name: Publish to PyPI
needs: [validate-release-tag]
runs-on: ubuntu-latest
name: Publish to PyPI
needs: [validate-release-tag]
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v2
steps:
- name: Checkout source
uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install flit
run: pip install flit~=3.4
- name: Install flit
run: pip install flit~=3.4

- name: Build and publish
run: flit publish
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.pypi_token }}
- name: Build and publish
run: flit publish
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.pypi_token }}
114 changes: 57 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,73 @@ on: [push, pull_request]

jobs:

pre-commit:
pre-commit:

runs-on: ubuntu-latest
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'

- uses: pre-commit/[email protected]
- uses: pre-commit/[email protected]

tests:
tests:

runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']

services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: test_db
POSTGRES_PASSWORD: ''
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
rabbitmq:
image: rabbitmq:latest
ports:
- 5672:5672
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: test_db
POSTGRES_PASSWORD: ''
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
rabbitmq:
image: rabbitmq:latest
ports:
- 5672:5672

steps:
- uses: actions/checkout@v2
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install -e .[testing,auth]
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install -e .[testing,auth]
- name: Run test suite
env:
- name: Run test suite
env:
# show timings of tests
PYTEST_ADDOPTS: "--durations=0"
AIIDA_WARN_v3: true
run: pytest --cov aiida_restapi --cov-report=xml
PYTEST_ADDOPTS: --durations=0
AIIDA_WARN_v3: true
run: pytest --cov aiida_restapi --cov-report=xml

- name: Upload to Codecov
if: matrix.python-version == 3.8
uses: codecov/codecov-action@v4
with:
name: pytests
flags: pytests
file: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
- name: Upload to Codecov
if: matrix.python-version == 3.8
uses: codecov/codecov-action@v4
with:
name: pytests
flags: pytests
file: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
26 changes: 10 additions & 16 deletions .github/workflows/validate_release_tag.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Validate that the version in the tag label matches the version of the package."""

import argparse
import ast
from pathlib import Path
Expand All @@ -13,33 +13,27 @@ 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()
tag_prefix = "refs/tags/v"
assert args.GITHUB_REF.startswith(
tag_prefix
), f'GITHUB_REF should start with "{tag_prefix}": {args.GITHUB_REF}'
tag_prefix = 'refs/tags/v'
assert args.GITHUB_REF.startswith(tag_prefix), f'GITHUB_REF should start with "{tag_prefix}": {args.GITHUB_REF}'
tag_version = args.GITHUB_REF.removeprefix(tag_prefix)
package_version = get_version_from_module(
Path("aiida_restapi/__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('aiida_restapi/__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
Loading

0 comments on commit 11d8aad

Please sign in to comment.